【问题标题】:Using logical operators in CLIPS在 CLIPS 中使用逻辑运算符
【发布时间】:2012-11-26 22:53:37
【问题描述】:

我正在尝试在 CLIPS 中定义大于规则,但它似乎不起作用。关于如何修复它的任何想法。问题似乎发生在 defrule btwn100and120

(defrule part-credits
    (or (current-part "a")
        (current-part "b")
        (current-part "c"))
    =>
    (bind ?reply (get-text-from-user "How many points did you achieve?"))
    (assert (part-credits ?reply))
)

(defrule btwn100and120
    (part-credits => 100)
    (part-credits <= 120)
    =>
    (bind ?reply (get-text-from-user "Did you Part A before the changes? (y/n)"))
    (assert (btwn100and120 ?reply))
)

【问题讨论】:

    标签: expert-system clips


    【解决方案1】:

    使用test 函数进行数值比较。另外,请注意 CLIPS 对数学运算符使用前缀表示法。这是一个简化的规则,可以满足您的需求:

    (defrule MAIN::btwn100and120
      (part-credits ?val)
      (test (<= ?val 120))
      (test (>= ?val 100))
    =>
      (printout t "Value " ?val " is in range." crlf)
    )
    

    这是对规则的测试:

    CLIPS> (watch facts)
    CLIPS> (watch activations)
    CLIPS> (assert (part-credits 99))
    ==> f-0     (part-credits 99)
    <Fact-0>
    CLIPS> (assert (part-credits 110))
    ==> f-1     (part-credits 110)
    ==> Activation 0      btwn100and120: f-1
    <Fact-1>
    CLIPS> (run)
    Value 110 is in range.
    CLIPS> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-18
      • 2020-12-20
      • 1970-01-01
      • 2021-11-02
      • 2019-09-01
      相关资源
      最近更新 更多