Question

I have downloaded an installed Jess plugin for eclipse and FuzzyJ Toolkit with it. Now I am trying to run the following simple code:

(import nrc.fuzzy.*)

(bind ?temperature (new FuzzyVariable "temperature" 0 100 "°C"))
(bind ?pressure (new FuzzyVariable "pressure" 0.1 50 "MPa"))

(?temperature addTerm "cold" (new RightLinearFuzzySet 6 20))
(?temperature addTerm "warm" (new TrapezoidFuzzySet 15 20 25 30))
(?temperature addTerm "hot"  (new LeftLinearFuzzySet 25 50))

(?pressure addTerm "low"    (new RightLinearFuzzySet 0.9 5))
(?pressure addTerm "medium" (new TrapezoidFuzzySet 2 8 14 28))
(?pressure addTerm "high"  (new LeftLinearFuzzySet 22 50))

(deffunction about (?number ?fuzzyVariable)
    (bind ?delta (- (?fuzzyVariable getMaxUOD) (?fuzzyVariable getMinUOD)))
    (new FuzzyValue ?fuzzyVariable 
        (new TriangleFuzzySet 
            (- ?number (* ?delta 0.01))
        ?number   
            (+ ?number (* ?delta 0.01)) 
        )
    )
)

; (printout t ((about 34 ?temperature) plotFuzzyValue "*"))

(assert (Temperature (about 43 ?temperature)))

(defrule trivial-rule
    (Temperature ?t & :(fuzzy-match ?t "hot"))
    =>
    (assert (Pressure (new FuzzyValue ?pressure "low")))    
)

(defrule printing
    (Pressure ?p)
    =>
    (printout t (?p plotFuzzyValue "*"))    
)


(run)

However when I run the code, I only get an exception saying that function fuzzy-match is not defined. I already changed the main class to FuzzyMain. I also tried to run FuzzyConsole and load the code from there, as well as trying to add FuzzyFunctions to the engine using addPackage, but in any case I still get that error.

Was it helpful?

Solution

Although Jess in Action unfortunately doesn't tell you this, you have to explicitly load the fuzzy functions, even when launching with FuzzyMain. Add the following line near the top of your Jess code and it will work as desired:

(load-package nrc.fuzzy.jess.FuzzyFunctions)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top