When we talk about the efficiency of a rule-based system, it's the
amount of work that it takes to find pattern matches that
counts. Because in the worst case that amount is polynomial in the
number of facts, it can dwarf the effort of actually firing the
rules after the matches are found. So left-hand-side concerns matter
much more than how many rules fire.
Now, comparing the efficiency of rules which do different things is
meaningless, so we can't really say that a or b is more or less
efficient than 1.5 itself. In this case, you need to find an actual
match, you want to use the most efficient rule which does exactly
that.
I think Jerry Hoe wrote:
> Hi again,
>
> Can I say that _1.5 will be more efficient than _1.5a and _1.5b since
> it only fires at most once per matching cycle?
>
> Using _1.5, I would like to get the handle to the (first) fact that activates
> the rule and retract it. However, I can't use 'not' since it cannot be used
> to define the values of any variables! So, does it mean that I have to
> resort to using either _1.5a or _1.5b which is probably less efficient?
>
> Thanks again!
>
> --
> Regards,
> Jerry
>
> [EMAIL PROTECTED] wrote:
>
> > _1.5a and _1.5b mean the same thing, but _1.5a will be more
> > efficient. In general, function calls will have more overhead
> > than direct pattern matching.
> >
> > _1.5 actually has a different meaning. Whereas the second two rules
> > match each e5crt fact where the field is not 0, 1, or 8, the first
> > rule matches the absence of any e5crt facts with the field equal to 0,
> > 1, or 8. The first rule will then be activated no more than once
> > simultaneously, while the other two can each be activated multiple
> > times, once for each matching fact.
> >
> > I think Jerry Hoe wrote:
> > > Hi again,
> > >
> > > The rules below produce the same effect. I can't decide which one to use.
> > > So, can someone please points out the pros and cons of each rule? What
> > > is the rule of thumb when resolving such situations? Thanks in appreciation.
> > >
> > > (defrule _1.5
> > > (not(e5crt ?val&:(= ?val 0)|:(= ?val 1)|:(= ?val 8)))
> > > =>
> > > (assert (result .)))
> > >
> > > (defrule _1.5a
> > > (e5crt ?val&~0&~1&~8)
> > > =>
> > > (assert (result .)))
> > >
> > > (defrule _1.5b
> > > (e5crt ?val&:(<> ?val 0)&:(<> ?val 1)&:(<> ?val 8))
> > > =>
> > > (assert (result .)))
>
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list (use your own address!) List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------