mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
bugfix #186
This commit is contained in:
parent
e5ada2f6d9
commit
e543665da2
6 changed files with 43 additions and 2 deletions
|
|
@ -25,6 +25,7 @@ import jsprit.core.algorithm.recreate.VehicleSwitched;
|
|||
import jsprit.core.algorithm.state.*;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.constraint.SwitchNotFeasible;
|
||||
import jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
|
|
@ -89,6 +90,7 @@ public class PrettyAlgorithmBuilder {
|
|||
constraintManager.addTimeWindowConstraint();
|
||||
constraintManager.addLoadConstraint();
|
||||
constraintManager.addSkillsConstraint();
|
||||
constraintManager.addConstraint(new SwitchNotFeasible(stateManager));
|
||||
stateManager.updateLoadStates();
|
||||
stateManager.updateTimeWindowStates();
|
||||
UpdateVehicleDependentPracticalTimeWindows twUpdater = new UpdateVehicleDependentPracticalTimeWindows(stateManager, vrp.getTransportCosts());
|
||||
|
|
|
|||
|
|
@ -49,4 +49,6 @@ public class InternalStates {
|
|||
public static final StateId FUTURE_WAITING = new StateFactory.StateIdImpl("future_waiting", 13);
|
||||
|
||||
public static final StateId EARLIEST_WITHOUT_WAITING = new StateFactory.StateIdImpl("earliest_without_waiting", 14);
|
||||
|
||||
public static final StateId SWITCH_NOT_FEASIBLE = new StateFactory.StateIdImpl("switch_not_feasible", 15);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,6 +97,9 @@ public class UpdateVehicleDependentPracticalTimeWindows implements RouteVisitor,
|
|||
double potentialLatestArrivalTimeAtCurrAct = latestArrTimeAtPrevAct - transportCosts.getBackwardTransportTime(activity.getLocation(), prevLocation,
|
||||
latestArrTimeAtPrevAct, route.getDriver(), vehicle) - activity.getOperationTime();
|
||||
double latestArrivalTime = Math.min(activity.getTheoreticalLatestOperationStartTime(), potentialLatestArrivalTimeAtCurrAct);
|
||||
if(latestArrivalTime < activity.getTheoreticalEarliestOperationStartTime()){
|
||||
stateManager.putTypedInternalRouteState(route,vehicle,InternalStates.SWITCH_NOT_FEASIBLE,true);
|
||||
}
|
||||
stateManager.putInternalTypedActivityState(activity, vehicle, InternalStates.LATEST_OPERATION_START_TIME, latestArrivalTime);
|
||||
latest_arrTimes_at_prevAct[vehicle.getVehicleTypeIdentifier().getIndex()] = latestArrivalTime;
|
||||
location_of_prevAct[vehicle.getVehicleTypeIdentifier().getIndex()] = activity.getLocation();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package jsprit.core.problem.constraint;
|
||||
|
||||
import jsprit.core.algorithm.state.InternalStates;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
|
||||
/**
|
||||
* Created by schroeder on 19/09/15.
|
||||
*/
|
||||
public class SwitchNotFeasible implements HardRouteConstraint{
|
||||
|
||||
private StateManager stateManager;
|
||||
|
||||
public SwitchNotFeasible(StateManager stateManager) {
|
||||
this.stateManager = stateManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fulfilled(JobInsertionContext insertionContext) {
|
||||
Boolean notFeasible = stateManager.getRouteState(insertionContext.getRoute(),insertionContext.getNewVehicle(), InternalStates.SWITCH_NOT_FEASIBLE,Boolean.class);
|
||||
if(notFeasible == null) return true;
|
||||
else return !notFeasible;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -114,6 +114,14 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic
|
|||
matrix = builder.matrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* First dim is from, second to and third indicates whether it is a distance value (index=0) or time value (index=1).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public double[][][] getMatrix(){
|
||||
return matrix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTransportTime(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue