VRP with Time Windows - ArrivalTimeListener is not invoked

34 views
Skip to first unread message

Balakrishna Kudikala

unread,
Jun 15, 2022, 8:24:30 PM6/15/22
to OptaPlanner development
Hi,

I am trying to impement VRP solution with time windows. I have gone through the examples, quick starts and trying to implement the same. I am using the same domain model explained in  https://docs.optaplanner.org/8.20.0.Final/optaplanner-docs/html_single/index.html#vehicleRoutingDomainModel. However, ArrivalTimeListener is not being invoked during the solving.

Listener Class:
public class ArrivalTimeUpdatingVariableListener implements VariableListener<VehicleRoutingSolution, Customer> {

@Override
public void afterEntityAdded(ScoreDirector<VehicleRoutingSolution> scoreDirector, Customer customer) {
if (customer instanceof TimeWindowedCustomer) {
updateArrivalTime(scoreDirector, (TimeWindowedCustomer) customer);
}
}

@Override
public void afterVariableChanged(ScoreDirector<VehicleRoutingSolution> scoreDirector, Customer customer) {
if (customer instanceof TimeWindowedCustomer) {
updateArrivalTime(scoreDirector, (TimeWindowedCustomer) customer);
}
}
// other blank implementations

TimeWindowedCustomer class:
@PlanningEntity
public class TimeWindowedCustomer extends Customer {
// fields and getters, setters
@CustomShadowVariable(variableListenerClass = ArrivalTimeUpdatingVariableListener.class,
sources = { @PlanningVariableReference(variableName = "previousStandstill") })
public Long getArrivalTime() {
return arrivalTime;
}
}

VRPSolverConfig.xml:
<solutionClass>com.staples.lastmile.planner.domain.VehicleRoutingSolution</solutionClass>
<entityClass>com.staples.lastmile.planner.domain.Standstill</entityClass>
<entityClass>com.staples.lastmile.planner.domain.Customer</entityClass>

Could you please let us know what is wrong in this approach? I could not figure out whats missing.

Thanks
Bala

Geoffrey De Smet

unread,
Jun 17, 2022, 10:12:47 AM6/17/22
to optapla...@googlegroups.com

VRPSolverConfig.xml:
<solutionClass>com.staples.lastmile.planner.domain.VehicleRoutingSolution</solutionClass>
<entityClass>com.staples.lastmile.planner.domain.Standstill</entityClass>
<entityClass>com.staples.lastmile.planner.domain.Customer</entityClass>

You need to register TimeWindowedCustomer as an <entityClass> too.

Or use our Quarkus or Spring integration to avoid having to register any.

With kind regards,
Geoffrey De Smet

--
You received this message because you are subscribed to the Google Groups "OptaPlanner development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to optaplanner-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/optaplanner-dev/dfd3bb2f-8d99-4dbe-9f60-5842a72cb700n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages