[rules-users] Large number of rules in Drools

Shweta1986 shweta.a.thakkar at gmail.com
Tue Jan 10 18:07:47 EST 2012


I can look into the solution of writing my own Java application for this
solution. But I would still like to understand, if the problem is just
because of the 3 values being checked in the rules ? Do complex rules dont
have more than 1 checks ?
If yes then this case should be supported no matter how simple the rule is
right ?

Also for the UI issue I mentioned. Assume some other complex rules. Is
copying the thousands of lines in the text area not a problem in guvnor ?

On Tue, Jan 10, 2012 at 12:38 PM, laune [via Drools] <
ml-node+s46999n3648792h90 at n3.nabble.com> wrote:

> Assuming that the remaining 19998 rules are of the same kind, there is a
> lot of data in these rules, and only very little logic. Ignoring the issue
> of "Olympia" being one of the cities not being "Seattle", we have the
> problem of matching a triplet of <field,state,city> from a Student fact so
> that we can store one or more Subjects in Student.subjects.
>
> Imagine that you have objects of type Inscribe containing a triplet of
> field, state, city and the pertaining List<Subject>. Then you could write a
> single (!) rule
>
> rule register
> when
>   $stu: Student ( $f: field, $s: state, $c: city )
>   $ins: Inscribe( field==$f, state==$s, city==$c )
> then
>   $stu.setSubjects( $ins.getSubjects() );
> end
>
> BTW: Why do you use equals with state? Using "==" should be possible here,
> too.
>
> And, of course, matching ~20000 different triplets to facts of a single
> type isn't really RBS fodder. You can design a simple Java program that
> achieves this goal, assuming you can come up with a straightforward
> representation of the <field,state,city;subject+> mapping.
>
> -W
>
>
> 2012/1/10 Shweta1986 <[hidden email]<http://user/SendEmail.jtp?type=node&node=3648792&i=0>
> >
>
>> My rules are  as follows.
>>
>> rule "rule1"
>>     salience -2
>>     dialect "mvel"
>>     when
>>     stud : Student ( field == "ARTS", state.equals("WA"))
>> then
>>     java.util.List subList = new java.util.ArrayList();
>>     Subject subject = new Subject();
>>     subject.setName("ABC");
>>     subject.setFees(33454);
>>     subject.duration(4);
>>     subList.add(subject);
>>
>>     subject = new Subject();
>>     subject.setName("XYZ");
>>     subject.setFees(33454);
>>     subject.duration(4);
>>     subList.add(subject);
>>
>>     stud.setSubjects(subList);
>> end
>> rule "rule2"
>>     salience -100
>>     dialect "mvel"
>>     when
>>     stud : Student ( field == "ARTS", state.equals("WA") , city ==
>> "SEATTLE"))
>> then
>>     java.util.List subList = new java.util.ArrayList();
>>     Subject subject = new Subject();
>>     subject.setName("ABC");
>>     subject.setFees(33454);
>>     subject.duration(4);
>>     subList.add(subject);
>>
>>     subject = new Subject();
>>     subject.setName("XYZ");
>>     subject.setFees(33454);
>>     subject.duration(4);
>>     subList.add(subject);
>>
>>     stud.setSubjects(subList);
>> end
>>
>>
>>
>> Student is the main object and it contains List of Subjects. here the way
>> I am using the salience because
>> if the input us shweta, ARTS, WA,Olympia it matched rule1
>> but if the input is shweta, ARTS, WA, Seattle it matches 1 and 2 but i
>> want the rule 2 to be executed  so salience.
>>
>> I am using StatelessKnowledge Session and also the resource change
>> scanner.
>> I execute one rule at a time and the scanner poll interval is 1 hour.
>> When I started with 100 rules I was using "PK" as my source in
>> changeSet.xml but when the rules grew to 20K I was not able to build the
>> rules in Guvnor UI and hence I started using "DRL" as source.
>>
>> The way I generate drl is using a script which converts the csv to drl
>> format.
>> I copy the drl to the text area in techincal rules and save it. ( this
>> copy is also paiful so I asked that if there is an upload drl file unlike
>> the import drl file)
>> In changeset I give the path to the url in webdav
>> /guvnor/org.drools.guvnor.Guvnor/webdav/packages/StudentRules/StudentRules.drl
>>
>> I am not sure if I am doing it the right way. Please suggest.
>>
>> Thanks,
>> Shweta
>>
>> On Mon, Jan 9, 2012 at 11:58 PM, laune [via Drools] <[hidden email]<http://user/SendEmail.jtp?type=node&node=3648661&i=0>
>> > wrote:
>>
>>> Salience is just one way to force the evaluation of a condition before
>>> others. In fact, using salience throughout is just a way of re-creating a
>>> sequence of plain old if statements using a rules engine.
>>>
>>> I'm not going to waste my time and yours by elaborating on possible
>>> alternatives unless you come up with a detailed description of your rules,
>>> and how you run your rules engine: fact insertion, calls to fire, etc.
>>>
>>> -W
>>>
>>> 2012/1/10 Shweta1986 <[hidden email]<http://user/SendEmail.jtp?type=node&node=3647015&i=0>
>>> >
>>>
>>>> I am not sure I understand that. What is the other option for this
>>>> case. Why would simple rules not work for 20 K rules. Am I missing
>>>> something. I cannot use database to store my rules. Drools also gives me
>>>> salience which I need for my usecase.
>>>>
>>>> On Thu, Jan 5, 2012 at 11:29 PM, laune [via Drools] <[hidden email]<http://user/SendEmail.jtp?type=node&node=3646449&i=0>
>>>> > wrote:
>>>>
>>>>> 2012/1/6 Shweta1986 <[hidden email]<http://user/SendEmail.jtp?type=node&node=3637255&i=0>
>>>>> >
>>>>>
>>>>>> And my rules are very simple it is like if string comparison then set
>>>>>> that's it..
>>>>>>
>>>>> This doesn't really warrant the use of a rule based system. If keeping
>>>>> this logic out of the application or an easy maintenance of these if-then's
>>>>> are your main goals, there are other ways. I've already hinted at this,
>>>>> with the idea of providing the information embedded in similar rules as
>>>>> data.
>>>>> -W
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> rules-users mailing list
>>>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=3637255&i=1>
>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>
>>>>>
>>>>> ------------------------------
>>>>>  If you reply to this email, your message will be added to the
>>>>> discussion below:
>>>>>
>>>>> http://drools.46999.n3.nabble.com/Large-number-of-rules-in-Drools-tp3630385p3637255.html
>>>>>  To start a new topic under Drools: User forum, email [hidden email]<http://user/SendEmail.jtp?type=node&node=3646449&i=1>
>>>>> To unsubscribe from Drools: User forum, click here.
>>>>> NAML<http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>>>>
>>>>
>>>>
>>>> ------------------------------
>>>> View this message in context: Re: [rules-users] Large number of rules
>>>> in Drools<http://drools.46999.n3.nabble.com/Large-number-of-rules-in-Drools-tp3630385p3646449.html>
>>>>
>>>> Sent from the Drools: User forum mailing list archive<http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html>at Nabble.com.
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=3647015&i=1>
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=3647015&i=2>
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>> ------------------------------
>>>  If you reply to this email, your message will be added to the
>>> discussion below:
>>>
>>> http://drools.46999.n3.nabble.com/Large-number-of-rules-in-Drools-tp3630385p3647015.html
>>>  To start a new topic under Drools: User forum, email [hidden email]<http://user/SendEmail.jtp?type=node&node=3648661&i=1>
>>> To unsubscribe from Drools: User forum, click here.
>>> NAML<http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>>
>>
>>
>> ------------------------------
>> View this message in context: Re: [rules-users] Large number of rules in
>> Drools<http://drools.46999.n3.nabble.com/Large-number-of-rules-in-Drools-tp3630385p3648661.html>
>> Sent from the Drools: User forum mailing list archive<http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html>at Nabble.com.
>>
>> _______________________________________________
>> rules-users mailing list
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=3648792&i=1>
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> _______________________________________________
> rules-users mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=3648792&i=2>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://drools.46999.n3.nabble.com/Large-number-of-rules-in-Drools-tp3630385p3648792.html
>  To start a new topic under Drools: User forum, email
> ml-node+s46999n47000h38 at n3.nabble.com
> To unsubscribe from Drools: User forum, click here<http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=47000&code=c2h3ZXRhLmEudGhha2thckBnbWFpbC5jb218NDcwMDB8LTE5NzY4Nzg0NzI=>
> .
> NAML<http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>


--
View this message in context: http://drools.46999.n3.nabble.com/Large-number-of-rules-in-Drools-tp3630385p3649201.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120110/dd7593b7/attachment.html 


More information about the rules-users mailing list