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

added vehicle dependent time-window updater

This commit is contained in:
oblonski 2014-07-17 18:36:38 +02:00
parent a3afd00614
commit 78ce320187

View file

@ -6,21 +6,31 @@ import jsprit.core.problem.solution.route.activity.ReverseActivityVisitor;
import jsprit.core.problem.solution.route.activity.TourActivity;
import jsprit.core.problem.solution.route.state.StateFactory;
import jsprit.core.problem.vehicle.Vehicle;
import jsprit.core.problem.vehicle.VehicleFleetManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
public class UpdateVehicleDependentPracticalTimeWindows implements ReverseActivityVisitor, StateUpdater{
public static interface VehiclesToUpdate {
public Collection<Vehicle> get(VehicleRoute route);
}
private final VehiclesToUpdate vehiclesToUpdate = new VehiclesToUpdate() {
@Override
public Collection<Vehicle> get(VehicleRoute route) {
return Arrays.asList(route.getVehicle());
}
};
private final StateManager stateManager;
private final VehicleRoutingTransportCosts transportCosts;
private final VehicleFleetManager fleetManager;
private final boolean vehicleSwitchAllowed;
private VehicleRoute route;
private double[] latest_arrTimes_at_prevAct;
@ -29,23 +39,21 @@ public class UpdateVehicleDependentPracticalTimeWindows implements ReverseActivi
private Collection<Vehicle> vehicles;
public UpdateVehicleDependentPracticalTimeWindows(StateManager stateManager, VehicleRoutingTransportCosts tpCosts, VehicleFleetManager fleetManager, boolean isVehicleSwitchAllowed) {
public UpdateVehicleDependentPracticalTimeWindows(StateManager stateManager, VehicleRoutingTransportCosts tpCosts) {
super();
this.stateManager = stateManager;
this.transportCosts = tpCosts;
this.fleetManager = fleetManager;
this.vehicleSwitchAllowed=isVehicleSwitchAllowed;
latest_arrTimes_at_prevAct = new double[stateManager.getMaxIndexOfVehicleTypeIdentifiers() + 1];
location_of_prevAct = new String[stateManager.getMaxIndexOfVehicleTypeIdentifiers() + 1];
}
public void setVehiclesToUpdate(VehiclesToUpdate vehiclesToUpdate){
}
@Override
public void begin(VehicleRoute route) {
this.route = route;
vehicles = new ArrayList<Vehicle>();
if(vehicleSwitchAllowed) vehicles.addAll(fleetManager.getAvailableVehicles(route.getVehicle()));
vehicles.add(route.getVehicle());
vehicles = vehiclesToUpdate.get(route);
for(Vehicle vehicle : vehicles){
latest_arrTimes_at_prevAct[vehicle.getVehicleTypeIdentifier().getIndex()] = vehicle.getLatestArrival();
location_of_prevAct[vehicle.getVehicleTypeIdentifier().getIndex()] = vehicle.getEndLocationId();