VehicleRoutingProblem.Builder serviceProblemBuilder = VehicleRoutingProblem.Builder.newInstance();
Service s1 = Service.Builder.newInstance("s").addSizeDimension(0,10).setLocationId("loc").build();
Service s2 = Service.Builder.newInstance("s2").addSizeDimension(0,5).setLocationId("loc").build();
serviceProblemBuilder.addJob(s1).addJob(s2);
final VehicleRoutingProblem serviceProblem = serviceProblemBuilder.build();
final VehicleRoutingProblem.Builder pdProblemBuilder = VehicleRoutingProblem.Builder.newInstance();
Pickup pickup = (Pickup) Pickup.Builder.newInstance("pick").addSizeDimension(0,10).setLocationId("loc").build();
Delivery delivery = (Delivery) Delivery.Builder.newInstance("del").addSizeDimension(0,5).setLocationId("loc").build();
pdProblemBuilder.addJob(pickup).addJob(delivery);
final VehicleRoutingProblem pdProblem = pdProblemBuilder.build();
final VehicleRoutingProblem.Builder shipmentProblemBuilder = VehicleRoutingProblem.Builder.newInstance();
Shipment shipment1 = Shipment.Builder.newInstance("s1").addSizeDimension(0,10).setPickupLocationId("pick").setDeliveryLocationId("del").build();
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0,5).setPickupLocationId("pick").setDeliveryLocationId("del").build();
shipmentProblemBuilder.addJob(shipment1).addJob(shipment2).build();
final VehicleRoutingProblem shipmentProblem = shipmentProblemBuilder.build();
VehicleRoute.Builder serviceRouteBuilder = VehicleRoute.Builder.newInstance(vehicle);
serviceRouteBuilder.setJobActivityFactory(new JobActivityFactory() {
@Override
public List<AbstractActivity> createActivities(Job job) {
return serviceProblem.copyAndGetActivities(job);
}
});
serviceRoute = serviceRouteBuilder.addService(s1).addService(s2).build();
VehicleRoute.Builder pdRouteBuilder = VehicleRoute.Builder.newInstance(vehicle);
pdRouteBuilder.setJobActivityFactory(new JobActivityFactory() {
@Override
public List<AbstractActivity> createActivities(Job job) {
return pdProblem.copyAndGetActivities(job);
}
});
pickup_delivery_route = pdRouteBuilder.addService(pickup).addService(delivery).build();
VehicleRoute.Builder shipmentRouteBuilder = VehicleRoute.Builder.newInstance(vehicle);
shipmentRouteBuilder.setJobActivityFactory(new JobActivityFactory() {
@Override
public List<AbstractActivity> createActivities(Job job) {
return shipmentProblem.copyAndGetActivities(job);
}
});
shipment_route = shipmentRouteBuilder.addPickup(shipment1).addPickup(shipment2).addDelivery(shipment2).addDelivery(shipment1).build();
stateManager = new StateManager(mock(VehicleRoutingProblem.class));