Re: error using Facts in other facts

28 views
Skip to first unread message

CLIPS Support

unread,
Jun 5, 2013, 3:37:39 PM6/5/13
to clip...@googlegroups.com
It looks like you're trying to embed a fact within another fact in your deffacts statement:

(relation (relname v1) (reltype butt) (part (pname P1) (parttype Plate) (pname P2) (parttype Plate)))

If you want to link the facts, then do this instead:

(relation (relname v1) (reltype butt) (part P1 P2))

In your rules you can use conditions such as these to find the linked facts:

(relation (part $? ?part $?))
(part (pname ?part))

Just add any of the additional slots you want to examine to the pattern.

On Friday, May 31, 2013 2:04:19 PM UTC-5, Deepak Agrawal wrote:
I want to define relation as facts in which I have to use parts which are also facts, using multislot
eg. rel1=fillet type part1 part2

I am new to CLIPS so I don't know where did go wrong. Any help will be greatly appreciated. Here is the code I could come up with.

(deftemplate part
(slot pname
(type SYMBOL)
(default Unknown))
(slot parttype
(type SYMBOL)
(default Unknown)))

(deftemplate relation
(slot relname (type SYMBOL) (default Unknown))
(slot reltype (type SYMBOL) (default Unknown))
(multislot part))

;(deftemplate ruls
;(slot rulename (type SYMBOL))
;(multislot relation))



(deffacts parts
(part (pname P1) (parttype Plate))
(part (pname P2) (parttype Plate))
(part (pname g1) (parttype girder))
(part (pname g2) (parttype girder))
(part (pname r1) (parttype rib))
(part (pname r2) (parttype rib)))

(deffacts relations
(relation (relname v1) (reltype butt) (part (pname P1) (parttype Plate) (pname P2) (parttype Plate)))
(relation (relname v2) (reltype fillet) (part (pname r1) (parttype rib) (pname P1) (parttype Plate))) 
(relation (relname v3) (reltype fillet) (part (pname r1) (parttype rib) (pname P2) (parttype Plate))) 
(relation (relname v4) (reltype fillet) (part (pname r2) (parttype rib) (pname P1) (parttype Plate)))
(relation (relname v5) (reltype fillet) (part (pname r2) (parttype rib) (pname P2) (parttype Plate))) 
(relation (relname v6) (reltype fillet) (part (pname g1) (parttype girder) (pname P1) (parttype Plate))) 
(relation (relname v7) (reltype fillet) (part (pname g2) (parttype girder) (pname P2) (parttype Plate))) 
(relation (relname v8) (reltype through) (part (pname g1) (parttype girder) (pname r1) (parttype rib))) 
(relation (relname v9) (reltype through) (part (pname g1) (parttype girder) (pname r2) (parttype rib)))
(relation (relname v10) (reltype through) (part (pname g2) (parttype girder) (pname r1) (parttype rib))) 
(relation (relname v11) (reltype through) (part (pname g2) (parttype girder) (pname r2) (parttype rib))))

Deepak Agrawal

unread,
Jun 7, 2013, 1:12:15 PM6/7/13
to clip...@googlegroups.com
Thanks. That helped.
Reply all
Reply to author
Forward
0 new messages