mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
This reverts commit 550e633d0b.
This commit is contained in:
parent
550e633d0b
commit
d1948fb255
2 changed files with 9 additions and 7 deletions
|
|
@ -101,9 +101,7 @@ final class VehicleTypeDependentJobInsertionCalculator implements JobInsertionCo
|
|||
InsertionData bestIData = new InsertionData.NoInsertionFound();
|
||||
double bestKnownCost_ = bestKnownCost;
|
||||
Collection<Vehicle> relevantVehicles = new ArrayList<Vehicle>();
|
||||
double currentVehicleFixedCost = .0;
|
||||
if (!(selectedVehicle instanceof VehicleImpl.NoVehicle)) {
|
||||
currentVehicleFixedCost = selectedVehicle.getType().getVehicleCostParams().fix;
|
||||
relevantVehicles.add(selectedVehicle);
|
||||
if (vehicleSwitchAllowed && !isVehicleWithInitialRoute(selectedVehicle)) {
|
||||
relevantVehicles.addAll(fleetManager.getAvailableVehicles(selectedVehicle));
|
||||
|
|
@ -120,13 +118,17 @@ final class VehicleTypeDependentJobInsertionCalculator implements JobInsertionCo
|
|||
bestIData.getFailedConstraintNames().addAll(iData.getFailedConstraintNames());
|
||||
continue;
|
||||
}
|
||||
|
||||
double additionalFixedCost = v.getType().getVehicleCostParams().fix - currentVehicleFixedCost;
|
||||
if (iData.getInsertionCost() + additionalFixedCost < bestKnownCost_) {
|
||||
iData.setInsertionCost(iData.getInsertionCost() + v.getType().getVehicleCostParams().fix);
|
||||
if (iData.getInsertionCost() < bestKnownCost_) {
|
||||
bestIData = iData;
|
||||
bestKnownCost_ = iData.getInsertionCost();
|
||||
}
|
||||
}
|
||||
|
||||
if (bestIData.getSelectedVehicle() != null) {
|
||||
bestIData.setInsertionCost(bestIData.getInsertionCost() - bestIData.getSelectedVehicle().getType().getVehicleCostParams().fix);
|
||||
}
|
||||
|
||||
return bestIData;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,10 +112,10 @@ 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 iDataVeh1WithoutFixed = new InsertionData(insertionCost1, InsertionData.NO_INDEX, 1, veh1, 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, iDataVeh1WithoutFixed.getInsertionCost())).thenReturn(iDataVeh1WithoutFixed);
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue