Employee Availability Constraint
This constraint can be used for three purposes, all related to which periods or shifts an employee should be considered available for:
- Mark an employee as strictly unavailable for specific periods or shifts.
- Mark an employee as available but undesirable for specific periods or shifts.
- Mark an employee as available and desirable for specific periods or shifts.
Employee Availability Constraint in the request payload
id required | string (constraintId) The id of the constraint should be UNIQUE in the context of constraint type. |
importance required | string (constraintImportance) Enum: "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. |
isDesired required | boolean If set to true, it will be considered preferable for employees to work the shifts that this constraint applies to during the specified periods. If set to false, the solver will try to avoid assigning applicable shifts to employees during the specified periods. If importance is set to strict, this must be false. |
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 (periods) = 1 properties List of periods in the schedule. Periods can either be defined explicitly using custom definitions, or through a recurrent definition. A recurrent definition can be used to easily generate a list of similar periods (such as weeks, months, etc.). |
{- "id": "string",
- "importance": "VERY_LOW",
- "isDesired": true,
- "filters": {
- "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."
}
}, - "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."
}
}, - "shiftTypeIds": {
- "example_ids": {
- "value": [
- "shift_type_1",
- "shift_type_2"
], - "summary": "The constraint will be applied only to shift types with id \"shift_type_1\" and \"shift_type_2\"."
}, - "example_all_shift_types": {
- "value": [ ],
- "summary": "The constraint will be applied to all defined shift types."
}
}, - "workTypeIds": {
- "example_1": {
- "value": [
- 0,
- 3
], - "summary": "The constraint will be applied only to work type with id 0 and 3."
}, - "example_2": {
- "value": [ ],
- "summary": "The constraint will be applied to all defined work types."
}
}
}, - "periods": {
- "days": {
- "dates": [
- {
- "example_1": {
- "value": "2023-12-24",
- "summary": "The 24th of December 2023."
}
}
]
}
}
}
Strict unavailability
To define certain periods as strictly unavailable for an employee, simply specify the periods in the constraint. The solver will then never assign shifts to the employee during these periods.
The below constraint makes it strictly impossible for employee with id 'employee-1' to work on weekends.
{
"id": "eac-weekends",
"importance": "STRICT",
"isDesired": false,
"filters": {
"employeeIds": ["employee-1"],
}
"periods": {
"labels": ["WEEKENDS"]
}
}
Undesired availability
To mark that an employee would rather not work during certain periods, set the isDesired
field to false
and choose an importance level different than STRICT
.
The solver will try to avoid assigning shifts to the employee during these periods, but it is not strictly forbidden.
The below constraint makes it undesirable for employee with id 'employee-1' to work on Mondays or Thursdays.
{
"id": "eac-undesired-mondays-thursdays",
"importance": "HIGH",
"isDesired": false,
"filters": {
"employeeIds": ["employee-1"],
}
"periods": {
"days": {
"daysOfWeek": ["MON", "THU"]
}
}
}
Desired availability
To mark that an employee prefers working on certain periods or shifts, set the isDesired
field to true
and choose an importance level different than STRICT
(STRICT
is currently not supported on desired constraints).
The below constraint makes it preferred to assign shifts with shift type night
to employee with id 'employee-1' on Mondays, Tuesdays or Wednesdays.
{
"id": "eac-desired-night-shifts",
"importance": "MEDIUM",
"isDesired": true,
"filters": {
"employeeIds": ["employee-1"],
"shiftTypeIds": ["night"]
}
"periods": {
"days": {
"daysOfWeek": ["MON", "TUE", "WED"]
}
}
}