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

moved tw-update from core.algorithm.state.StateManager to core.algorithm.io.VehicleRoutingAlgorithms

This commit is contained in:
oblonski 2014-07-23 23:08:14 +02:00
parent 6844a92e67
commit a1f448c113
3 changed files with 25 additions and 7 deletions

View file

@ -532,7 +532,23 @@ public class VehicleRoutingAlgorithms {
//create fleetmanager
final VehicleFleetManager vehicleFleetManager = createFleetManager(vrp);
if(stateManager.timeWindowUpdateIsActivated()){
UpdateVehicleDependentPracticalTimeWindows timeWindowUpdater = new UpdateVehicleDependentPracticalTimeWindows(stateManager,vrp.getTransportCosts());
timeWindowUpdater.setVehiclesToUpdate(new UpdateVehicleDependentPracticalTimeWindows.VehiclesToUpdate() {
@Override
public Collection<Vehicle> get(VehicleRoute route) {
Collection<Vehicle> vehicles = new ArrayList<Vehicle>();
vehicles.add(route.getVehicle());
vehicles.addAll(vehicleFleetManager.getAvailableVehicles(route.getVehicle()));
return vehicles;
}
});
stateManager.addStateUpdater(timeWindowUpdater);
}
SolutionCostCalculator costCalculator;
if(solutionCostCalculator==null) costCalculator = getDefaultCostCalculator(stateManager);
else costCalculator = solutionCostCalculator;

View file

@ -690,11 +690,12 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
* Updates time-window states.
*/
public void updateTimeWindowStates() {
if(!updateTWs){
updateTWs=true;
addActivityVisitor(new UpdatePracticalTimeWindows(this, routingCosts));
}
updateTWs=true;
}
public boolean timeWindowUpdateIsActivated(){
return updateTWs;
}
}