[rules-users] Is Drools suitable for preprocessing my Resource Allocation Problem

Vincent LEGENDRE vincent.legendre at eurodecision.com
Wed Dec 12 13:57:02 EST 2012


Hi Raphael, 

There are multiple concerns mixed here, I don't know if this post would benefit of being cutted in at least 2 : 
1- How drools works : read about RETE algorithm (wikipedia is a good start) and about drools-expert (core module that contains the engine, first chapter of the doc explain various things about how it works, how you shoud use, and when you should use or not rules engines). 
2- How to mix rules (written by business users I guess) with another optimisation module? For that point the solution will be some architectural design to be as much efficient as possible to stay within the 1 minute. It is highly dependant of what you are using in the optimisation module (especially the KPI form), and/or if you need to call the rules in the middle of solving of not. 

So, let's go with you case : 


> I am currently playing with Drools, and trying to build rules in Java from my own Rule objects, with the help of the lang.api. 

So you have your own Rule list somewhere. 
You don't plan to use drools langage to define them ? 
What they look like ? (if you can share at least the structure) 



> Actually, there is a optimization-team that already worked on that and came up with their own solution. 


> They also evaluated Drool-planner for the "planning" part but went another direction for several reasons. 

This would be interresting to know these reasons. 


>I am only working here into transforming the complex user-filled rules into "forbid" pairs as an input 
>to the optimizer. 
> 

>I might use drools-planner for this. 

Don't use planner only to generate pairs. You don't need planner there, drools 'basic' will do the job . 
If you use planner, use it for you whole optim problem, and feed it with all yours "complex user-filled rules". 
Using planner for that will let you write at most any kind of criteria/KPI or contraints. 


> NoT a stream, but yes, this is a service that will stay up and act as a method : 
> Return the list of forbids for a given list of activities and resources. 
> 
>If I have two rule A and B that may produce the same forbid pairs, I want to produce this pair only once. 

>For that, I will use inference and produce a : 
> 

>insert(new Forbid(ressource, activity)) 
> 

>Then, in each rule, I will check that this forbid is not already present. 

If the problem is generating a Set of Forbid pairs, you should conlude your rules by adding in a Set (in a kind of response object), and not inserting at all (and remove you check in each rule, except If you use them for more than that). 



>So my question is : 
>Will Drools "learn" from preivous processings and "learn" that rule A matches more often than rule B ? 
> And so will it promote A to be processed first ? 
>Even if I flush the working memory between two calls ? 

Calling "fireAllRules" will fire all possible rules, whatever their execution order. 
It is not processed "by rules", see RETE algo. 



Vincent 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20121212/e52d078e/attachment.html 


More information about the rules-users mailing list