Skip to main content

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).

Payload example 1

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
}
}
}
]
}
Payload example 2

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": {
    },
  • "filters": {
    },
  • "fairness": {
    },
  • "minimumContinuousRestDuration": {
    },
  • "periods": {
    },
  • "employeeIds": {
    },
  • "shiftIds": {
    }
}