根据AddingRuleWithJessTab中给出的多插槽设置的示例规则AssertingHasSiblingMulti1
,我创建了以下Jess规则,用于在我的属性foundPollutionSources上设置多槽值:
(defrule findPHPolluters
(declare (salience 553))
(object
(is-a http..#PollutionSources)
(OBJECT ?sitepoll)
(http..potentialPollutant
$? ?b&:(eq (instance-name ?b)(instance-name http..#pH)) $?)
(http..#pollutionSourceName ?psName)
(http..#pollutionType ?psType)
)
(object
(is-a http..#MeasurementSite)
(OBJECT ?loc)
(http..#hasSourcesOfPollution $?sitepoll_list)
)
(object
(is-a http..#ModeratePHMeasurement)
(OBJECT ?mob)
(http..#observationResultLocation ?loc)
(http..#foundPollutionSources $?existing_poll_list)
)
=>
(if (not (member$ ?sitepoll $?sitepoll_list)) then
(printout t "pH pollution source: " ?psName " (Location: " ?psType ")" crlf)
(slot-set ?mob http..#foundPollutionSources (create$ $?existing_poll_list ?sitepoll))
)
)
但是,当我运行此规则时,会出现以下异常:
Jess在执行时报告了例程ValueVector.set中的错误 在执行规则LHS(TECT)时规则LHS(MTELN)。消息:不好 索引117调用此向量上的set():...
答案 0 :(得分:0)
与多时隙值的(部分)绑定的变量的通常Jess使用模式存在偏差。观察:
(object
...
(http..#foundPollutionSources $?existing_poll_list))
带前缀的'$'会将foundPollutionSources插槽中的所有值绑定到?existing_poll_list
。通常的用法(参见Jess手册和链接的例子)将是,例如:
(printout t "pollution sources " ?existing_poll_list crlf))
但你的RHS代码有
(create$ $?existing_poll_list ...)
注意虚假的'$' - 我会省略它并再试一次。
我不知道什么保护和/或Jess可能会对此做出什么,我没有时间在后者中进行研究。