Weekend Distribution Constraint
Soft constraint
The Weekend Distribution Constraint is being deprecated in favour of the PeriodicDistributionConstraint. You should no longer build a new integration with this constraint.
Set rules for maximum working weekends or minimum non-working weekends surrounding a work weekend.
The minimum surrounding weekends is a count of weekends before or after a working weekend which the employee must have off.
The constraint can also be configured to only apply to particular workTypes
.
The constraint is specified with a weight, and for this weight, particular logic applies during solving.
Weight | Logic |
---|---|
0-89 | The constraint is scored according to the weight - the heigher the weight, the worse it is to violate the constraint, but the solver will do it if it is necessary. |
90-99 | The constraint is still scored according to weight, but in the first round of solving, maximum weekends (free neighbours/maxWeekend properties) cannot be violated. In subsequent rounds, that constraint is relaxed (not applying, and may be violated). |
100 | The constraint is scored according to weight, and the solver will not violate the constraint. |
See the payload example below to get started and check out the API reference for full configurability of the constraint.
The following defines that employee 2 should work a maximum of two weekends of work types 1 or 2.
{
"weekendDistributionConstraints": [
{
"id": "wdc-123",
"weight": 100,
"maxWorkingWeekends": 2,
"workTypeIds": ["1", "2"],
"employeeIds": ["2"]
}
]
}
Weekend Distribution 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. | |
maxWorkingWeekends | integer >= 0 Defines the number of weekends in the scheduling period that employee can work. The constraint is triggered if the number of working weekends exceeds this value. 0 means that employee can't work any weekend in scheduling period. Will default to the total number of weekends in the scheduling period if not specified. |
minSurroundingFreeWeekends | integer >= 0 Default: 0 Defines the smallest number of free weekends employee should have before and after working on a weekend. 0 means that employee(s) can work on a weekend even when the previous and/or the next weekend is not free. |
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
}, - "maxWorkingWeekends": [
- {
- "example_1": {
- "value": 2,
- "summary": "Employee can work on 2 weekends in scheduling period."
}
}, - {
- "example_2": {
- "value": 0,
- "summary": "Employee can't work any weekend in scheduling period."
}
}
], - "minSurroundingFreeWeekends": [
- {
- "example_1": {
- "value": 1,
- "summary": "Employee can work on the weekend only if he has at least one free weekend before and after the working weekend."
}
}, - {
- "example_2": {
- "value": 0,
- "summary": "Employee can work on the weekend even when the previous or next weekend is not free."
}
}, - {
- "example_3": {
- "value": 2,
- "summary": "Employee can work on the weekend only if he has at least two free weekends before and after the working weekend."
}
}
], - "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."
}
}
}