<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Times New Roman; font-size: 12pt; color: #000000'><font face="lucida console,sans-serif" size="2">Hi Raphael,<br><br>There are multiple concerns mixed here, I don't know if this post would benefit of being cutted in at least 2 :<br>&nbsp;&nbsp; 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).<br>&nbsp;&nbsp; 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.<br><br>So, let's go with you case :<br><br></font><div style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none;"><font face="lucida console,sans-serif" size="2">&gt; 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.<br><br>So you have your own Rule list somewhere. <br>You don't plan to use drools langage to define them ?<br>What they look like ? (if you can share at least the structure)<br></font><div><font face="lucida console,sans-serif" size="2"><br><br></font></div><font face="lucida console,sans-serif" size="2">&gt; Actually, there is a optimization-team that already worked on that and came up with their&nbsp;own solution.&nbsp;</font><div><div class="gmail_quote">

<div><font face="lucida console,sans-serif" size="2">&gt; They also evaluated Drool-planner for the "planning" part but went another direction for several reasons.<br><br>This would be interresting to know these reasons.<br><br><br>&gt;I am only working here into transforming the complex user-filled rules into "forbid" pairs as an input&nbsp;</font></div>

<div><font face="lucida console,sans-serif" size="2">&gt;to the optimizer.<br>&gt;<br></font></div><div><font face="lucida console,sans-serif" size="2">&gt;I might use drools-planner for this.<br><br>Don't use planner only to generate pairs. You don't need planner there, drools 'basic' will do the job.<br>If you use planner, <font size="2">use</font> it for you whole optim problem, and feed it with all yours "complex user-filled rules".<br>Using planner for that will let you write at most any kind of criteria/KPI or contraints.<br></font></div><div><font face="lucida console,sans-serif" size="2"><br>&nbsp;</font></div><font face="lucida console,sans-serif" size="2">&gt; NoT a stream, but yes, this is a service that will stay up and act as a method :&nbsp;</font><div><font face="lucida console,sans-serif" size="2">&gt; Return the list of forbids for a given list of activities and resources.<br>&gt;<br></font></div><font face="lucida console,sans-serif" size="2">&gt;If I have two rule A and B that may produce the same forbid pairs, I want to produce this pair only once.<br></font><div><font face="lucida console,sans-serif" size="2">&gt;For that, I will use inference and produce a :</font></div><div><font face="lucida console,sans-serif" size="2">&gt;<br></font></div><div><font face="lucida console,sans-serif" size="2">&gt;insert(new Forbid(ressource, activity))</font></div><div><font face="lucida console,sans-serif" size="2">&gt;<br></font></div><div><font face="lucida console,sans-serif" size="2">&gt;Then, in each rule, I will check that this forbid is not already present.</font></div><div><font face="lucida console,sans-serif" size="2"><br>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).<br><br><br></font></div><div><font face="lucida console,sans-serif" size="2">&gt;So my question is :<br>&gt;Will Drools "learn" from preivous processings and "learn" that rule A matches more often than rule B ? <br>&gt;And so will it promote A to be processed first ?<br>&gt;Even if I flush the working memory between two calls ?<br><br>Calling "fireAllRules" will fire all possible rules, whatever their execution order.<br>It is not processed "by rules", see RETE algo.<br></font></div>

<div><font face="lucida console,sans-serif" size="2">&nbsp;<br></font></div><font face="lucida console,sans-serif" size="2"><br></font></div></div></div><font face="lucida console,sans-serif" size="2">Vincent<br></font></div></body></html>