A practical example may be to add a "not Finish()" condition to your rules.
Then all you have to do to finish up is assert a Finish object and it will
effectively stop (I just made that up, may be better examples).
On 5/6/06, Peter Lin <[EMAIL PROTECTED]> wrote:
LIFO ordering is the result of how facts propogate down the RETE network.
facts that are newer end up in the agenda later. the general theory is
that
new facts are more important than older facts.
to learn more about it, look at papers that talk about conflict
resolution.
peter
On 5/5/06, Ray Krueger <[EMAIL PROTECTED]> wrote:
>
> I was curious about the reasoning for the LIFO behavior. Thanks.
>
>
> On 5/5/06, Mark Proctor <[EMAIL PROTECTED]> wrote:
> > or in other words Activations with newer data take priority over
> > activations with older data.
> > Mark Proctor wrote:
> > > That is correct LIFO behaviour - last in first out.
> > > Ray Krueger wrote:
> > >> The agenda, when calling getNextFocus, calls getLast(). Which
causes
> > >> the consequences to be executed in reverse order. Is there a reason
> > >> for that?
> > >>
> > >> For example, the following example....
> > >>
> > >> public static void main(String[] args) throws Exception {
> > >>
> > >> StringBuffer rules = new StringBuffer();
> > >> rules.append("package example;\n")
> > >> .append("import java.lang.Integer;\n")
> > >> .append("rule \"Count\"\n")
> > >> .append("when\n")
> > >> .append("i : Integer()\n")
> > >> .append("then\n")
> > >> .append("System.out.println(i);\n")
> > >> .append("end\n");
> > >>
> > >> System.out.println(rules);
> > >>
> > >>
> > >> final PackageBuilder builder = new PackageBuilder();
> > >> builder.addPackageFromDrl(new StringReader(rules.toString
()));
> > >>
> > >> final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
> > >> ruleBase.addPackage(builder.getPackage());
> > >>
> > >> final WorkingMemory workingMemory =
ruleBase.newWorkingMemory
> ();
> > >>
> > >> for (int i = 0; i < 10; i++) {
> > >> workingMemory.assertObject(new Integer(i));
> > >> }
> > >>
> > >> workingMemory.fireAllRules();
> > >> }
> > >>
> > >>
> > >> Will print out...
> > >> 9
> > >> 8
> > >> 7
> > >> 6
> > >> 5
> > >> 4
> > >> 3
> > >> 2
> > >> 1
> > >> 0
> > >>
> > >>
> > >
> > >
> > >
> >
> >
>