Constraints
Constraints can be considered hard, medium, or soft.
Hard constraints represent rules and limitations of the real world that any planning solution has to respect. For instance, there are only 24 hours in a day and people can only be in one place at a time. Hard constraints also include rules that must be adhered to, for instance, technicians must have specific skills for specific jobs.
Breaking hard constraints results in infeasible plans.
Medium constraints help manage plans when resources are limited, for instance, scheduling as many mandatory visits as possible. Medium constraints incentivize Timefold Platform to assign as many visits as possible.
Soft constraints help optimize plans based on the business goals, for instance, to minimize travel time.
To help determine the quality of the solution, plans are assigned a score with values for hard, medium, and soft constraints.
0hard/-257medium/-6119520soft
From this example score we can see zero hard constraints were broken, while both the medium and soft scores have negative values (the scores do not show how many constraints were broken, but values associated with those constraints).
Because breaking hard constraints would result in an infeasible solution, a solution that breaks zero hard constraints and has a soft constraint score of -1,000,000 is better than a solution that breaks 1 hard constraint but has a soft constraint score of 0.
To learn more about individual constraints in field service routing, see the Vehicle resource constraints and Visit service constraints guides.
1. Constraint weights
Every constraint has a weight and a match score that will be applied to the run every time the constraint is matched.
For instance, if a rule specifies a technician should finish work at 17:00, but the technician is assigned overtime and does not arrive at their end location until 17:10, the Max shift end time (soft)
will return a score of 600 (the penalty is derived from every second between the time they should have finished and the time they did finish).
The final score for this instance of the constraint being matched is calculated by multiplying the constraint weight by the match score.
Active soft constraints have a default weight of 1, meaning that all soft constraints are equally weighted. Constraint weights can be changed to preference some constraints over others.
To increase the impact of a score by a factor of 10, set the related constraint weight to 10.
For example, in order to preference minimizing missing skills 10 times more than other soft constraints, set minimizeUnnecessarySkillsWeight
to 10
.
{
"config": {
"model": {
"overrides": {
"minimizeUnnecessarySkillsWeight": 10
}
}
}
}
To effectively turn a constraint off, set the related constraint weight to 0.