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
},
"workTypeIds": ["1", "2"],
"shiftIds": ["1", "2", "3", "5"],
"employeeIds": ["2", "3"]
}
]
}
Rest Between Shifts 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 (constraintFairness)

Describes how much fairness is taken into account for the constraint.

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

List of workType IDs for which the constraint applies. The workTypeIds should be present in workType section. If work type ids are not specified, the constraint will be applied to all work types.

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.

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.

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