New Working Day Constraint
Soft constraint
The New Working Day Constraint is being deprecated in favour of a new constraint. The goal is to merge it with ExistingWorkingDayChangeConstraint and to resolve outstanding issues with this constraint. It is not suggested at this time to integrate with it, and instead to wait for the new constraint to be released.
When there are non-locked pre-assigned shifts, this constraint is used to avoid changing the working days of these shifts.
Changing the shift itself is not penalized, as long as the working day is not changed.
One can specify which workTypeIds
and scheduleDays
this constraint should affect.
See the payload example below to get started and check out the API reference for full configurability of the constraint.
The following defines a constraint that penalizes changing the working day of pre-assigned shifts of work type ID 1 on Sundays.
{
"newWorkingDayConstraints": [
{
"id": "nwdc-123",
"weight": 100,
"scheduleDays": {
"weekDays": [7]
},
"workTypeIds": ["1"]
}
]
}
New Working Day 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. |
object (constraintFairness) Describes how much fairness is taken into account for the constraint. | |
object (scheduleDays) non-empty The constraint is only applied to the days specified. If no days are specified the constraint is applied to all days. If a specific day is specified, the solver will try to avoid adding a shift to that day. | |
workTypeIds | Array of strings (constraintWorkTypeIds) unique List of workType IDs for which the constraint applies. The workTypeIds should be present in workType section. If work type ids are not specified, the constraint will be applied to all work types. |
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. |
{- "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."
}
}, - "fairness": {
- "fairnessWeight": {
- "example_1": {
- "value": 0,
- "summary": "The fairness is not taken into account when solving the schedule."
}, - "example_2": {
- "value": 100,
- "summary": "Solver will try its best to make the constraint as fair as possible."
}
}, - "fteAdjustedFairness": 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."
}
}
}, - "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."
}
}, - "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."
}
}
}