<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">Op 04-03-13 13:39, Mats Norén schreef:<br>
</div>
<blockquote
cite="mid:CAAE3K7U54=KH5_pW5UEkvBsGnFu8TrB9yTojrzB8QdtDFzKu7Q@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>Hi Geoffrey,<br>
</div>
After a long period away from this problem I've come
back to it and I'm feeling a bit lost :-)<br>
<br>
</div>
Could you elaborate on how to best model the rules and
domain objects. I've looked at the nurse rostering
example but didn't find any clues on how to proceed.<br>
<br>
</div>
My first stab on this uses the following rules:<br>
<br>
rule "arrivalTime"<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 "arrivalWithinTimeWindow"<br>
when<br>
VrpCustomerVisitArrivalTime($c : customer, $a :
arrival)<br>
not CustomerTimeWindow(customer == $c, $a >
startTime, $a < endTime)<br>
then<br>
insertLogical(new
IntConstraintOccurrence("arrivalWithinTimeWindow",
ConstraintType.HARD, -$a, $c))<br>
end<br>
<br>
</div>
I've added a method arrivalTime to VrpCustomer that walks
the VrpAppearances to the Depot and accumulates the travel
time between each appearance. (I'm using GraphHopper and
the OpenStreetMap roadnetwork). This works similar to the
getDistance(VrpLocation location). <br>
<br>
</div>
What I didn't grasp is how the rule in your example is using
the CustomerTimeWindow? I'm assuming the CustomerTimeWindow
is a property on VrpCustomer?<br>
</div>
</div>
</div>
</blockquote>
The example only does the capacitated vehicle routing problem (VRP +
capacity limits), not the windowed vehicle routing problem.<br>
<blockquote
cite="mid:CAAE3K7U54=KH5_pW5UEkvBsGnFu8TrB9yTojrzB8QdtDFzKu7Q@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div><br>
</div>
Should I add each CustomerTimeWindow as a fact in the
VrpSchedule.getProblemFacts?<br>
</div>
</div>
</blockquote>
Yes, so your score rules can exploit it.<br>
Also, you 'll want to make sure that your score rule penalize "the
number of minutes that a time window isn't met".<br>
<blockquote
cite="mid:CAAE3K7U54=KH5_pW5UEkvBsGnFu8TrB9yTojrzB8QdtDFzKu7Q@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<br>
</div>
<div>Btw, I'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"><<a moz-do-not-send="true"
href="mailto:mats.noren@gmail.com" target="_blank">mats.noren@gmail.com</a>></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'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 >
start, $a < end)<br>
then<br>
insertLogical(new IntConstraintOccurrence(...))<br>
end<br>
<br>
See nurseRosteringScoreRules.drl for an example of
use of<br>
insertLogical's like that<br>
</div>
<div>
<div><br>
<div class="im">
_______________________________________________<br>
rules-users mailing list<br>
<a moz-do-not-send="true"
href="mailto:rules-users@lists.jboss.org"
target="_blank">rules-users@lists.jboss.org</a><br>
<a moz-do-not-send="true"
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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a></pre>
</blockquote>
<br>
</body>
</html>