Constraints
1. Overview
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, employees must have certain skills to be assigned to specific shifts.
Breaking hard constraints results in infeasible plans.
Medium constraints help manage plans when resources are limited, for instance, assign as many mandatory shifts as possible. Medium constraints incentivize Timefold Platform to assign as many shifts as possible.
Soft constraints help optimize plans based on the business goals, for instance, keeping costs per period in a preferred range.
To help determine the quality of solutions, plans are assigned a score with values for hard, medium, and soft constraints.
0hard/-257medium/-6119520soft
Timefold examines many solutions during solving and is incentivized to use the solution with the highest score.
From the example score above, you 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.
It’s important to note that constraints have competing goals, for instance, a constraint that is concerned with fairness or load balancing may result in a solution that takes longer to execute, whereas constraints concerned with shortening the overall solution time may result in a solution that isn’t fairly disrupted among the available resources.
Timefold balances the competing priorities of constraints to arrive at solutions with the best overall score.
2. Employee shift scheduling constraint groups and constraints
Constraints are grouped together with similar constraints into constraint groups. The following constraint groups are available in employee shift scheduling.
Employee resource constraints:
Shift service constraints:
3. Constraint weights
Every constraint has a weight and a match score that will be applied to the dataset score every time the constraint is matched.
The final score for an instance of a 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 make some constraints more important than others.
A constraint with a weight of 10, increases the impact of the score by a factor of 10 (10 * match score).
When a constraint has a weight of 0, the constraint score has no impact.
The match score is derived from the penalty or reward constraints apply when they are matched.
For instance, the Minutes worked per period not in preferred range for employee constraint adds a soft penalty that is derived from the additional minutes an employee works.
If a rule specifies an employee can work a maximum of 240 minutes per day, but the employee is assigned 300 minutes, the Minutes worked per period not in preferred range for employee constraint will return a match score of -60.
If the minutesWorkedPerPeriodNotInPreferredRangeForEmployeeWeight (which sets the weight of the Minutes worked per period not in preferred range for employee constraint) is set to 1, the final soft score for this instance of the constraint matching will be -60.
If the minutesWorkedPerPeriodNotInPreferredRangeForEmployeeWeight is set to 2, the final soft score for this instance of the constraint matching will be -120.
3.1. Constraint weight configuration
Constraint weights can be configured in individual input datasets or as part of a configuration profile that can be reused with future input datasets.
You can access the list of available constraint weights in the configuration profiles.
3.1.1. Configure a configuration profile
Constraint weights can be configured in Timefold Platform by creating a configuration profile and setting the weight in the configuration profile.
Setting the constraint weights in a configuration profile ensures the same weights are used whenever the configuration profile is applied to a dataset.
To configure constraint weights:
-
Log in to Timefold Platform: app.timefold.ai
-
Select the employee shift scheduling tile.
-
Select Configuration profiles.
-
Add a new configuration profile (or modify an existing profile) and configure the constraint weights.
The configuration profile can be specified when you submit a new dataset by appending a query parameter with the configuration profile name to the POST URL.
For instance, if the configuration profile is called test, the query parameter would be: ?configurationId=test
Learn more about configuration parameters and profiles.
Next
-
See the full API spec or try the online API.
-
Learn more about employee shift scheduling from our YouTube playlist.
-
Learn about balancing different optimization goals.