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. |
employeeIds | Array of strings (constraintEmployeeIds) unique List of employee ids for which the constraint applies. The employee ids must be present in the employee section. If not specified, the constraint will be applied to all employees. |
object (constraintFairness) Describes how much fairness is taken into account for the constraint. | |
shiftIds | Array of strings (constraintShiftIds) unique List of shift ids for which the constraint applies. The shift ids must be present in the shift section. If not specified, the constraint will be applied to all shifts. |
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. |
{- "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."
}
}, - "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."
}
}, - "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
}, - "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."
}
}, - "minimumContinuousRestDuration": {
- "hours": 0,
- "minutes": 0
}, - "periods": {
- "customDefinitions": [
- {
- "type": "BASIC",
- "startDay": {
- "dayIndex": {
- "example_1": {
- "value": 9,
- "summary": "The 10th day of the planning horizon."
}
}
}, - "endDay": {
- "dayIndex": {
- "example_1": {
- "value": 9,
- "summary": "The 10th day of the planning horizon."
}
}
}, - "startTime": "14:15:22Z",
- "endTime": "14:15:22Z",
- "applyTimeToAllDays": false
}
]
}
}