2016-12-03 67 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