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

add .addPenaltyVehicle(penaltyFactor,absFixedPenalty) to assign an abs.

value for penaltyVehicle's fixed costs and test it
This commit is contained in:
oblonski 2014-01-14 17:58:00 -05:00
parent c809d4b7c9
commit cc93458c6a
2 changed files with 53 additions and 2 deletions

View file

@ -391,6 +391,32 @@ public class VehicleRoutingProblemTest {
}
@Test
public void whenSettingAddPenaltyVehicleOptionsWithAbsoluteFixedCostsAndTwoVehiclesWithSameLocationAndType_onePenaltyVehicleIsAddedWithTheCorrectPenaltyFixedCosts(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleType type = VehicleTypeImpl.Builder.newInstance("type", 0).build();
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(type).build();
Vehicle vehicle2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type).build();
builder.addVehicle(vehicle);
builder.addVehicle(vehicle2);
builder.setFleetSize(FleetSize.FINITE);
builder.addPenaltyVehicles(3.0,10000);
VehicleRoutingProblem vrp = builder.build();
assertEquals(3,vrp.getVehicles().size());
double fix = 0.0;
for(Vehicle v : vrp.getVehicles()){
if(v.getId().equals("penaltyVehicle_loc_type")) {
fix = v.getType().getVehicleCostParams().fix;
}
}
assertEquals(10000,fix,0.01);
}
@Test
public void whenSettingAddPenaltyVehicleOptionsAndTwoVehiclesWithDiffLocationAndType_twoPenaltyVehicleIsAdded(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();