W3C home > Mailing lists > Public > public-rif-wg@w3.org > August 2010

Re: Fwd: Clips behavior

From: Mark Proctor <mproctor@redhat.com>
Date: Tue, 03 Aug 2010 08:57:58 +0100
Message-ID: <4C57CC06.4060605@redhat.com>
To: Gary Hallmark <gary.hallmark@oracle.com>
CC: RIF WG <public-rif-wg@w3.org>, Neal Wyse <neal.wyse@oracle.com>
  On 25/11/2009 16:14, Gary Hallmark wrote:
> A colleague and I have tested OBR, Jess, and Clips refraction behavior. All are consistent. All contradict PRD. I do not think the issue is whether actions are effective immediately, although there may also be issues with that. Rather, the issue ssems to be that PRD should consider all rule vars in the IF part, even existential vars, as part of the rule instance. Thus far, I have only heard that ILOG works like PRD says, and I haven't actually seen a test report verifying that.
I have done a blog that sheds some light on this.
http://blog.athico.com/2010/07/slot-specific-and-refraction.html

JRules is not the only one that does refraction. OPSJ does and OPS5, it 
is also part of the original LEX and MEA conflict resolution  
strategies. I think it's something that got "forgotten about" as the 
documentation on what refraction is, is almost impossible for lamen to 
interpret :)

As the blog points out neither Jess, Drools or Clips implement 
refraction. Instead they both have no-loop. No-loop is not the same as 
jrules modify + refresh.

Refraction means that once a rule+data fires no rule can make that 
rule+data fire again, no matter how it's fields are modified by other 
rules, as long as that rule+data remains true. A rule first has to make 
that rule+data false before it can be made true again and re-added to 
the agenda again.  And when it refers to +data with OO systems it's 
talking about the rule+(chain of fact time stamps), when you modify a 
fact's fields the timestamps do not change.

Where as no-loop only has focus on the current rule at the current point 
of firing, it simply says I'm firing now, can I re-add myself to the agenda?

This means for rules to execute the same on Jess, Clips, Drools and 
JRules; JRules would need to use refresh after every modify and no one 
can use no-loop. Which is not an ideal situation.

As you can see from the Jess conversation in the mailing list Ernest 
implemented slot-specific as an alternative to refraction, and 
slot-specific is the only way that Clips COOL works; as COOL objects are 
actually tripples of deftemplates. In the thread James Owen also 
provides a definition of what refraction is.

On a personal level my experience with users has told me that 
"slot-specific" is the way that most users expect an engine to behave 
and without it or refraction recursion becomes a problem - no-loop does 
not suffice. I held off on doing refraction because I felt that 
"refresh" was a bit too coarse, as you cannot choose which patterns are 
refreshed or not, which might cause unnecessary recursion. A combination 
of slot-specific, refraction and no-loop is ideal :)

For Drools I'll add refraction soon, intime for BRF. So that if ilog 
still want to do any RIF demos we can have the same behaviour. My 
suggestion is "refraction" become a on/off  setting; it should not be 
dropped.

Mark
> -------- Original Message --------
> Subject: Clips behavior
> From: Neal Wyse<neal.wyse@oracle.com>
> To: Gary Hallmark<Gary.Hallmark@oracle.com>
> CC: null
>
> Hi Gary,
>
> I've attached 3 Clips examples.
> rif1.clp - Modify_loop test
> rif2.clp, rif3.clp - two approaches to the Modify_noloop test
> They all loop with Clips which is what I expected.
> I'm not sure if we can get closer than that for the noloop test.
>
> Neal
> (deftemplate foo
>      (slot count)
> )
>
> (defrule r3
>   (and
>     ?f1<- (foo (count ?c))
>     (not (not (test (>  ?c 0))))
>   )
>   =>
>   (modify ?f1 (count (- ?c 1)))
>   (printout t (str-cat "r3 fired: ") ?c crlf)
> )
>
> (assert (foo (count 10)))
> (run)
> (deftemplate foo
>      (slot count)
> )
>
> (defrule r1
>     ?f1<- (foo (count ?c&:(>  ?c 0)))
>   =>
>   (modify ?f1 (count (- ?c 1)))
>   (printout t (str-cat "r1 fired: ") ?c crlf)
> )
>
> (assert (foo (count 10)))
> (run)
> (deftemplate foo
>      (slot count)
> )
>
> (defrule r2
>   (and
>     ?f1<- (foo)
>     (not (and  (foo (count ?c))
>        (test (not (>  ?c 0))))
>     )
>   )
>   =>
>   (bind ?cnt (fact-slot-value ?f1 count))
>   ;(modify ?f1 (count (- (fact-slot-value ?f1 count) 1)))
>   (modify ?f1 (count (- ?cnt 1)))
>   (printout t (str-cat "r2 fired: ") ?cnt crlf)
> )
>
> (assert (foo (count 10)))
> (run)
Received on Tuesday, 3 August 2010 07:58:42 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 August 2010 07:58:43 GMT