Rest Between Shifts Constraint
Soft constraint *
* with possibility for hard constraintSet a minimum rest time between shifts.
One can specify which workTypes
this constraint should affect, which is defaulted to all if left empty.
It is also possible to specify which employees
this constraint should affect. If left empty, all employees are affected.
When one or multiple workTypes are specified for this constraint, the hours of rest will be enforced in the following way for all affected employees:
Any two schedulings of shifts that have any of the constrained workTypes will have at least the minimum required hours between them.
When the weight of this constraint is set to a value below 100, a violation of the constrait does not make the solution infeasible but the solution will be considered worse (soft constraint).
When the weight is set to 100, a violation of the constraint does make the solution infeasible (hard constraint). Therefore the constraint can never be violated in a solution.
See the payload example below to get started and check out the API reference for full configurability of the constraint.
The following defines a minimum rest length of 24 hours for employees 2 and 3 when scheduling shifts with IDs 1, 2, 3 or 5 that have work type IDs 1 or 2.
This means that for both employee 2 and 3, there should be 24 hours or more between any two schedulings of shifts that have work type IDs 1 or 2 and shift IDs 1, 2, 3 or 5.
Any shift with a different workType (e.g. workType 3) will be seen as "rest" for this constraint, and can therefore be planned in between shifts with workType 1 or 2 without effect on the feasibility.
{
"restBetweenShiftsConstraints": [
{
"id": "rbsc-123",
"minRestDuration": {
"hours": 24
},
"filters": {
"workTypeIds": ["1", "2"],
"shiftIds": ["1", "2", "3", "5"],
"employeeIds": ["2", "3"]
}
}
]
}
Rest Between Shifts Constraint in the request payload
id required | string (constraintId) The id of the constraint should be UNIQUE in the context of constraint type. |
weight | integer (constraintWeightPositive) [ 0 .. 100 ] Describes how much the constraint is taken into account when solving the schedule. The higher the value, the more solver will penalize the constraint violation. None of the weight values make it a hard constraint - even when weight is set to 100 it is not guaranteed that the constraint will be satisfied. The weight value is relative to other constraints. |
object (constraintFairness) Describes how much fairness is taken into account for the constraint. | |
object (constraintFilters) Filters to determine the scope of the constraint. Used to decide which employees and which shifts the constraint should be applied to. Filters use logical OR filtering - an employee or shift is included as long as it is targeted by any of the filters. | |
required | object (duration) non-empty The required duration between shifts. Will be rounded up to the nearest 5 minutes as this is the smallest time unit used for demand segments. |
workTypeIds | Array of strings (constraintWorkTypeIds) unique Deprecated DEPRECATED - Use filters instead. |
employeeIds | Array of strings (constraintEmployeeIds) unique Deprecated DEPRECATED - Use filters instead. |
shiftIds | Array of strings (constraintShiftIds) unique Deprecated DEPRECATED - Use filters instead. |
{- "id": "string",
- "weight": {
- "example_1": {
- "value": 0,
- "summary": "The constraint is not taken into account when solving the schedule as it has weight 0."
}, - "example_2": {
- "value": 100,
- "summary": "Solver will try its best to satisfy the constraint as it has weight 100."
}
}, - "fairness": {
- "fairnessWeight": {
- "example_1": {
- "value": 0,
- "summary": "The fairness is not taken into account when solving the schedule."
}, - "example_2": {
- "value": 100,
- "summary": "Solver will try its best to make the constraint as fair as possible."
}
}, - "fteAdjustedFairness": false
}, - "filters": {
- "employeeIds": {
- "example_ints": {
- "value": [
- 1,
- 5,
- 3
], - "summary": "The constraint will be applied only to employees with id 1, 5 and 3."
}, - "example_all_employees": {
- "value": [ ],
- "summary": "The constraint will be applied to all defined employees."
}, - "example_string": {
- "value": [
- "Lars Petersen",
- "123qwerty"
], - "summary": "The constraint will be applied to listed employees."
}
}, - "shiftIds": {
- "example_1": {
- "value": [
- "shift_1",
- "shift_2"
], - "summary": "The constraint will be applied only to shifts with id \"shift_1\" or \"shift_2\"."
}, - "example_2": {
- "value": [ ],
- "summary": "The constraint will be applied to all defined shifts."
}
}, - "shiftTypeIds": {
- "example_ids": {
- "value": [
- "shift_type_1",
- "shift_type_2"
], - "summary": "The constraint will be applied only to shift types with id \"shift_type_1\" and \"shift_type_2\"."
}, - "example_all_shift_types": {
- "value": [ ],
- "summary": "The constraint will be applied to all defined shift types."
}
}, - "workTypeIds": {
- "example_1": {
- "value": [
- 0,
- 3
], - "summary": "The constraint will be applied only to work type with id 0 and 3."
}, - "example_2": {
- "value": [ ],
- "summary": "The constraint will be applied to all defined work types."
}
}
}, - "minRestDuration": {
- "hours": 0,
- "minutes": 0
}, - "workTypeIds": {
- "example_1": {
- "value": [
- 0,
- 3
], - "summary": "The constraint will be applied only to work type with id 0 and 3."
}, - "example_2": {
- "value": [ ],
- "summary": "The constraint will be applied to all defined work types."
}
}, - "employeeIds": {
- "example_ints": {
- "value": [
- 1,
- 5,
- 3
], - "summary": "The constraint will be applied only to employees with id 1, 5 and 3."
}, - "example_all_employees": {
- "value": [ ],
- "summary": "The constraint will be applied to all defined employees."
}, - "example_string": {
- "value": [
- "Lars Petersen",
- "123qwerty"
], - "summary": "The constraint will be applied to listed employees."
}
}, - "shiftIds": {
- "example_1": {
- "value": [
- "shift_1",
- "shift_2"
], - "summary": "The constraint will be applied only to shifts with id \"shift_1\" or \"shift_2\"."
}, - "example_2": {
- "value": [ ],
- "summary": "The constraint will be applied to all defined shifts."
}
}
}