From 2ce279d5a53be2cfb02fc804243e915ad444eb78 Mon Sep 17 00:00:00 2001 From: oblonski Date: Thu, 17 Sep 2015 16:04:56 +0200 Subject: [PATCH] separate long running tests - fix #178 --- jsprit-core/pom.xml | 29 ++ .../java/jsprit/core/IntegrationTest.java | 7 + .../BuildCVRPAlgoFromScratch_IT.java | 3 + .../BuildPDVRPAlgoFromScratch_IT.java | 3 + ...dPDVRPWithShipmentsAlgoFromScratch_IT.java | 3 + ...iesAndDifferentInsertionStrategies_IT.java | 4 + .../core/algorithm/CVRPwithDeliveries_IT.java | 4 + .../core/algorithm/CVRPwithMatrix_IT.java | 5 + .../core/algorithm/CVRPwithPickups_IT.java | 4 + ...etManagerIdentifiesDistinctVehicle_IT.java | 3 + .../java/jsprit/core/algorithm/PDTW_IT.java | 188 ------- .../algorithm/PickupsAndDeliveries_IT.java | 4 + ...CostsHigherThanTimesAndFiniteFleet_IT.java | 3 + ...niteFleet_withTimeAndDistanceCosts_IT.java | 3 + .../core/algorithm/RefuseCollection_IT.java | 6 + .../{state => }/SolomonSkills_IT.java | 8 +- .../algorithm/{state => }/Solomon_IT.java | 6 +- .../VariableDepartureAndWaitingTime_IT.java | 4 + .../jsprit/core/algorithm/box/JspritTest.java | 374 +------------ ...iteVrpWithInitialSolutionForWriterTest.xml | 493 +++++++++--------- .../test/resources/infiniteWriterV2Test.xml | 171 +++--- jsprit-instances/pom.xml | 2 + pom.xml | 25 +- 23 files changed, 440 insertions(+), 912 deletions(-) create mode 100644 jsprit-core/src/test/java/jsprit/core/IntegrationTest.java delete mode 100644 jsprit-core/src/test/java/jsprit/core/algorithm/PDTW_IT.java rename jsprit-core/src/test/java/jsprit/core/algorithm/{state => }/SolomonSkills_IT.java (96%) rename jsprit-core/src/test/java/jsprit/core/algorithm/{state => }/Solomon_IT.java (87%) diff --git a/jsprit-core/pom.xml b/jsprit-core/pom.xml index a79fee3c..a9f13f25 100644 --- a/jsprit-core/pom.xml +++ b/jsprit-core/pom.xml @@ -55,8 +55,37 @@ + + + maven-surefire-plugin + 2.18.1 + + jsprit.core.IntegrationTest + + + + maven-failsafe-plugin + 2.18.1 + + + **/*.java + + jsprit.core.IntegrationTest + + + + + integration-test + verify + + + + + + + diff --git a/jsprit-core/src/test/java/jsprit/core/IntegrationTest.java b/jsprit-core/src/test/java/jsprit/core/IntegrationTest.java new file mode 100644 index 00000000..b16ee817 --- /dev/null +++ b/jsprit-core/src/test/java/jsprit/core/IntegrationTest.java @@ -0,0 +1,7 @@ +package jsprit.core; + +/** + * Created by schroeder on 17/09/15. + */ +public interface IntegrationTest { +} diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/BuildCVRPAlgoFromScratch_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/BuildCVRPAlgoFromScratch_IT.java index 745a0ff2..fbe11cab 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/BuildCVRPAlgoFromScratch_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/BuildCVRPAlgoFromScratch_IT.java @@ -16,6 +16,7 @@ ******************************************************************************/ package jsprit.core.algorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.acceptor.GreedyAcceptance; import jsprit.core.algorithm.module.RuinAndRecreateModule; import jsprit.core.algorithm.recreate.BestInsertionBuilder; @@ -38,6 +39,7 @@ import jsprit.core.problem.vehicle.VehicleFleetManager; import jsprit.core.util.Solutions; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.Collection; @@ -95,6 +97,7 @@ public class BuildCVRPAlgoFromScratch_IT { } @Test + @Category(IntegrationTest.class) public void testVRA() { Collection solutions = vra.searchSolutions(); System.out.println("costs=" + Solutions.bestOf(solutions).getCost() + ";#routes=" + Solutions.bestOf(solutions).getRoutes().size()); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/BuildPDVRPAlgoFromScratch_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/BuildPDVRPAlgoFromScratch_IT.java index d2869446..59a559c0 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/BuildPDVRPAlgoFromScratch_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/BuildPDVRPAlgoFromScratch_IT.java @@ -16,6 +16,7 @@ ******************************************************************************/ package jsprit.core.algorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.acceptor.GreedyAcceptance; import jsprit.core.algorithm.module.RuinAndRecreateModule; import jsprit.core.algorithm.recreate.BestInsertionBuilder; @@ -42,6 +43,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.Collection; @@ -104,6 +106,7 @@ public class BuildPDVRPAlgoFromScratch_IT { } @Test + @Category(IntegrationTest.class) public void test() { try { Collection solutions = vra.searchSolutions(); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/BuildPDVRPWithShipmentsAlgoFromScratch_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/BuildPDVRPWithShipmentsAlgoFromScratch_IT.java index cba8afc9..9c756ca4 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/BuildPDVRPWithShipmentsAlgoFromScratch_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/BuildPDVRPWithShipmentsAlgoFromScratch_IT.java @@ -16,6 +16,7 @@ ******************************************************************************/ package jsprit.core.algorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.acceptor.GreedyAcceptance; import jsprit.core.algorithm.module.RuinAndRecreateModule; import jsprit.core.algorithm.recreate.BestInsertionBuilder; @@ -37,6 +38,7 @@ import jsprit.core.problem.solution.route.VehicleRoute; import jsprit.core.problem.vehicle.InfiniteFleetManagerFactory; import jsprit.core.problem.vehicle.VehicleFleetManager; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.Collection; @@ -46,6 +48,7 @@ import static org.junit.Assert.assertTrue; public class BuildPDVRPWithShipmentsAlgoFromScratch_IT { @Test + @Category(IntegrationTest.class) public void test() { VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(builder).read("src/test/resources/pdp.xml"); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithDeliveriesAndDifferentInsertionStrategies_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithDeliveriesAndDifferentInsertionStrategies_IT.java index d928ebde..19cdd207 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithDeliveriesAndDifferentInsertionStrategies_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithDeliveriesAndDifferentInsertionStrategies_IT.java @@ -16,18 +16,21 @@ ******************************************************************************/ package jsprit.core.algorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.io.VrpXMLReader; import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import junit.framework.Assert; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.Collection; public class CVRPwithDeliveriesAndDifferentInsertionStrategies_IT { @Test + @Category(IntegrationTest.class) public void whenWithTwoInsertionStrategiesWhereOnleOneIsInAlgo_itShouldWork() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml"); @@ -43,6 +46,7 @@ public class CVRPwithDeliveriesAndDifferentInsertionStrategies_IT { } @Test + @Category(IntegrationTest.class) public void whenWithTwoInsertionStrategiesWhereBothAreInAlgo_itShouldWork() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml"); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithDeliveries_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithDeliveries_IT.java index 8278b97d..ba823254 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithDeliveries_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithDeliveries_IT.java @@ -16,6 +16,7 @@ ******************************************************************************/ package jsprit.core.algorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.box.Jsprit; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.problem.VehicleRoutingProblem; @@ -23,6 +24,7 @@ import jsprit.core.problem.io.VrpXMLReader; import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.util.Solutions; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.Collection; @@ -31,6 +33,7 @@ import static org.junit.Assert.assertEquals; public class CVRPwithDeliveries_IT { @Test + @Category(IntegrationTest.class) public void whenSolvingVRPNC1withDeliveries_solutionsMustNoBeWorseThan5PercentOfBestKnownSolution() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml"); @@ -42,6 +45,7 @@ public class CVRPwithDeliveries_IT { } @Test + @Category(IntegrationTest.class) public void whenSolvingVRPNC1withDeliveriesWithJsprit_solutionsMustNoBeWorseThan5PercentOfBestKnownSolution() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml"); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithMatrix_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithMatrix_IT.java index 83f7e729..a37205de 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithMatrix_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithMatrix_IT.java @@ -16,6 +16,7 @@ ******************************************************************************/ package jsprit.core.algorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.analysis.SolutionAnalyser; import jsprit.core.problem.Location; @@ -31,6 +32,7 @@ import jsprit.core.util.EuclideanDistanceCalculator; import jsprit.core.util.FastVehicleRoutingTransportCostsMatrix; import jsprit.core.util.Solutions; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.ArrayList; import java.util.Collection; @@ -44,6 +46,7 @@ public class CVRPwithMatrix_IT { @Test + @Category(IntegrationTest.class) public void whenReturnToDepot_itShouldWorkWithMatrix() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml"); @@ -56,6 +59,7 @@ public class CVRPwithMatrix_IT { } @Test + @Category(IntegrationTest.class) public void whenNotReturnToDepot_itShouldWorkWithMatrix() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml"); @@ -71,6 +75,7 @@ public class CVRPwithMatrix_IT { } @Test + @Category(IntegrationTest.class) public void whenCalcTimeWithSolutionAnalyser_itShouldWork() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml"); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithPickups_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithPickups_IT.java index 59df237b..c80d4e73 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithPickups_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithPickups_IT.java @@ -16,6 +16,7 @@ ******************************************************************************/ package jsprit.core.algorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.box.Jsprit; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.problem.VehicleRoutingProblem; @@ -23,6 +24,7 @@ import jsprit.core.problem.io.VrpXMLReader; import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.util.Solutions; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.Collection; @@ -31,6 +33,7 @@ import static org.junit.Assert.assertEquals; public class CVRPwithPickups_IT { @Test + @Category(IntegrationTest.class) public void whenSolvingVRPNC1WithPickups_solutionsMustNoBeWorseThan5PercentOfBestKnownSolution() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-pickups.xml"); @@ -42,6 +45,7 @@ public class CVRPwithPickups_IT { } @Test + @Category(IntegrationTest.class) public void whenSolvingVRPNC1WithPickupsWithJsprit_solutionsMustNoBeWorseThan5PercentOfBestKnownSolution() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-pickups.xml"); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/FiniteVehicleFleetManagerIdentifiesDistinctVehicle_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/FiniteVehicleFleetManagerIdentifiesDistinctVehicle_IT.java index e25d5bb7..42b48d3e 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/FiniteVehicleFleetManagerIdentifiesDistinctVehicle_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/FiniteVehicleFleetManagerIdentifiesDistinctVehicle_IT.java @@ -18,6 +18,7 @@ ******************************************************************************/ package jsprit.core.algorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.box.Jsprit; import jsprit.core.algorithm.box.SchrimpfFactory; import jsprit.core.algorithm.recreate.NoSolutionFoundException; @@ -25,6 +26,7 @@ import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.io.VrpXMLReader; import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.ArrayList; import java.util.Collection; @@ -35,6 +37,7 @@ import static org.junit.Assert.assertTrue; public class FiniteVehicleFleetManagerIdentifiesDistinctVehicle_IT { @Test + @Category(IntegrationTest.class) public void whenEmployingVehicleWhereOnlyOneDistinctVehicleCanServeAParticularJob_algorithmShouldFoundDistinctSolution() { final List testFailed = new ArrayList(); for (int i = 0; i < 10; i++) { diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/PDTW_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/PDTW_IT.java deleted file mode 100644 index 29a752cd..00000000 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/PDTW_IT.java +++ /dev/null @@ -1,188 +0,0 @@ -package jsprit.core.algorithm; - - -import jsprit.core.algorithm.box.Jsprit; -import jsprit.core.algorithm.box.SchrimpfFactory; -import jsprit.core.problem.AbstractJob; -import jsprit.core.problem.Location; -import jsprit.core.problem.VehicleRoutingProblem; -import jsprit.core.problem.VehicleRoutingProblem.FleetSize; -import jsprit.core.problem.job.Service; -import jsprit.core.problem.job.Shipment; -import jsprit.core.problem.solution.VehicleRoutingProblemSolution; -import jsprit.core.problem.solution.route.VehicleRoute; -import jsprit.core.problem.solution.route.activity.TourActivity; -import jsprit.core.problem.vehicle.Vehicle; -import jsprit.core.problem.vehicle.VehicleImpl; -import jsprit.core.problem.vehicle.VehicleImpl.Builder; -import jsprit.core.problem.vehicle.VehicleType; -import jsprit.core.problem.vehicle.VehicleTypeImpl; -import jsprit.core.util.Coordinate; -import jsprit.core.util.Solutions; -import org.junit.Test; - -import java.util.Collection; -import java.util.Random; - -import static org.junit.Assert.assertFalse; - - -public class PDTW_IT { - - int nJobs = 200; - int nVehicles = 40; - Random random = new Random(1623); - int nextShipmentId = 1; - int nextVehicleId = 1; - - @Test - public void whenDealingWithShipments_timeWindowsShouldNOTbeBroken() { - VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); - for (int i = 0; i < nVehicles; i++) { - vrpBuilder.addVehicle(createVehicle()); - } - for (int i = 0; i < nJobs; i++) { - vrpBuilder.addJob(createShipment()); - } - vrpBuilder.setFleetSize(FleetSize.FINITE); - VehicleRoutingProblem problem = vrpBuilder.build(); - VehicleRoutingAlgorithm algorithm = new SchrimpfFactory().createAlgorithm(problem); - algorithm.setMaxIterations(0); - Collection solutions = algorithm.searchSolutions(); - VehicleRoutingProblemSolution bestSolution = Solutions.bestOf(solutions); - - for (VehicleRoute route : bestSolution.getRoutes()) { - Vehicle v = route.getVehicle(); - for (TourActivity ta : route.getActivities()) { - if (ta.getArrTime() > v.getLatestArrival() * 1.00001) { - assertFalse(true); - } - } - } - } - - - @Test - public void whenDealingWithServices_timeWindowsShouldNOTbeBroken() { - VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); - for (int i = 0; i < nVehicles; i++) { - vrpBuilder.addVehicle(createVehicle()); - } - for (int i = 0; i < nJobs; i++) { - vrpBuilder.addJob(createService()); - } - vrpBuilder.setFleetSize(FleetSize.FINITE); - VehicleRoutingProblem problem = vrpBuilder.build(); - VehicleRoutingAlgorithm algorithm = new SchrimpfFactory().createAlgorithm(problem); - algorithm.setMaxIterations(100); - Collection solutions = algorithm.searchSolutions(); - VehicleRoutingProblemSolution bestSolution = Solutions.bestOf(solutions); - - for (VehicleRoute route : bestSolution.getRoutes()) { - Vehicle v = route.getVehicle(); - for (TourActivity ta : route.getActivities()) { - if (ta.getArrTime() * 1.000001 > v.getLatestArrival()) { - assertFalse(true); - } - } - } - } - - @Test - public void whenDealingWithShipments_usingJsprit_timeWindowsShouldNOTbeBroken() { - VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); - for (int i = 0; i < nVehicles; i++) { - vrpBuilder.addVehicle(createVehicle()); - } - for (int i = 0; i < nJobs; i++) { - vrpBuilder.addJob(createShipment()); - } - vrpBuilder.setFleetSize(FleetSize.FINITE); - VehicleRoutingProblem problem = vrpBuilder.build(); - VehicleRoutingAlgorithm algorithm = Jsprit.createAlgorithm(problem); - algorithm.setMaxIterations(0); - Collection solutions = algorithm.searchSolutions(); - VehicleRoutingProblemSolution bestSolution = Solutions.bestOf(solutions); - - for (VehicleRoute route : bestSolution.getRoutes()) { - Vehicle v = route.getVehicle(); - for (TourActivity ta : route.getActivities()) { - if (ta.getArrTime() > v.getLatestArrival() * 1.00001) { - assertFalse(true); - } - } - } - } - - - @Test - public void whenDealingWithServices_usingJsprit_timeWindowsShouldNOTbeBroken() { - VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); - for (int i = 0; i < nVehicles; i++) { - vrpBuilder.addVehicle(createVehicle()); - } - for (int i = 0; i < nJobs; i++) { - vrpBuilder.addJob(createService()); - } - vrpBuilder.setFleetSize(FleetSize.FINITE); - VehicleRoutingProblem problem = vrpBuilder.build(); - VehicleRoutingAlgorithm algorithm = Jsprit.createAlgorithm(problem); - algorithm.setMaxIterations(100); - Collection solutions = algorithm.searchSolutions(); - VehicleRoutingProblemSolution bestSolution = Solutions.bestOf(solutions); - - for (VehicleRoute route : bestSolution.getRoutes()) { - Vehicle v = route.getVehicle(); - for (TourActivity ta : route.getActivities()) { - if (ta.getArrTime() * 1.000001 > v.getLatestArrival()) { - assertFalse(true); - } - } - } - } - - private AbstractJob createService() { - Service.Builder b = Service.Builder.newInstance(Integer.toString(nextShipmentId++)); - b.addSizeDimension(0, 1); - b.setServiceTime(random.nextDouble() * 5); - b.setLocation(createLocation()); - return b.build(); - } - - private Location createLocation() { - return loc(new Coordinate(50 * random.nextDouble(), 50 * random.nextDouble())); - } - - private Shipment createShipment() { - Shipment.Builder b = Shipment.Builder.newInstance(Integer.toString(nextShipmentId++)); - b.addSizeDimension(0, 1); - b.setPickupServiceTime(random.nextDouble() * 5); - b.setDeliveryServiceTime(random.nextDouble() * 5); - b.setDeliveryLocation(createLocation()); - b.setPickupLocation(createLocation()); - return b.build(); - } - - private VehicleImpl createVehicle() { - VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType" + nextVehicleId).addCapacityDimension(0, 2); - vehicleTypeBuilder.setCostPerDistance(1.0); - vehicleTypeBuilder.setCostPerTime(1); - vehicleTypeBuilder.setFixedCost(1000); - VehicleType vehicleType = vehicleTypeBuilder.build(); - Builder v = VehicleImpl.Builder.newInstance("vehicle" + nextVehicleId); - Location l = createLocation(); - v.setStartLocation(l); - v.setEndLocation(l); - v.setType(vehicleType); - v.setEarliestStart(50); - v.setLatestArrival(200); - nextVehicleId++; - return v.build(); - } - - - private static Location loc(Coordinate coordinate) { - return Location.Builder.newInstance().setCoordinate(coordinate).build(); - } -} - diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/PickupsAndDeliveries_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/PickupsAndDeliveries_IT.java index 8823bde7..2c36121f 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/PickupsAndDeliveries_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/PickupsAndDeliveries_IT.java @@ -18,6 +18,7 @@ ******************************************************************************/ package jsprit.core.algorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.box.Jsprit; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.problem.VehicleRoutingProblem; @@ -25,6 +26,7 @@ import jsprit.core.problem.io.VrpXMLReader; import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.util.Solutions; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.Collection; @@ -33,6 +35,7 @@ import static org.junit.Assert.assertEquals; public class PickupsAndDeliveries_IT { @Test + @Category(IntegrationTest.class) public void whenSolvingLR101InstanceOfLiLim_solutionsMustNoBeWorseThan5PercentOfBestKnownSolution() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(vrpBuilder).read("src/test/resources/lilim_lr101.xml"); @@ -44,6 +47,7 @@ public class PickupsAndDeliveries_IT { } @Test + @Category(IntegrationTest.class) public void whenSolvingLR101InstanceOfLiLim_withJsprit_solutionsMustNoBeWorseThan5PercentOfBestKnownSolution() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(vrpBuilder).read("src/test/resources/lilim_lr101.xml"); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT.java index f275e5c5..576b6f69 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT.java @@ -16,6 +16,7 @@ ******************************************************************************/ package jsprit.core.algorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.box.GreedySchrimpfFactory; import jsprit.core.algorithm.termination.IterationWithoutImprovementTermination; import jsprit.core.problem.Location; @@ -32,6 +33,7 @@ import jsprit.core.util.Solutions; import jsprit.core.util.VehicleRoutingTransportCostsMatrix; import jsprit.core.util.VehicleRoutingTransportCostsMatrix.Builder; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.io.*; import java.util.Collection; @@ -101,6 +103,7 @@ public class RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT { } @Test + @Category(IntegrationTest.class) public void testAlgo() { diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_withTimeAndDistanceCosts_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_withTimeAndDistanceCosts_IT.java index 2da06504..ea33b2ed 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_withTimeAndDistanceCosts_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_withTimeAndDistanceCosts_IT.java @@ -16,6 +16,7 @@ ******************************************************************************/ package jsprit.core.algorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.box.GreedySchrimpfFactory; import jsprit.core.algorithm.termination.IterationWithoutImprovementTermination; import jsprit.core.problem.Location; @@ -32,6 +33,7 @@ import jsprit.core.util.Solutions; import jsprit.core.util.VehicleRoutingTransportCostsMatrix; import jsprit.core.util.VehicleRoutingTransportCostsMatrix.Builder; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.io.*; import java.util.Collection; @@ -101,6 +103,7 @@ public class RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_withTimeAndD } @Test + @Category(IntegrationTest.class) public void testAlgo() { diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollection_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollection_IT.java index 348aadd2..f7a0e897 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollection_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollection_IT.java @@ -16,6 +16,7 @@ ******************************************************************************/ package jsprit.core.algorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.box.Jsprit; import jsprit.core.algorithm.box.SchrimpfFactory; import jsprit.core.algorithm.termination.IterationWithoutImprovementTermination; @@ -34,6 +35,7 @@ import jsprit.core.util.Solutions; import jsprit.core.util.VehicleRoutingTransportCostsMatrix; import jsprit.core.util.VehicleRoutingTransportCostsMatrix.Builder; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.io.*; import java.util.Collection; @@ -45,6 +47,7 @@ public class RefuseCollection_IT { @Test + @Category(IntegrationTest.class) public void whenReadingServices_itShouldCalculateCorrectly() { /* @@ -89,6 +92,7 @@ public class RefuseCollection_IT { } @Test + @Category(IntegrationTest.class) public void whenReadingServices_usingJsprit_itShouldCalculateCorrectly() { /* @@ -133,6 +137,7 @@ public class RefuseCollection_IT { } @Test + @Category(IntegrationTest.class) public void whenReadingPickups_itShouldCalculateCorrectly() { /* @@ -177,6 +182,7 @@ public class RefuseCollection_IT { } @Test + @Category(IntegrationTest.class) public void whenReadingDeliveries_itShouldCalculateCorrectly() { /* diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/state/SolomonSkills_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/SolomonSkills_IT.java similarity index 96% rename from jsprit-core/src/test/java/jsprit/core/algorithm/state/SolomonSkills_IT.java rename to jsprit-core/src/test/java/jsprit/core/algorithm/SolomonSkills_IT.java index 014e5f9f..e358360d 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/state/SolomonSkills_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/SolomonSkills_IT.java @@ -15,11 +15,11 @@ * License along with this library. If not, see . ******************************************************************************/ -package jsprit.core.algorithm.state; +package jsprit.core.algorithm; -import jsprit.core.algorithm.VehicleRoutingAlgorithm; -import jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.recreate.NoSolutionFoundException; +import jsprit.core.algorithm.state.StateManager; import jsprit.core.problem.Skills; import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.constraint.ConstraintManager; @@ -34,6 +34,7 @@ import jsprit.core.problem.vehicle.VehicleType; import jsprit.core.util.Solutions; import jsprit.core.util.TestUtils; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.Collection; @@ -45,6 +46,7 @@ import static org.junit.Assert.*; public class SolomonSkills_IT { @Test + @Category(IntegrationTest.class) public void itShouldMakeCorrectAssignmentAccordingToSkills() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(vrpBuilder).read("src/test/resources/solomon_c101.xml"); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/state/Solomon_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/Solomon_IT.java similarity index 87% rename from jsprit-core/src/test/java/jsprit/core/algorithm/state/Solomon_IT.java rename to jsprit-core/src/test/java/jsprit/core/algorithm/Solomon_IT.java index 0ba91f05..98fa3d91 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/state/Solomon_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/Solomon_IT.java @@ -1,12 +1,13 @@ -package jsprit.core.algorithm.state; +package jsprit.core.algorithm; -import jsprit.core.algorithm.VehicleRoutingAlgorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.io.VrpXMLReader; import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.util.Solutions; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.Collection; @@ -18,6 +19,7 @@ import static org.junit.Assert.assertEquals; public class Solomon_IT { @Test + @Category(IntegrationTest.class) public void itShouldFindTheBestKnownSolution() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(vrpBuilder).read("src/test/resources/solomon_c101.xml"); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/VariableDepartureAndWaitingTime_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/VariableDepartureAndWaitingTime_IT.java index d4b4daa1..6d94565c 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/VariableDepartureAndWaitingTime_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/VariableDepartureAndWaitingTime_IT.java @@ -1,5 +1,6 @@ package jsprit.core.algorithm; +import jsprit.core.IntegrationTest; import jsprit.core.algorithm.box.Jsprit; import jsprit.core.algorithm.state.StateManager; import jsprit.core.analysis.SolutionAnalyser; @@ -21,6 +22,7 @@ import jsprit.core.util.Solutions; import junit.framework.Assert; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.categories.Category; /** * Created by schroeder on 22/07/15. @@ -72,6 +74,7 @@ public class VariableDepartureAndWaitingTime_IT { } @Test + @Category(IntegrationTest.class) public void plainSetupShouldWork() { VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build(); Service s1 = Service.Builder.newInstance("s1").setLocation(Location.newInstance(10, 0)).build(); @@ -88,6 +91,7 @@ public class VariableDepartureAndWaitingTime_IT { } @Test + @Category(IntegrationTest.class) public void withTimeWindowsShouldWork() { VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build(); Service s1 = Service.Builder.newInstance("s1").setTimeWindow(TimeWindow.newInstance(1010, 1100)).setLocation(Location.newInstance(10, 0)).build(); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/box/JspritTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/box/JspritTest.java index 8bb3ecad..6dd1fafd 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/box/JspritTest.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/box/JspritTest.java @@ -3,21 +3,16 @@ package jsprit.core.algorithm.box; import jsprit.core.algorithm.SearchStrategy; import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.listener.StrategySelectedListener; -import jsprit.core.algorithm.recreate.InsertionData; -import jsprit.core.algorithm.recreate.listener.BeforeJobInsertionListener; import jsprit.core.algorithm.recreate.listener.JobInsertedListener; import jsprit.core.algorithm.ruin.listener.RuinListener; -import jsprit.core.algorithm.termination.VariationCoefficientTermination; import jsprit.core.problem.Location; import jsprit.core.problem.VehicleRoutingProblem; -import jsprit.core.problem.io.VrpXMLReader; import jsprit.core.problem.job.Job; import jsprit.core.problem.job.Service; import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.problem.solution.route.VehicleRoute; import jsprit.core.problem.vehicle.VehicleImpl; import jsprit.core.util.RandomNumberGeneration; -import jsprit.core.util.Solutions; import junit.framework.Assert; import org.junit.Test; @@ -35,7 +30,7 @@ public class JspritTest { VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build(); VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(v).addJob(s).build(); VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); - vra.setMaxIterations(10000); + vra.setMaxIterations(10); final Map counts = new HashMap(); vra.addListener(new StrategySelectedListener() { @@ -59,79 +54,6 @@ public class JspritTest { } -// @Test -// public void defaultStrategyProbabilitiesShouldWork_(){ -// Service s = Service.Builder.newInstance("s1").setLocation(Location.newInstance(1,1)).build(); -// Service s2 = Service.Builder.newInstance("s2").setLocation(Location.newInstance(1,2)).build(); -// VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0,0)).build(); -// VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(v).addJob(s2).addJob(s).build(); -// VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); -// vra.setMaxIterations(5000); -// final Map counts = new HashMap(); -// vra.addListener(new StrategySelectedListener() { -// -// @Override -// public void informSelectedStrategy(SearchStrategy.DiscoveredSolution discoveredSolution, VehicleRoutingProblem vehicleRoutingProblem, Collection vehicleRoutingProblemSolutions) { -// count(discoveredSolution.getStrategyId()); -// } -// -// private void count(String strategyId) { -// if(!counts.containsKey(strategyId)) counts.put(strategyId,1); -// Integer integer = counts.get(strategyId); -// counts.put(strategyId, integer +1); -// } -// -// }); -// vra.searchSolutions(); -// Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.RADIAL_BEST.toString())); -// Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.WORST_BEST.toString())); -// Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.CLUSTER_BEST.toString())); -// Integer randomBestCounts = counts.get(Jsprit.Strategy.RANDOM_BEST.toString()); -// Assert.assertEquals(5000.*0.5/3.5,(double) randomBestCounts,100); -// Assert.assertEquals(5000.*0.5/3.5,(double) counts.get(Jsprit.Strategy.RANDOM_REGRET.toString()),100); -// Assert.assertEquals(5000.*0.5/3.5,(double) counts.get(Jsprit.Strategy.RADIAL_REGRET.toString()),100); -// Assert.assertEquals(5000.*1./3.5,(double) counts.get(Jsprit.Strategy.WORST_REGRET.toString()),100); -// Assert.assertEquals(5000.*1./3.5,(double) counts.get(Jsprit.Strategy.CLUSTER_REGRET.toString()),100); -// -// } -// -// @Test -// public void whenChangingStratProb_itShouldBeReflected(){ -// Service s = Service.Builder.newInstance("s1").setLocation(Location.newInstance(1,1)).build(); -// Service s2 = Service.Builder.newInstance("s2").setLocation(Location.newInstance(1,2)).build(); -// VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0,0)).build(); -// VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(v).addJob(s2).addJob(s).build(); -// VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp) -// .setProperty(Jsprit.Strategy.RANDOM_BEST,"100.").buildAlgorithm(); -// vra.setMaxIterations(5000); -// final Map counts = new HashMap(); -// vra.addListener(new StrategySelectedListener() { -// -// @Override -// public void informSelectedStrategy(SearchStrategy.DiscoveredSolution discoveredSolution, VehicleRoutingProblem vehicleRoutingProblem, Collection vehicleRoutingProblemSolutions) { -// count(discoveredSolution.getStrategyId()); -// } -// -// private void count(String strategyId) { -// if(!counts.containsKey(strategyId)) counts.put(strategyId,1); -// Integer integer = counts.get(strategyId); -// counts.put(strategyId, integer +1); -// } -// -// }); -// vra.searchSolutions(); -// Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.RADIAL_BEST.toString())); -// Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.WORST_BEST.toString())); -// Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.CLUSTER_BEST.toString())); -// Integer randomBestCounts = counts.get(Jsprit.Strategy.RANDOM_BEST.toString()); -// Assert.assertEquals(5000.*100./103.,(double) randomBestCounts,100); -// Assert.assertEquals(5000.*0.5/103.,(double) counts.get(Jsprit.Strategy.RANDOM_REGRET.toString()),100); -// Assert.assertEquals(5000.*0.5/103.,(double) counts.get(Jsprit.Strategy.RADIAL_REGRET.toString()),100); -// Assert.assertEquals(5000.*1./103.,(double) counts.get(Jsprit.Strategy.WORST_REGRET.toString()),100); -// Assert.assertEquals(5000.*1./103.,(double) counts.get(Jsprit.Strategy.CLUSTER_REGRET.toString()),100); -// -// } - @Test public void whenActivatingStrat_itShouldBeReflected() { Service s = Service.Builder.newInstance("s1").setLocation(Location.newInstance(1, 1)).build(); @@ -140,7 +62,7 @@ public class JspritTest { VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(v).addJob(s2).addJob(s).build(); VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp) .setProperty(Jsprit.Strategy.RADIAL_BEST, "100.").buildAlgorithm(); - vra.setMaxIterations(5000); + vra.setMaxIterations(100); final Map counts = new HashMap(); vra.addListener(new StrategySelectedListener() { @@ -161,7 +83,7 @@ public class JspritTest { } @Test - public void test_v3() { + public void whenActivatingStrat_itShouldBeReflectedV2() { Service s = Service.Builder.newInstance("s1").setLocation(Location.newInstance(1, 1)).build(); Service s2 = Service.Builder.newInstance("s2").setLocation(Location.newInstance(1, 2)).build(); Service s3 = Service.Builder.newInstance("s3").setLocation(Location.newInstance(1, 2)).build(); @@ -169,7 +91,7 @@ public class JspritTest { VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build(); VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(s3).addVehicle(v).addJob(s2).addJob(s).build(); VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); - vra.setMaxIterations(5000); + vra.setMaxIterations(100); final Map counts = new HashMap(); vra.addListener(new StrategySelectedListener() { @@ -198,7 +120,7 @@ public class JspritTest { VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build(); VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(s4).addJob(s3).addVehicle(v).addJob(s2).addJob(s).build(); VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); - vra.setMaxIterations(5000); + vra.setMaxIterations(100); final Map counts = new HashMap(); vra.addListener(new StrategySelectedListener() { @@ -228,7 +150,7 @@ public class JspritTest { VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build(); VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(s4).addJob(s3).addVehicle(v).addJob(s2).addJob(s).build(); VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); - vra.setMaxIterations(1000); + vra.setMaxIterations(100); final List firstRecord = new ArrayList(); vra.addListener(new StrategySelectedListener() { @@ -242,7 +164,7 @@ public class JspritTest { RandomNumberGeneration.reset(); VehicleRoutingAlgorithm second = Jsprit.createAlgorithm(vrp); - second.setMaxIterations(1000); + second.setMaxIterations(100); final List secondRecord = new ArrayList(); second.addListener(new StrategySelectedListener() { @@ -254,7 +176,7 @@ public class JspritTest { }); second.searchSolutions(); - for (int i = 0; i < 1000; i++) { + for (int i = 0; i < 100; i++) { if (!firstRecord.get(i).equals(secondRecord.get(i))) { org.junit.Assert.assertFalse(true); } @@ -273,7 +195,7 @@ public class JspritTest { VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build(); VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(s4).addJob(s3).addVehicle(v).addJob(s2).addJob(s).build(); VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); - vra.setMaxIterations(1000); + vra.setMaxIterations(100); final List firstRecord = new ArrayList(); vra.addListener(new RuinListener() { @Override @@ -294,63 +216,7 @@ public class JspritTest { vra.searchSolutions(); VehicleRoutingAlgorithm second = Jsprit.createAlgorithm(vrp); - second.setMaxIterations(1000); - final List secondRecord = new ArrayList(); - second.addListener(new RuinListener() { - @Override - public void ruinStarts(Collection routes) { - - } - - @Override - public void ruinEnds(Collection routes, Collection unassignedJobs) { - - } - - @Override - public void removed(Job job, VehicleRoute fromRoute) { - secondRecord.add(job.getId()); - } - }); - second.searchSolutions(); - - Assert.assertEquals(secondRecord.size(), firstRecord.size()); - for (int i = 0; i < firstRecord.size(); i++) { - if (!firstRecord.get(i).equals(secondRecord.get(i))) { - Assert.assertFalse(true); - } - } - Assert.assertTrue(true); - } - - @Test - public void whenBiggerProblem_ruinedJobsShouldBeReproducible() { - VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); - new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml"); - VehicleRoutingProblem vrp = vrpBuilder.build(); - VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); - vra.setMaxIterations(1000); - final List firstRecord = new ArrayList(); - vra.addListener(new RuinListener() { - @Override - public void ruinStarts(Collection routes) { - - } - - @Override - public void ruinEnds(Collection routes, Collection unassignedJobs) { - - } - - @Override - public void removed(Job job, VehicleRoute fromRoute) { - firstRecord.add(job.getId()); - } - }); - vra.searchSolutions(); - - VehicleRoutingAlgorithm second = Jsprit.createAlgorithm(vrp); - second.setMaxIterations(1000); + second.setMaxIterations(100); final List secondRecord = new ArrayList(); second.addListener(new RuinListener() { @Override @@ -390,7 +256,7 @@ public class JspritTest { VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(s4).addJob(s3).addVehicle(v).addJob(s2).addJob(s).build(); VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); - vra.setMaxIterations(1000); + vra.setMaxIterations(100); final List firstRecord = new ArrayList(); vra.addListener(new JobInsertedListener() { @Override @@ -401,7 +267,7 @@ public class JspritTest { vra.searchSolutions(); VehicleRoutingAlgorithm second = Jsprit.createAlgorithm(vrp); - second.setMaxIterations(1000); + second.setMaxIterations(100); final List secondRecord = new ArrayList(); second.addListener(new JobInsertedListener() { @Override @@ -420,221 +286,5 @@ public class JspritTest { Assert.assertTrue(true); } - @Test - public void whenBiggerProblem_insertionShouldBeReproducible() { - VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); - new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml"); - VehicleRoutingProblem vrp = vrpBuilder.build(); - - VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); - vra.setMaxIterations(200); - final List firstRecord = new ArrayList(); - vra.addListener(new JobInsertedListener() { - @Override - public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) { - firstRecord.add(job2insert.getId()); - } - }); - vra.searchSolutions(); - - VehicleRoutingAlgorithm second = Jsprit.createAlgorithm(vrp); - second.setMaxIterations(200); - final List secondRecord = new ArrayList(); - second.addListener(new JobInsertedListener() { - @Override - public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) { - secondRecord.add(job2insert.getId()); - } - }); - second.searchSolutions(); - - Assert.assertEquals(secondRecord.size(), firstRecord.size()); - for (int i = 0; i < firstRecord.size(); i++) { - if (!firstRecord.get(i).equals(secondRecord.get(i))) { - Assert.assertFalse(true); - } - } - Assert.assertTrue(true); - } - - @Test - public void whenBiggerProblem_insertionPositionsShouldBeReproducible() { - - VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); - new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml"); - VehicleRoutingProblem vrp = vrpBuilder.build(); - - VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); - vra.setMaxIterations(200); - final List firstRecord = new ArrayList(); - vra.addListener(new BeforeJobInsertionListener() { - @Override - public void informBeforeJobInsertion(Job job, InsertionData data, VehicleRoute route) { - firstRecord.add(data.getDeliveryInsertionIndex()); - } - }); - Collection firstSolutions = vra.searchSolutions(); - - VehicleRoutingAlgorithm second = Jsprit.createAlgorithm(vrp); - second.setMaxIterations(200); - final List secondRecord = new ArrayList(); - second.addListener(new BeforeJobInsertionListener() { - @Override - public void informBeforeJobInsertion(Job job, InsertionData data, VehicleRoute route) { - secondRecord.add(data.getDeliveryInsertionIndex()); - } - }); - Collection secondSolutions = second.searchSolutions(); - - Assert.assertEquals(secondRecord.size(), firstRecord.size()); - for (int i = 0; i < firstRecord.size(); i++) { - if (!firstRecord.get(i).equals(secondRecord.get(i))) { - Assert.assertFalse(true); - } - } - Assert.assertTrue(true); - Assert.assertEquals(Solutions.bestOf(firstSolutions).getCost(), Solutions.bestOf(secondSolutions).getCost()); - } - - - @Test - public void whenTerminatingWithVariationCoefficient_terminationShouldBeReproducible() { - - VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); - new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml"); - VehicleRoutingProblem vrp = vrpBuilder.build(); - - VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); - vra.setMaxIterations(1000); - VariationCoefficientTermination termination = new VariationCoefficientTermination(50, 0.005); - vra.setPrematureAlgorithmTermination(termination); - vra.addListener(termination); - final List firstRecord = new ArrayList(); - vra.addListener(new BeforeJobInsertionListener() { - @Override - public void informBeforeJobInsertion(Job job, InsertionData data, VehicleRoute route) { - firstRecord.add(data.getDeliveryInsertionIndex()); - } - }); - Collection firstSolutions = vra.searchSolutions(); - - VehicleRoutingAlgorithm second = Jsprit.createAlgorithm(vrp); - VariationCoefficientTermination secondTermination = new VariationCoefficientTermination(50, 0.005); - second.setPrematureAlgorithmTermination(secondTermination); - second.addListener(secondTermination); - second.setMaxIterations(1000); - final List secondRecord = new ArrayList(); - second.addListener(new BeforeJobInsertionListener() { - @Override - public void informBeforeJobInsertion(Job job, InsertionData data, VehicleRoute route) { - secondRecord.add(data.getDeliveryInsertionIndex()); - } - }); - Collection secondSolutions = second.searchSolutions(); - - Assert.assertEquals(secondRecord.size(), firstRecord.size()); - for (int i = 0; i < firstRecord.size(); i++) { - if (!firstRecord.get(i).equals(secondRecord.get(i))) { - Assert.assertFalse(true); - } - } - Assert.assertTrue(true); - Assert.assertEquals(Solutions.bestOf(firstSolutions).getCost(), Solutions.bestOf(secondSolutions).getCost()); - } - - @Test - public void whenBiggerProblem_insertioPositionsShouldBeReproducibleWithoutResetingRNGExplicitly() { - - VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); - new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml"); - VehicleRoutingProblem vrp = vrpBuilder.build(); - - VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); - vra.setMaxIterations(200); - final List firstRecord = new ArrayList(); - vra.addListener(new BeforeJobInsertionListener() { - @Override - public void informBeforeJobInsertion(Job job, InsertionData data, VehicleRoute route) { - firstRecord.add(data.getDeliveryInsertionIndex()); - } - }); - Collection firstSolutions = vra.searchSolutions(); - - VehicleRoutingAlgorithm second = Jsprit.createAlgorithm(vrp); - second.setMaxIterations(200); - final List secondRecord = new ArrayList(); - second.addListener(new BeforeJobInsertionListener() { - @Override - public void informBeforeJobInsertion(Job job, InsertionData data, VehicleRoute route) { - secondRecord.add(data.getDeliveryInsertionIndex()); - } - }); - Collection secondSolutions = second.searchSolutions(); - - Assert.assertEquals(secondRecord.size(), firstRecord.size()); - for (int i = 0; i < firstRecord.size(); i++) { - if (!firstRecord.get(i).equals(secondRecord.get(i))) { - Assert.assertFalse(true); - } - } - Assert.assertTrue(true); - Assert.assertEquals(Solutions.bestOf(firstSolutions).getCost(), Solutions.bestOf(secondSolutions).getCost()); - } - - @Test - public void whenBiggerProblem_ruinedJobsShouldBeReproducibleWithoutResetingRNGExplicitly() { - VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); - new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml"); - VehicleRoutingProblem vrp = vrpBuilder.build(); - VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); - vra.setMaxIterations(200); - final List firstRecord = new ArrayList(); - vra.addListener(new RuinListener() { - @Override - public void ruinStarts(Collection routes) { - - } - - @Override - public void ruinEnds(Collection routes, Collection unassignedJobs) { - - } - - @Override - public void removed(Job job, VehicleRoute fromRoute) { - firstRecord.add(job.getId()); - } - }); - vra.searchSolutions(); - - VehicleRoutingAlgorithm second = Jsprit.createAlgorithm(vrp); - second.setMaxIterations(200); - final List secondRecord = new ArrayList(); - second.addListener(new RuinListener() { - @Override - public void ruinStarts(Collection routes) { - - } - - @Override - public void ruinEnds(Collection routes, Collection unassignedJobs) { - - } - - @Override - public void removed(Job job, VehicleRoute fromRoute) { - secondRecord.add(job.getId()); - } - }); - second.searchSolutions(); - - Assert.assertEquals(secondRecord.size(), firstRecord.size()); - for (int i = 0; i < firstRecord.size(); i++) { - if (!firstRecord.get(i).equals(secondRecord.get(i))) { - Assert.assertFalse(true); - } - } - Assert.assertTrue(true); - } } diff --git a/jsprit-core/src/test/resources/finiteVrpWithInitialSolutionForWriterTest.xml b/jsprit-core/src/test/resources/finiteVrpWithInitialSolutionForWriterTest.xml index 9c77fd3c..ef4c344b 100644 --- a/jsprit-core/src/test/resources/finiteVrpWithInitialSolutionForWriterTest.xml +++ b/jsprit-core/src/test/resources/finiteVrpWithInitialSolutionForWriterTest.xml @@ -1,256 +1,255 @@ - - FINITE - - - - v3 - vehType2 - - startLoc - - - - endLoc - - - - 0.0 - 1000.0 - - true - - - v2 - vehType2 - - depotLoc - - - - depotLoc - - - - 0.0 - 1000.0 - - false - - - v4 - vehType2 - - startLoc - - - - endLoc - - - - 0.0 - 1000.0 - - true - - - v5 - vehType3 - - startLoc - - - - endLoc - - - - 0.0 - 1000.0 - - true - - - v1 - vehType - - depotLoc2 - - - - depotLoc2 - - - - 0.0 - 1000.0 - - true - - - - - vehType - - 20 - - - 0.0 - 0.0 - - - - - vehType2 - - 200 - - - 0.0 - 0.0 - - - - - vehType3 - - 100 - 1000 - 10000 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 100000 - - - 0.0 - 0.0 - - - - - - - - j(1,5) - - - - 1 - - 10.0 - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd"> + + FINITE + + + + v3 + vehType2 + + startLoc + + + + endLoc + + + 0.0 - 4000.0 - - - - - - i(3,9) - - - - 1 - - 0.0 - - + 1000.0 + + true + + + v2 + vehType2 + + depotLoc + + + + depotLoc + + + 0.0 - 4000.0 - - - - - - - - + 1000.0 + + false + + + v4 + vehType2 + + startLoc + + + + endLoc + + + + 0.0 + 1000.0 + + true + + + v5 + vehType3 + + startLoc + + + + endLoc + + + + 0.0 + 1000.0 + + true + + + v1 + vehType + + depotLoc2 + + + + depotLoc2 + + + + 0.0 + 1000.0 + + true + + + + + vehType + + 20 + + + 0.0 + 0.0 + + + + + vehType2 + + 200 + + + 0.0 + 0.0 + + + + + vehType3 + + 100 + 1000 + 10000 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 100000 + + + 0.0 + 0.0 + + + + + + + + j(1,5) + + + + 1 + + 10.0 + + + 0.0 + 4000.0 + + + + + i(3,9) - - 10.0 - + + + 1 + + 0.0 + - 1000.0 - 4000.0 + 0.0 + 4000.0 - - - - - i(9,9) - - - 100.0 - - - 6000.0 - 10000.0 - - - - - 10 - - - - - - [x=10.0][y=10.0] - - - 0.0 - - - 1000.0 - 4000.0 - - - - - - [x=10.0][y=0.0] - - - 100.0 - - - 6000.0 - 10000.0 - - - - - 10 - - - - - - noDriver - v1 - 10.0 - - 4 - 0.0 - 0.0 - - - 4 - 0.0 - 0.0 - - 0.0 - - + + + + + + + + i(3,9) + + + 10.0 + + + 1000.0 + 4000.0 + + + + + + i(9,9) + + + 100.0 + + + 6000.0 + 10000.0 + + + + + 10 + + + + + + [x=10.0][y=10.0] + + + 0.0 + + + 1000.0 + 4000.0 + + + + + + [x=10.0][y=0.0] + + + 100.0 + + + 6000.0 + 10000.0 + + + + + 10 + + + + + + noDriver + v1 + 10.0 + + 4 + 0.0 + 0.0 + + + 4 + 0.0 + 0.0 + + 0.0 + + diff --git a/jsprit-core/src/test/resources/infiniteWriterV2Test.xml b/jsprit-core/src/test/resources/infiniteWriterV2Test.xml index 617218e2..2d9058ab 100644 --- a/jsprit-core/src/test/resources/infiniteWriterV2Test.xml +++ b/jsprit-core/src/test/resources/infiniteWriterV2Test.xml @@ -1,91 +1,90 @@ - - INFINITE - - - - v1 - vehType - - loc - - - loc - - - 0.0 - 1.7976931348623157E308 - - true - - - - - vehType - - 20 - - - 0.0 - 1.0 - - - - - - - - loc - - - 1 - - 2.0 - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd"> + + INFINITE + + + + v1 + vehType + + loc + + + loc + + 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 - - - - - - - + + true + + + + + vehType + + 20 + + + 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-instances/pom.xml b/jsprit-instances/pom.xml index d221bccf..8e4555bc 100644 --- a/jsprit-instances/pom.xml +++ b/jsprit-instances/pom.xml @@ -43,6 +43,8 @@ + + ${project.groupId} diff --git a/pom.xml b/pom.xml index 27786574..ab9124ab 100644 --- a/pom.xml +++ b/pom.xml @@ -136,30 +136,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - + maven-enforcer-plugin 1.1.1