Control the number of consecutive shifts or days that employees can work.
This constraint allows you to control how many consecutive shifts or days employees can work. It can be used to set both minimum and maximum limits on consecutive work periods, helping you balance employee workload and prevent burnout.
Labels for the constraint. Labels can be used to group constraints together. For example, if multiple constraints are related to the same shift type, they can all be labeled with the same label.
string (enum: NONE | VERY_LOW | LOW | MEDIUM | HIGH | ...)
required
The importance of the constraint. The higher the importance, the more the solver will take the constraint into account. Under strict importance, the constraint may never be violated.
Filters to determine the scope of the constraint. Used to indicate what the constraint should be applied to (which employees, which shifts, etc). Leaving this empty means that the constraint always applies.
Used to indicate how to apply the label filters. For example, if set to ANY, entities that have any of the specified labels will be included. Default: “ANY”.
Used to indicate how to apply the label filters. For example, if set to ANY, entities that have any of the specified labels will be included. Default: “ANY”.
The minimum number of consecutive entities that an employee should ideally work. This cannot be set as a strict limit and will be treated as a target instead.
To limit the maximum number of consecutive shifts or days an employee can work, use the max property in the targets object. This limit can only be enforced with STRICT importance, meaning the solver will never violate it.
The below constraint strictly prevents employees from working more than 4 consecutive days. If an employee works on Monday, Tuesday, Wednesday, and Thursday, they must have at least one day off before working again.
To encourage employees to work a minimum number of consecutive shifts, use the min property in the targets object. This is treated as a target rather than a strict requirement, so the solver will try to achieve it but may not always succeed.
The below constraint encourages employees to work at least 3 consecutive shifts when they do work. This helps create more predictable work patterns and reduces fragmentation.
You can combine both min and max targets in a single constraint to create a preferred range of consecutive work periods. Note that when using max, the importance must be STRICT for the maximum limit to be enforced. The minimum target will be treated as a target that the solver will try to achieve.
The below constraint encourages employees to work between 3 and 5 consecutive days when they do work. The solver will try to achieve at least 3 consecutive days (as a target), and will strictly prevent more than 5 consecutive days.