Periodic Rest Constraint
The Periodic Rest Constraint can be used to set a minimum duration of continuous rest that an employee gets in a period. Of all the periods of rest the employee gets, the constraint ensures that at least one of them is of the specified minimum duration per period. A good example of this constraint is to ensure that employees get at least 48 hours of continuous rest in each week, so that they will always have at least 2 consecutive days off (regardless of which days it is planned on).
The following example defines a periodic rest constraint that ensures that all employees get at least one 48-hour long continuous rest in each week.
{
"periodicRestConstraints": [
{
"id": "48-hours-per-week",
"minimumContinuousRestDuration": {
"hours": 48
},
"periods": {
"recurrentDefinition": {
"daysPerPeriod": 7
}
}
}
]
}
The following example defines a periodic rest constraint that ensures that all employees get at least one 72-hour long continuous rest in each month.
{
"periodicRestConstraints": [
{
"id": "72-hours-per-month",
"minimumContinuousRestDuration": {
"hours": 72
},
"periods": {
"customDefinitions": [
{
"startDate": "2022-01-01",
"endDate": "2022-01-31"
},
{
"startDate": "2022-02-01",
"endDate": "2022-02-28"
}
]
}
}
]
}
Periodic Rest 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 (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. | |
object (constraintFairness) Describes how much fairness is taken into account for the constraint. | |
required | object (duration) non-empty The minimum duration of continuous rest the employee should have in each period. For example, if the minimumContinuousRestDuration is set to 24 hours, the employee should have at least one 24-hour long continuous rest within each period. |
required | object (periods) = 1 properties The periods in which the constraint should be applied. |
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."
}
}, - "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."
}
}
}, - "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
}, - "minimumContinuousRestDuration": {
- "hours": 0,
- "minutes": 0
}, - "periods": {
- "days": {
- "dates": [
- {
- "example_1": {
- "value": "2023-12-24",
- "summary": "The 24th of December 2023."
}
}
]
}
}, - "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."
}
}
}