Solved

java error jfuzzylogic library

Posted on 2011-03-01
5
1,067 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
Comment Utility
Can you post both input files - the one which works and thew one which does not?
0
 

Author Comment

by:chudyksg
Comment Utility
-------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
Comment Utility
>>{'zeroTimeRange', 'mediumTimeRange', 'highTimeRange'}

try commenting this line from Java
0
 

Author Comment

by:chudyksg
Comment Utility
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
Comment Utility
>>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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

744 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

17 Experts available now in Live!

Get 1:1 Help Now