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, employee contracts.
Breaking hard constraints would result in infeasible plans.
Medium constraints help manage plans when resources are limited, for instance, when there aren’t enough employees to work all the available shifts. Medium constraints incentivize Timefold Platform to assign as many shifts as possible.
Soft constraints help optimize plans based on the business goals, for instance, assign employees to their preferred shifts.
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 one hard constraint and has a soft constraint score of 0.
To learn more about individual constraints, see the Employee resource constraints and Shift service constraints guides.
1. Constraint weight overrides
Every constraint has a default weight of 1, meaning that all constraints are equally important.
Use this to express preference of some constraints over others.
For example, in order to express that the employee pairing constraint is more important than the rest of the constraints, set the value of the employeeIsPairedWithPreferredEmployeeWeight
attribute to 10.
In order to turn off a constraint, set the value of the corresponding attribute to 0.
"config": { "overrides": { "employeeIsPairedWithPreferredEmployeeWeight": 10, "employeeWorksDuringPreferredTimeWeight": 0 } }