home › Forums › # Technical Support › Error Operand "OR" (Java)
- This topic has 11 replies, 2 voices, and was last updated 8 years, 3 months ago by
Unknown.
-
AuthorPosts
-
June 11, 2015 at 04:56 #1857
Unknown
MemberHi Juan, thanks for this awesome work. I have created my fuzzy logic using fuzzylight and exported it for Java. When i try to use it on Java i keep getting the error:
[syntax error] logical operator <or> expects two operands, but found <3>
I have searched and found only one topic related to that. I´ve download some java files to correct it, but still get the same error. Is there any fix for this issue? Or i can replace those java files (Antecedent.java and Engine.java) on .jar and recompile it?
Bellow the code where I´m getting this error.
RuleBlock ruleBlock = new RuleBlock(); ruleBlock.setEnabled(true); ruleBlock.setName("Gases"); ruleBlock.setConjunction(new AlgebraicProduct()); ruleBlock.setDisjunction(new AlgebraicSum()); ruleBlock.setActivation(new AlgebraicProduct()); ruleBlock.addRule(Rule.parse("if C2H2_C2H4 is A and CH4_H2 is B and (C2H4_C2H6 is A or C2H4_C2H6 is B) then DIAGNOSTICO is D1", engine)); ruleBlock.addRule(Rule.parse("if C2H2_C2H4 is A and CH4_H2 is B and C2H4_C2H6 is C then DIAGNOSTICO is D2", engine)); ruleBlock.addRule(Rule.parse("if C2H2_C2H4 is A and (CH4_H2 is C or CH4_H2 is D) and (C2H4_C2H6 is A or C2H4_C2H6 is B ) then DIAGNOSTICO is D2N", engine)); ruleBlock.addRule(Rule.parse("if C2H2_C2H4 is A and (CH4_H2 is C or CH4_H2 is D) and C2H4_C2H6 is C then DIAGNOSTICO is D3", engine)); ruleBlock.addRule(Rule.parse("if C2H2_C2H4 is A and (CH4_H2 is C or CH4_H2 is D) and C2H4_C2H6 is D then DIAGNOSTICO is D4", engine)); ruleBlock.addRule(Rule.parse("if C2H2_C2H4 is A and CH4_H2 is A and (C2H4_C2H6 is A or C2H4_C2H6 is B) then DIAGNOSTICO is D5", engine)); ruleBlock.addRule(Rule.parse("if (C2H2_C2H4 is A or C2H2_C2H4 is B) and CH4_H2 is A and (C2H4_C2H6 is A or C2H4_C2H6 is B) then DIAGNOSTICO is D6", engine)); ruleBlock.addRule(Rule.parse("if C2H2_C2H4 is not A and CH4_H2 is B and (C2H4_C2H6 is A or C2H4_C2H6 is B) then DIAGNOSTICO is D7", engine)); ruleBlock.addRule(Rule.parse("if (C2H2_C2H4 is B or C2H2_C2H4 is C) and CH4_H2 is B and C2H4_C2H6 is D then DIAGNOSTICO is D8", engine)); engine.addRuleBlock(ruleBlock);
June 11, 2015 at 05:31 #1858Unknown
MemberJune 11, 2015 at 12:27 #1859Juan Rada-Vilela (admin)
KeymasterHi,
could you please comment all rules, and uncomment one by one until you find which rule is throwing the exception? There must be a problem with a rule not being correctly written.
Cheers.
June 11, 2015 at 13:43 #1860Unknown
MemberJuan, good night. Those using OR, if i comment, it works. The first one is not working. And it works on the program.This code has been export from QtFuzzyLite 5…it hasn´t been made manually. All those rules using OR get the same problem. If i put two simple rules instead the one using or it works.
For example:
ruleBlock.addRule(Rule.parse(“if C2H2_C2H4 is A and CH4_H2 is B and C2H4_C2H6 is A or C2H4_C2H6 is B) then DIAGNOSTICO is D1”, engine));
ruleBlock.addRule(Rule.parse(“if C2H2_C2H4 is A and CH4_H2 is B and C2H4_C2H6 is A then DIAGNOSTICO is D1”, engine));
ruleBlock.addRule(Rule.parse(“if C2H2_C2H4 is A and CH4_H2 is B and C2H4_C2H6 is B then DIAGNOSTICO is D1”, engine));Thanks Juan.
June 11, 2015 at 14:13 #1861Juan Rada-Vilela (admin)
KeymasterHi,
in
Rule.parse(“if C2H2_C2H4 is A and CH4_H2 is B and C2H4_C2H6 is A or C2H4_C2H6 is B) then DIAGNOSTICO is D1
you have an unmatched parenthesis.Are you using jfuzzylite-5.0?
June 11, 2015 at 14:16 #1862Unknown
MemberruleBlock.addRule(Rule.parse("if C2H2_C2H4 is A and CH4_H2 is B and (C2H4_C2H6 is A or C2H4_C2H6 is B) then DIAGNOSTICO is D1", engine));
It was a ctrl + c and ctrl + v problem… the rule is shown.. this is the onde that is getting this error.
Sorry.. for bad copy and paste..🙁
June 11, 2015 at 14:22 #1863Juan Rada-Vilela (admin)
KeymasterHi,
could you post the FLL code of the engine? Are you using jfuzzylite version 5.0?
Meanwhile, could you try creating the rule proposition by proposition? That is,
ruleBlock.addRule(Rule.parse("if C2H2_C2H4 is A then DIAGNOSTICO is D1", engine)); ruleBlock.addRule(Rule.parse("if C2H2_C2H4 is A and CH4_H2 is B then DIAGNOSTICO is D1", engine)); ruleBlock.addRule(Rule.parse("if C2H2_C2H4 is A and CH4_H2 is B then DIAGNOSTICO is D1 and (C2H4_C2H6 is A)", engine)); ruleBlock.addRule(Rule.parse("if C2H2_C2H4 is A and CH4_H2 is B then DIAGNOSTICO is D1 and (C2H4_C2H6 is A or C2H4_C2H6 is B)", engine));
Once you know where it fails, make sure the variables and terms are written correctly. Once you find the error, I will revise how to provide a more meaningful description of the error.
June 11, 2015 at 14:26 #1864Unknown
MemberYes, that is my next step.. writing proposition by proposition without using or..
Engine: P&D321 InputVariable: C2H2_C2H4 enabled: true range: 0.000 6.000 term: A Trapezoid 0.000 0.000 0.050 0.100 term: B Trapezoid 0.050 0.100 0.975 1.000 term: C Trapezoid 0.975 1.000 2.950 3.000 term: D Ramp 2.950 3.000 InputVariable: CH4_H2 enabled: true range: 0.000 6.000 term: A Trapezoid 0.000 0.000 0.050 0.100 term: B Trapezoid 0.050 0.100 0.950 1.000 term: C Trapezoid 0.950 1.000 2.950 3.000 term: D Ramp 2.950 3.000 InputVariable: C2H4_C2H6 enabled: true range: 0.000 6.000 term: A Trapezoid 0.000 0.000 0.050 0.100 term: B Trapezoid 0.050 0.100 0.950 1.000 term: C Trapezoid 0.950 1.000 2.950 3.000 term: D Ramp 2.950 3.000 OutputVariable: DIAGNOSTICO enabled: true range: -0.050 9.000 accumulation: Maximum defuzzifier: Centroid 250 default: 8.000 lock-previous: false lock-range: false term: D1 Trapezoid 0.000 0.000 0.500 1.000 term: D2 Trapezoid 0.500 1.000 1.500 2.000 term: D2N Trapezoid 1.500 2.000 2.500 3.000 term: D3 Trapezoid 2.500 3.000 3.500 4.000 term: D4 Trapezoid 3.500 4.000 4.500 5.000 term: D5 Trapezoid 4.500 5.000 5.500 6.000 term: D6 Trapezoid 5.500 6.000 6.500 7.000 term: D7 Trapezoid 6.500 7.000 7.500 8.000 term: D8 Ramp 7.500 8.000 RuleBlock: 1 enabled: true conjunction: EinsteinProduct disjunction: AlgebraicSum activation: Minimum rule: if C2H2_C2H4 is A and CH4_H2 is B and (C2H4_C2H6 is A or C2H4_C2H6 is B) then DIAGNOSTICO is D1 rule: if C2H2_C2H4 is A and CH4_H2 is B and C2H4_C2H6 is C then DIAGNOSTICO is D2 rule: if C2H2_C2H4 is A and (CH4_H2 is C or CH4_H2 is D) and (C2H4_C2H6 is A or C2H4_C2H6 is B ) then DIAGNOSTICO is D2N rule: if C2H2_C2H4 is A and (CH4_H2 is C or CH4_H2 is D) and C2H4_C2H6 is C then DIAGNOSTICO is D3 rule: if C2H2_C2H4 is A and (CH4_H2 is C or CH4_H2 is D) and C2H4_C2H6 is D then DIAGNOSTICO is D4 rule: if C2H2_C2H4 is A and CH4_H2 is A and (C2H4_C2H6 is A or C2H4_C2H6 is B) then DIAGNOSTICO is D5 rule: if (C2H2_C2H4 is A or C2H2_C2H4 is B) and CH4_H2 is A and (C2H4_C2H6 is A or C2H4_C2H6 is B) then DIAGNOSTICO is D6 rule: if C2H2_C2H4 is not A and CH4_H2 is B and (C2H4_C2H6 is A or C2H4_C2H6 is B) then DIAGNOSTICO is D7 rule: if (C2H2_C2H4 is B or C2H2_C2H4 is C) and CH4_H2 is B and C2H4_C2H6 is D then DIAGNOSTICO is D8
Is this the code you want? This is my .fll file.. Thanks for your help Juan…
June 11, 2015 at 14:41 #1865Juan Rada-Vilela (admin)
KeymasterHi,
thank you for posting your engine. It seems to me it might be a bug. I will revise this later today. If you would like to do some debugging meanwhile, please try to find out what are the three operands found in the stack in Antecedent when loading the rule.
Sorry about this.
Alternatively, you could just do:
Engine engine = new FllImporter().fromFile("yourFile.fll");
June 11, 2015 at 14:43 #1866Unknown
MemberThanks a lot Juan.. I´ll try debugging the class.. if i find anything i´ll tell you.. And i will try using the engine like you said. Thanks a lot.
-
AuthorPosts
- You must be logged in to reply to this topic.