home › Forums › # Technical Support › Error when running application
- This topic has 8 replies, 2 voices, and was last updated 6 years, 6 months ago by
Unknown.
-
AuthorPosts
-
February 26, 2017 at 03:11 #2307
Unknown
MemberHi,
I have an application with two input variables; speed and acceleration.
On running I get the following error.
E/ERROR: [syntax error] expected variable or logical operator, but found <Z>Any ideas on what it could be please?
Your time and effort are greatly appreciated!
February 26, 2017 at 05:50 #2308Juan Rada-Vilela (admin)
KeymasterHi,
the best you can do is to export engine to FLL
FL_LOG(engine->toString())
and import it into QtFuzzyLite. You can use the commercial version or the community version. I am sure you will find the answer there.If not, please post the FLL code for your engine here.
Cheers.
Juan.
February 26, 2017 at 05:56 #2309Unknown
MemberHi Juan,
Thank you for your response. I’m relatively new to fuzzy logic so please bear with me. The following code is what i’m using. I have no compiler errors but only when running the application.
public void fuzzyMethod(double carspeed, double acceleration){
Engine engine = new Engine();
engine.setName(“Driver-Classifier”);/*Speed input value
Speed range set between 0 and 95km/hr
Three terms – slow, normal, fast
*/
InputVariable speed = new InputVariable();
speed.setEnabled(true);
speed.setName(“SPEED”);
speed.setRange(0.000,95.000);
speed.addTerm(new Triangle(“SLOW”,0.000,25.000,50.000 ));
speed.addTerm(new Triangle(“NORMAL”,45.000,55.000,65.000));
speed.addTerm(new Triangle(“FAST”, 55.000, 75.000,95.000));
engine.addInputVariable(speed);/*
Accelerometer values in z-axis direction – left to right
*/
InputVariable zaxis = new InputVariable();
zaxis.setEnabled(true);
zaxis.setName(“Z Axis Acceleration”);
zaxis.setRange(-4.500,4.500);//Deceleration
zaxis.addTerm(new Triangle(“HARD DECELERATION”,1.500,3.00,4.500 ));
zaxis.addTerm(new Triangle(“DECELERATION”,0.500,1.5,2.5));//Calm/Neutral
zaxis.addTerm(new Triangle(“NEUTRAL”,-0.5,0,0.5));//Acceleration
zaxis.addTerm(new Triangle(“ACCELERATION”,-0.500,-1.250,-2.000));
zaxis.addTerm(new Triangle(“HARD ACCELERATION”,-1.500,-3.000,-4.500));
engine.addInputVariable(zaxis);OutputVariable drivingStyle = new OutputVariable();
drivingStyle.setName(“DRIVING STYLE”);
drivingStyle.addTerm(new Triangle(“CALM”,0,0.5,1));
drivingStyle.addTerm(new Triangle(“NORMAL”,1,1.5,2));
drivingStyle.addTerm(new Triangle(“AGGRESSIVE”,2, 2.5, 3));
engine.addOutputVariable(drivingStyle);//Set Rules
RuleBlock ruleBlock = new RuleBlock();
//SLOW SPEED
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and Z-AXIS ACCELERATION is HARD DECELERATION then DRIVING STYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and Z-AXIS ACCELERATION is DECELERATION then DRIVING STYLE is NORMAL”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and Z-AXIS ACCELERATION is NEUTRAL then DRIVING STYLE is NORMAL”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and Z-AXIS ACCELERATION is ACCELERATION then DRIVING STYLE is NORMAL”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and Z-AXIS ACCELERATION is HARD ACCELERATION then DRIVING STYLE is AGGRESSIVE”, engine));//NORMAL SPEED
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and Z-AXIS ACCELERATION is HARD DECELERATION then DRIVING STYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and Z-AXIS ACCELERATION is DECELERATION then DRIVING STYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and Z-AXIS ACCELERATION is NEUTRAL then DRIVING STYLE is NORMAL”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and Z-AXIS ACCELERATION is ACCELERATION then DRIVING STYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and Z-AXIS ACCELERATION is HARD ACCELERATION then DRIVING STYLE is AGGRESSIVE”, engine));//TOO FAST
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and Z-AXIS ACCELERATION is HARD DECELERATION then DRIVING STYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and Z-AXIS ACCELERATION is DECELERATION then DRIVING STYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and Z-AXIS ACCELERATION is NEUTRAL then DRIVING STYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and Z-AXIS ACCELERATION is ACCELERATION then DRIVING STYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and Z-AXIS ACCELERATION is HARD ACCELERATION then DRIVING STYLE is AGGRESSIVE”, engine));
engine.addRuleBlock(ruleBlock);speed.setInputValue(carspeed);
zaxis.setInputValue(acceleration);
engine.process();
//Log.d(“fuzzy”,drivingStyle.getOutputValue()+ ” “);February 26, 2017 at 05:59 #2311Juan Rada-Vilela (admin)
KeymasterHi,
you cannot use spaces for variable names, nor names for terms. They must follow the conventions for variables in any programming language.
Still, you should use QtFuzzyLite to find out the source of these errors.
Cheers.
February 26, 2017 at 06:06 #2312Unknown
MemberThank you Juan. I have removed all spaces but still getting the error;
E/ERROR: [syntax error] expected variable or logical operator, but found <ZAXISACCELERATION>
Can you guide me as to what else needs to be changed please?
public void fuzzyMethod(double carspeed, double acceleration){
Engine engine = new Engine();
engine.setName(“DriverClassifier”);/*Speed input value
Speed range set between 0 and 95km/hr
Three terms – slow, normal, fast
*/
InputVariable speed = new InputVariable();
speed.setEnabled(true);
speed.setName(“SPEED”);
speed.setRange(0.000,95.000);
speed.addTerm(new Triangle(“SLOW”,0.000,25.000,50.000 ));
speed.addTerm(new Triangle(“NORMAL”,45.000,55.000,65.000));
speed.addTerm(new Triangle(“FAST”, 55.000, 75.000,95.000));
engine.addInputVariable(speed);/*
Accelerometer values in z-axis direction – left to right
*/
InputVariable zaxis = new InputVariable();
zaxis.setEnabled(true);
zaxis.setName(“ZAxisAcceleration”);
zaxis.setRange(-4.500,4.500);//Deceleration
zaxis.addTerm(new Triangle(“HARDDECELERATION”,1.500,3.00,4.500 ));
zaxis.addTerm(new Triangle(“DECELERATION”,0.500,1.5,2.5));//Calm/Neutral
zaxis.addTerm(new Triangle(“NEUTRAL”,-0.5,0,0.5));//Acceleration
zaxis.addTerm(new Triangle(“ACCELERATION”,-0.500,-1.250,-2.000));
zaxis.addTerm(new Triangle(“HARDACCELERATION”,-1.500,-3.000,-4.500));
engine.addInputVariable(zaxis);OutputVariable drivingStyle = new OutputVariable();
drivingStyle.setName(“DRIVINGSTYLE”);
drivingStyle.addTerm(new Triangle(“CALM”,0,0.5,1));
drivingStyle.addTerm(new Triangle(“NORMAL”,1,1.5,2));
drivingStyle.addTerm(new Triangle(“AGGRESSIVE”,2, 2.5, 3));
engine.addOutputVariable(drivingStyle);//Set Rules
RuleBlock ruleBlock = new RuleBlock();
//SLOW SPEED
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and ZAXISACCELERATION is HARD DECELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and ZAXISACCELERATION is DECELERATION then DRIVINGSTYLE is NORMAL”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and ZAXISACCELERATION is NEUTRAL then DRIVINGSTYLE is NORMAL”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and ZAXISACCELERATION is ACCELERATION then DRIVINGSTYLE is NORMAL”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and ZAXISACCELERATION is HARD ACCELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));//NORMAL SPEED
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and ZAXISACCELERATION is HARD DECELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and ZAXISACCELERATION is DECELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and ZAXISACCELERATION is NEUTRAL then DRIVINGSTYLE is NORMAL”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and ZAXISACCELERATION is ACCELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and ZAXISACCELERATION is HARD ACCELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));//TOO FAST
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and ZAXISACCELERATION is HARD DECELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and ZAXISACCELERATION is DECELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and ZAXISACCELERATION is NEUTRAL then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and ZAXISACCELERATION is ACCELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and ZAXISACCELERATION is HARD ACCELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
engine.addRuleBlock(ruleBlock);speed.setInputValue(carspeed);
zaxis.setInputValue(acceleration);
engine.process();
Log.d(“fuzzy”,drivingStyle.getOutputValue()+ ” “);
//FuzzyLite.logger().info(Op.str(drivingStyle.getOutputValue()));
}February 26, 2017 at 06:09 #2313Juan Rada-Vilela (admin)
KeymasterHi,
please download QtFuzzyLite. You will fix your problems using that. You can use the paid commercial version, or the free community version.
Cheers.
February 26, 2017 at 17:14 #2314Juan Rada-Vilela (admin)
KeymasterVariable names are case sensitive.
Please, change the name of the
zaxis.setName("ZAxisAcceleration");
to match exactly the name you are using in the rules.February 27, 2017 at 07:01 #2315Unknown
MemberHi Juan,
Thank you for your response! That was the issue.
Regards
StevenFebruary 28, 2017 at 06:54 #2316Unknown
MemberHi Juan,
I came across another issue. The system requests a conjunction operator. Can you suggest the best conjunction operator for my system; taking the acceleration and speed generated by the smartphone, feed it to the fuzzy inference system in order to generate the drivers behavior ( calm, normal and aggressive ).
Thank you in advance.
The below is the FLL;
Engine: Driver Classification
InputVariable: Speed
enabled: true
range: 0.000 95.000
term: Slow Triangle 0.000 25.000 50.000
term: Normal Triangle 40.000 52.500 65.000
term: Fast Triangle 55.000 75.500 95.000
InputVariable: Acceleration
enabled: true
range: -4.500 4.500
term: HardDeceleration Triangle 1.500 3.000 4.500
term: Deceleration Triangle 0.500 1.500 2.500
term: Neutral Triangle -0.500 0.000 0.500
term: Acceleration Triangle -2.000 -1.250 -0.500
term: HardDeceleration Triangle -4.500 -3.000 -1.500
OutputVariable: DrivingStyle
enabled: true
range: 0.000 1.000
accumulation: none
defuzzifier: WeightedSum
default: nan
lock-valid: false
lock-range: false
term: Calm Triangle 0.000 0.250 0.500
term: Normal Triangle 0.250 0.500 0.750
term: Aggressive Triangle 0.500 0.750 1.000
RuleBlock:
enabled: true
conjunction: BoundedDifference
disjunction: none
activation: HamacherProduct
rule: if Speed is Slow and Acceleration is HardDeceleration then DrivingStyle is Aggressive
rule: if Speed is Slow and Acceleration is Deceleration then DrivingStyle is Calm
rule: if Speed is Slow and Acceleration is Neutral then DrivingStyle is Calm
rule: if Speed is Slow and Acceleration is Acceleration then DrivingStyle is Calm
rule: if Speed is Slow and Acceleration is HardDeceleration then DrivingStyle is Aggressive
rule: if Speed is Normal and Acceleration is HardDeceleration then DrivingStyle is Aggressive
rule: if Speed is Normal and Acceleration is Deceleration then DrivingStyle is Normal
rule: if Speed is Normal and Acceleration is Neutral then DrivingStyle is Calm
rule: if Speed is Normal and Acceleration is Acceleration then DrivingStyle is Normal
rule: if Speed is Normal and Acceleration is HardDeceleration then DrivingStyle is Aggressive
rule: if Speed is Fast and Acceleration is HardDeceleration then DrivingStyle is Aggressive
rule: if Speed is Fast and Acceleration is Deceleration then DrivingStyle is Aggressive
rule: if Speed is Fast and Acceleration is Neutral then DrivingStyle is Aggressive
rule: if Speed is Fast and Acceleration is Acceleration then DrivingStyle is Aggressive
rule: if Speed is Fast and Acceleration is HardDeceleration then DrivingStyle is AggressiveRegards,
Steven Farrugia -
AuthorPosts
- You must be logged in to reply to this topic.