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

@ -533,6 +533,22 @@ public class VehicleRoutingAlgorithms {
//create fleetmanager //create fleetmanager
final VehicleFleetManager vehicleFleetManager = createFleetManager(vrp); 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; SolutionCostCalculator costCalculator;
if(solutionCostCalculator==null) costCalculator = getDefaultCostCalculator(stateManager); if(solutionCostCalculator==null) costCalculator = getDefaultCostCalculator(stateManager);
else costCalculator = solutionCostCalculator; else costCalculator = solutionCostCalculator;

View file

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

View file

@ -54,6 +54,7 @@ public class SolomonExample {
*/ */
new SolomonReader(vrpBuilder).read("input/C101_solomon.txt"); new SolomonReader(vrpBuilder).read("input/C101_solomon.txt");
/* /*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances). * Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/ */