diff --git a/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLReader.java b/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLReader.java index a6895d41..7cde83f8 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLReader.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLReader.java @@ -320,9 +320,9 @@ public class VrpXMLReader{ builder.setPickupLocation(pickupLocationId); Coordinate pickupCoord = getCoord(shipmentConfig,"pickup."); - builder.setPickupCoord(pickupCoord); - + if(pickupCoord != null){ + builder.setPickupCoord(pickupCoord); if(pickupLocationId != null){ vrpBuilder.addLocation(pickupLocationId,pickupCoord); } @@ -341,9 +341,9 @@ public class VrpXMLReader{ builder.setDeliveryLocation(deliveryLocationId); Coordinate deliveryCoord = getCoord(shipmentConfig,"delivery."); - builder.setDeliveryCoord(deliveryCoord); if(deliveryCoord != null){ + builder.setDeliveryCoord(deliveryCoord); if(deliveryLocationId != null){ vrpBuilder.addLocation(deliveryLocationId,deliveryCoord); } diff --git a/jsprit-instances/instances/vrph/c20_3mix.txt b/jsprit-instances/instances/vrph/c20_3mix.txt deleted file mode 100644 index 9003a6d2..00000000 --- a/jsprit-instances/instances/vrph/c20_3mix.txt +++ /dev/null @@ -1,29 +0,0 @@ -20 - 0 30 40 0 - 1 37 52 7 - 2 49 49 30 - 3 52 64 16 - 4 20 26 9 - 5 40 30 21 - 6 21 47 15 - 7 17 63 19 - 8 31 62 23 - 9 52 33 11 - 10 51 21 5 - 11 42 41 19 - 12 31 32 29 - 13 5 25 23 - 14 12 42 21 - 15 36 16 10 - 16 52 41 15 - 17 27 23 3 - 18 17 33 41 - 19 13 13 9 - 20 57 58 28 -//Vehicles characteristics: type, volume, fixed cost -5 -v 1 20 20 -v 2 30 35 -v 3 40 50 -v 4 70 120 -v 5 120 225 diff --git a/jsprit-instances/instances/vrph/c20_4mix.txt b/jsprit-instances/instances/vrph/c20_4mix.txt deleted file mode 100644 index f7dd9eaa..00000000 --- a/jsprit-instances/instances/vrph/c20_4mix.txt +++ /dev/null @@ -1,27 +0,0 @@ -20 - 0 30 40 0 - 1 37 52 7 - 2 49 49 30 - 3 52 64 16 - 4 20 26 9 - 5 40 30 21 - 6 21 47 15 - 7 17 63 19 - 8 31 62 23 - 9 52 33 11 - 10 51 21 5 - 11 42 41 19 - 12 31 32 29 - 13 5 25 23 - 14 12 42 21 - 15 36 16 10 - 16 52 41 15 - 17 27 23 3 - 18 17 33 41 - 19 13 13 9 - 20 57 58 28 -//Vehicles characteristics: type, volume, fixed cost -3 -v 1 60 1000 -v 2 80 1500 -v 3 150 3000 diff --git a/jsprit-instances/instances/vrph/c20_5mix.txt b/jsprit-instances/instances/vrph/c20_5mix.txt deleted file mode 100644 index 5a9c33e7..00000000 --- a/jsprit-instances/instances/vrph/c20_5mix.txt +++ /dev/null @@ -1,29 +0,0 @@ -20 - 0 30 40 0 - 1 37 52 7 - 2 49 49 30 - 3 52 64 16 - 4 20 26 9 - 5 40 30 21 - 6 21 47 15 - 7 17 63 19 - 8 31 62 23 - 9 52 33 11 - 10 51 21 5 - 11 42 41 19 - 12 31 32 29 - 13 5 25 23 - 14 12 42 21 - 15 36 16 10 - 16 52 41 15 - 17 27 23 3 - 18 17 33 41 - 19 13 13 9 - 20 57 58 28 -//Vehicles characteristics: type, volume, fixed cost -5 -v 1 20 20 -v 2 30 35 -v 3 40 50 -v 4 70 120 -v 5 120 225 \ No newline at end of file diff --git a/jsprit-instances/instances/vrph/c20_6mix.txt b/jsprit-instances/instances/vrph/c20_6mix.txt deleted file mode 100644 index f7dd9eaa..00000000 --- a/jsprit-instances/instances/vrph/c20_6mix.txt +++ /dev/null @@ -1,27 +0,0 @@ -20 - 0 30 40 0 - 1 37 52 7 - 2 49 49 30 - 3 52 64 16 - 4 20 26 9 - 5 40 30 21 - 6 21 47 15 - 7 17 63 19 - 8 31 62 23 - 9 52 33 11 - 10 51 21 5 - 11 42 41 19 - 12 31 32 29 - 13 5 25 23 - 14 12 42 21 - 15 36 16 10 - 16 52 41 15 - 17 27 23 3 - 18 17 33 41 - 19 13 13 9 - 20 57 58 28 -//Vehicles characteristics: type, volume, fixed cost -3 -v 1 60 1000 -v 2 80 1500 -v 3 150 3000 diff --git a/jsprit-instances/instances/vrph/cn_17mix.txt b/jsprit-instances/instances/vrph/cn_17mix.txt index c137802e..fe1cff90 100644 --- a/jsprit-instances/instances/vrph/cn_17mix.txt +++ b/jsprit-instances/instances/vrph/cn_17mix.txt @@ -78,10 +78,11 @@ //Vehicles characteristics: volume, fixed cost, variable cost, number available //See E. D. Taillard, "A heuristic column generation method for the heterogeneous fleet vrp" //RAIRO Rech. Op�r. 33 (1) 1999, pp 1-14) -//see http://ina2.eivd.ch/collaborateurs/etd/articles.dir/vrphen.pdf50 25 1.0 4 -v 1 120 80 1.2 4 -v 2 200 150 1.5 2 -v 3 350 320 1.8 1 +//see http://ina2.eivd.ch/collaborateurs/etd/articles.dir/vrphen.pdf +v 1 50 25 1.0 4 +v 2 120 80 1.2 4 +v 3 200 150 1.5 2 +v 4 350 320 1.8 1 7 350 0 1000000 703.124497 + 7 * 150 = 1753.12 14 27 57 15 37 20 70 60 71 69 36 47 5 29 45 2685412 diff --git a/jsprit-instances/src/main/java/jsprit/instance/reader/VrphGoldenReader.java b/jsprit-instances/src/main/java/jsprit/instance/reader/VrphGoldenReader.java index d4e793c8..bfb77624 100644 --- a/jsprit-instances/src/main/java/jsprit/instance/reader/VrphGoldenReader.java +++ b/jsprit-instances/src/main/java/jsprit/instance/reader/VrphGoldenReader.java @@ -23,8 +23,6 @@ import jsprit.core.util.Coordinate; * *

See {@link VrphType} what kind of problems can be generated * - *

Note that c20_3-c20_6 do not have variable costs and a limited nuVehicle, thus they can only be used for FSMF. - * * @author schroeder * */ @@ -110,6 +108,7 @@ public class VrphGoldenReader { typeBuilder.setCostPerDistance(Double.parseDouble(tokens[4])); nuOfVehicles = Integer.parseInt(tokens[5]); vrpBuilder.setFleetSize(FleetSize.FINITE); + vrpBuilder.addPenaltyVehicles(5.0, 5000); } else throw new IllegalStateException("option " + vrphType + " cannot be applied with this instance"); } @@ -119,6 +118,7 @@ public class VrphGoldenReader { typeBuilder.setCostPerDistance(Double.parseDouble(tokens[4])); nuOfVehicles = Integer.parseInt(tokens[5]); vrpBuilder.setFleetSize(FleetSize.FINITE); + vrpBuilder.addPenaltyVehicles(5.0, 5000); } else throw new IllegalStateException("option " + vrphType + " cannot be applied with this instance"); } diff --git a/jsprit-instances/src/test/java/jsprit/instance/reader/GoldenReaderTest.java b/jsprit-instances/src/test/java/jsprit/instance/reader/GoldenReaderTest.java index bd482aab..787dbe5b 100644 --- a/jsprit-instances/src/test/java/jsprit/instance/reader/GoldenReaderTest.java +++ b/jsprit-instances/src/test/java/jsprit/instance/reader/GoldenReaderTest.java @@ -6,6 +6,7 @@ import static org.junit.Assert.assertTrue; import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.job.Job; import jsprit.core.problem.job.Service; +import jsprit.core.problem.vehicle.PenaltyVehicleType; import jsprit.core.problem.vehicle.Vehicle; import jsprit.core.util.Coordinate; import jsprit.instance.reader.VrphGoldenReader.VrphType; @@ -20,7 +21,13 @@ public class GoldenReaderTest { new VrphGoldenReader(vrpBuilder, VrphType.HVRPD) .read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath()); VehicleRoutingProblem vrp = vrpBuilder.build(); - assertEquals(17,vrp.getVehicles().size()); + int nuOfVehicles = 0; + for(Vehicle v : vrp.getVehicles()){ + if(!(v.getType() instanceof PenaltyVehicleType)){ + nuOfVehicles++; + } + } + assertEquals(17,nuOfVehicles); } @Test @@ -31,7 +38,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int nuOfType1Vehicles = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_1")){ + if(v.getType().getTypeId().equals("type_1") && !(v.getType() instanceof PenaltyVehicleType) ){ nuOfType1Vehicles++; } } @@ -46,7 +53,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int sumOfType1Cap = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_1")){ + if(v.getType().getTypeId().equals("type_1") && !(v.getType() instanceof PenaltyVehicleType) ){ sumOfType1Cap+=v.getCapacity(); } } @@ -61,7 +68,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int nuOfType1Vehicles = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_2")){ + if(v.getType().getTypeId().equals("type_2") && !(v.getType() instanceof PenaltyVehicleType) ){ nuOfType1Vehicles++; } } @@ -76,7 +83,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int sumOfType1Cap = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_2")){ + if(v.getType().getTypeId().equals("type_2") && !(v.getType() instanceof PenaltyVehicleType) ){ sumOfType1Cap+=v.getCapacity(); } } @@ -91,7 +98,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int nuOfType1Vehicles = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_3")){ + if(v.getType().getTypeId().equals("type_3") && !(v.getType() instanceof PenaltyVehicleType) ){ nuOfType1Vehicles++; } } @@ -106,7 +113,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int sumOfType1Cap = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_3")){ + if(v.getType().getTypeId().equals("type_3") && !(v.getType() instanceof PenaltyVehicleType) ){ sumOfType1Cap+=v.getCapacity(); } } @@ -121,7 +128,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int nuOfType1Vehicles = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_4")){ + if(v.getType().getTypeId().equals("type_4") && !(v.getType() instanceof PenaltyVehicleType) ){ nuOfType1Vehicles++; } } @@ -136,7 +143,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int sumOfType1Cap = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_4")){ + if(v.getType().getTypeId().equals("type_4") && !(v.getType() instanceof PenaltyVehicleType) ){ sumOfType1Cap+=v.getCapacity(); } } @@ -151,7 +158,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int nuOfType1Vehicles = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_5")){ + if(v.getType().getTypeId().equals("type_5") && !(v.getType() instanceof PenaltyVehicleType) ){ nuOfType1Vehicles++; } } @@ -166,7 +173,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int sumOfType1Cap = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_5")){ + if(v.getType().getTypeId().equals("type_5") && !(v.getType() instanceof PenaltyVehicleType) ){ sumOfType1Cap+=v.getCapacity(); } } @@ -181,7 +188,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int nuOfType1Vehicles = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_6")){ + if(v.getType().getTypeId().equals("type_6") && !(v.getType() instanceof PenaltyVehicleType) ){ nuOfType1Vehicles++; } } @@ -196,7 +203,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int sumOfType1Cap = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_6")){ + if(v.getType().getTypeId().equals("type_6") && !(v.getType() instanceof PenaltyVehicleType) ){ sumOfType1Cap+=v.getCapacity(); } }