Solved

java error jfuzzylogic library

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
difference of if loops 23 49
Tomcat: Unable to run tomcat service. 2 19
null output 3 25
Chrome and Firefox Java 5 32
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

773 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