【问题标题】:terminate instruction in CLIPS在 CLIPS 中终止指令
【发布时间】:2013-12-23 01:31:06
【问题描述】:

我是 CLIPS 专家系统的新手。

我如何告诉 CLIPS 在执行特定指令后停止执行规则????!!

有点像这样:

(defrule  firstRule   
   (some assumption) 
   => 
   (if (X happened) then (and (print "yikes 1")(terminate the program))

(defrule  secondRule 
   (some assumption) 
   => 
   (if (Y happened) then (and (print "yikes 2")(terminate the program))

(defrule  thirdRule 
   (some assumption) 
   => 
   (if (Z happened) then (and (print "yikes 3")(terminate the program))

如果发生 Y 和 Z 而 X 没有发生,我希望打印出这样的内容:

yikes 2

【问题讨论】:

    标签: break clips


    【解决方案1】:

    使用这个:

    (if [condition]
       then
       (printout t "yikes 3" crlf)
       (halt))
    

    其中 [condition] 可以是变量 ?b 或表达式 (> 3 4) 之类的东西。在 printout 语句中,t 是逻辑名称,指示输出应指向的位置(在这种情况下,t 表示标准输出),crlf 打印回车/换行符(输出的新行)。 (halt) 语句在当前规则执行完毕后暂停规则的执行。然后,您可以通过在命令提示符下输入 (run) 来重新开始执行。或者,(exit) 命令将立即终止规则和 CLIPS 的执行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-30
      • 2013-09-18
      • 1970-01-01
      相关资源
      最近更新 更多