Hi Geoffrey,
After a long period away from this problem I've come back to it and I'm feeling a bit lost :-)

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.

My first stab on this uses the following rules:

rule "arrivalTime"
    when
        $vehicle : VrpVehicle()
        $customer : VrpCustomer(
                vehicle == $vehicle,
                $arrivalTime : arrivalTime)
    then
        insertLogical(new VrpCustomerVisitArrivalTime($customer, $arrivalTime));
end

rule "arrivalWithinTimeWindow"
    when
        VrpCustomerVisitArrivalTime($c : customer, $a : arrival)
        not CustomerTimeWindow(customer == $c, $a > startTime, $a < endTime)
    then
        insertLogical(new IntConstraintOccurrence("arrivalWithinTimeWindow", ConstraintType.HARD, -$a, $c))
end

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).

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?

Should I add each CustomerTimeWindow as a fact in the VrpSchedule.getProblemFacts?

Btw, I'm using drools-planner 6.0.0-SNAPSHOT.

Regards,
Mats

ps.
I like the new name OptaPlanner.
ds.





On Tue, Nov 20, 2012 at 1:54 PM, Mats Norén <mats.noren@gmail.com> wrote:
Ok, so on the first rule should fire for all occurrences of a Customer since each Customer should have at least one visit? 

It's not another planning variable,
instead,
do something like

when
  ...
then
   insertLogical(new CustomerVisitArrivalTime(...));
end

when
    CustomerVisitArrivalTime($c : customer, $a : arrival)
    not CustomerTimeWindow(customer == $c, $a > start, $a < end)
then
    insertLogical(new IntConstraintOccurrence(...))
end

See nurseRosteringScoreRules.drl for an example of use of
insertLogical's like that

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Btw, thanks for your help and thanks for a great product!

Regards,
Mats