pcingola / jFuzzyLogic

The most complete fuzzy logic library in Java. The de-facto standard for research and industrial applications.
GNU Lesser General Public License v3.0
67 stars 33 forks source link

Certain fcl files cannot be converted to cpp code, even though they work. #6

Open z-a-k opened 9 years ago

z-a-k commented 9 years ago

Hi,

If I use d1.fcl with -e or by itself (just d1.flc for params) it runs, but with -c the result is:

C:\...>java -jar jFuzzyLogic.jar -c d1.fcl
jFuzzyLogic version JFuzzyLogic 3.3 (build 2015-04-09), by Pablo Cingolani.

Exception in thread "main" java.lang.ClassCastException: net.sourceforge.jFuzzyL
ogic.defuzzifier.DefuzzifierCenterOfGravitySingletons cannot be cast to net.sour
ceforge.jFuzzyLogic.defuzzifier.DefuzzifierContinuous
        at net.sourceforge.jFuzzyLogic.FunctionBlock.toStringCpp(FunctionBlock.j
ava:685)
        at net.sourceforge.jFuzzyLogic.FIS.toStringCpp(FIS.java:299)
        at net.sourceforge.jFuzzyLogic.JFuzzyLogic.compile(JFuzzyLogic.java:48)
        at net.sourceforge.jFuzzyLogic.JFuzzyLogic.run(JFuzzyLogic.java:170)
        at net.sourceforge.jFuzzyLogic.JFuzzyLogic.main(JFuzzyLogic.java:36)

d1.fcl:

FUNCTION_BLOCK d1

    VAR_INPUT
        temp :        REAL;
        pressure :  REAL;
    END_VAR

    VAR_OUTPUT
        valve :        REAL;
    END_VAR

    FUZZIFY temp
        TERM cold := (3, 1)  (27, 0);
        TERM hot  := (3, 0 )  (27, 1);
    END_FUZZIFY

    FUZZIFY pressure
        TERM low := (55, 1) (95, 0);
        TERM high:= (55, 0) (95, 1);
    END_FUZZIFY

    DEFUZZIFY valve
        TERM drainage     := -100;
        TERM closed       := 0;
        TERM inlet        := 100;
        METHOD : COGS;
        DEFAULT  := 0;
    END_DEFUZZIFY

    RULEBLOCK No1
        AND : MIN;
        ACCU : MAX;
        RULE 1 : IF temp IS cold AND pressure IS low THEN valve IS inlet;
        RULE 2 : IF temp IS cold AND pressure IS high THEN valve IS closed WITH 0.8;
        RULE 3 : IF temp IS hot AND pressure IS low THEN valve IS closed;
        RULE 4 : IF temp IS hot AND pressure IS high THEN valve IS drainage;
    END_RULEBLOCK

END_FUNCTION_BLOCK