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@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@gmail
            .com>                                                      To
            Sent by:                  rules-users@lists.jboss.org
            rules-users-bounc                                          cc
            es@lists.jboss.or
            g                                                     Subject
                                      [rules-users] "Exists" CE behaviour

            13/07/2009 14:11


            Please respond to
            Rules Users List
            <rules-users@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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users