fuzzylite操作数错误。逻辑运算符<和>需要两个操作数,但找到&lt; 3&gt; </和>

时间:2014-03-06 14:56:47

标签: fuzzy operand

在fuzzylite API中,当我定义一个超过2个运算符的规则时(我不确定),我收到以下错误:

 03-06 17:19:49.155: W/System.err(712): java.lang.RuntimeException: [syntax error] logical operator <and> expects two operands, but found <3>

我的规则是:

    RuleBlock ruleBlock = new RuleBlock();
                     ruleBlock.addRule(Rule.parse("if chestpain is TYPIC and restpress is MIN and serum is MINLEVEL and smoke is LOWPOSSIBILITY and sugar is LEVELNO and maxrate is MINRATE and restrate is LOWRATE then angin  is MILD", engine));
                     ruleBlock.addRule(Rule.parse("if chestpain is ASYMPTOMATIC and restpress is MIN and serum is MAXLEVEL and smoke is LOWPOSSIBILITY and sugar is LEVELNO and  maxrate is MINRATE and restrate is HIGHRATE then angin is MASSIVE", engine));

完整的错误消息是:

03-06 17:19:49.155: W/System.err(712): java.lang.RuntimeException: [syntax error] logical operator <and> expects two operands, but found <3>
03-06 17:19:49.155: W/System.err(712):  at com.fuzzylite.rule.Antecedent.load(Unknown Source)
03-06 17:19:49.155: W/System.err(712):  at com.fuzzylite.rule.Rule.parse(Unknown Source)
03-06 17:19:49.155: W/System.err(712):  at com.example.trsa.RAP1$4.onClick(RAP1.java:253)
03-06 17:19:49.155: W/System.err(712):  at android.view.View.performClick(View.java:2485)
03-06 17:19:49.155: W/System.err(712):  at android.view.View$PerformClick.run(View.java:9080)
03-06 17:19:49.165: W/System.err(712):  at android.os.Handler.handleCallback(Handler.java:587)
03-06 17:19:49.165: W/System.err(712):  at android.os.Handler.dispatchMessage(Handler.java:92)
03-06 17:19:49.165: W/System.err(712):  at android.os.Looper.loop(Looper.java:123)
03-06 17:19:49.165: W/System.err(712):  at android.app.ActivityThread.main(ActivityThread.java:3683)
03-06 17:19:49.165: W/System.err(712):  at java.lang.reflect.Method.invokeNative(Native Method)
03-06 17:19:49.165: W/System.err(712):  at java.lang.reflect.Method.invoke(Method.java:507)
03-06 17:19:49.175: W/System.err(712):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-06 17:19:49.186: W/System.err(712):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-06 17:19:49.186: W/System.err(712):  at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:0)

http://www.fuzzylite.com/forums/topic/logical-operators-grammers-error-in-numbers-of-operands/

回答了这些问题

具体来说,问题在于规则:

if (chestpain is ASYMPTOMATIC or restpress is MAX or serum is MAXLEVEL) and (smoke is LOWPOSSIBILITY or sugar is LEVELNO or minrate is MINRATE or restrate is HIGHRATE) then angin is MASSIVE

您指的是minrate,但是您没有将任何名为minrate的变量添加到引擎中。

此外,请确保您已考虑过连接器和/或规则的优先顺序。如果不确定,请像我一样在括号中分组命题(如果该分组对您的问题有意义)。

另请注意,由于您正在使用和/或在您的规则中,您必须设置您选择的相应连接和分离运算符。例如,

engine.configure("AlgebraicProduct", "AlgebraicSum", "AlgebraicProduct", "AlgebraicSum", "Centroid");

如需将来参考,请参阅www.fuzzylite.com论坛,以获取解决您可能遇到的任何问题的帮助。