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

modified Pickup and Delivery to deal with multiple cap-dims

This commit is contained in:
oblonski 2014-02-17 22:34:23 +01:00
parent 8946e130c8
commit fe4b4ae4ca
6 changed files with 117 additions and 2 deletions

View file

@ -20,6 +20,7 @@ import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
import jsprit.core.problem.driver.Driver;
import jsprit.core.problem.driver.DriverImpl;
import jsprit.core.problem.job.Pickup;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.job.Shipment;
import jsprit.core.problem.misc.JobInsertionContext;
import jsprit.core.problem.solution.route.VehicleRoute;
@ -240,8 +241,10 @@ public class ShipmentInsertionCalculatorTest {
ServiceInsertionCalculator serviceInsertionCalc = new ServiceInsertionCalculator(routingCosts, activityInsertionCostsCalculator, constraintManager);
ShipmentInsertionCalculator insertionCalculator = new ShipmentInsertionCalculator(routingCosts, activityInsertionCostsCalculator, constraintManager);
switcher.put(Pickup.class, serviceInsertionCalc);
switcher.put(Service.class, serviceInsertionCalc);
switcher.put(Shipment.class, insertionCalculator);
// Service service = Service.Builder.newInstance("pick", 1).setLocationId("5,5").build();
Pickup service = (Pickup)Pickup.Builder.newInstance("pick", 1).setLocationId("5,5").build();
InsertionData iData = switcher.getInsertionData(route, service, vehicle, 0, DriverImpl.noDriver(), Double.MAX_VALUE);
// routeActVisitor.visit(route);

View file

@ -1,5 +1,7 @@
package jsprit.core.problem.job;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class DeliveryTest {
@ -8,5 +10,35 @@ public class DeliveryTest {
public void whenNeitherLocationIdNorCoordIsSet_itThrowsException(){
Delivery.Builder.newInstance("p", 0).build();
}
@Test
public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
Delivery one = (Delivery)Delivery.Builder.newInstance("s").setLocationId("foofoo")
.addCapacityDimension(0,2)
.addCapacityDimension(1,4)
.build();
assertEquals(2,one.getCapacity().getNuOfDimensions());
assertEquals(2,one.getCapacity().get(0));
assertEquals(4,one.getCapacity().get(1));
}
@Test
public void whenPickupIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero(){
Delivery one = (Delivery)Delivery.Builder.newInstance("s").setLocationId("foofoo")
.build();
assertEquals(1,one.getCapacity().getNuOfDimensions());
assertEquals(0,one.getCapacity().get(0));
}
@Test
public void whenPickupIsBuiltWithConstructorWhereSizeIsSpecified_capacityShouldBeSetCorrectly(){
Delivery one = (Delivery)Delivery.Builder.newInstance("s",1).setLocationId("foofoo")
.build();
assertEquals(1,one.getCapacityDemand());
assertEquals(1,one.getCapacity().getNuOfDimensions());
assertEquals(1,one.getCapacity().get(0));
}
}

View file

@ -1,5 +1,7 @@
package jsprit.core.problem.job;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class PickupTest {
@ -8,5 +10,35 @@ public class PickupTest {
public void whenNeitherLocationIdNorCoordIsSet_itThrowsException(){
Pickup.Builder.newInstance("p", 0).build();
}
@Test
public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
Pickup one = (Pickup)Pickup.Builder.newInstance("s").setLocationId("foofoo")
.addCapacityDimension(0,2)
.addCapacityDimension(1,4)
.build();
assertEquals(2,one.getCapacity().getNuOfDimensions());
assertEquals(2,one.getCapacity().get(0));
assertEquals(4,one.getCapacity().get(1));
}
@Test
public void whenPickupIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero(){
Pickup one = (Pickup)Pickup.Builder.newInstance("s").setLocationId("foofoo")
.build();
assertEquals(1,one.getCapacity().getNuOfDimensions());
assertEquals(0,one.getCapacity().get(0));
}
@Test
public void whenPickupIsBuiltWithConstructorWhereSizeIsSpecified_capacityShouldBeSetCorrectly(){
Pickup one = (Pickup)Pickup.Builder.newInstance("s",1).setLocationId("foofoo")
.build();
assertEquals(1,one.getCapacityDemand());
assertEquals(1,one.getCapacity().getNuOfDimensions());
assertEquals(1,one.getCapacity().get(0));
}
}