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

separate long running tests - fix #178

This commit is contained in:
oblonski 2015-09-17 16:04:56 +02:00
parent 01bf0d55af
commit 2ce279d5a5
23 changed files with 440 additions and 912 deletions

View file

@ -55,8 +55,37 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<excludedGroups>jsprit.core.IntegrationTest</excludedGroups>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<groups>jsprit.core.IntegrationTest</groups>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>

View file

@ -0,0 +1,7 @@
package jsprit.core;
/**
* Created by schroeder on 17/09/15.
*/
public interface IntegrationTest {
}

View file

@ -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<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
System.out.println("costs=" + Solutions.bestOf(solutions).getCost() + ";#routes=" + Solutions.bestOf(solutions).getRoutes().size());

View file

@ -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<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();

View file

@ -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");

View file

@ -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");

View file

@ -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");

View file

@ -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");

View file

@ -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");

View file

@ -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<Boolean> testFailed = new ArrayList<Boolean>();
for (int i = 0; i < 10; i++) {

View file

@ -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<VehicleRoutingProblemSolution> 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<VehicleRoutingProblemSolution> 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<VehicleRoutingProblemSolution> 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<VehicleRoutingProblemSolution> 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();
}
}

View file

@ -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");

View file

@ -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() {

View file

@ -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() {

View file

@ -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() {
/*

View file

@ -15,11 +15,11 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
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");

View file

@ -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");

View file

@ -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();

View file

@ -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<String, Integer> counts = new HashMap<String, Integer>();
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<String,Integer> counts = new HashMap<String,Integer>();
// vra.addListener(new StrategySelectedListener() {
//
// @Override
// public void informSelectedStrategy(SearchStrategy.DiscoveredSolution discoveredSolution, VehicleRoutingProblem vehicleRoutingProblem, Collection<VehicleRoutingProblemSolution> 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<String,Integer> counts = new HashMap<String,Integer>();
// vra.addListener(new StrategySelectedListener() {
//
// @Override
// public void informSelectedStrategy(SearchStrategy.DiscoveredSolution discoveredSolution, VehicleRoutingProblem vehicleRoutingProblem, Collection<VehicleRoutingProblemSolution> 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<String, Integer> counts = new HashMap<String, Integer>();
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<String, Integer> counts = new HashMap<String, Integer>();
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<String, Integer> counts = new HashMap<String, Integer>();
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<String> firstRecord = new ArrayList<String>();
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<String> secondRecord = new ArrayList<String>();
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<String> firstRecord = new ArrayList<String>();
vra.addListener(new RuinListener() {
@Override
@ -294,63 +216,7 @@ public class JspritTest {
vra.searchSolutions();
VehicleRoutingAlgorithm second = Jsprit.createAlgorithm(vrp);
second.setMaxIterations(1000);
final List<String> secondRecord = new ArrayList<String>();
second.addListener(new RuinListener() {
@Override
public void ruinStarts(Collection<VehicleRoute> routes) {
}
@Override
public void ruinEnds(Collection<VehicleRoute> routes, Collection<Job> 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<String> firstRecord = new ArrayList<String>();
vra.addListener(new RuinListener() {
@Override
public void ruinStarts(Collection<VehicleRoute> routes) {
}
@Override
public void ruinEnds(Collection<VehicleRoute> routes, Collection<Job> 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<String> secondRecord = new ArrayList<String>();
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<String> firstRecord = new ArrayList<String>();
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<String> secondRecord = new ArrayList<String>();
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<String> firstRecord = new ArrayList<String>();
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<String> secondRecord = new ArrayList<String>();
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<Integer> firstRecord = new ArrayList<Integer>();
vra.addListener(new BeforeJobInsertionListener() {
@Override
public void informBeforeJobInsertion(Job job, InsertionData data, VehicleRoute route) {
firstRecord.add(data.getDeliveryInsertionIndex());
}
});
Collection<VehicleRoutingProblemSolution> firstSolutions = vra.searchSolutions();
VehicleRoutingAlgorithm second = Jsprit.createAlgorithm(vrp);
second.setMaxIterations(200);
final List<Integer> secondRecord = new ArrayList<Integer>();
second.addListener(new BeforeJobInsertionListener() {
@Override
public void informBeforeJobInsertion(Job job, InsertionData data, VehicleRoute route) {
secondRecord.add(data.getDeliveryInsertionIndex());
}
});
Collection<VehicleRoutingProblemSolution> 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<Integer> firstRecord = new ArrayList<Integer>();
vra.addListener(new BeforeJobInsertionListener() {
@Override
public void informBeforeJobInsertion(Job job, InsertionData data, VehicleRoute route) {
firstRecord.add(data.getDeliveryInsertionIndex());
}
});
Collection<VehicleRoutingProblemSolution> 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<Integer> secondRecord = new ArrayList<Integer>();
second.addListener(new BeforeJobInsertionListener() {
@Override
public void informBeforeJobInsertion(Job job, InsertionData data, VehicleRoute route) {
secondRecord.add(data.getDeliveryInsertionIndex());
}
});
Collection<VehicleRoutingProblemSolution> 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<Integer> firstRecord = new ArrayList<Integer>();
vra.addListener(new BeforeJobInsertionListener() {
@Override
public void informBeforeJobInsertion(Job job, InsertionData data, VehicleRoute route) {
firstRecord.add(data.getDeliveryInsertionIndex());
}
});
Collection<VehicleRoutingProblemSolution> firstSolutions = vra.searchSolutions();
VehicleRoutingAlgorithm second = Jsprit.createAlgorithm(vrp);
second.setMaxIterations(200);
final List<Integer> secondRecord = new ArrayList<Integer>();
second.addListener(new BeforeJobInsertionListener() {
@Override
public void informBeforeJobInsertion(Job job, InsertionData data, VehicleRoute route) {
secondRecord.add(data.getDeliveryInsertionIndex());
}
});
Collection<VehicleRoutingProblemSolution> 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<String> firstRecord = new ArrayList<String>();
vra.addListener(new RuinListener() {
@Override
public void ruinStarts(Collection<VehicleRoute> routes) {
}
@Override
public void ruinEnds(Collection<VehicleRoute> routes, Collection<Job> 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<String> secondRecord = new ArrayList<String>();
second.addListener(new RuinListener() {
@Override
public void ruinStarts(Collection<VehicleRoute> routes) {
}
@Override
public void ruinEnds(Collection<VehicleRoute> routes, Collection<Job> 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);
}
}

View file

@ -1,256 +1,255 @@
<?xml version="1.0" encoding="UTF-8"?>
<problem xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
<problemType>
<fleetSize>FINITE</fleetSize>
</problemType>
<vehicles>
<vehicle>
<id>v3</id>
<typeId>vehType2</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v2</id>
<typeId>vehType2</typeId>
<startLocation>
<id>depotLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>depotLoc</id>
<coord x="10.0" y="100.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>false</returnToDepot>
</vehicle>
<vehicle>
<id>v4</id>
<typeId>vehType2</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v5</id>
<typeId>vehType3</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v1</id>
<typeId>vehType</typeId>
<startLocation>
<id>depotLoc2</id>
<coord x="100.0" y="100.0"/>
</startLocation>
<endLocation>
<id>depotLoc2</id>
<coord x="100.0" y="100.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
</vehicles>
<vehicleTypes>
<type>
<id>vehType</id>
<capacity-dimensions>
<dimension index="0">20</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
</costs>
</type>
<type>
<id>vehType2</id>
<capacity-dimensions>
<dimension index="0">200</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
</costs>
</type>
<type>
<id>vehType3</id>
<capacity-dimensions>
<dimension index="0">100</dimension>
<dimension index="1">1000</dimension>
<dimension index="2">10000</dimension>
<dimension index="3">0</dimension>
<dimension index="4">0</dimension>
<dimension index="5">0</dimension>
<dimension index="6">0</dimension>
<dimension index="7">0</dimension>
<dimension index="8">0</dimension>
<dimension index="9">0</dimension>
<dimension index="10">100000</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
</costs>
</type>
</vehicleTypes>
<services>
<service id="1" type="service">
<location>
<id>j(1,5)</id>
<coord x="10.0" y="10.0"/>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>10.0</duration>
<timeWindows>
<timeWindow>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
<problemType>
<fleetSize>FINITE</fleetSize>
</problemType>
<vehicles>
<vehicle>
<id>v3</id>
<typeId>vehType2</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</service>
<service id="2" type="service">
<location>
<id>i(3,9)</id>
<coord x="10.0" y="10.0"/>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>0.0</duration>
<timeWindows>
<timeWindow>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v2</id>
<typeId>vehType2</typeId>
<startLocation>
<id>depotLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>depotLoc</id>
<coord x="10.0" y="100.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</service>
</services>
<shipments>
<shipment id="3">
<pickup>
<location>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>false</returnToDepot>
</vehicle>
<vehicle>
<id>v4</id>
<typeId>vehType2</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v5</id>
<typeId>vehType3</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v1</id>
<typeId>vehType</typeId>
<startLocation>
<id>depotLoc2</id>
<coord x="100.0" y="100.0"/>
</startLocation>
<endLocation>
<id>depotLoc2</id>
<coord x="100.0" y="100.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
</vehicles>
<vehicleTypes>
<type>
<id>vehType</id>
<capacity-dimensions>
<dimension index="0">20</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
</costs>
</type>
<type>
<id>vehType2</id>
<capacity-dimensions>
<dimension index="0">200</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
</costs>
</type>
<type>
<id>vehType3</id>
<capacity-dimensions>
<dimension index="0">100</dimension>
<dimension index="1">1000</dimension>
<dimension index="2">10000</dimension>
<dimension index="3">0</dimension>
<dimension index="4">0</dimension>
<dimension index="5">0</dimension>
<dimension index="6">0</dimension>
<dimension index="7">0</dimension>
<dimension index="8">0</dimension>
<dimension index="9">0</dimension>
<dimension index="10">100000</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
</costs>
</type>
</vehicleTypes>
<services>
<service id="1" type="service">
<location>
<id>j(1,5)</id>
<coord x="10.0" y="10.0"/>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>10.0</duration>
<timeWindows>
<timeWindow>
<start>0.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</service>
<service id="2" type="service">
<location>
<id>i(3,9)</id>
<coord x="10.0" y="10.0"/>
</location>
<duration>10.0</duration>
<timeWindows>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>0.0</duration>
<timeWindows>
<timeWindow>
<start>1000.0</start>
<end>4000.0</end>
<start>0.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</pickup>
<delivery>
<location>
<id>i(9,9)</id>
<coord x="10.0" y="0.0"/>
</location>
<duration>100.0</duration>
<timeWindows>
<timeWindow>
<start>6000.0</start>
<end>10000.0</end>
</timeWindow>
</timeWindows>
</delivery>
<capacity-dimensions>
<dimension index="0">10</dimension>
</capacity-dimensions>
</shipment>
<shipment id="4">
<pickup>
<location>
<id>[x=10.0][y=10.0]</id>
<coord x="10.0" y="10.0"/>
</location>
<duration>0.0</duration>
<timeWindows>
<timeWindow>
<start>1000.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</pickup>
<delivery>
<location>
<id>[x=10.0][y=0.0]</id>
<coord x="10.0" y="0.0"/>
</location>
<duration>100.0</duration>
<timeWindows>
<timeWindow>
<start>6000.0</start>
<end>10000.0</end>
</timeWindow>
</timeWindows>
</delivery>
<capacity-dimensions>
<dimension index="0">10</dimension>
</capacity-dimensions>
</shipment>
</shipments>
<initialRoutes>
<route>
<driverId>noDriver</driverId>
<vehicleId>v1</vehicleId>
<start>10.0</start>
<act type="pickupShipment">
<shipmentId>4</shipmentId>
<arrTime>0.0</arrTime>
<endTime>0.0</endTime>
</act>
<act type="deliverShipment">
<shipmentId>4</shipmentId>
<arrTime>0.0</arrTime>
<endTime>0.0</endTime>
</act>
<end>0.0</end>
</route>
</initialRoutes>
</timeWindows>
</service>
</services>
<shipments>
<shipment id="3">
<pickup>
<location>
<id>i(3,9)</id>
<coord x="10.0" y="10.0"/>
</location>
<duration>10.0</duration>
<timeWindows>
<timeWindow>
<start>1000.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</pickup>
<delivery>
<location>
<id>i(9,9)</id>
<coord x="10.0" y="0.0"/>
</location>
<duration>100.0</duration>
<timeWindows>
<timeWindow>
<start>6000.0</start>
<end>10000.0</end>
</timeWindow>
</timeWindows>
</delivery>
<capacity-dimensions>
<dimension index="0">10</dimension>
</capacity-dimensions>
</shipment>
<shipment id="4">
<pickup>
<location>
<id>[x=10.0][y=10.0]</id>
<coord x="10.0" y="10.0"/>
</location>
<duration>0.0</duration>
<timeWindows>
<timeWindow>
<start>1000.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</pickup>
<delivery>
<location>
<id>[x=10.0][y=0.0]</id>
<coord x="10.0" y="0.0"/>
</location>
<duration>100.0</duration>
<timeWindows>
<timeWindow>
<start>6000.0</start>
<end>10000.0</end>
</timeWindow>
</timeWindows>
</delivery>
<capacity-dimensions>
<dimension index="0">10</dimension>
</capacity-dimensions>
</shipment>
</shipments>
<initialRoutes>
<route>
<driverId>noDriver</driverId>
<vehicleId>v1</vehicleId>
<start>10.0</start>
<act type="pickupShipment">
<shipmentId>4</shipmentId>
<arrTime>0.0</arrTime>
<endTime>0.0</endTime>
</act>
<act type="deliverShipment">
<shipmentId>4</shipmentId>
<arrTime>0.0</arrTime>
<endTime>0.0</endTime>
</act>
<end>0.0</end>
</route>
</initialRoutes>
</problem>

View file

@ -1,91 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<problem xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
<problemType>
<fleetSize>INFINITE</fleetSize>
</problemType>
<vehicles>
<vehicle>
<id>v1</id>
<typeId>vehType</typeId>
<startLocation>
<id>loc</id>
</startLocation>
<endLocation>
<id>loc</id>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1.7976931348623157E308</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
</vehicles>
<vehicleTypes>
<type>
<id>vehType</id>
<capacity-dimensions>
<dimension index="0">20</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>1.0</distance>
<time>0.0</time>
</costs>
</type>
</vehicleTypes>
<services>
<service id="1" type="service">
<location>
<id>loc</id>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>2.0</duration>
<timeWindows>
<timeWindow>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
<problemType>
<fleetSize>INFINITE</fleetSize>
</problemType>
<vehicles>
<vehicle>
<id>v1</id>
<typeId>vehType</typeId>
<startLocation>
<id>loc</id>
</startLocation>
<endLocation>
<id>loc</id>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1.7976931348623157E308</end>
</timeWindow>
</timeWindows>
</service>
<service id="2" type="service">
<location>
<id>loc2</id>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>4.0</duration>
<timeWindows>
<timeWindow>
<start>0.0</start>
<end>1.7976931348623157E308</end>
</timeWindow>
</timeWindows>
</service>
</services>
<solutions>
<solution>
<cost>10.0</cost>
<routes>
<route>
<driverId>noDriver</driverId>
<vehicleId>v1</vehicleId>
<start>0.0</start>
<act type="service">
<serviceId>1</serviceId>
<arrTime>0.0</arrTime>
<endTime>0.0</endTime>
</act>
<end>0.0</end>
</route>
</routes>
<unassignedJobs>
<job id="2"/>
</unassignedJobs>
</solution>
</solutions>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
</vehicles>
<vehicleTypes>
<type>
<id>vehType</id>
<capacity-dimensions>
<dimension index="0">20</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>1.0</distance>
<time>0.0</time>
</costs>
</type>
</vehicleTypes>
<services>
<service id="1" type="service">
<location>
<id>loc</id>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>2.0</duration>
<timeWindows>
<timeWindow>
<start>0.0</start>
<end>1.7976931348623157E308</end>
</timeWindow>
</timeWindows>
</service>
<service id="2" type="service">
<location>
<id>loc2</id>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>4.0</duration>
<timeWindows>
<timeWindow>
<start>0.0</start>
<end>1.7976931348623157E308</end>
</timeWindow>
</timeWindows>
</service>
</services>
<solutions>
<solution>
<cost>10.0</cost>
<routes>
<route>
<driverId>noDriver</driverId>
<vehicleId>v1</vehicleId>
<start>0.0</start>
<act type="service">
<serviceId>1</serviceId>
<arrTime>0.0</arrTime>
<endTime>0.0</endTime>
</act>
<end>0.0</end>
</route>
</routes>
<unassignedJobs>
<job id="2"/>
</unassignedJobs>
</solution>
</solutions>
</problem>

View file

@ -43,6 +43,8 @@
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>

25
pom.xml
View file

@ -136,30 +136,7 @@
</plugins>
</pluginManagement>
<plugins>
<!-- <plugin> -->
<!-- <groupId>org.eclipse.m2e</groupId> -->
<!-- <artifactId>lifecycle-mapping</artifactId> -->
<!-- <version>1.0.0</version> -->
<!-- <configuration> -->
<!-- <lifecycleMappingMetadata> -->
<!-- <pluginExecutions> -->
<!-- <pluginExecution> -->
<!-- <pluginExecutionFilter> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-enforcer-plugin</artifactId> -->
<!-- <versionRange>[1.0.0,)</versionRange> -->
<!-- <goals> -->
<!-- <goal>enforce</goal> -->
<!-- </goals> -->
<!-- </pluginExecutionFilter> -->
<!-- <action> -->
<!-- <ignore /> -->
<!-- </action> -->
<!-- </pluginExecution> -->
<!-- </pluginExecutions> -->
<!-- </lifecycleMappingMetadata> -->
<!-- </configuration> -->
<!-- </plugin> -->
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.1.1</version>