[rules-users] "Exists" CE behaviour

Wolfgang Laun wolfgang.laun at gmail.com
Mon Jul 13 06:27:03 EDT 2009


Quite right, since not(not(Foo())) is equivalent to exists(Foo()).

Martin, would you please submit a JIRA?

-W


On 7/13/09, Chivotario Martin <chivotario at gmail.com> wrote:
> Hi Visu,
>
> My understanding (also tested) is that activations are created no matter the
> knowledge base has the rule packages loaded
> before or after the working memory is filled with facts, but the execution
> of the rules happens automatically if the working memory is filled in
> advance.Setting the RuleBaseUpdateHandler to null, prevents the execution of
> the rules but keeps activations to be created when adding a rule to the
> kbase.
> In this case, it seems the exists CE only creates activations if the rules
> are loaded before the working memory is populated.
> But this doesn't happen if i change the statement :
>
>   exists ( Foo() ) --> not ( not ( Foo() ) )
>
> In this case, activations are created no matter whether the kbase is empty
> or not before populating the WM.
>
>
>
>
> 2009/7/13 Viswanathan Nageswaran <visu.nageswaran at in.ibm.com>
>
> > Chivotario,
> >
> > >From what I understand, the activation of rules happen as facts are
> > inserted into the working memory; hence it is important for the session to
> > be begun against a knowledge base that has the rule packages loaded before
> > the facts are inserted.
> >
> > -Visu
> >
> >
> >
> >
> >             Chivotario Martin
> >             <chivotario at gmail
> >             .com>                                                      To
> >             Sent by:                  rules-users at lists.jboss.org
> >             rules-users-bounc                                          cc
> >             es at lists.jboss.or
> >             g                                                     Subject
> >                                       [rules-users] "Exists" CE behaviour
> >
> >             13/07/2009 14:11
> >
> >
> >             Please respond to
> >             Rules Users List
> >             <rules-users at list
> >               s.jboss.org>
> >
> >
> >
> >
> >
> >
> >
> > Hi ,
> >
> > I'm trying to use the Exists keyword within my rules with the following
> > snippet :
> >
> > // Create a session
> > KnowledgeBaseConfiguration config =
> >
> KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
> >
> ((RuleBaseConfiguration)config).setRuleBaseUpdateHandler(
> null ); *
> > KnowledgeBase kbase =
> KnowledgeBaseFactory.newKnowledgeBase(config);
> > StatefulKnowledgeSession session =
> kbase.newStatefulKnowledgeSession();
> >
> > // Add some objects
> > for (int i=0; i<5; i++) {
> > }
> >
> >
> > // Add a DRL to the kbase
> > KnowledgeBuilder kbuilder =
> KnowledgeBuilderFactory.newKnowledgeBuilder();
> > kbuilder.add( ResourceFactory.newClassPathResource(
> "test/existsTest.drl"
> > ), ResourceType.DRL);
> > kbase.addKnowledgePackages(
> kbuilder.getKnowledgePackages() );
> >
> > // Fire rules
> > int fireCount = session.fireAllRules();
> >
> >
> > existsTest.drl :
> >
> > rule "existsTest"
> > ( Foo() ) ); (2)
> >
> > end
> >
> > When launched , the rule is not fired (no messages , fireCount 0), but it
> > is when changing
> > exists with a double not condition (2).
> > If the working memory is populated after adding the rules file, the exists
> > CE works as expected.
> > * I've used no RuleBaseUpdateHandler preventing automatic activations to
> be
> > executed so fireAllRules can be used to get the fireCount, but commenting
> > this line out doesn't change the results.
> >
> > Probably i'm doing something wrong so a little help would be very
> > appreciated.
> >
> > Regards,
> > Manuel.
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>



More information about the rules-users mailing list