Solved

java error jfuzzylogic library

Posted on 2011-03-01
5
1,088 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
  • 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Securing Jmx Console and web console 2 65
replace a word with other 1 40
factorial example 4 35
even odd program using while loop 3 29
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now