Help with nested rules

67 views
Skip to first unread message

shanthala

unread,
Mar 10, 2008, 5:29:52 PM3/10/08
to CLIPSESG
I am new to CLIPS and trying different things to understand how it
works. But i have run into a problem here and i hope somebody can
help.

I have the following(below) in my rules fiile that i load into clips.
I have set the break points in all the rules. I have also set the
focus. Now, i assert MoreThanZeroLessThan10 and revnum. When i run, I
see that each rule is executed except for the last one(mymodule::4).
This is never put in the agenda. After excuting rule 2, 0 and 1 are
put on the agenda and are executed. After it is done, i see the
current module is set to MAIN. And the the last rule is never
executed. What am i missing here? I thought mymodule::4 will be
executed when there is a Condition <condname> and Satisfied <condname>
in the fact list.

Any help much appreciated.


(defmodule mymodule)

(defrule mymodule::0
(Condition MoreThanZero)
(num ?num_var)
(test (> ?num_var 0))
=>
(assert(Satisfied MoreThanZero)))

(defrule mymodule::1
?f <- (Condition LessThan10)
(num ?num_var)
(test (< ?num_var 10))
=>
(assert (Satisfied LessThan10)))

(defrule mymodule::2
?f <- (Condition MoreThanZeroLessThan10)
(revnum ?revnum_var)
=>
(retract ?f)
(assert (num ?revnum_var))
(assert (Condition MoreThanZero))
(assert (Condition LessThan10)))

(defrule tc.CE::4
(exists (Condition ?))
(forall (Condition ?condition)
(Satisfied ?condition))
=>
(assert( Satisfied all-satisfied)))

CLIPS Support

unread,
Mar 10, 2008, 8:48:19 PM3/10/08
to CLIPSESG
There is no rule mymodule::4. The last rule is tc.CE::4 which is in a
different module.

Tyler

unread,
Mar 10, 2008, 9:01:14 PM3/10/08
to CLIP...@googlegroups.com
Your rule is not named correctly. As support wrote, there is no rule in
your original code called mymodule::4. tc.CE is a totally different module.

(defrule mymodule::4


(exists (Condition ?))
(forall (Condition ?condition)
(Satisfied ?condition))
=>
(assert( Satisfied all-satisfied)))

shanthala

unread,
Mar 10, 2008, 10:14:26 PM3/10/08
to CLIPSESG
Sorry for the confusion. The last rule is mymodule::4. I forgot to
change it when i posted.

Thanks
Shanthala
> > (assert( Satisfied all-satisfied)))- Hide quoted text -
>
> - Show quoted text -

shanthala

unread,
Mar 10, 2008, 10:21:08 PM3/10/08
to CLIPSESG
One other note - When i loaded the rule file, i get the
following(below) warning. Is this the cause of the problem? Thanks
(load "D:/Cond..../nestedCondition1.clp")
+*****[FACTLHS1] WARNING: Creating implied initial-fact deftemplate in
module mymodule.
You probably want to import this deftemplate from MAIN module.


On Mar 10, 9:01 pm, "Tyler" <tw...@kc.rr.com> wrote:

CLIPS Support

unread,
Mar 10, 2008, 10:36:50 PM3/10/08
to CLIPSESG
Yes.

shanthala

unread,
Mar 11, 2008, 12:34:01 AM3/11/08
to CLIPSESG
How do i fix this?

Thanks
> > > - Show quoted text -- Hide quoted text -

CLIPS Support

unread,
Mar 11, 2008, 1:17:00 AM3/11/08
to CLIPSESG
(defmodule mymodule (import MAIN deftemplate initial-fact))

shanthala

unread,
Mar 11, 2008, 9:49:43 AM3/11/08
to CLIPSESG
I tried this. and i get the error while loading the rules file. It
says:
'Module MAIN does not export any constructs'

Thanks

shanthala

unread,
Mar 11, 2008, 11:25:46 AM3/11/08
to CLIPSESG
I got it working. I have to export the deftemplate initial-fact from
MAIN and then import it.

Thanks
Reply all
Reply to author
Forward
0 new messages