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:
parent
6844a92e67
commit
a1f448c113
3 changed files with 25 additions and 7 deletions
|
|
@ -533,6 +533,22 @@ 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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ public class SolomonExample {
|
|||
*/
|
||||
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).
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue