Skip to main content

Weekend Distribution Constraint

Soft constraint

Deprecated 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.

WeightLogic
0-89The 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-99The 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).
100The 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.

Payload example

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": {
    },
  • "fairness": {
    },
  • "maxWorkingWeekends": [
    ],
  • "minSurroundingFreeWeekends": [
    ],
  • "workTypeIds": {
    },
  • "employeeIds": {
    }
}