Matching all the values of a multislot with slots in several facts

449 views
Skip to first unread message

Manuel Caeiro

unread,
Aug 14, 2008, 7:05:16 AM8/14/08
to CLIPSESG
Hi,

I am a novice in CLIPS and I do not know how to solve the following
problem.

I have the following code (among others)


(deftemplate Connector

(slot element-id)

(multislot input-event)
)


(deftemplate Event

(slot element-id)
)

(deffacts simple

(Connector (element-id 1) (input-event 10 11))
(Connector (element-id 2) (input-event 12 13 14 15))

(Event (element-id 11))
(Event (element-id 12))
(Event (element-id 13))
(Event (element-id 14))
(Event (element-id 15))
)


Now, I want to define a rule that needs to be activated if all the
Events indicated in the input-event multislot of the Connector have
been asserted. In this case, the rule would be activated for the
Connector with element-id 2.

How I could define such a rule?

Thanks in advance,

Manuel Caeiro

CLIPS Support

unread,
Aug 14, 2008, 12:45:19 PM8/14/08
to CLIPSESG
(defrule all-contained
(Connector (element-id ?id))
(forall (Connector (element-id ?id) (input-event $? ?event $?))
(Event (element-id ?event)))
=>
(printout t "Connector " ?id crlf))

Manuel Caeiro Rodríguez

unread,
Aug 14, 2008, 1:08:01 PM8/14/08
to CLIP...@googlegroups.com
Thank you very much.

In addition, I have another need. The Event facts include additional slots, such as parameters, and I need to have access to that slots. Is that possible in CLIPS?

2008/8/14 CLIPS Support <gdronl...@swbell.net>

CLIPS Support

unread,
Aug 15, 2008, 11:30:30 AM8/15/08
to CLIPSESG
Yes. Just bind the slot value to a variable and you can use it on the
RHS of the rule. The primary restriction in doing this is that
variables that have initially been bound inside a not CE (which the
forall uses) can not be referenced on the RHS since the not CE if
satisfied means that no such fact exists from which to pull the slot
value.

On Aug 14, 12:08 pm, "Manuel Caeiro Rodríguez" <mcaei...@gmail.com>
wrote:
> Thank you very much.
>
> In addition, I have another need. The Event facts include additional slots,
> such as parameters, and I need to have access to that slots. Is that
> possible in CLIPS?
>
> 2008/8/14 CLIPS Support <gdronline2...@swbell.net>
Reply all
Reply to author
Forward
0 new messages