public class ServiceDeliveriesFirstConstraint extends Object implements HardActivityConstraint
HardActivityConstraint.ConstraintsStatus| Constructor and Description |
|---|
ServiceDeliveriesFirstConstraint() |
| Modifier and Type | Method and Description |
|---|---|
HardActivityConstraint.ConstraintsStatus |
fulfilled(JobInsertionContext iFacts,
TourActivity prevAct,
TourActivity newAct,
TourActivity nextAct,
double prevActDepTime)
Returns whether newAct can be inserted in between prevAct and nextAct.
|
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())Copyright © 2013–2020. All rights reserved.