forked from graphhopper/jsprit
-
Notifications
You must be signed in to change notification settings - Fork 0
Vrp with pickups and deliveries
jsprit edited this page Mar 6, 2014
·
7 revisions
This example assumes that you know SimpleExample and covers:
- defining shipments
The only difference compared to SimpleExample is the creation of shipments instead of services. However, you define them much like you define services:
/*
* build shipments at the required locations, each with a capacity-demand of 1.
* 4 shipments
* 1: (5,7)->(6,9)
* 2: (5,13)->(6,11)
* 3: (15,7)->(14,9)
* 4: (15,13)->(14,11)
*/
Shipment shipment1 = Shipment.Builder.newInstance("1").addSizeDimension(0,1).setPickupCoord(Coordinate.newInstance(5,7))
.setDeliveryCoord(Coordinate.newInstance(6, 9)).build();
Shipment shipment2 = Shipment.Builder.newInstance("2").addSizeDimension(0,1).setPickupCoord(Coordinate.newInstance(5,13))
.setDeliveryCoord(Coordinate.newInstance(6, 11)).build();
Shipment shipment3 = Shipment.Builder.newInstance("3").addSizeDimension(0,1).setPickupCoord(Coordinate.newInstance(15,7))
.setDeliveryCoord(Coordinate.newInstance(14, 9)).build();
Shipment shipment4 = Shipment.Builder.newInstance("4").addSizeDimension(0,1).setPickupCoord(Coordinate.newInstance(15,13))
.setDeliveryCoord(Coordinate.newInstance(14, 11)).build();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/*
* add these shipments to the problem
*/
vrpBuilder.addJob(shimpent1).addJob(shimpent2).addJob(shimpent3).addJob(shimpent4);
and proceed with what you know from SimpleExample. The entire code of the example can be found here.
You might also be interested in combining shipments and (depot-bounded) services. Look at the code of this example.