Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

java error jfuzzylogic library

Posted on 2011-03-01
5
Medium Priority
?
1,170 Views
Last Modified: 2012-05-11
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
Comment
Question by:chudyksg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 35009834
Can you post both input files - the one which works and thew one which does not?
0
 

Author Comment

by:chudyksg
ID: 35010038
-------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
 
LVL 26

Accepted Solution

by:
ksivananth earned 2000 total points
ID: 35010256
>>{'zeroTimeRange', 'mediumTimeRange', 'highTimeRange'}

try commenting this line from Java
0
 

Author Comment

by:chudyksg
ID: 35011898
yeah that is working but also had to comment out >>variable 'concernLevel' : {'clZero', 'clMedium', 'clHigh' }
Do you have any idea why this happens?
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 35017482
>>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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question