Skip to main content

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:

  1. Mark an employee as strictly unavailable for specific periods or shifts.
  2. Mark an employee as available but undesirable for specific periods or shifts.
  3. 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": {
    },
  • "periods": {
    }
}

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.

Payload example

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

Payload example

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

Payload example

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"]
}
}
}