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

added test-cases to reproduce bug #104

This commit is contained in:
oblonski 2014-06-11 10:40:52 +02:00
parent a739ab77d0
commit e6d7c4322f

View file

@ -8,6 +8,7 @@ import jsprit.core.algorithm.box.SchrimpfFactory;
import jsprit.core.algorithm.recreate.NoSolutionFoundException; import jsprit.core.algorithm.recreate.NoSolutionFoundException;
import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.job.Service; import jsprit.core.problem.job.Service;
import jsprit.core.problem.job.Shipment;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.core.problem.vehicle.Vehicle; import jsprit.core.problem.vehicle.Vehicle;
import jsprit.core.problem.vehicle.VehicleImpl; import jsprit.core.problem.vehicle.VehicleImpl;
@ -43,6 +44,49 @@ public class OpenRoutesTest {
} }
@Test
public void whenDealingWithOpenRouteAndShipments_insertionShouldNotRequireRouteToBeClosed(){
VehicleType type = VehicleTypeImpl.Builder.newInstance("type").build();
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLatestArrival(11.)
.setType(type).setReturnToDepot(false).setStartLocationCoordinate(Coordinate.newInstance(0, 0)).build();
Shipment shipment = Shipment.Builder.newInstance("s").setPickupCoord(Coordinate.newInstance(5, 0))
.setDeliveryCoord(Coordinate.newInstance(10, 0)).build();
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(shipment).addVehicle(vehicle).build();
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
try{
@SuppressWarnings("unused")
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertTrue(true);
}
catch(NoSolutionFoundException e){
assertFalse(true);
}
}
@Test
public void whenDealingWithOpenRouteAndShipments_algorithmShouldCalculateCorrectCosts(){
VehicleType type = VehicleTypeImpl.Builder.newInstance("type").build();
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLatestArrival(20.)
.setType(type).setReturnToDepot(false).setStartLocationCoordinate(Coordinate.newInstance(0, 0)).build();
Shipment shipment = Shipment.Builder.newInstance("s").setPickupCoord(Coordinate.newInstance(5, 0))
.setDeliveryCoord(Coordinate.newInstance(10, 0)).build();
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(shipment).addVehicle(vehicle).build();
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(10.,Solutions.bestOf(solutions).getCost(),0.01);
}
@Test @Test
public void whenDealingWithOpenRoute_algorithmShouldCalculateCorrectCosts(){ public void whenDealingWithOpenRoute_algorithmShouldCalculateCorrectCosts(){
VehicleType type = VehicleTypeImpl.Builder.newInstance("type").build(); VehicleType type = VehicleTypeImpl.Builder.newInstance("type").build();