0

我正在使用 [家庭本体][1] 来测试 Jess 规则。除非使用 Jess 内置函数(例如 min 和 max)处理数据,否则一切正常。我设计了以下规则:

(defrule print_people_min_age 
(object  (https://wiki.csc.calpoly.edu/OntologyTutorial/family_example.owl#age ?a)) 
   => 
(printout t "Min age " (min ?a) crlf))

该规则编译得很好,但我没有得到想要的输出。它输出本体中每个人的年龄。我试图将 min 函数放在 LHS 中,但它会导致错误。

[1]:家庭本体https://wiki.csc.calpoly.edu/OntologyTutorial/attachment/wiki/AddingRuleWithJessTab/family_example_for_rules.owl

4

1 回答 1

1

函数(min <numeric-expresion>+)(max <numeric-expresion>+)旨在应用于多个参数 - 你只用一个参数调用它。该规则为每个对象触发一次,并且该单个年龄的最小值是 - 该年龄。

此规则说明了如何找到最小值:

(defrule print_people_min_age 
(object  (https://wiki.csc.calpoly.edu/OntologyTutorial/family_example.owl#age ?a1))
(not (object (https://wiki.csc.calpoly.edu/OntologyTutorial/family_example.owl#age ?a2&:(< ?a2 ?a1))))
=> 
(printout t "Min age " ?a1 crlf))
于 2014-12-14T13:15:41.857 回答