gpt4 book ai didi

drools - 属性访问问题

转载 作者:行者123 更新时间:2023-12-04 03:06:43 27 4
gpt4 key购买 nike

我尝试使用这个规则:

rule "conformSyncConstraint"
when
$syn_con : SyncConstraint(
$left_stp_period : leftSTP.period,
$right_stp_period : rightSTP.period)
eval( ($left_stp_period.dayOfWeek == $right_stp_period.dayOfWeek &&
$left_stp_period.dayOrder == $right_stp_period.dayOrder) == false)

then
insertLogical(new IntConstraintOccurrence("conformSyncConstraint",
ConstraintType.NEGATIVE_HARD,
1,
$syn_con));
end

但我遇到了这个错误,这似乎是一个黑匣子:

Rule Compilation error : [Rule name='conformSyncConstraint']
in/co/technovia/timetabler/domain/Rule_conformSyncConstraint_4401252830cd4ee7bc49416ead3da86c.java (8:1459) : The field Period.dayOfWeek is not visible
in/co/technovia/timetabler/domain/Rule_conformSyncConstraint_4401252830cd4ee7bc49416ead3da86c.java (8:1490) : The field Period.dayOfWeek is not visible


at org.drools.planner.config.solver.SolverConfig.buildRuleBase(SolverConfig.java:238)
at org.drools.planner.config.solver.SolverConfig.buildSolver(SolverConfig.java:170)
at org.drools.planner.config.XmlSolverConfigurer.buildSolver(XmlSolverConfigurer.java:103)
at in.co.technovia.timetabler.TimeTableApp.createSolver(TimeTableApp.java:61)
at in.co.technovia.timetabler.TimeTableApp.main(TimeTableApp.java:45)

这里出了什么问题?

最佳答案

无论何时使用 eval,您都会退回到正在使用的方言。在您的情况下,您使用的是 java 方言,因此您必须使用 java 语法编写表达式:.getDayOfWeek() 而不是 .dayOfWeek。

如果您不使用 evals,或者如果您将方言切换为 mvel,则可以使用简化语法。

例如:

when
$syn_con : SyncConstraint(
leftSTP.period.dayOfWeek != rightSTP.period.dayOfWeek ||
leftSTP.period.dayOrder != rightSTP.period.dayOrder
)
then

关于drools - 属性访问问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9978800/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com