From ffd720216f319236cf7b319bbe6d577fdfaba521 Mon Sep 17 00:00:00 2001 From: oblonski Date: Wed, 22 Apr 2015 07:57:15 +0200 Subject: [PATCH] fix example --- .../test/resources/infiniteWriterV2Test.xml | 81 ++++++++++++------- .../jsprit/examples/MultipleDepotExample.java | 7 +- .../examples/MultipleDepotExample2.java | 10 +-- 3 files changed, 63 insertions(+), 35 deletions(-) diff --git a/jsprit-core/src/test/resources/infiniteWriterV2Test.xml b/jsprit-core/src/test/resources/infiniteWriterV2Test.xml index 07c5406a..2d9058ab 100644 --- a/jsprit-core/src/test/resources/infiniteWriterV2Test.xml +++ b/jsprit-core/src/test/resources/infiniteWriterV2Test.xml @@ -2,24 +2,9 @@ - FINITE + INFINITE - - v2 - vehType2 - - loc - - - loc - - - 0.0 - 1.7976931348623157E308 - - true - v1 vehType @@ -48,16 +33,58 @@ - - vehType2 - - 200 - - - 0.0 - 1.0 - - - + + + + loc + + + 1 + + 2.0 + + + 0.0 + 1.7976931348623157E308 + + + + + + loc2 + + + 1 + + 4.0 + + + 0.0 + 1.7976931348623157E308 + + + + + + + 10.0 + + + noDriver + v1 + 0.0 + + 1 + 0.0 + 0.0 + + 0.0 + + + + + + + diff --git a/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExample.java b/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExample.java index bd3ec39b..daca79ce 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExample.java +++ b/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExample.java @@ -21,8 +21,9 @@ import jsprit.analysis.toolbox.GraphStreamViewer; import jsprit.analysis.toolbox.Plotter; import jsprit.analysis.toolbox.StopWatch; import jsprit.core.algorithm.VehicleRoutingAlgorithm; -import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; +import jsprit.core.algorithm.box.Jsprit; import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority; +import jsprit.core.problem.Location; import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.VehicleRoutingProblem.FleetSize; import jsprit.core.problem.io.VrpXMLReader; @@ -73,7 +74,7 @@ public class MultipleDepotExample { for(Coordinate depotCoord : Arrays.asList(firstDepotCoord,second,third,fourth)){ for(int i=0;i solutions = vra.searchSolutions(); diff --git a/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExample2.java b/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExample2.java index cb37cf20..d3e14ed9 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExample2.java +++ b/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExample2.java @@ -21,11 +21,11 @@ import jsprit.analysis.toolbox.GraphStreamViewer; import jsprit.analysis.toolbox.Plotter; import jsprit.analysis.toolbox.StopWatch; import jsprit.core.algorithm.VehicleRoutingAlgorithm; -import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; +import jsprit.core.algorithm.box.Jsprit; import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority; +import jsprit.core.problem.Location; import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.VehicleRoutingProblem.FleetSize; -import jsprit.core.problem.io.VrpXMLReader; import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.problem.vehicle.VehicleImpl; import jsprit.core.problem.vehicle.VehicleType; @@ -76,7 +76,7 @@ public class MultipleDepotExample2 { .addCapacityDimension(0, capacity).setCostPerDistance(1.0).build(); String vehicleId = depotCounter + "_" + (i+1) + "_vehicle"; VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance(vehicleId); - vehicleBuilder.setStartLocationCoordinate(depotCoord); + vehicleBuilder.setStartLocation(Location.newInstance(depotCoord.getX(),depotCoord.getY())); vehicleBuilder.setType(vehicleType); vehicleBuilder.setLatestArrival(maxDuration); VehicleImpl vehicle = vehicleBuilder.build(); @@ -104,8 +104,8 @@ public class MultipleDepotExample2 { /* * solve the problem */ - VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp,12, "input/algorithmConfig.xml"); - vra.setMaxIterations(5000); + VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.THREADS,"5").buildAlgorithm(); + vra.setMaxIterations(2000); vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH); vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png")); Collection solutions = vra.searchSolutions();