I'd tackle this with a set of rules according to:<br><br>First, a rule that collects everything a customer has bought. Then, low-priority rules matching defined Status sets with accumulated sets; this checks whether a customer has reached a certain status. Other rules detect customer sets that are subsets of status sets and these can easily compute the missing complement.<br>
<br>It may be of advantage to implement a set relation "subset of" as a custom operator, which isn't difficult.<br><br>Status sets can be composed by some external tool and injected during startup. This will keep all rules generic.<br>
<br>-W<br><br><br><div class="gmail_quote">2011/2/4 David Jacobsson <span dir="ltr"><<a href="mailto:david.jacobsson@netlight.se">david.jacobsson@netlight.se</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div dir="ltr"><font color="#000000" face="Tahoma" size="2">Hi,</font><font face="tahoma" size="2"></font></div>
<div dir="ltr"><font face="tahoma" size="2"></font> </div>
<div dir="ltr"><font face="tahoma" size="2">I'm currently working with a system where we have customers with different status flags. This could look something like:</font></div>
<div dir="ltr"><font face="tahoma" size="2"></font> </div>
<div dir="ltr"><font face="tahoma" size="2">customer has bought a car and a bicycle -> "wheel" status</font></div>
<div dir="ltr"><font face="tahoma" size="2">customer has bought a tent, a jacket and food -> "camper" status</font></div>
<div dir="ltr"><font face="tahoma" size="2"></font> </div>
<div dir="ltr"><font face="tahoma" size="2">Since these rules can be quite complex and change often using Drools would be a good way so solve the problem. The problem now is that we want to answer the question, what's needed to achieve "camper" status?
</font><font face="tahoma" size="2">When it comes to DRL this becomes that we want to know which LHS facts that are missing for the "camper" rule to fire, i.e. so we can tell the customer that in order to achieve "camper" status you also need to buy a tent
when he/she already have bought a jacket and food.</font></div>
<div dir="ltr"><font face="tahoma" size="2"></font> </div>
<div dir="ltr"><font face="tahoma" size="2">The solution we have so far is to add a number of "negative" rules in DRL that can identify the missing facts. Our concern though is that this doesn't scale since these extra rules become several more then the base
rules that define the statuses.</font></div>
<div dir="ltr"><font face="tahoma" size="2"></font> </div>
<div dir="ltr"><font face="tahoma" size="2">Is it possible to solve this in a general way with Drools, i.e. to find missing facts leading to a specific conclusion?</font></div>
<div dir="ltr"><font face="tahoma" size="2"></font> </div>
<div dir="ltr"><font face="tahoma" size="2">And example of status rule in DRL would look something like:</font></div>
<div dir="ltr"><font face="tahoma" size="2">-----</font></div>
<div dir="ltr"><font face="tahoma" size="2">when</font></div>
<div dir="ltr"><font face="tahoma" size="2"> BoughtCar( $c : customer )</font></div>
<div dir="ltr"><font face="tahoma" size="2"> BoughtBicycle( customer == $c )</font></div>
<div dir="ltr"><font face="tahoma" size="2">then</font></div>
<div dir="ltr"><font face="tahoma" size="2"> insert( new WheelStatus( $c ) );</font></div>
<div dir="ltr"><font face="tahoma" size="2">end</font></div>
<div dir="ltr"><font face="tahoma" size="2">-----</font></div>
<div dir="ltr"><font face="tahoma" size="2"></font> </div>
<div dir="ltr"><font face="tahoma" size="2">The example above is of course just an example and not actual rules from our system.</font></div>
<div dir="ltr"><font face="tahoma" size="2"></font> </div>
<div dir="ltr"><font face="tahoma" size="2">Regards,</font></div>
<div dir="ltr"><font face="tahoma" size="2">David</font></div>
<div dir="ltr"><font face="tahoma" size="2"></font> </div>
</div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>