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) Unique identifier for the constraint. |
| labels | Array of strings (constraintLabels) unique 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. |
| importance | string (importanceWithStrict) Enum: "NONE" "VERY_LOW" "LOW" "MEDIUM" "HIGH" "VERY_HIGH" "STRICT" 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. |
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 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. |
| weight | integer (constraintWeightPositive) [ 0 .. 100 ] Deprecated DEPRECATED - Use importance instead. |
object (constraintFairness) Deprecated DEPRECATED - Use FairnessConstraints instead. |
{- "id": "string",
- "labels": [
- "string"
], - "importance": "NONE",
- "filters": {
- "employees": {
- "ids": [
- "string"
], - "labels": [
- "string"
]
}, - "shifts": {
- "ids": [
- "string"
], - "labels": [
- "string"
], - "advanced": {
- "filters": [
- {
- "field": "string",
- "values": [
- "string"
], - "matchType": "NONE"
}
], - "matchType": "NONE"
}
}, - "employeeIds": [
- "string"
], - "shiftIds": [
- "string"
], - "shiftTypeIds": [
- "string"
], - "workTypeIds": [
- "string"
]
}, - "minimumContinuousRestDuration": {
- "hours": 0,
- "minutes": 0
}, - "periods": {
- "days": {
- "dates": [
- "2019-08-24"
], - "dayIndices": [
- 0
], - "daysOfWeek": [
- "MON"
], - "startTime": "14:15:22Z",
- "endTime": "14:15:22Z"
}
}, - "employeeIds": [
- "string"
], - "shiftIds": [
- "string"
], - "weight": 0,
- "fairness": {
- "fairnessWeight": 0,
- "fteAdjustedFairness": false
}
}