Skip to main content

Working Time Preference Constraint

Soft constraint

Define intervals when employees prefer to work using particular weekdays, dates or day indices, and start and end time stamps.

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 all employees prefers to work between 08:00 and 16:00 during the weekdays. This constraint should also apply fairly to all employees, adjusted by their FTE working hours.

{
"workingTimePreferenceConstraints": [
{
"id": "wtpc-123",
"weight": 100,
"fairness": {
"fairnessWeight": 100,
"fteAdjustedFairness": true
},
"intervals": [
{
"scheduleDays": {
"weekDays": [ 1, 2, 3, 4, 5 ]
},
"startTime": "08:00",
"endTime": "16:00"
}
]
}
]
}
Working Time Preference 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 (constraintWeightFullRange) [ -100 .. 100 ]

Describes how much the constraint is taken into account when solving the schedule. Also allows negative weights indicating that constraint should be violated instead of satisfied. For example, if some pattern should be avoided instead of enforced. The higher the absolute value of the weight, the more solver will penalize the constraint violation. The 100 or -100 makes it a hard constraint. The weight value is relative to other constraints.

object (constraintFairness)

Describes how much fairness is taken into account for the constraint.

required
Array of objects (workingTimePreferenceInterval)
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.

{
  • "example_1": {
    },
  • "summary": "This example defines a working time preference constraint which is applied to employees with ids 1, 2 and 3, and defines two intervals. Both intervals have work type id 0. The first interval is from Monday to Friday between 08:00 and 16:00, and the second interval is from Saturday to Sunday between 08:00 and 16:00. The first interval is weighted as 100 while the second interval is weighted as 50, which means that the preferences are considered less important during the weekend."
}