Skip to main content

Prioritization Constraint

Soft constraint *

* with possibility for hard constraint

Takes prioritizations of employees into account during scheduling. The constraint can be used in one of two ways: the prioritization of employees can be configured for the demands or for the shifts.

  • Demands: For every demand, it is possible to provide a prioritization of employees. This will have the effect that, given a demand, an employee with a higher priority will be more likely to cover that demand than an employee with a lower priority.

  • Shifts: For every shift, it is possible to provide a prioritization of employees. This will have the effect that, given a shift, an employee with a higher priority will be more likely to be scheduled for that shift than an employee with a lower priority.\

Warning

It is recommended only to use Prioritization for shifts when working with ShiftDemands. When used with TimeDemand, it can happen that shifts are planned that do not cover demands fully.

Priority scores

A prioritization of employees for a demand/shift is defined using priority scores. The priority scores can be numbers between 0 and 100, where 100 is the highest priority. Priority scores should be assigned to employees, such that more preferred employees are given higher scores than less preferred employees.
In addition, a priority score of -1 can be used to denote that an employee can never be scheduled for a demand/shift. Priority scores of -1 are therefore hard constraints.

Priority score matrix

In the payload, these employee prioritizations for demands/shifts have to be provided in a matrix. This matrix has employees in its rows and demands/shifts in its columns. Priority scores are the elements of the matrix.

In order to allow for more compact matrices, a group of demands/shifts which have the same prioritization of employees can be sent in as one column of the matrix. The columns of the matrix therefore defined as groups of demands/shifts. If there are demands/shifts that cannot be grouped, they have to be sent in as a group of one.
The same goes for employees; employees that are prioritized in the exact same way for all shifts/demands can be sent in as one group in one row of the matrix.

Payload

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 prioritization based on whether employees have a driver's licence or not. Employees with a driver's licence are prioritized for delivery demands, and employees without a driver's licence are prioritized for sorting demands. The employees without a driver's licence cannot be scheduled for delivery demands.

{
"prioritizationConstraints": [
{
"id": "pc-123",
"weight": 100,
"employeeGroups": [
{
"employeeIds": ["1", "2", "3"],
"employeeGroupLabel": "drivers_licence_group"
},
{
"employeeIds": ["4", "5"],
"employeeGroupLabel": "not_drivers_licence_group"
}
],
"demandGroups": [
{
"demandIds": ["demand_1", "demand_2"],
"demandGroupLabel": "delivery"
},
{
"demandIds": ["demand_3"],
"demandGroupLabel": "sorting"
}
],
"scoreMatrix": [
[100, 50],
[-1, 100]
]
}
]
}
Prioritization Constraint in the request payload
id
required
string (constraintId)

The id of the constraint should be UNIQUE in the context of constraint type.

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

defaultScore
integer (priorityScore) [ -1 .. 100 ]

A score of the priority of an employee covering a demand. The normal score can range from 0 to 100. A score of -1 can be used to denote that the employee can not cover (a part of) the demand under any circumstances. If no defaultScore is defined, a default score of 0 will be used.

required
Array of objects non-empty

Groupings of employees that have the same priority score for all demands/shifts. If no employees share the same priority scores, then the employees should be in groups of size one. An employee can either be in one group or in no group. It cannot be in several groups. Employees that aren't in any group will be given the default score for all demands/shifts.

Array of objects non-empty

Used when prioritization is defined for employees and timeSlots. This array contains groups of timeSlots for which the prioritization of employees is the same. If all timeSlots are differently prioritized, then each timeSlotGroup will be of size one. A timeSlot can either be in one group or in no group. It cannot be in several groups. timeSlots that aren't in any group will be given the default score for all employees.

Array of objects non-empty

Used when prioritization is defined for employees and shifts. This array contains groups of shifts for which the prioritization of employees is the same. If all shifts are differently prioritized, then each shiftGroup will be of size one. A shift can either be in one group or in no group. It cannot be in several groups. Shifts that aren't in any group will be given the default score for all employees.

scoreMatrix
required
Array of integers (priorityScore) non-empty [ items non-empty [ items [ -1 .. 100 ] ] ]

Matrix with rows of employee groups and columns of demand or shift groups. The order of these groups in the rows and columns is the same as the order of the groups in employeeGroups and demandGroups or shiftGroups. The matrix contains the priority scores that employees in the groups have for all demands/shifts in the groups. The format of this matrix is an array of arrays. The "outer" array contains the rows of the matrix. One "inner" array therefore contains all priority scores of one employee group.

{
  • "id": "string",
  • "weight": {
    },
  • "defaultScore": 0,
  • "employeeGroups": [
    ],
  • "timeSlotGroups": [
    ],
  • "shiftGroups": [
    ],
  • "scoreMatrix": [
    ]
}