Employee Utilization Constraint
This constraint can be for two purposes:
- Set an upper bound on the amount of hours worked by employees in some period.
- Set a lower bound on the amount of hours worked by employees in some period.
Upper bounds on the amount of hours are strictly enforced. An employee will never work more hours than specified in a constraint. Lower bounds are treated as targets. The solver will attempt to assign each employee at least as many hours as specified in a constraint. The importance of satisfying the minHours
targets is set by adjusting this constraint's weight
.
Specifying the scope of a constraint
By default, an employee utilization constraint applies to all employees. Specifying employeeIds
will make the constraint apply to these employees only. Each constraint is applied to every targeted employee individually: a constraint applied to 2 employees with a maxHours
of 30 will allow each of them to work 30 hours in total.
Similarly, the constraint applies to the entire scheduling period by default. Specifying scheduleDays
will make the constraint apply only to hours worked on those days. A constraint does not put any limits on hours worked outside of its scheduleDays
.
If shiftIds
is specified, the constraint will only limit the number of hours worked on any of the specified shifts. For example, if a constraint has a maxHours
of 10 and a shiftIds
targeting shift-1
, then the constraint only ensures employees work no more than 10 hours on shift-1
shifts. The number of hours worked on other shifts is not affected.
The following example shows an employee utilization constraint which has the following effects:
- In the first week, each employee is preferred to work at least 20 hours on
shift-1
andshift-2
shifts. - In the first week, each employee may work no more than 40 hours on
shift-1
andshift-2
shifts.
The constraint applies to all employees, since no employeeIds
were specified.
{
"employeeUtilizationConstraints": [
{
"id": "euc-1",
"minHours": 20,
"maxHours": 40,
"shiftIds": [
"1", "2"
],
"scheduleDays": {
"dayIndexes": [0, 1, 2, 3, 4]
}
}
]
},
Employee Utilization 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. |
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. |
roleIds | Array of strings unique List of role ids that the constraint should be applied to. If roles are specified, the constraint will only take into account work that is carried out using one of these roles. |
minHours | integer The minimum number of hours that should be worked by employees on shifts that match the constraint in each period. This is treated as a target - it is not guaranteed that the number of hours worked will be greater than this value. |
maxHours | integer The maximum number of hours that should be worked by employees on shifts that match the constraint in each period. This is treated as a hard limit - the number of hours worked will never exceed this value. |
minShifts | integer The minimum number of shifts that match the constraint that an employee should work in each period. This is treated as a target - it is not guaranteed that the number of shifts worked will be greater than this value. |
maxShifts | integer The maximum number of shifts that match the constraint that an employee should work in each period. This is treated as a hard limit - the number of shifts worked will never exceed this value. |
object Settings to determine if and how bonus time rules affect the constraint. | |
object Settings to determine if and how default time rules affect the constraint. | |
object (periods) = 1 properties The periods in which the constraint should be applied. The minHours and maxHours will be applied to each period separately. | |
object (scheduleDays) non-empty Deprecated DEPRECATED - Use periods instead. |
{- "id": "string",
- "weight": {
- "example_1": {
- "value": 0,
- "summary": "The constraint is not taken into account when solving the schedule as it has weight 0."
}, - "example_2": {
- "value": 100,
- "summary": "Solver will try its best to satisfy the constraint as it has weight 100."
}
}, - "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."
}
}, - "roleIds": [
- "string"
], - "minHours": 0,
- "maxHours": 0,
- "minShifts": 0,
- "maxShifts": 0,
- "bonusTime": {
- "includeBonusHours": true,
- "averageHoursThreshold": 0,
- "averageHoursCap": 0
}, - "defaultTime": {
- "includeDefaultHours": true,
- "minOverlapHours": 0
}, - "periods": {
- "customDefinitions": [
- {
- "type": "BASIC",
- "startDay": {
- "dayIndex": {
- "example_1": {
- "value": 9,
- "summary": "The 10th day of the planning horizon."
}
}
}, - "endDay": {
- "dayIndex": {
- "example_1": {
- "value": 9,
- "summary": "The 10th day of the planning horizon."
}
}
}, - "startTime": "14:15:22Z",
- "endTime": "14:15:22Z",
- "applyTimeToAllDays": false
}
]
}, - "scheduleDays": {
- "weekDays": {
- "example_1": {
- "value": [
- 1
], - "summary": "All Mondays in the planning horizon."
}
}, - "dayIndexes": {
- "example_1": {
- "value": [
- 0,
- 1,
- 2,
- 3
], - "summary": "First four days of the planning horizon."
}
}, - "dates": {
- "example_1": {
- "value": [
- "2023-12-24",
- "2023-12-25"
], - "summary": "The 24th and 25th of December 2023."
}
}
}
}