Fairness
Drivers like to know they receive a fair share of the workload, and that one driver isn’t unfairly assigned more or less work than other drivers. Uneven workloads are a common cause of burnout and turnover, so balancing them fairly helps protect morale and retention.
The Balance time utilization soft constraint distributes the workload fairly across drivers.
It uses the standard Timefold approach to fairness described in the solver documentation.
This guide explains fairness with the following:
1. Balance time utilization
By default, the Balance time utilization constraint is disabled.
To activate the constraint, set balanceTimeUtilizationWeight in the model configuration:
{
"config": {
"model": {
"overrides": {
"balanceTimeUtilizationWeight": 1
}
}
}
}
The constraint compares the time utilization of all drivers. The time utilization of a driver is their assigned workload divided by their availability:
-
The assigned workload of a driver shift starts at the shift’s
minFirstStopArrivalTime, or at itsminStartTimeifminFirstStopArrivalTimeisn’t set. It ends when the driver arrives at the shift’sendLocationafter the last stop, or at thestartLocationif the shift has noendLocation. The assigned workload includes all travel times, service times, waiting times, and break times in between, including breaks taken after the last stop. A driver shift without stops has no workload. -
The availability of a driver shift starts at the same time as the workload. The availability ends at the shift’s
maxLastStopDepartureTime, or at themaxEndTimeifmaxLastStopDepartureTimeisn’t set.
The workload and availability of all shifts of a driver are added up before the time utilization is calculated.
The time utilization can exceed 100%, for example when the travel time from the last stop to the end location goes past maxLastStopDepartureTime, or when a driver works overtime.
When a shift has a minFirstStopArrivalTime, the travel time from the start location to the first stop before that time isn’t part of the workload.
|
The constraint adds a soft penalty to the dataset score based on how unevenly the time utilization is distributed across drivers.
The penalty is the unfairness of the drivers' time utilizations multiplied by 1000 and rounded to a whole number.
The unfairness is the square root of the sum of the squared differences between each driver’s time utilization and the average time utilization.
A perfectly balanced workload has a penalty of 0.
The lower the penalty, the fairer the solution.
The model prefers the route plan with the best score.
For example, Ann and Beth both have an eight-hour shift starting from and ending at the same depot, and there are two stops to assign. Each stop takes one hour, including the travel time to and from the depot.
-
If both stops are assigned to Ann, her time utilization is 25% (two of eight hours) and Beth’s is 0%. The unfairness is 0.177, so the penalty is
177. -
If each driver gets one stop, both have a time utilization of 12.5%, so the penalty is
0.
The model prefers assigning one stop to each driver, unless that adds more than 177 seconds of travel time.
With only one stop, assigning the stop to either driver results in the same penalty, so other constraints, such as Minimize travel time, decide who gets the stop.
|
Soft constraints compete with each other as the solver optimizes the final solution. That means this constraint may leave jobs unassigned in favor of jobs with different soft constraints. Every soft constraint has a weight that can be configured to change the relative importance of the constraint compared to other constraints. Learn about constraint weights. |
With a weight of 1, the penalty of the Balance time utilization constraint is small compared to the penalty of the Minimize travel time constraint, which is expressed in seconds.
In the example above, a 25% difference in time utilization between two drivers results in a penalty equal to 177 seconds of travel time.
A higher weight pushes the model toward solutions with a more even workload, even if that means more travel time.
A lower weight does the opposite.
2. Historical data
By default, the constraint only considers the workload and availability in the current dataset.
Historical data that includes both the driver’s hours previously worked and their historical availability can also be considered. This helps ensure fairness to drivers not just in the current planning window, but over an extended period of time.
| Provide historical data for all drivers to avoid skewing the results of the solution. When a driver has no historical data, for instance a new driver, you can provide an average from the other drivers for the new driver to maintain the fairness of the solution. |
Add the historical data to drivers in the dataset:
{
"drivers": [
{
"id": "Ann",
"shifts": [
{
"id": "Ann-2027-02-01",
"startLocation": [33.68786, -84.18487],
"minStartTime": "2027-02-01T09:00:00Z",
"maxEndTime": "2027-02-01T17:00:00Z"
}
],
"historicalTimeUtilized": "PT2280M",
"historicalTimeCapacity": "PT2400M"
},
{
"id": "Beth",
"shifts": [
{
"id": "Beth-2027-02-01",
"startLocation": [33.68786, -84.18487],
"minStartTime": "2027-02-01T09:00:00Z",
"maxEndTime": "2027-02-01T17:00:00Z"
}
],
"historicalTimeUtilized": "PT1000M",
"historicalTimeCapacity": "PT2400M"
}
]
}
-
historicalTimeUtilizedis the amount of time the driver worked in the time period being considered. -
historicalTimeCapacityis the driver’s availability in the time period being considered.
In the example above, Ann and Beth both had an availability of 2400 minutes in the previous time period.
Ann’s historicalTimeUtilized is 2280 minutes, and Beth’s historicalTimeUtilized is 1000 minutes.
Ann’s historical time utilization is 95% and Beth’s is about 42%, so the model prefers assigning the stops in this dataset to Beth.
The historical workload and availability are added to the workload and availability of the driver’s shifts in the dataset before the time utilization is calculated.
When adding historicalTimeUtilized and historicalTimeCapacity, use data from the same time period for all drivers, otherwise the fairness calculations will be incorrect.
If they aren’t provided, a default duration of 0 is used for both fields.
|
Next
-
See the full API spec, try the online API, or start a free trial.
-
Learn about Shift hours and overtime.