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

Merge pull request #24 from bringg/remove-fixed-cost-back

Remove fixed cost back
This commit is contained in:
kobyb 2018-01-29 13:11:05 +02:00 committed by GitHub
commit 8d4de24ff7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -124,6 +124,11 @@ final class VehicleTypeDependentJobInsertionCalculator implements JobInsertionCo
bestKnownCost_ = iData.getInsertionCost();
}
}
if (bestIData.getSelectedVehicle() != null) {
bestIData.setInsertionCost(bestIData.getInsertionCost() - bestIData.getSelectedVehicle().getType().getVehicleCostParams().fix);
}
return bestIData;
}

View file

@ -31,6 +31,7 @@ import java.util.Collections;
import java.util.Random;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ -111,13 +112,16 @@ public class CalcVehicleTypeDependentServiceInsertionTest {
JobInsertionCostsCalculator calc = mock(JobInsertionCostsCalculator.class);
InsertionData iDataVeh1 = new InsertionData(insertionCost1, InsertionData.NO_INDEX, 1, veh1, null);
InsertionData iDataVeh2 = new InsertionData(insertionCost2, InsertionData.NO_INDEX, 1, veh2, null);
InsertionData iDataVeh1PlusFixed = new InsertionData(insertionCost1 + fixed1, InsertionData.NO_INDEX, 1, veh1, null);
when(calc.getInsertionData(vehicleRoute, service, veh1, veh1.getEarliestDeparture(), null, Double.MAX_VALUE)).thenReturn(iDataVeh1);
when(calc.getInsertionData(vehicleRoute, service, veh2, veh2.getEarliestDeparture(), null, Double.MAX_VALUE)).thenReturn(iDataVeh2);
when(calc.getInsertionData(vehicleRoute, service, veh2, veh2.getEarliestDeparture(), null, insertionCost1 + fixed1)).thenReturn(iDataVeh1);
when(calc.getInsertionData(vehicleRoute, service, veh2, veh2.getEarliestDeparture(), null, iDataVeh1PlusFixed.getInsertionCost())).thenReturn(iDataVeh1PlusFixed);
VehicleRoutingProblem vrp = mock(VehicleRoutingProblem.class);
when(vrp.getInitialVehicleRoutes()).thenReturn(Collections.<VehicleRoute>emptyList());
VehicleTypeDependentJobInsertionCalculator insertion = new VehicleTypeDependentJobInsertionCalculator(vrp, fleetManager, calc);
InsertionData iData = insertion.getInsertionData(vehicleRoute, service, null, 0.0, null, Double.MAX_VALUE);
assertEquals(iData.getInsertionCost(), insertionCost1, 0.001);
assertThat(iData.getSelectedVehicle(), is(veh1));
}