Constraints
1. Hard
Hard constraints represent rules and limitations of the real world that the resulting solution has to respect. For that reason, the Field Service Model prefers leaving visits unassigned to breaking hard constraints.
1.1. Max shift end time (hard)
A vehicle shift may end either by:
The former is more appropriate for vehicles that end their shifts in employer’s depot or office. The latter is suitable for vehicle shifts that end at employee’s home and the travel from the last visit home is considered outside the working hours.
Make sure to define at least one of these hard limits, otherwise the vehicle shift effectively never ends.
1.2. Require skills
Both vehicle shifts and visits define skills. You can use skills to model a skill or trade with its level of proficiency (optional) and its service duration multiplier (optional). The constraint makes sure visits are assigned to vehicle shifts that match their required skills and their levels. Triggers for any visit assigned to a vehicle shift with at least a single missing skill (or its insufficient level) required by the visit.
A vehicle shift can also define temporary skills that apply only in the specified time interval.
1.3. Require tags
Both vehicle shifts and visits define tags. You can use tags to model skills, regions, contractors, and similar. The constraint makes sure visits are assigned to vehicle shifts that match their required tags. Triggers for any visit assigned to a vehicle shift with at least a single missing tag required by the visit.
A vehicle shift can also define temporary tags that apply only in the specified time interval.
1.4. Require vehicles
A visit may define required vehicles to limit the vehicle shifts assignable to the visit only to the shifts of the specified required vehicles. You can use this feature to specify that a visit needs to be handled by a specific technician.
The constraint makes sure visits are assigned to vehicle shifts that belong to a vehicle specified in the list of required vehicles. If no required vehicles are defined, the visit can be assigned to a vehicle shift of any vehicle.
Triggers for any visit assigned to a vehicle shift of a vehicle not in the visit’s list of required vehicles.
1.5. Require service max start time
Vehicles have to fulfill the service within the customer visit’s availability window. The constraint triggers when the vehicle shift’s start service time exceeds the visit’s max start time.
1.6. Require service max end time
Vehicles have to fulfill the service within the customer visit’s availability window. The constraint triggers when the vehicle shift’s departure time exceeds the visit’s max end time.
1.7. Max travel time per visit (hard)
Vehicle shift can define a maximum travel time spent per a single visit. This limit may result in visits in distant locations being unassigned. The constraint triggers when the vehicle shift’s travel time exceeds the limit.
1.8. Require visit dependency prerequisite assigned
When Visit B depends on Visit A, and Visit B is assigned to a vehicle shift, Visit A must be assigned as well (to any vehicle shift). For instance, when one maintenance task requires the completion of another task. Triggers if the plan contains an assigned visit depending on an unassigned preceding visit.
1.9. Require visit dependency delay
Visits may depend on each other with a minimal required delay between them. For instance, between two consecutive maintenance tasks, there needs to be a technological pause. Triggers if a visit starts before the minimal delay after the departure time from the defined preceding visit.
1.10. Require the same vehicle for dependent visit
Visits depending on each other may require to be assigned to the same vehicle (possibly different vehicle shift). For instance, two related tasks have to be performed by the same technician. Triggers if a visit required to be assigned to the same vehicle as its preceding visit is assigned to a different vehicle.
1.11. Balance movable and non-movable visits
Often it is important to spread movable visits (visits with an availability window spanning multiple days) over the planning windows to keep free time for optimizing non-movable visits (visits with an availability window within a single day) and placing sudden emergencies.
The movable occupation ratio threshold defines the capacity for movable visits in the following way:
If the vehicle shift occupancy grows above the threshold, the constraint penalizes the solution score for the exceeding travel and service duration of movable visits assigned to this vehicle shift.
2. Soft
Soft constraints represent optimization goals and additional requirements on the quality of feasible solutions.
2.1. Max shift end time (soft)
Similarly to Vehicle shift end time (hard), there are also soft limits of the vehicle shift end:
If you use these soft limits, make sure to set them to earlier time than the corresponding hard limits.
2.2. Minimize travel time
Minimizes the total travel time over all vehicles. Triggers for every visit assigned to a vehicle shift. This constraint represents an optimization goal to reduce the travel time and is typically not used in combination with the Minimize travel distance constraint.
2.3. Minimize travel distance
Minimizes the total travel distance over all vehicles. Triggers for every visit assigned to a vehicle shift. This constraint represents an optimization goal to reduce the travel distance and, by that, also the mileage driven together with a fuel consumption. It is typically not used in combination with the Minimize travel time constraint.
2.4. Prefer visits scheduled to the earliest day
Schedules movable visits to the earliest possible day to reduce the risk of not being able to assign them later. The constraint triggers for every movable visit that is scheduled to a later date that its minimum start time.
2.5. Prefer scheduling optional visits
Assigns as many optional visits (movable visits with availability windows spanning multiple days) as possible without breaking hard constraints and without making a mandatory visit unassigned. Optional visits with approaching deadlines come first. Applies to any unassigned optional visit with its maximum end time outside the current planning window.
2.6. Minimize the visit completion risk
If a vehicle crew gets behind the schedule during the day, there is a risk the last one or two visits might not get finished. As a result, these visits have to be rescheduled to some other day.
This constraint penalizes any visit with its departure time exceeding the visitCompletionRiskMinimalTimeToShiftEnd
based on the visit priority.
To define the minimal priority level to consider for the risk evaluation, use the visitCompletionRiskMinimalPriority
.
That way, high-priority visits are more likely to be scheduled earlier in the day, while low-priority visits are likely to move towards the vehicle shift end.
2.7. Minimize scheduling vehicles with unnecessary skill levels
Minimizes the sum of all unnecessary skill levels (provided skill level minus required skill level) over all assigned visits. The penalty is proportional to both the skill level difference and the visit effective service duration (the time of a more skilled technician is more expensive).
In the case of not specifying any skill levels, the provided skill levels will default to 1
and required skill levels will default to null
(meaning the skill requirement does not care about skill level at all), therefore no optimization will take place.
If this is the case, you might even want to turn off this constraint for performance reasons by setting its weight to 0.
Triggers for every visit assigned to a vehicle shift.
This constraint represents an optimization goal to reduce over-qualification: scheduling highly qualified vehicles/technicians to simple tasks.
2.8. Balance technicians' workloads
Balances the workload of technicians based on the assigned workload (i.e. travel times, wait times, service times, break times) and the available working hours based on technicians' shifts. It can also consider historical information if it is provided with the input. The constraint relies on Timefold’s default approach on determining the unfairness of a solution. Therefore, the penalty of this constraint is directly based on the unfairness score. The smaller the penalty is, the fairer and more balanced the solution is.
3. Constraint configuration
Constraint configuration contains weights of soft constraints together with additional constraint parameters. Every constraint defines a match weight; a basic score impact for every constraint match. The overall score impact of a constraint match is calculated by multiplying the match weight by the constraint weight.
The default value of a constraint weight is 1. To make the score impact of a constraint ten times bigger, set the related constraint weight to 10. To effectively turn a constraint off, set the related constraint weight to 0.