2016-12-03 21 views
0

我想检查是否已经存在相同的实例或不。杰斯multislot值匹配忽略订单

(defemplate justificand (slot consq) (multislot antes)) 
(assert (justificand (consq s) (antes p q r))) ;;; order p q r 

(defrule test 
    (exists (justificand (consq s) (antes q p r))) ;;; order q p r 
    => 
    (printout t "matching success " crlf)) 

以我为例,我主张用(前注p q R),但P,Q和R的顺序 并不重要一justificand。因此,即使用(antes q p r)进行测试,测试规则也需要成功。

但是,jess似乎考虑多时隙值的匹配顺序。

任何忽略多槽值匹配顺序的方法?

感谢

回答

0

有了您的自定义模板,这功能

(deffunction unleq (?l1 $?l2) 
    (and (eq (length$ ?l1)(length$ $?l2)) 
     (eq (length$ ?l1)(length$ (intersection$ ?l1 $?l2))))) 

并插入事实:

(deffacts f1 
    (justificand (consq s1) (antes p q r)) 
    (justificand (consq s2) (antes r p q)) 
    (justificand (consq s3) (antes p q x)) 
    (justificand (consq s4) (antes p q)) 
    (justificand (consq s4) (antes r q q p p))) 

这个规则被触发:

(defrule match 
    (justificand (consq ?s) (antes $?pqr&:(unleq $?pqr p q r))) 
=> 
    (printout t "match for " ?s crlf)) 

match for s2 
match for s1 
+0

非常感谢!我很感谢您的帮助! – youngtackpark