[rules-users] Identify Rule on Attributes

Nikhil_dev k.nikhil at verchaska.com
Fri Mar 13 08:16:27 EDT 2009


Perfect this is the situation but the only difference is the last part,

Rulebase for all the 3 Rules are stored in memory.

Now i have is attributes(implemented as bean class), but the issue is i dont
know which Rulebase to use out of the three which is present in the memory,
fetching them one by one and executing it individually is possible but a
long procedure which i want to avoid.(executing 3 Rule is ok what if i have
100000 rules it will be very slow process)

I would like to know is there any mechanism to understand which rulebase
will be appropriate without executing the rule completely. a mechanism such
as where we can compare the set of variable required by the rule and set of
variable that i am passing for execution. this can be one of the mechanism,
like that is there any other mechanism available with drools.

I hope i am clear enough, please let knw...if i need to be more clear, it
will be very helpful...... 

Thank u all for the response.....

Anstis, Michael (M.) wrote:
> 
> Hi Nikhil,
> 
> Let's break down what you have said into pseudo Drools terms:-
> 
> Rule 1
> 	AdultFare(value==3000)
> 	ChildFare(value==2500)
> Then
> 	//Do what you want to do
> End
> 
> Rule 2
> 	ChildFare(value==2000) or 
> 	InfantFare(value==1500)
> Then
> 	//Do what you want to do
> End
> 
> Rule 3
> 	AdultFare($f1 : value)
> 	InfantFare($f2 : value)
> 	eval($f1 + $f2 < 4000)
> Then
> 	//Do what you want to do
> End
> 
> You suggest you have a RuleBase that has been successfully loaded. 
> 
> You state you have some attributes (I assume these to be implemented as
> Classes).
> 
> StatefulSession ss = rulebase.newStatefulSession();
> ss.insert( new AdultFare(1000) );    //<-- Causes object to be compared
> to ALL rules. This is how RETE works
> ss.insert( new InfantFare(1000) );   //<-- Causes object to be compared
> to ALL rules. This is how RETE works
> ss.fireAllRules();                   //<-- Causes the "then" part of
> Rule 3 to execute
> 
> It sounds like you are trying to hard.
> 
> With kind regards,
> 
> Mike
> 
> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org
> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Nikhil_dev
> Sent: 13 March 2009 11:19
> To: rules-users at lists.jboss.org
> Subject: RE: [rules-users] Identify Rule on Attributes
> 
> 
> Thank you Michael, 
> Following is the use-case/example/Situation that i trying to make it
> work
> Consider Example ::::
> Rule 1: requires attributes/Values :::::::: adultFare == 3000 and
> ChildFare
> == 2500
> Rule 2: requires attributes/Values :::::::: ChildFare == 2000 or
> InfantFare 
> == 1500
> Rule 3: requires attributes/Values :::::::: AdultFare + InfantFare <
> 4000
> 
> Above said rules is complied and its Rulebase is stored in the
> memory......
> 
> Now i have adultFare and InfantFare Attribute in hand....... so now is
> there
> any way with the help of drools we can identify which rule to execute
> with
> out executing all of them one after the another.......as per the example
> Rule3 should be executed....and will give right output.......
> 
> I hope u got what i am trying to do..... let me know weather it is
> possible........  through RETE algo used inside drools or should i do it
> on
> my own of identifying the rules.......
> 
> 
> Anstis, Michael (M.) wrote:
>> 
>> I concur everybody's statements fully.
>> 
>> The purpose of a rules engine is to remove the need for the
> application
>> developer to code algorithms to determine which of a set of rules
> should
>> execute given a set of facts\properties\objects. Drools implements the
>> RETE algorithm. Writing your own code to determine which rule should
> be
>> executed would be like writing your own video driver so you can
> display
>> an image. 
>> 
>> Of course "we" all assume you plan on using Drools as a rule engine; a
>> black box to drive the execution of consequences based upon rule
>> definitions and domain objects. As you state in your last post below;
>> your "point is that [you] want to use rule engine in [your]
> application
>> at it's fullest". Without a clearer description of your use-case it
>> might be impossible for anybody to give an answer that helps with your
>> particular issue.
>> 
>> These forums are an excellent place to find solutions. Everybody has
>> always been extremely helpful to me.
>> 
>> I hope you are not discouraged by the responses received to date and
> am
>> sure everybody is genuinely trying to help.
>> 
>> With kind regards,
>> 
>> Mike
>> 
>> -----Original Message-----
>> From: rules-users-bounces at lists.jboss.org
>> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Nikhil_dev
>> Sent: 13 March 2009 06:44
>> To: rules-users at lists.jboss.org
>> Subject: RE: [rules-users] Identify Rule on Attributes
>> 
>> 
>> Hi Vikrant,
>> 
>> Please go through all the post and try understand what i am trying to
>> get
>> from rule engine............ please do not post just for the namesake.
>> My point is that i want to use rule engine in my application at its
>> fullest,
>> if something is possible in Rule engine i would like to experiment on
>> it. 
>> 
>> Cheers,
>> Nikhil.
>> 
>> 
>> 
>> 
>> Vikrant Yagnick wrote:
>>> 
>>> Hi Nikhil,
>>> 
>>> Drools implements the RETE algorithm. The "average" rules user does
>> not
>>> need to bother or even care about it. All you need to do is use the
>> rule
>>> engine(for which you do not need to design or write your own
>> algorithm)
>>> and it will automatically do the work for you.
>>> 
>>> Cheers,
>>> Vikrant
>>> 
>>> -----Original Message-----
>>> From: rules-users-bounces at lists.jboss.org
>>> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Nikhil_dev
>>> Sent: Friday, March 13, 2009 11:35 AM
>>> To: rules-users at lists.jboss.org
>>> Subject: Re: [rules-users] Identify Rule on Attributes
>>> 
>>> 
>>> 
>>> from the doc i got what is Rete algo ... but not getting the way to
>>> implement it.... using drools
>>> 
>>> 
>>> Nikhil_dev wrote:
>>>>
>>>>
>>>> if this is the doc
>>>>
>>
> http://downloads.jboss.com/drools/docs/4.0.4.17825.GA/html_single/index.
>> html
>>>> u are talking about then i coudl'nt  find much help.
>>>> It will be very helpful if u can give me a kick start on the
>> same.......
>>>> since i am just an average rule engine user.....some helpful doc on
>> the
>>>> same
>>>>
>>>>
>>>>
>>>> Greg Barton wrote:
>>>>>
>>>>>
>>>>> Yes, if you use a rules engine that implements rete the
>> functionality
>>>>> you
>>>>> need is available.
>>>>>
>>>>> Read the Drools docs.
>>>>>
>>>>> Carefully.
>>>>>
>>>>> GreG
>>>>>
>>>>> On Mar 12, 2009, at 23:40, Nikhil_dev <k.nikhil at verchaska.com>
>> wrote:
>>>>>
>>>>>
>>>>> thank u Scott and Greg for u'r reply......
>>>>>
>>>>> by the way Greg is it possible for me to use this rete algo through
>> rule
>>>>> engine as this functionality already available in the core of Rule
>>>>> Enigne
>>>>> or
>>>>> should i implement this out side rule engine.
>>>>>
>>>>>
>>>>> Greg Barton wrote:
>>>>>
>>>>>
>>>>> That's the core functionality of a rule engine.  The rete algorithm
>> does
>>>>> this, and drools implements rete.
>>>>>
>>>>> --- On Thu, 3/12/09, Nikhil_dev <k.nikhil at verchaska.com> wrote:
>>>>>
>>>>> so now is there
>>>>> any way with the help of drools we can identify which rule
>>>>> to execute with
>>>>> out executing all of them one after the another
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> rules-users mailing list
>>>>> rules-users at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----
>>>>> Regards,
>>>>> :working:Nikhil
>>>>> --
>>>>> View this message in context:
>>>>>
>>
> http://www.nabble.com/Identify-Rule-on-Attributes-tp22471473p22490126.ht
>> ml
>>>>> Sent from the drools - user mailing list archive at Nabble.com.
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>>>
>>>>>
>>>>
>>>>
>>> 
>>> 
>>> -----
>>> Regards,
>>> :working:Nikhil
>>> --
>>> View this message in context:
>>>
>>
> http://www.nabble.com/Identify-Rule-on-Attributes-tp22471473p22490776.ht
>> ml
>>> Sent from the drools - user mailing list archive at Nabble.com.
>>> 
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>> 
>>> 
>>> MASTEK LTD.
>>> Mastek is in NASSCOM's 'India Top 20' Software Service Exporters
> List.
>>> In the US, we're called MAJESCOMASTEK
>>> 
>>>
>>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> Opinions expressed in this e-mail are those of the individual and not
>> that
>>> of Mastek Limited, unless specifically indicated to that effect.
>> Mastek
>>> Limited does not accept any responsibility or liability for it. This
>>> e-mail and attachments (if any) transmitted with it are confidential
>>> and/or privileged and solely for the use of the intended person or
>> entity
>>> to which it is addressed. Any review, re-transmission, dissemination
>> or
>>> other use of or taking of any action in reliance upon this
> information
>> by
>>> persons or entities other than the intended recipient is prohibited.
>> This
>>> e-mail and its attachments have been scanned for the presence of
>> computer
>>> viruses. It is the responsibility of the recipient to run the virus
>> check
>>> on e-mails and attachments before opening them. If you have received
>> this
>>> e-mail in error, kindly delete this e-mail from desktop and server.
>>>
>>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> 
>>> 
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>> 
>>> 
>> 
>> 
>> -----
>> Regards,
>> :working:Nikhil
>> -- 
>> View this message in context:
>>
> http://www.nabble.com/Identify-Rule-on-Attributes-tp22471473p22491091.ht
>> ml
>> Sent from the drools - user mailing list archive at Nabble.com.
>> 
>> _______________________________________________
>> 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
>> 
>> 
> 
> 
> -----
> Regards,
> :working:Nikhil
> -- 
> View this message in context:
> http://www.nabble.com/Identify-Rule-on-Attributes-tp22471473p22494433.ht
> ml
> Sent from the drools - user mailing list archive at Nabble.com.
> 
> _______________________________________________
> 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
> 
> 


-----
Regards,
:working:Nikhil
-- 
View this message in context: http://www.nabble.com/Identify-Rule-on-Attributes-tp22471473p22495260.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list