Jess程序设计语言
外观

Jess是Java平台上的规则引擎,它是CLIPS程序设计语言的超集,由Sandia国家实验室的Ernest Friedman-Hill开发。它的第一个版本写于1995年晚期。
Jess提供适合自动化专家系统的逻辑编程,它常被称作“专家系统外壳”。近年来,智能代理系统也在相似的能力上发展起来。
与一个程序中有一个只运行一次的循环的指令式編程语言不同,Jess使用的宣告式编程通过一个名为“模式匹配”的过程连续的对一个事实的集合运用一系列规则。规则可以修改事实集合,或者运行任何Java代码。
Jess可以被用来构建使用规则定义形式的知识来推倒结论和推论的Java Servlet、EJB、Applet和应用程序。因为不同的规则匹配不同的输入,所以有了一些有效的通用匹配算法。Jess规则引擎使用Rete算法。
许可证
Jess不是开源软件,而CLIPS是。
代码实例
代码实例:
; 分号后面的是注释
(bind ?x 100) ; x = 100
(deffunction max (?a ?b) (if (> ?a ?b) then ?a else ?b))
(deffacts myroom (furniture chair) (furniture table) (furniture bed) )
(deftemplate car (slot color) (slot mileage) (slot value) )
(assert (car (color red) (mileage 10000) (value 400)))
例子代码:
(clear) (deftemplate blood-donor (slot name) (slot type)) (deffacts blood-bank ; put names & their types into working memory (blood-donor (name "Alice")(type "A")) (blood-donor (name "Agatha")(type "A")) (blood-donor (name "Bob")(type "B")) (blood-donor (name "Barbara")(type "B")) (blood-donor (name "Jess")(type "AB")) (blood-donor (name "Karen")(type "AB")) (blood-donor (name "Onan")(type "O")) (blood-donor (name "Osbert")(type "O")) ) (defrule can-give-to-same-type-but-not-self ; handles A > A, B > B, O > O, AB > AB, but not N1 > N1 (blood-donor (name ?name)(type ?type)) (blood-donor (name ?name2)(type ?type2 &:(eq ?type ?type2) &: (neq ?name ?name2) )) => (printout t ?name " can give blood to " ?name2 crlf) ) (defrule O-gives-to-others-but-not-itself ; O to O cover in above rule (blood-donor (name ?name)(type ?type &:(eq ?type "O"))) (blood-donor (name ?name2)(type ?type2 &: (neq ?type ?type2) &: (neq ?name ?name2) )) => (printout t ?name " can give blood to " ?name2 crlf) ) (defrule A-or-B-gives-to-AB ; case O gives to AB and AB gives to AB already dealt with (blood-donor (name ?name)(type ?type &:(or (eq ?type "A") (eq ?type "B" )))) (blood-donor (name ?name2)(type ?type2 &: (eq ?type2 "AB") &: (neq ?name ?name2) )) => (printout t ?name " can give blood to " ?name2 crlf) ) ;(watch all) (reset) (run)