Hi,

   Ok, let me try to understand... in the following piece of code:

       CDEntryCache( (ValueCode.iterator.next == "277.1" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "277.2" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "277.3" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "277.4" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )

   Is "ValueCode" a list? meaning iterator is actually creating an iterator for each of these conditions?
   Can we simplify this?

       CDEntryCache( valueCode[0] in ( "277.1", "277.2", "277.3", "277.4"), valueCodeSystem[0] == "2.16.840.1.113883.6.2" )

    Assuming valueCode and valueCodeSystem are lists and by "iterator.next" you was getting the first element in each list, the above pattern is equivalent to that snippet from your rule. Assuming this is true, we could simplify a lot your rules, obviously improving the overall performance of the system.

    Just so you understand, every time you use "or", behind the scenes the system calculates all possible logical branches and creates one "sub-rule" for each logical branch. With the amount of nested "or"s you used in your example rule, your kbase must be generating thousands of subrules.

    Let me know if the above works for you and we can proceed.

    Edson


2010/1/29 kashif10 <kash452@yahoo.com>

Yes we have around 15-20K rules & each rule have different set of conditions
ANDed/ORed.
Some rules are small have 10-15 conditions but some have more than 100
conditions to be fullfilled to trigger the rule.

The eval() function was taking time & never loads the single rule.
So today I change my logic & start using java beans, & insert the patient
profile/data in CDEntryCache bean this will not fullfilled all of us
condition, as we have some complex matching condition need to communicate
with db e.g drug formualrtions etc but to give a try, I create the rule as
follows:

Following rule having some conditions which should be matched with
WM(patient profile) to trigger the alert.

#created on: Jan 29, 2009
package my.rule;

import java.util.List;
import java.util.Vector;
import java.rule.*;

global java.util.Vector resultIds;

rule "kash3"

       when
        #conditions

        (


        (

       CDEntryCache( (valueName.iterator.next == "Vibrio abc 1")||
                    (ValueCode.iterator.next == "243327001" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.96") )

       or

       CDEntryCache( (valueName.iterator.next == "Vibrio abc splendidus 2")||
                    (ValueCode.iterator.next == "243327002" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.96") )

       or
       CDEntryCache( (valueName.iterator.next == "Vibrio abc splendidus 3")||
                    (ValueCode.iterator.next == "243327003" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.96") )

       or
       CDEntryCache( (valueName.iterator.next == "Vibrio abc splendidus 4")||
                    (ValueCode.iterator.next == "243327004" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.96") )


        )
       and

        (

       CDEntryCache( (ValueCode.iterator.next == "277.1" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "277.2" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "277.3" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "277.4" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
        )

       and

        (

       CDEntryCache( (ValueCode.iterator.next == "377.1" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "377.2" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "377.3" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "377.4" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
        )

                       and
        (

       CDEntryCache( (ValueCode.iterator.next == "477.1" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "477.2" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "477.3" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "477.4" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
        )


       and

        (

       CDEntryCache( (ValueCode.iterator.next == "577.1" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "577.2" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "577.3" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "577.4" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
        )


       and

        (

       CDEntryCache( (ValueCode.iterator.next == "677.1" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "677.2" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "677.3" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "477.4" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
        )


       and

        (

       CDEntryCache( (ValueCode.iterator.next == "877.1" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "877.2" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "877.3" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "877.4" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
        )


       and


        (

       CDEntryCache( (ValueCode.iterator.next == "977.1" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "977.2" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "977.3" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "977.4" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
        )


       and

                        (

       CDEntryCache( (ValueCode.iterator.next == "777.1" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "777.2" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "777.3" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
       or
       CDEntryCache( (ValueCode.iterator.next == "777.4" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )
        )


       and
        (


       CDEntryCache( (valueName.iterator.next == "Vibrio splendidus biogroup I")||
                    (ValueCode.iterator.next == "115054009" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.96") )

        )

       and
       CDEntryCache( (ValueCode.iterator.next == "277.6" &&
ValueCodeSystem.iterator.next == "2.16.840.1.113883.6.2") )

        )



       then
               #actions
               System.out.println("*********** RULE TRIGGERS ************");
               resultIds.add("kash3");

end


The above rule have 36 conditions of CDEntryCache 3-4 conditions ORed with
each other then ANDed with another similar type of condition block. And it
takes so much memory of the system on kbase.addKnowledgePackages
the rule file is around 6kb but the knowdge package taking so much memory.
from 40Mb it goes to 401Mb

after  kbuilder.getKnowledgePackages()
Total Memory: 799145984
       Used: 42047936
       Free: 757098048
Percent Used: 5.261608872703789
Percent Free: 94.73839112729621
Time: 2010-01-29 15:55:53.419

after  kbase.addKnowledgePackages(pkgs)
Total Memory: 799145984
       Used: 420606424
       Free: 378539560
Percent Used: 52.63198870057764
Percent Free: 47.368011299422356
Time: 2010-01-29 15:56:09.999



Thanks.
--
View this message in context: http://n3.nabble.com/Weblogic-rules-to-Drools-rules-tp126265p144134.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com