Skip to main content

Fairness Constraint

Fairness is a special type of constraint that can be used to improve the fair distribution of (in)conveniences from other constraints among employees. Some examples include the number of night shifts that employees have to work, the number of hours employees receive and the number of times employees receive work during their preferred hours.


Fairness Constraint in the request payload
id
required
string (constraintId)

Unique identifier for the constraint.

importance
string (importance)
Enum: "NONE" "VERY_LOW" "LOW" "MEDIUM" "HIGH" "VERY_HIGH"

The importance of adhering to this fairness constraint.

constraintIds
required
Array of strings unique

List of constraint ids for which the corresponding (in)conveniences should be distributed fairly. May only contain constraints of the same type.

applyConstraintImportanceScaling
boolean
Default: true

If true, more importance is given to (in)conveniences for constraints with a higher importance.

{
  • "id": "string",
  • "importance": "NONE",
  • "constraintIds": [
    ],
  • "applyConstraintImportanceScaling": true
}

Constraints that support fairness

Implementing a fairness constraint

A fairness constraint must always apply to one or more other (non-fairness) constraints. In addition, since fairness constraints will compare the (in)conveniences that come from these constraints, the constraints must be of the same type to ensure that they are comparable.

The current list of constraint types that a fairness constraint can apply to is as follows:

Constraint typeFairness target impact
EmployeeAvailability (desired)Equal amount of desired hours for all employees
EmployeeAvailability (undesired)Equal amount of undesired hours for all employees
EmployeeUtilizationEqual fraction of ideal hours/ideal shifts for all employees
PeriodDistributionEqual amount of period distribution violations for all employees
PeriodicRestEqual amount of missing periodic rest minutes for all employees
RestBetweenShiftsEqual amount of missing rest minutes for all employees

Example - Fairness on Employee Availability

In order to make sure employees receive the same amount of (un)desired work, you can send in a fairness constraint that applies to a group of EmployeeAvailabilityConstraints.

Payload example

In the below example, the solver will try to assign the same amounts of undesired hours to employees 1 and 2. Notice that the undesired hours can come from different shifts - it might be that employee 1 does not want to work weekends, while employee 2 does not want to work on Mondays. The constraint will make sure that the total amount of undesired hours is the same for both employees.

{
"id": "fairness-undesired-availability",
"importance": "HIGH",
"constraintIds": [
"undesired-availability-employee-1",
"undesired-availability-employee-2"
],
"applyConstraintImportanceScaling": true
}

In addition, notice that the above fairness constraint applies constraint importance scaling. This means that if the undesired-availability-employee-1 constraint has a higher importance than the undesired-availability-employee-2 constraint, the solver will take this into account when comparing the (in)conveniences of the two constraints.


Example - Fairness on Employee Utilization

In general, when applying a fairness constraint it makes most sense to apply it to constraints that cover similar use cases. For example, on Employee Utilization it could make sense to have separate fairness constraints for employees' total utilization and employee's weekly utilization.

Payload example

In the below example, the solver will try to make sure that employees 1 and 2 receive the same share of their ideal total hours and the same share of their ideal weekly hours.

[
{
"id": "fairness-total-hours",
"importance": "VERY_HIGH",
"constraintIds": [
"total-utilization-employee-1",
"total-utilization-employee-2"
]
},
{
"id": "fairness-weekly-hours",
"importance": "HIGH",
"constraintIds": [
"weekly-utilization-employee-1",
"weekly-utilization-employee-2"
]
}
]
Payload example

It is also possible to apply a fairness constraint to just one constraint, but that will only have an effect if the constraint applies to multiple employees. The below example shows a constraint which will try to give all employees the same share of their weekly 40 hours.

{
"id": "fairness-weekly-hours",
"importance": "VERY_HIGH",
"constraintIds": ["utilization-40-hours-for-all-employees"]
}