public class ConstraintManager extends Object implements HardActivityConstraint, HardRouteConstraint, SoftActivityConstraint, SoftRouteConstraint
| Modifier and Type | Class and Description |
|---|---|
static class |
ConstraintManager.Priority |
HardActivityConstraint.ConstraintsStatus| Constructor and Description |
|---|
ConstraintManager(VehicleRoutingProblem vrp,
RouteAndActivityStateGetter stateManager) |
ConstraintManager(VehicleRoutingProblem vrp,
RouteAndActivityStateGetter stateManager,
Collection<Constraint> constraints) |
public ConstraintManager(VehicleRoutingProblem vrp, RouteAndActivityStateGetter stateManager)
public ConstraintManager(VehicleRoutingProblem vrp, RouteAndActivityStateGetter stateManager, Collection<Constraint> constraints)
public Collection<HardRouteConstraint> getHardRouteConstraints()
public Collection<HardActivityConstraint> getCriticalHardActivityConstraints()
public Collection<HardActivityConstraint> getHighPrioHardActivityConstraints()
public Collection<HardActivityConstraint> getLowPrioHardActivityConstraints()
public DependencyType[] getDependencyTypes()
public void setDependencyType(String jobId, DependencyType dependencyType)
public DependencyType getDependencyType(String jobId)
public void addTimeWindowConstraint()
public void addLoadConstraint()
public void addSkillsConstraint()
public void addConstraint(HardActivityConstraint actLevelConstraint, ConstraintManager.Priority priority)
public void addConstraint(HardRouteConstraint routeLevelConstraint)
public void addConstraint(SoftActivityConstraint softActivityConstraint)
public void addConstraint(SoftRouteConstraint softRouteConstraint)
public boolean fulfilled(JobInsertionContext insertionContext)
HardRouteConstraintfulfilled in interface HardRouteConstraintinsertionContext - provides context information about inserting a new job, i.e. the new job (insertionContext.getJob()),
the route where the new job should be inserted (insertionContext.getRoute()), the new vehicle that
should operate the route plus the new job (insertionContext.getNewVehicle()) and the new departure
time at this vehicle's start location (insertionContext.getNewDepartureTime()).public HardActivityConstraint.ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime)
HardActivityConstraint
When you check activities, you need to understand the following:
Let us assume an existing route;
start, ..., i-1, i, j, j+1, ..., end
When inserting a shipment, two activities will be inserted, pickupShipment k_pick and deliverShipment k_deliver, i.e. jsprit loops through this route (activity sequence) and checks hard and soft constraints and calculates (marginal) insertion costs. For the activity sequence above, it means:
start, k_pick, start+1 (prevAct, newAct, nextAct)
...
i-1, k_pick, i
i, k_pick, j
...
accordingly:
start, k_pick, k_delivery (prevAct, newAct, nextAct)
...
i-1, k_delivery, i
i, k_delivery, j
...
You specify a hard activity constraint, you to check whether for example k_pick can be inserted between prevActivity and nextActivity at all.
If so, your hard constraint should return ConstraintsStatus.FULFILLED.
If not, you can return ConstraintsStatus.NOT_FULFILLED or ConstraintsStatus.NOT_FULFILLED_BREAK.
Latter should be used, if your constraint can never be fulfilled anymore when looping further through your route.
Since constraint checking at activity level is rather time consuming (you need to do this thousand/millions times), you can memorize states behind activities to avoid additional loopings through your activity sequence and thus to check your constraint locally (only by looking at prevAct, newAct, nextAct) in constant time.
fulfilled in interface HardActivityConstraintiFacts - JobInsertionContext provides additional information that might be important when evaluating the insertion of newActprevAct - the previous activity, i.e. the activity before the new activitynewAct - the new activity to be inserted in between prevAct and nextActnextAct - the next activity, i.e. the activity after the new activityprevActDepTime - the departure time at previous activity (prevAct) with the new vehicle (iFacts.getNewVehicle())public Collection<Constraint> getConstraints()
public double getCosts(JobInsertionContext insertionContext)
getCosts in interface SoftRouteConstraintpublic double getCosts(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime)
getCosts in interface SoftActivityConstraintCopyright © 2013–2020. All rights reserved.