Karim,

It would be good to have a simple self contained sample to run and make tests and also to look at your DSL to know what these rules translates to. Some tips I can give you in this matter:

1. If your category conditions does not overlap each other, you must not use salience. The use of salience will force the engine to use priority queues and will avoid possible optimizations. Simply state the conditions for each category in each rule and let the engine decide how to classify your categories.

2. The use of the condition "The category is empty" will cause all other activations to be canceled as soon as you do a modifyObject() in a category that matched a rule. Also, if the only thing your rules do is to set the category and the conditions are not overlapping conditions, you don't need to call modifyObject() at all. So, don't call clearAgenda(). Usually, a rule should never try to control the engine, as it is not declarative and is an indicative that something else is wrong.

3. There is a feature in Drools that is known as "Alpha node hashing". It is used to optimize cases like the one you have where each rule checks for a different literal value in a column attribute. Although, this feature is automatically enabled for ObjectTypeNodes and disabled for Alpha Nodes. As the condition we are interested in is your second constraint: "Type of the input is 'XX'", you might try activating it for alpha nodes too. To do it, simply set the following system property:

org.drools.alpha-hash.alpha-node=true

Also, as all your first constraints are the same: "The category is empty", you might want to disable it for the ObjectTypeNodes, but this shall not have any major impact:

org.drools.alpha-hash.type-node=false

So, if you send us your DSL or a simple self-contained test, we might be able to help more. For all the considerations above, I assumed you are doing something like that in your translated rule:

rule "Cat1"
       salience 980 # salience should not be used in this case
when
obj : SomeClass( category == null, input == '10', color matches 'regex' )
then
       obj.setCategory("CAT1");
       drools.clearAgenda() // THIS SHOULD NOT BE DONE
end

   If you are doing something different, the tips above might not be valid.

   Hope it helps.

   []s
   Edson


Karim wrote:

Hi Michael, Drools users, I've one hundred rules in my rulebase.
Each rules have a different salience (they're all ordered between them ).
Each rule can set the value of the category and "exclude" all other rules.
That is to say that when a category is set, I clear the agenda.

My rulefile looks like this (in pseudo-code ) :

rule "CAT1" salience 980 when
                The category is empty
               Type of the input is '10' //The 1st and the 2nd chars of the 
record
                The color matches 'Regular Expression' //The 3rd to 20th chars 
of the record
        then
                Set to the category the value 'CAT1'
                drools.clearAgenda()
end


rule "CAT2" salience 970
        when
                The category is empty
                Type of the input is '20' //The 1st and the 2nd chars of the 
record
                The area is neither 'XX' nor 'YY' //The 20th to 22th chars of 
the record
        then
                Set to the category the value 'CAT2'
                drools.clearAgenda()
end

rule "CAT3" salience 960 when
                The category is empty
                Type of the input is '20' //The 1st and the 2nd chars of the 
record
                The area is either 'XX' or 'YY' //The 20th to 22th chars of the 
record
        then
                Set to the category the value 'CAT3'
                drools.clearAgenda()
end
        

Do you need some more infos or is it enough ?

Thanks for your help.


De: "Michael Neale" <[EMAIL PROTECTED]>
A: [email protected]
Objet: Re: [drools-user] Using Drools to modify the records of a file
Date: Thu, 4 May 2006 11:05:32 +1000

may need some more info on the specifics of your rule.
On 5/3/06, Karim <[EMAIL PROTECTED]> wrote:
Hi all Drools users,<br>
I'm trying to use Drools in order to determinize a category from a
record from an input file and write the category int an output file.<br>
I have around 100 categories and so around 100 rules.<br>
Everything works well except the fact that the perf are really bad.<br>
After profiling my program, it appears that the performance problem
cames from the call of the modifyObject method everytime I read a new
record. With a file of 10000 lines, I need 200 seconds to determinize
all the categories. The modifyObject method calls represents 185
seconds.<br>
<br>
The problem is that I've not found any other ways to activate my rules
without making a call to modifyObject.<br>
<br>
Is there any other way to read a file, and determinize all my
categories without regenerating the activations in the agenda every new
line ?<br>
<br>
I already tried to activate all my rules, to get all the activations
:<br>
org.drools.spi.Activation[] acts = workingMemory.getAgenda
().getActivations();<br>
<br>
To create a new agenda Group :<br>
org.drools.common.AgendaGroupImpl group = new
org.drools.common.AgendaGroupImpl("test");<br>
       for(int j = 0; j < acts.length; j++  {<br>
           group.add(acts[j]);<br>
       }<br>
<br>
To create my agenda :<br>
org.drools.common.Agenda agenda = new org.drools.common.Agenda
(workingMemory);<br>
       agenda.addAgendaGroup(group);<br>
       agenda.setFocus(group);<br>
<br>
And I modified the working memory to always fire the rules in my agenda
:<br>
workingMemory.fireAllRules(agenda);<br>
<br>
But the problem is that the LHS is not evaluated and all the rules
activated are fired so I always have the same result (the one from the
rules with the smaller salience...).<br>
<br>
I will really appreciate any help :-)<br>
<br>
Thank you<br>
<br>
<br>

CaraMail le seul webmail à vous offir des fils d'infos RSS -
www.caramail.com


Avec M6mobile, remixe « la Boulette » de Diam?s et crée ton propre tube. 
Inscris ton mix au concours et soumets le aux oreilles des internautes ET à 
celles de Diam?s ! Visit: http://ad.fr.doubleclick.net/clk;32430316;13177692;b


Reply via email to