首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CLIPSjni集成java

CLIPSjni集成java
EN

Stack Overflow用户
提问于 2022-05-25 07:54:06
回答 1查看 36关注 0票数 0

我刚开始使用与Jade agent.java集成的剪辑,我的事实和规则加载在不同的.clp文件中,我已经花了很多时间来比较我认为是数字的东西,但由于某种原因,它不起作用,尝试了许多不同的东西,没有什么东西使它工作:这里是我的事实的一部分:

代码语言:javascript
复制
(deffacts products 
        (product (name "USB Memory") (category storage) (part-number 1234) (price 9.99))
        (product (name Amplifier) (category electronics) (part-number 2341) (price 399.99))
        (product (name Speakers) (category electronics) (part-number 23241) (price 19.99))
        (product (name "iPhone 7") (category smartphone) (part-number 3412) (price 99))
        (product (name "Samsung Edge 7") (category smartphone) (part-number 34412) (price 88))
)

And here I have the rules that are not working:
(defrule my-rule14
   (not (product (category smartphone) **(price<50)**))
   =>
   (printout t "no smartphones cheaper than 50"  crlf ))


;; Defining a rule for finding smartphones cheaper than 100 dlls
(defrule my-rule15
   (product (category smartphone) (name ?nameb) **(price<100))**
   =>
   (printout t ?nameb " is cheaper than 100 dlls" crlf ))

没有一条规则起作用,我试着将比较改为{price<100},(price< 100),(价格< 100),(价格?价格)(测试(<?price< 100))

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2022-05-25 18:43:02

基本编程指南的5.4.1.5和5.4.2节包含了所需语法的相关信息:

代码语言:javascript
复制
         CLIPS (6.4 2/9/21)
CLIPS> 
(deftemplate product
   (slot name)
   (slot category)
   (slot part-number)
   (slot price))
CLIPS>    
(deffacts products 
   (product (name "USB Memory") (category storage) (part-number 1234) (price 9.99))
   (product (name Amplifier) (category electronics) (part-number 2341) (price 399.99))
   (product (name Speakers) (category electronics) (part-number 23241) (price 19.99))
   (product (name "iPhone 7") (category smartphone) (part-number 3412) (price 99))
   (product (name "Samsung Edge 7") (category smartphone) (part-number 34412) (price 88)))
CLIPS> 
(defrule my-rule14
   (not (product (category smartphone) (price ?price&:(< ?price 50))))
   =>
   (printout t "no smartphones cheaper than 50" crlf))
CLIPS> 
(defrule my-rule15
   (product (category smartphone) (name ?nameb) (price ?price))
   (test (< ?price 100))
   =>
   (printout t ?nameb " is cheaper than 100 dlls" crlf ))
CLIPS> (reset)
CLIPS> (agenda)
0      my-rule15: f-5
0      my-rule15: f-4
0      my-rule14: *
For a total of 3 activations.
CLIPS> (run)
Samsung Edge 7 is cheaper than 100 dlls
iPhone 7 is cheaper than 100 dlls
no smartphones cheaper than 50
CLIPS> 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72373850

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档