I thought that modules, by design as a stack, only fire rules after the
previous modules' rules have had the chance to fire. There doesn't seem
to be any reason to run each module separately unless I'm missing
something. In other words, shouldn't the following be equivalent to the
previous method?
(focus B)
(focus A)
(run)
Or in Java
rete.setFocus("B");
rete.setFocus("A");
rete.run();
Would there be a performance difference between a single run for all
modules and multiple runs, one for each module?
Also, another reason to use modules instead of salience is that salience
can be more difficult to maintain as a rule set grows, assuming the
design would use more salience declarations than modules.
Brian
-----Original Message-----
From: [email protected] [mailto:[email protected]]
On Behalf Of Ernest Friedman-Hill
Sent: Monday, October 12, 2009 7:23 PM
To: jess-users
Subject: Re: JESS: general question about using module to control rule
execution
Salience is considered bad form for two reasons: first, because it's
considered bad form, in general, to try to force the engine to fire
rules in a particular order; and second, it negatively impacts
performance. The truth is, though, if it's the most sensible or
elegant alternative in a particular application, there's really no
reason not to use it.
If you want to not fire any rules in module B until all rules in
module A have had a chance to fire, then rather than putting the focus
statements into a rule, you probably want to put them into the same
code that calls "run" -- i.e.,
(focus A)
(run)
(focus B)
(run)
On Oct 12, 2009, at 3:44 PM, Felix Chan wrote:
> Hi,
>
> I have a general question how to control execution using modules.
>
> I have business rules that apply at the country (US) level, and
> rules that apply at state level. What I would like to do is to apply
> country-level rules first and then state-level rules second. The
> state-level rules will overwrite some of the facts that were
> modified or asserted as a result of the country-level rules.
>
> I do NOT want to have any state-level rules applied before country-
> level rules have a chance to fire.
>
> I can group all the country-level rules in module COUNTRY and state-
> level rules in module STATE. I understand that I can put (focus
> STATE) on the RHS to move from one module to another to control
> execution flow.
>
> Question: What should I do to ensure that I will switch to the STATE
> module only after ALL APPLICABLE country-level rules have been
> applied (fired)?
>
> I can use salience, but the book says that it's bad form. So I am
> wondering if I should module.
>
> Thanks.
>
> Felix
---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com
--------------------------------------------------------------------
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].
--------------------------------------------------------------------
--------------------------------------------------------------------
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].
--------------------------------------------------------------------