Run FuzzyJess files in console. Is it possible? (new in Jess)

151 Views Asked by At

I'm new in Jess and I was executing my .clp files on windows 10 console with:

java jess.Main example.clp

Now I'm learning about fuzzy logic and read that to execute fuzzyjess .clp have to use:

java nrc.fuzzy.jess.FuzzyMain fuzzyE.clp

But it launchs this error:

Jess reported an error in routine new
        while executing (new FuzzyVariable "temperature" 0 100 "┬░C")
        while executing (bind ?temperature (new FuzzyVariable "temperature" 0 100 "┬░C")).
  Message: Constructor not found: (new FuzzyVariable "temperature" 0 100 "┬░C").
  Program text: ( bind ?temperature ( new FuzzyVariable "temperature" 0 100 "┬░C" ) )  at line 8.
Nested exception is:
nrc.fuzzy.FuzzyVariable
java.lang.NoSuchMethodException: nrc.fuzzy.FuzzyVariable
        at jess.c6.call(Unknown Source)
        at jess.ep.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.FuncallValue.resolveValue(Unknown Source)
        at jess.c1.call(Unknown Source)
        at jess.ep.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.Jesp.a(Unknown Source)
        at jess.Jesp.for(Unknown Source)
        at jess.Jesp.parse(Unknown Source)
        at jess.Jesp.parse(Unknown Source)
        at jess.Main.execute(Unknown Source)
        at nrc.fuzzy.jess.FuzzyMain.main(Unknown Source)

This is the code for fuzzyE.clp (I found it on internet, to try if it runs) :

;; Load
(load-package nrc.fuzzy.jess.FuzzyFunctions)

(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)) 
        )
    )
)

(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 "*"))    
)

; (reset)
(run)

I am almost sure the code is right, but maybe I'm wrong. I put the fuzzyJ-2.0.jar in the classpath like I did for jess.jar. But that "Constructor not found" makes me think FuzzyJess is not correctly installed. Maybe is not possible to run this files in console? Just in eclipse? I'm a begginer please any hint would be very helpful. The reason I want to make it in console is because I can make a .bat to make the program executable. I don't know if that is possible without deppending of eclipse.

I also try with this:

java -classpath "%classpath%";c:\Jess61p4\fuzzyJ-2.0.jar;.\ nrc.fuzzy.jess.FuzzyMain fuzzyE.clp
1

There are 1 best solutions below

3
On

This looks to just be an issue with the FuzzyJ API rather than a Jess issue; by that I mean the error messages indicate that you've properly loaded the FuzzyJ classes, but the Jess code you're running is looking for methods that don't exist in the FuzzyJ library you're using. There were several versions of FuzzyJ over the years and the version you have doesn't seem to match the example code you're trying to run.

Here is a link to a version of FuzzyJ that definitely does contain that constructor, and also includes Javadocs so that you can check your code yourself; hopefully that will get you running.