Skip to main content

Rest Between Shifts Constraint

Soft constraint *

* with possibility for hard constraint

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

Payload example

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)

Unique identifier for the constraint.

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

object (constraintFairness)
Deprecated

DEPRECATED - Use FairnessConstraints instead.

weight
integer (constraintWeightPositive) [ 0 .. 100 ]
Deprecated

DEPRECATED - Use importance instead.

{
  • "id": "string",
  • "importance": "NONE",
  • "filters": {
    },
  • "minRestDuration": {
    },
  • "workTypeIds": {
    },
  • "employeeIds": {
    },
  • "shiftIds": {
    },
  • "fairness": {
    },
  • "weight": {
    }
}