<div dir="ltr"><div><div><div><div><div><div><div>Hi Geoffrey,<br></div>After a long period away from this problem I&#39;ve come back to it and I&#39;m feeling a bit lost :-)<br><br></div>Could you elaborate on how to best model the rules and domain objects. I&#39;ve looked at the nurse rostering example but didn&#39;t find any clues on how to proceed.<br>
<br></div>My first stab on this uses the following rules:<br><br>rule &quot;arrivalTime&quot;<br>    when<br>        $vehicle : VrpVehicle()<br>        $customer : VrpCustomer(<br>                vehicle == $vehicle,<br>                $arrivalTime : arrivalTime)<br>
    then<br>        insertLogical(new VrpCustomerVisitArrivalTime($customer, $arrivalTime));<br>end<br><br>rule &quot;arrivalWithinTimeWindow&quot;<br>    when<br>        VrpCustomerVisitArrivalTime($c : customer, $a : arrival)<br>
        not CustomerTimeWindow(customer == $c, $a &gt; startTime, $a &lt; endTime)<br>    then<br>        insertLogical(new IntConstraintOccurrence(&quot;arrivalWithinTimeWindow&quot;, ConstraintType.HARD, -$a, $c))<br>end<br>
<br></div>I&#39;ve added a method arrivalTime to VrpCustomer that walks the VrpAppearances to the Depot and accumulates the travel time between each appearance.  (I&#39;m using GraphHopper and the OpenStreetMap roadnetwork). This works similar to the getDistance(VrpLocation location). <br>
<br></div>What I didn&#39;t grasp is how the rule in your example is using the CustomerTimeWindow? I&#39;m assuming the CustomerTimeWindow is a property on VrpCustomer?<br><br></div>Should I add each CustomerTimeWindow as a fact in the VrpSchedule.getProblemFacts?<br>
<br></div><div>Btw, I&#39;m using drools-planner 6.0.0-SNAPSHOT.<br></div><div><br></div>Regards,<br>Mats<br><div><div><div><div><div><div><br></div><div>ps.<br></div><div>I like the new name OptaPlanner.<br></div><div>ds.<br>
<br></div><div><br><br></div></div></div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Nov 20, 2012 at 1:54 PM, Mats Norén <span dir="ltr">&lt;<a href="mailto:mats.noren@gmail.com" target="_blank">mats.noren@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Ok, so on the first rule should fire for all occurrences of a Customer since each Customer should have at least one visit? </div>
<div><br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
It&#39;s not another planning variable,<br>
instead,<br>
do something like<br>
<br>
when<br>
  ...<br>
then<br>
   insertLogical(new CustomerVisitArrivalTime(...));<br>
end<br>
<br>
when<br>
    CustomerVisitArrivalTime($c : customer, $a : arrival)<br>
    not CustomerTimeWindow(customer == $c, $a &gt; start, $a &lt; end)<br>
then<br>
    insertLogical(new IntConstraintOccurrence(...))<br>
end<br>
<br>
See nurseRosteringScoreRules.drl for an example of use of<br>
insertLogical&#39;s like that<br>
</div><div><div><br><div class="im">
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
</div></div></div></blockquote></div><br></div><div class="gmail_extra">Btw, thanks for your help and thanks for a great product!</div><div class="gmail_extra"><br></div><div class="gmail_extra">Regards,</div><div class="gmail_extra">

Mats</div>
</blockquote></div><br></div>