mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
added test-cases to reproduce bug #105
This commit is contained in:
parent
a739ab77d0
commit
21cd56a777
1 changed files with 90 additions and 0 deletions
|
|
@ -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;
|
||||||
|
|
@ -20,6 +21,31 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class OpenRoutesTest {
|
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
|
@Test
|
||||||
public void whenDealingWithOpenRoute_insertionShouldNotRequireRouteToBeClosed(){
|
public void whenDealingWithOpenRoute_insertionShouldNotRequireRouteToBeClosed(){
|
||||||
VehicleType type = VehicleTypeImpl.Builder.newInstance("type").build();
|
VehicleType type = VehicleTypeImpl.Builder.newInstance("type").build();
|
||||||
|
|
@ -43,6 +69,70 @@ public class OpenRoutesTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@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
|
||||||
|
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();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue