[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1193
  • Last Modified:

java error jfuzzylogic library

I am using jfuzzylogic. It loads an .fcl file like this http://jfuzzylogic.sourceforge.net/html/example_fcl.html 

I have two .fcl files with exactly the same text. On of them is written by hand based on the above example. The other one is created from within java using BufferedWriter to write this text into a file. The file written by hand is read with no problems by jfuzzylogic library. When I try to read the file generated by java I get an error:

line 13:1 no viable alternative at character '''
line 13:15 no viable alternative at character '''
line 13:18 no viable alternative at character '''
line 13:34 no viable alternative at character '''
line 13:37 no viable alternative at character '''
line 13:51 no viable alternative at character '''
line 20:9 no viable alternative at character '''
line 20:22 no viable alternative at character '''
line 20:27 no viable alternative at character '''
line 20:34 no viable alternative at character '''
line 20:37 no viable alternative at character '''
line 20:46 no viable alternative at character '''
line 20:49 no viable alternative at character '''
line 20:56 no viable alternative at character '''
line 13:0 mismatched input '{' expecting END_FUZZIFY
line 20:0 mismatched input 'variable' expecting END_DEFUZZIFY
Exception in thread "main" java.lang.RuntimeException: Unknown item 'FUZZIFY time

{zeroTimeRange, mediumTimeRange, highTimeRange}
TERM zeroTimeRange :=(0,0) (0,0) (0, 0)(390,0) (421,1) (452, 0)(763,0) (794,1) (826, 0)(1013,0) (1044,1) (1076, 0);
TERM mediumTimeRange :=(0,0) (104,1) (208, 0)(211,0) (315,1) (419, 0)(422,0) (514,1) (606, 0)(608,0) (700,1) (792, 0)(796,0) (857,1) (918, 0)(920,0) (981,1) (1042, 0)(1046,0) (1144,1) (1242, 0)(1243,0) (1341,1) (1439, 0);
TERM highTimeRange :=(104,0) (209,1) (315, 0)(514,0) (607,1) (700, 0)(857,0) (919,1) (981, 0)(1144,0) (1242,1) (1341, 0);
END_FUZZIFY':        <mismatched token: [@30,121:121='{',<75>,13:0], resync=FUZZIFY time

{zeroTimeRange, mediumTimeRange, highTimeRange}
TERM zeroTimeRange :=(0,0) (0,0) (0, 0)(390,0) (421,1) (452, 0)(763,0) (794,1) (826, 0)(1013,0) (1044,1) (1076, 0);
TERM mediumTimeRange :=(0,0) (104,1) (208, 0)(211,0) (315,1) (419, 0)(422,0) (514,1) (606, 0)(608,0) (700,1) (792, 0)(796,0) (857,1) (918, 0)(920,0) (981,1) (1042, 0)(1046,0) (1144,1) (1242, 0)(1243,0) (1341,1) (1439, 0);
TERM highTimeRange :=(104,0) (209,1) (315, 0)(514,0) (607,1) (700, 0)(857,0) (919,1) (981, 0)(1144,0) (1242,1) (1341, 0);
END_FUZZIFY>
        at net.sourceforge.jFuzzyLogic.FunctionBlock.fclTree(FunctionBlock.java:163)
        at net.sourceforge.jFuzzyLogic.FIS.createFromLexer(FIS.java:81)
        at net.sourceforge.jFuzzyLogic.FIS.load(FIS.java:153)
        at fuzzylogic.ConcernLevel.checkConcernLevel(ConcernLevel.java:21)
        at fuzzylogic.Main.main(Main.java:30)
Java Result: 1

Anybody knows why this occurs?

0
chudyksg
Asked:
chudyksg
  • 2
  • 2
1 Solution
 
for_yanCommented:
Can you post both input files - the one which works and thew one which does not?
0
 
chudyksgAuthor Commented:
-------WORKING ONE-----------


FUNCTION_BLOCK tipper      // Block definition (there may be more than one block per file)

VAR_INPUT                        // Define input variables
      time : REAL;
END_VAR

VAR_OUTPUT                        // Define output variable
      concernLevel : REAL;
END_VAR

FUZZIFY time                  // Fuzzify input variable 'time': {'zeroTimeRange', 'mediumTimeRange', 'highTimeRange'}
      TERM zeroTimeRange := (0,0) (0,0) (0, 0)(390,0) (421,1) (452, 0)(763,0) (794,1) (826, 0)(1013,0) (1044,1) (1076, 0);
      TERM mediumTimeRange := (0,0) (104,1) (208, 0)(211,0) (315,1) (419, 0)(422,0) (514,1) (606, 0)(608,0) (700,1) (792, 0)(796,0) (857,1) (918, 0)(920,0) (981,1) (1042, 0)(1046,0) (1144,1) (1242, 0)(1243,0) (1341,1) (1439, 0);
          TERM highTimeRange := (104,0) (209,1) (315, 0)(514,0) (607,1) (700, 0)(857,0) (919,1) (981, 0)(1144,0) (1242,1) (1341, 0);
END_FUZZIFY

DEFUZZIFY concernLevel                  // Defzzzify output variable 'concernLevel' : {'clZero', 'clMedium', 'clHigh' }
      TERM clZero := (-1,0) (0,1) (1,0);
      TERM clMedium := (0,0) (1,1) (2,0);
      TERM clHigh := (1,0) (2,1) (3,0);
      METHOD : COG;            // Use 'Center Of Gravity' defuzzification method
      DEFAULT := 0;            // Default value is 0 (if no rule activates defuzzifier)
END_DEFUZZIFY

RULEBLOCK No1
      AND : MIN;                  // Use 'min' for 'and' (also implicit use 'max' for 'or' to fulfill DeMorgan's Law)
      ACT : MIN;                  // Use 'min' activation method
      ACCU : MAX;                  // Use 'max' accumulation method
      RULE 1 : IF time IS zeroTimeRange THEN concernLevel IS clZero;
      RULE 2 : IF time IS mediumTimeRange THEN concernLevel IS clMedium;
      RULE 3 : IF time IS highTimeRange THEN concernLevel IS clHigh;
      
END_RULEBLOCK

END_FUNCTION_BLOCK

--------NOT WORKING ONE-----------


FUNCTION_BLOCK tipper
VAR_INPUT
time : REAL;
END_VAR

VAR_OUTPUT
concernLevel : REAL;

END_VAR

FUZZIFY time

{'zeroTimeRange', 'mediumTimeRange', 'highTimeRange'}
TERM zeroTimeRange :=(0,0) (0,0) (0, 0)(390,0) (421,1) (452, 0)(763,0) (794,1) (826, 0)(1013,0) (1044,1) (1076, 0);
TERM mediumTimeRange :=(0,0) (104,1) (208, 0)(211,0) (315,1) (419, 0)(422,0) (514,1) (606, 0)(608,0) (700,1) (792, 0)(796,0) (857,1) (918, 0)(920,0) (981,1) (1042, 0)(1046,0) (1144,1) (1242, 0)(1243,0) (1341,1) (1439, 0);
TERM highTimeRange :=(104,0) (209,1) (315, 0)(514,0) (607,1) (700, 0)(857,0) (919,1) (981, 0)(1144,0) (1242,1) (1341, 0);
END_FUZZIFY

DEFUZZIFY concernLevel
variable 'concernLevel' : {'clZero', 'clMedium', 'clHigh' }
TERM clZero := (-1,0) (0,1) (1,0);
TERM clMedium := (0,0) (1,1) (2,0);
TERM clHigh := (1,0) (2,1) (3,0);
METHOD : COG;
DEFAULT := 0;
END_DEFUZZIFY

RULEBLOCK No1
AND : MIN;
ACT : MIN;
ACCU : MAX;
RULE 1 : IF time IS zeroTimeRange THEN concernLevel IS clZero;
RULE 2 : IF time IS mediumTimeRange THEN concernLevel IS clMedium;
RULE 3 : IF time IS highTimeRange THEN concernLevel IS clHigh;
END_RULEBLOCK

END_FUNCTION_BLOCK


The only difference is I didn't include comments in the 2nd one
0
 
ksivananthCommented:
>>{'zeroTimeRange', 'mediumTimeRange', 'highTimeRange'}

try commenting this line from Java
0
 
chudyksgAuthor Commented:
yeah that is working but also had to comment out >>variable 'concernLevel' : {'clZero', 'clMedium', 'clHigh' }
Do you have any idea why this happens?
0
 
ksivananthCommented:
>>Do you have any idea why this happens?

the fuzzylogic library tries to parse them but don't understand. if you comment it, it iwll just ignore it!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now