1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

merge min-waiting-time branch

This commit is contained in:
oblonski 2015-09-12 13:39:23 +02:00
parent a9d1e03c56
commit 842067231d
62 changed files with 2770 additions and 2863 deletions

View file

@ -60,7 +60,7 @@ public class ConfigureAlgorithmInCodeInsteadOfPerXml {
VehicleImpl vehicle = vehicleBuilder.build();
/*
* build services at the required locations, each with a capacity-demand of 1.
* build services at the required locations, each with a capacity-demand of 1.
*/
Service service1 = Service.Builder.newInstance("1").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 7)).build();
Service service2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 13)).build();
@ -76,7 +76,7 @@ public class ConfigureAlgorithmInCodeInsteadOfPerXml {
VehicleRoutingProblem problem = vrpBuilder.build();
/*
* get the algorithm out-of-the-box.
* get the algorithm out-of-the-box.
*/
AlgorithmConfig algorithmConfig = getAlgorithmConfig();
VehicleRoutingAlgorithm algorithm = VehicleRoutingAlgorithms.createAlgorithm(problem, algorithmConfig);

View file

@ -40,23 +40,22 @@ import java.util.Collection;
* Illustrates how you can use jsprit with an already compiled distance and time matrix.
*
* @author schroeder
*
*/
public class CostMatrixExample {
public static void main(String[] args) {
/*
* some preparation - create output folder
public static void main(String[] args) {
/*
* some preparation - create output folder
*/
Examples.createOutputFolder();
Examples.createOutputFolder();
VehicleType type = VehicleTypeImpl.Builder.newInstance("type").addCapacityDimension(0, 2).setCostPerDistance(1).setCostPerTime(2).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle")
.setStartLocation(Location.newInstance("0")).setType(type).build();
VehicleType type = VehicleTypeImpl.Builder.newInstance("type").addCapacityDimension(0, 2).setCostPerDistance(1).setCostPerTime(2).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle")
.setStartLocation(Location.newInstance("0")).setType(type).build();
Service s1 = Service.Builder.newInstance("1").addSizeDimension(0, 1).setLocation(Location.newInstance("1")).build();
Service s2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocation(Location.newInstance("2")).build();
Service s3 = Service.Builder.newInstance("3").addSizeDimension(0, 1).setLocation(Location.newInstance("3")).build();
Service s1 = Service.Builder.newInstance("1").addSizeDimension(0, 1).setLocation(Location.newInstance("1")).build();
Service s2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocation(Location.newInstance("2")).build();
Service s3 = Service.Builder.newInstance("3").addSizeDimension(0, 1).setLocation(Location.newInstance("3")).build();
/*
@ -77,35 +76,35 @@ public class CostMatrixExample {
* 1,3,0.5
* 2,3,1.0
*/
//define a matrix-builder building a symmetric matrix
VehicleRoutingTransportCostsMatrix.Builder costMatrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true);
costMatrixBuilder.addTransportDistance("0", "1", 10.0);
costMatrixBuilder.addTransportDistance("0", "2", 20.0);
costMatrixBuilder.addTransportDistance("0", "3", 5.0);
costMatrixBuilder.addTransportDistance("1", "2", 4.0);
costMatrixBuilder.addTransportDistance("1", "3", 1.0);
costMatrixBuilder.addTransportDistance("2", "3", 2.0);
//define a matrix-builder building a symmetric matrix
VehicleRoutingTransportCostsMatrix.Builder costMatrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true);
costMatrixBuilder.addTransportDistance("0", "1", 10.0);
costMatrixBuilder.addTransportDistance("0", "2", 20.0);
costMatrixBuilder.addTransportDistance("0", "3", 5.0);
costMatrixBuilder.addTransportDistance("1", "2", 4.0);
costMatrixBuilder.addTransportDistance("1", "3", 1.0);
costMatrixBuilder.addTransportDistance("2", "3", 2.0);
costMatrixBuilder.addTransportTime("0", "1", 10.0);
costMatrixBuilder.addTransportTime("0", "2", 20.0);
costMatrixBuilder.addTransportTime("0", "3", 5.0);
costMatrixBuilder.addTransportTime("1", "2", 4.0);
costMatrixBuilder.addTransportTime("1", "3", 1.0);
costMatrixBuilder.addTransportTime("2", "3", 2.0);
costMatrixBuilder.addTransportTime("0", "1", 10.0);
costMatrixBuilder.addTransportTime("0", "2", 20.0);
costMatrixBuilder.addTransportTime("0", "3", 5.0);
costMatrixBuilder.addTransportTime("1", "2", 4.0);
costMatrixBuilder.addTransportTime("1", "3", 1.0);
costMatrixBuilder.addTransportTime("2", "3", 2.0);
VehicleRoutingTransportCosts costMatrix = costMatrixBuilder.build();
VehicleRoutingTransportCosts costMatrix = costMatrixBuilder.build();
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().setFleetSize(FleetSize.INFINITE).setRoutingCost(costMatrix)
.addVehicle(vehicle).addJob(s1).addJob(s2).addJob(s3).build();
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().setFleetSize(FleetSize.INFINITE).setRoutingCost(costMatrix)
.addVehicle(vehicle).addJob(s1).addJob(s2).addJob(s3).build();
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
SolutionPrinter.print(Solutions.bestOf(solutions));
SolutionPrinter.print(Solutions.bestOf(solutions));
new Plotter(vrp, Solutions.bestOf(solutions)).plot("output/yo.png", "po");
new Plotter(vrp, Solutions.bestOf(solutions)).plot("output/yo.png", "po");
}
}
}

View file

@ -81,7 +81,7 @@ public class EnRoutePickupAndDeliveryWithMultipleDepotsAndOpenRoutesExample {
VehicleImpl vehicle4 = vehicleBuilder4.build();
/*
* build shipments at the required locations, each with a capacity-demand of 1.
* build shipments at the required locations, each with a capacity-demand of 1.
*/
@ -121,7 +121,7 @@ public class EnRoutePickupAndDeliveryWithMultipleDepotsAndOpenRoutesExample {
VehicleRoutingProblem problem = vrpBuilder.build();
/*
* get the algorithm out-of-the-box.
* get the algorithm out-of-the-box.
*/
VehicleRoutingAlgorithm algorithm = VehicleRoutingAlgorithms.readAndCreateAlgorithm(problem, "input/algorithmConfig.xml");
// algorithm.setMaxIterations(30000);

View file

@ -54,7 +54,7 @@ public class MultipleDepotExample {
new VrpXMLReader(vrpBuilder).read("input/vrp_cordeau_01.xml");
/*
* add vehicles with its depots
* add vehicles with its depots
* 4 depots:
* (20,20)
* (30,40)
@ -81,7 +81,7 @@ public class MultipleDepotExample {
}
/*
* define problem with finite fleet
* define problem with finite fleet
*/
vrpBuilder.setFleetSize(FleetSize.FINITE);

View file

@ -56,7 +56,7 @@ public class MultipleDepotExample2 {
new CordeauReader(vrpBuilder).read("input/p08");
/*
* add vehicles with its depots
* add vehicles with its depots
* 2 depots:
* (-33,33)
* (33,-33)
@ -87,7 +87,7 @@ public class MultipleDepotExample2 {
/*
* define problem with finite fleet
* define problem with finite fleet
*/
vrpBuilder.setFleetSize(FleetSize.FINITE);

View file

@ -51,14 +51,14 @@ public class MultipleDepotWithInitialRoutesExample {
new VrpXMLReader(vrpBuilder).read("input/cordeau01.xml");
/*
* Add initial route with 1_4_vehicle and services 44, 26
* Add initial route with 1_4_vehicle and services 44, 26
*/
VehicleRoute initialRoute = VehicleRoute.Builder.newInstance(getVehicle("1_4_vehicle", vrpBuilder)).addService(getService("44", vrpBuilder))
.addService(getService("26", vrpBuilder)).build();
vrpBuilder.addInitialVehicleRoute(initialRoute);
/*
* build the problem
* build the problem
*/
VehicleRoutingProblem vrp = vrpBuilder.build();
/*

View file

@ -55,7 +55,7 @@ public class PickupAndDeliveryExample {
new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_solomon_r101_withoutTWs.xml");
/*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/
final VehicleRoutingProblem vrp = vrpBuilder.build();
@ -64,7 +64,7 @@ public class PickupAndDeliveryExample {
/*
* Define the required vehicle-routing algorithms to solve the above problem.
* Define the required vehicle-routing algorithms to solve the above problem.
*
* The algorithm can be defined and configured in an xml-file.
*/

View file

@ -63,14 +63,14 @@ public class PickupAndDeliveryExample2 {
/*
* Define the required vehicle-routing algorithms to solve the above problem.
* Define the required vehicle-routing algorithms to solve the above problem.
*
* The algorithm can be defined and configured in an xml-file.
*/
// VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig_solomon.xml");
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png"));
/*
/*
* Solve the problem.
*
*

View file

@ -53,7 +53,7 @@ public class PickupAndDeliveryOpenExample {
new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_solomon_r101_withoutTWs_open.xml");
/*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/
VehicleRoutingProblem vrp = vrpBuilder.build();
@ -61,7 +61,7 @@ public class PickupAndDeliveryOpenExample {
// SolutionPlotter.plotVrpAsPNG(vrp, "output/pd_solomon_r101_o.png", "pd_r101");
/*
* Define the required vehicle-routing algorithms to solve the above problem.
* Define the required vehicle-routing algorithms to solve the above problem.
*
* The algorithm can be defined and configured in an xml-file.
*/

View file

@ -74,12 +74,12 @@ public class RefuseCollectionExample {
vrpBuilder.addVehicle(bigVehicle);
/*
* read demand quantities
* read demand quantities
*/
readDemandQuantities(vrpBuilder);
/*
* create cost-matrix
* create cost-matrix
*/
VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true);
readDistances(matrixBuilder);

View file

@ -73,12 +73,12 @@ public class RefuseCollectionWithFastMatrixExample {
vrpBuilder.addVehicle(bigVehicle);
/*
* read demand quantities
* read demand quantities
*/
readDemandQuantities(vrpBuilder);
/*
* create cost-matrix
* create cost-matrix
*/
FastVehicleRoutingTransportCostsMatrix.Builder matrixBuilder = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(11, true);
readDistances(matrixBuilder);

View file

@ -68,7 +68,7 @@ public class ServicePickupsWithMultipleDepotsExample {
/*
* build shipments at the required locations, each with a capacity-demand of 1.
* 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)
@ -98,7 +98,7 @@ public class ServicePickupsWithMultipleDepotsExample {
VehicleRoutingProblem problem = vrpBuilder.build();
/*
* get the algorithm out-of-the-box.
* get the algorithm out-of-the-box.
*/
VehicleRoutingAlgorithm algorithm = VehicleRoutingAlgorithms.readAndCreateAlgorithm(problem, "input/algorithmConfig.xml");
algorithm.setMaxIterations(10);

View file

@ -60,7 +60,7 @@ public class SimpleDepotBoundedPickupAndDeliveryExample {
VehicleImpl vehicle = vehicleBuilder.build();
/*
* build pickups and deliveries at the required locations, each with a capacity-demand of 1.
* build pickups and deliveries at the required locations, each with a capacity-demand of 1.
*/
Pickup pickup1 = (Pickup) Pickup.Builder.newInstance("1").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 7)).build();
Delivery delivery1 = (Delivery) Delivery.Builder.newInstance("2").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 13)).build();
@ -77,7 +77,7 @@ public class SimpleDepotBoundedPickupAndDeliveryExample {
VehicleRoutingProblem problem = vrpBuilder.build();
/*
* get the algorithm out-of-the-box.
* get the algorithm out-of-the-box.
*/
VehicleRoutingAlgorithm algorithm = new SchrimpfFactory().createAlgorithm(problem);

View file

@ -61,7 +61,7 @@ public class SimpleEnRoutePickupAndDeliveryExample {
VehicleImpl vehicle = vehicleBuilder.build();
/*
* build shipments at the required locations, each with a capacity-demand of 1.
* 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)
@ -83,7 +83,7 @@ public class SimpleEnRoutePickupAndDeliveryExample {
VehicleRoutingProblem problem = vrpBuilder.build();
/*
* get the algorithm out-of-the-box.
* get the algorithm out-of-the-box.
*/
VehicleRoutingAlgorithm algorithm = new SchrimpfFactory().createAlgorithm(problem);

View file

@ -61,7 +61,7 @@ public class SimpleEnRoutePickupAndDeliveryOpenRoutesExample {
VehicleImpl vehicle = vehicleBuilder.build();
/*
* build shipments at the required locations, each with a capacity-demand of 1.
* 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)
@ -83,7 +83,7 @@ public class SimpleEnRoutePickupAndDeliveryOpenRoutesExample {
VehicleRoutingProblem problem = vrpBuilder.build();
/*
* get the algorithm out-of-the-box.
* get the algorithm out-of-the-box.
*/
VehicleRoutingAlgorithm algorithm = new SchrimpfFactory().createAlgorithm(problem);

View file

@ -63,7 +63,7 @@ public class SimpleEnRoutePickupAndDeliveryWithDepotBoundedDeliveriesExample {
VehicleImpl vehicle = vehicleBuilder.build();
/*
* build shipments at the required locations, each with a capacity-demand of 1.
* 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)
@ -77,7 +77,7 @@ public class SimpleEnRoutePickupAndDeliveryWithDepotBoundedDeliveriesExample {
Shipment shipment3 = Shipment.Builder.newInstance("3").addSizeDimension(0, 1).setPickupLocation(loc(Coordinate.newInstance(15, 7))).setDeliveryLocation(loc(Coordinate.newInstance(14, 9))).build();
Shipment shipment4 = Shipment.Builder.newInstance("4").addSizeDimension(0, 1).setPickupLocation(loc(Coordinate.newInstance(15, 13))).setDeliveryLocation(loc(Coordinate.newInstance(14, 11))).build();
//
/*
/*
* build deliveries, (implicitly picked up in the depot)
* 1: (4,8)
* 2: (4,12)

View file

@ -67,7 +67,7 @@ public class SimpleExample {
VehicleImpl vehicle = vehicleBuilder.build();
/*
* build services at the required locations, each with a capacity-demand of 1.
* build services at the required locations, each with a capacity-demand of 1.
*/
Service service1 = Service.Builder.newInstance("1").addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(5, 7)).build();
Service service2 = Service.Builder.newInstance("2").addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(5, 13)).build();
@ -83,7 +83,7 @@ public class SimpleExample {
VehicleRoutingProblem problem = vrpBuilder.build();
/*
* get the algorithm out-of-the-box.
* get the algorithm out-of-the-box.
*/
VehicleRoutingAlgorithm algorithm = new SchrimpfFactory().createAlgorithm(problem);

View file

@ -61,7 +61,7 @@ public class SimpleExampleOpenRoutes {
VehicleImpl vehicle = vehicleBuilder.build();
/*
* build services at the required locations, each with a capacity-demand of 1.
* build services at the required locations, each with a capacity-demand of 1.
*/
Service service1 = Service.Builder.newInstance("1").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 7)).build();
Service service2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 13)).build();
@ -77,7 +77,7 @@ public class SimpleExampleOpenRoutes {
VehicleRoutingProblem problem = vrpBuilder.build();
/*
* get the algorithm out-of-the-box.
* get the algorithm out-of-the-box.
*/
VehicleRoutingAlgorithm algorithm = VehicleRoutingAlgorithms.readAndCreateAlgorithm(problem, "input/algorithmConfig_fix.xml");

View file

@ -75,7 +75,7 @@ public class SimpleExampleWithSkills {
VehicleImpl vehicle2 = vehicle2Builder.build();
/*
* build services at the required locations, each with a capacity-demand of 1.
* build services at the required locations, each with a capacity-demand of 1.
*/
Service service1 = Service.Builder.newInstance("1").addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(5, 7)).build();
Service service2 = Service.Builder.newInstance("2").addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(5, 13)).build();
@ -92,7 +92,7 @@ public class SimpleExampleWithSkills {
VehicleRoutingProblem problem = vrpBuilder.build();
/*
* get the algorithm out-of-the-box.
* get the algorithm out-of-the-box.
*/
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(problem, "input/algorithmConfig.xml");
vraBuilder.addCoreConstraints();

View file

@ -63,7 +63,7 @@ public class SimpleVRPWithBackhaulsExample {
VehicleImpl vehicle = vehicleBuilder.build();
/*
* build pickups and deliveries at the required locations, each with a capacity-demand of 1.
* build pickups and deliveries at the required locations, each with a capacity-demand of 1.
*/
Pickup pickup1 = (Pickup) Pickup.Builder.newInstance("1").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 7)).build();
Delivery delivery1 = (Delivery) Delivery.Builder.newInstance("2").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 13)).build();
@ -89,7 +89,7 @@ public class SimpleVRPWithBackhaulsExample {
VehicleRoutingAlgorithm algorithm = vraBuilder.build();
/*
* and search a solution
* and search a solution
*/
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();

View file

@ -53,14 +53,14 @@ public class SolomonExample {
/*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/
VehicleRoutingProblem vrp = vrpBuilder.build();
new Plotter(vrp).plot("output/solomon_C101.png", "C101");
/*
* Define the required vehicle-routing algorithms to solve the above problem.
* Define the required vehicle-routing algorithms to solve the above problem.
*
* The algorithm can be defined and configured in an xml-file.
*/

View file

@ -59,7 +59,7 @@ public class SolomonExampleWithSpecifiedVehicleEndLocations {
new VrpXMLReader(vrpBuilder).read("input/deliveries_solomon_specifiedVehicleEndLocations_c101.xml");
/*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/
VehicleRoutingProblem vrp = vrpBuilder.build();
@ -67,7 +67,7 @@ public class SolomonExampleWithSpecifiedVehicleEndLocations {
pblmPlotter.plot("output/solomon_C101_specifiedVehicleEndLocations.png", "C101");
/*
* Define the required vehicle-routing algorithms to solve the above problem.
* Define the required vehicle-routing algorithms to solve the above problem.
*
* The algorithm can be defined and configured in an xml-file.
*/

View file

@ -58,7 +58,7 @@ public class SolomonExampleWithSpecifiedVehicleEndLocationsWithoutTWs {
new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_solomon_c101_withoutTWs_and_specifiedVehicleEndLocations.xml");
/*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/
// vrpBuilder.addProblemConstraint(Constraint.DELIVERIES_FIRST);
VehicleRoutingProblem vrp = vrpBuilder.build();
@ -67,7 +67,7 @@ public class SolomonExampleWithSpecifiedVehicleEndLocationsWithoutTWs {
pblmPlotter.plot("output/solomon_C101_specifiedVehicleEndLocations_withoutTWs.png", "C101");
/*
* Define the required vehicle-routing algorithms to solve the above problem.
* Define the required vehicle-routing algorithms to solve the above problem.
*
* The algorithm can be defined and configured in an xml-file.
*/

View file

@ -52,14 +52,14 @@ public class SolomonOpenExample {
new VrpXMLReader(vrpBuilder).read("input/deliveries_solomon_open_c101.xml");
/*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/
VehicleRoutingProblem vrp = vrpBuilder.build();
new Plotter(vrp).plot("output/solomon_C101_open.png", "C101");
/*
* Define the required vehicle-routing algorithms to solve the above problem.
* Define the required vehicle-routing algorithms to solve the above problem.
*
* The algorithm can be defined and configured in an xml-file.
*/

View file

@ -50,8 +50,8 @@ public class SolomonR101Example {
*/
// new SolomonReader(vrpBuilder).read("/Users/schroeder/IdeaProjects/jsprit/jsprit-instances/instances/solomon/R211.txt");
new VrpXMLReader(vrpBuilder).read("output/R211.xml");
/*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
/*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/
VehicleRoutingProblem vrp = vrpBuilder.build();

View file

@ -55,14 +55,14 @@ public class SolomonWithRegretInsertionExample {
/*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/
VehicleRoutingProblem vrp = vrpBuilder.build();
new Plotter(vrp).plot("output/solomon_C101.png", "C101");
/*
* Define the required vehicle-routing algorithms to solve the above problem.
* Define the required vehicle-routing algorithms to solve the above problem.
*
* The algorithm can be defined and configured in an xml-file.
*/

View file

@ -96,7 +96,7 @@ public class TransportOfDisabledPeople {
/*
* build shipments at the required locations, each with a capacity-demand of 1.
* build shipments at the required locations, each with a capacity-demand of 1.
*
*/
Shipment shipment1 = Shipment.Builder.newInstance("wheelchair_1").addSizeDimension(WHEELCHAIRSPACE_INDEX, 1).setPickupLocation(loc(Coordinate.newInstance(5, 7))).setDeliveryLocation(loc(Coordinate.newInstance(6, 9))).build();
@ -141,7 +141,7 @@ public class TransportOfDisabledPeople {
vrpBuilder.setFleetSize(FleetSize.FINITE);
/*
*
*
* wheelchair-bus can only pickup passenger where x<15
*/
HardRouteConstraint wheelchair_bus_passenger_pickup_constraint = new HardRouteConstraint() {

View file

@ -55,7 +55,7 @@ public class VRPWithBackhaulsExample {
new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_solomon_r101.xml");
/*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/
//
VehicleRoutingProblem vrp = vrpBuilder.build();
@ -63,7 +63,7 @@ public class VRPWithBackhaulsExample {
// SolutionPlotter.plotVrpAsPNG(vrp, "output/vrpwbh_solomon_r101.png", "pd_r101");
/*
* Define the required vehicle-routing algorithms to solve the above problem.
* Define the required vehicle-routing algorithms to solve the above problem.
*
* The algorithm can be defined and configured in an xml-file.
*/

View file

@ -61,7 +61,7 @@ public class VRPWithBackhaulsExample2 {
/*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/
final VehicleRoutingProblem vrp = vrpBuilder.build();
@ -69,7 +69,7 @@ public class VRPWithBackhaulsExample2 {
/*
* Define the required vehicle-routing algorithms to solve the above problem.
* Define the required vehicle-routing algorithms to solve the above problem.
*
* The algorithm can be defined and configured in an xml-file.
*/

View file

@ -26,26 +26,26 @@ public class WaitingTimeExample {
public static void main(String[] args) {
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("type").setCostPerDistance(4.).setCostPerWaitingTime(1.0).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type1").setCostPerDistance(4.).setCostPerWaitingTime(1.0).build();
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("type").setCostPerDistance(4.).setCostPerWaitingTime(4.0).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type1").setCostPerDistance(4.).setCostPerWaitingTime(4.0).build();
VehicleImpl v2 = VehicleImpl.Builder.newInstance("v2").setType(type).setReturnToDepot(true)
.setStartLocation(Location.newInstance(0, 0))
.setEarliestStart(0).setLatestArrival(220)
.build();
.setStartLocation(Location.newInstance(0, 0))
.setEarliestStart(0).setLatestArrival(220)
.build();
VehicleImpl v3 = VehicleImpl.Builder.newInstance("v3").setType(type1).setReturnToDepot(true)
.setStartLocation(Location.newInstance(0, 10))
.setEarliestStart(200).setLatestArrival(450)
.build();
.setStartLocation(Location.newInstance(0, 10))
.setEarliestStart(200).setLatestArrival(450)
.build();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
Random r = RandomNumberGeneration.newInstance();
for(int i=0;i<40;i++){
Service s = Service.Builder.newInstance("s_"+i).setServiceTime(5)
.setLocation(Location.newInstance(1 - r.nextInt(5), 10 + r.nextInt(10))).build();
for (int i = 0; i < 40; i++) {
Service s = Service.Builder.newInstance("s_" + i).setServiceTime(5)
.setLocation(Location.newInstance(1 - r.nextInt(5), 10 + r.nextInt(10))).build();
vrpBuilder.addJob(s);
}
Service s1 = Service.Builder.newInstance("s12").setLocation(Location.newInstance(-3, 15)).setTimeWindow(TimeWindow.newInstance(290, 600)).build();
Service s4 = Service.Builder.newInstance("s13").setLocation(Location.newInstance(0,20)).setTimeWindow(TimeWindow.newInstance(290, 340)).build();
Service s4 = Service.Builder.newInstance("s13").setLocation(Location.newInstance(0, 20)).setTimeWindow(TimeWindow.newInstance(290, 340)).build();
Service s2 = Service.Builder.newInstance("s10").setLocation(Location.newInstance(-1, 15)).setTimeWindow(TimeWindow.newInstance(300, 350)).build();
Service s3 = Service.Builder.newInstance("s11").setLocation(Location.newInstance(10, 10)).setTimeWindow(TimeWindow.newInstance(400, 600)).build();
vrpBuilder.addJob(s1).addJob(s2).addJob(s3).addJob(s4).addVehicle(v2).addVehicle(v3);
@ -62,13 +62,13 @@ public class WaitingTimeExample {
SolutionAnalyser sa = new SolutionAnalyser(vrp, solution, new TransportDistance() {
@Override
public double getDistance(Location from, Location to) {
return vrp.getTransportCosts().getTransportTime(from,to,0.,null,null);
return vrp.getTransportCosts().getTransportTime(from, to, 0., null, null);
}
});
System.out.println("totalWaiting: " + sa.getWaitingTime());
System.out.println("brokenTWs: " + sa.getTimeWindowViolation());
new Plotter(vrp,solution).setLabel(Plotter.Label.ID).plot("output/plot","plot");
new Plotter(vrp, solution).setLabel(Plotter.Label.ID).plot("output/plot", "plot");
}
}

View file

@ -29,7 +29,7 @@ public class WaitingTimeExample2 {
// VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type1").setCostPerDistance(1.5).setCostPerWaitingTime(.0).build();
VehicleImpl v2 = VehicleImpl.Builder.newInstance("v2").setType(type).setReturnToDepot(true)
.setStartLocation(Location.newInstance(0, 0)).build();
.setStartLocation(Location.newInstance(0, 0)).build();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
@ -38,46 +38,11 @@ public class WaitingTimeExample2 {
Service s4 = Service.Builder.newInstance("s13").setLocation(Location.newInstance(0, 10)).build();
Service s2 = Service.Builder.newInstance("s10").setLocation(Location.newInstance(1, 12)).build();
Service s3 = Service.Builder.newInstance("s11").setLocation(Location.newInstance(4, 10)).build();
Service s5 = Service.Builder.newInstance("s14").setLocation(Location.newInstance(6, 5)).setTimeWindow(TimeWindow.newInstance(110,220)).build();
Service s5 = Service.Builder.newInstance("s14").setLocation(Location.newInstance(6, 5)).setTimeWindow(TimeWindow.newInstance(110, 220)).build();
vrpBuilder.addJob(s1).addJob(s2).addJob(s3).addJob(s4).addJob(s5).addVehicle(v2);
vrpBuilder.setFleetSize(VehicleRoutingProblem.FleetSize.FINITE);
final VehicleRoutingProblem vrp = vrpBuilder.build();
// AlgorithmFactory algorithmFactory = new AlgorithmFactory() {
// @Override
// public VehicleRoutingAlgorithm createAlgorithm(final VehicleRoutingProblem vrp) {
// StateManager stateManager = new StateManager(vrp);
// stateManager.addStateUpdater(new UpdateFutureWaitingTimes(stateManager,vrp.getTransportCosts()));
// ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
//
// return Jsprit.Builder.newInstance(vrp)
// .addCoreStateAndConstraintStuff(true)
// .setStateAndConstraintManager(stateManager, constraintManager)
//// .setProperty(Jsprit.Parameter.THRESHOLD_INI, "0.1")
//// .setProperty(Jsprit.Parameter.THRESHOLD_ALPHA, "0.3")
//// .setProperty(Parameter.)
//// .setProperty(Jsprit.Parameter.CONSTRUCTION, Jsprit.Construction.BEST_INSERTION.toString())
// .setObjectiveFunction(new SolutionCostCalculator() {
// @Override
// public double getCosts(VehicleRoutingProblemSolution solution) {
// double costs = 0.;
// for (VehicleRoute route : solution.getRoutes()) {
// costs += route.getVehicle().getType().getVehicleCostParams().fix;
// TourActivity prevAct = route.getStart();
// for (TourActivity act : route.getActivities()) {
// costs += vrp.getTransportCosts().getTransportCost(prevAct.getLocation(), act.getLocation(), prevAct.getEndTime(), route.getDriver(), route.getVehicle());
// costs += vrp.getActivityCosts().getActivityCost(act, act.getArrTime(), route.getDriver(), route.getVehicle());
// prevAct = act;
// }
// costs += vrp.getTransportCosts().getTransportCost(prevAct.getLocation(), route.getEnd().getLocation(), prevAct.getEndTime(), route.getDriver(), route.getVehicle());
// }
// costs += solution.getUnassignedJobs().size() * 200;
// return costs;
// }
// })
// .buildAlgorithm();
// }
// };
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
vra.setMaxIterations(1000);
vra.addListener(new AlgorithmSearchProgressChartListener("output/search"));
@ -85,6 +50,6 @@ public class WaitingTimeExample2 {
System.out.println("c: " + solution.getCost());
SolutionPrinter.print(vrp, solution, SolutionPrinter.Print.VERBOSE);
new Plotter(vrp,solution).setLabel(Plotter.Label.ID).plot("output/plot","plot");
new Plotter(vrp, solution).setLabel(Plotter.Label.ID).plot("output/plot", "plot");
}
}