Task priorities¶
Sometimes there are more tasks than your fleet can handle. When not all tasks can be planned, priorities let you indicate which ones matter most. Each task has a priority value between 0 and 100, with a default of 50. Higher-priority tasks are preferred over lower-priority ones when not all tasks fit due to constraints like capacity or time windows.
Note
Priorities only matter when not all tasks can be planned. Otherwise, FastVRP finds solutions that minimise operational cost (see Cost optimisation).
Example¶
Consider five tasks at well-known spots in Amsterdam, each having a different priority:
- Vondelpark (100)
- Rijksmuseum (75)
- Dam Square (50)
- Van Gogh Museum (50)
- NEMO Science Museum (50)
The vehicle starts and returns to a depot at Central Station, but cannot visit more than three tasks. We model this by setting a capacity of 3 with a delivery of 1 per task.
{
"locations": [
{
"id": "loc-Central Station",
"latitude": 52.3791,
"longitude": 4.9003
},
{
"id": "loc-Vondelpark",
"latitude": 52.3580,
"longitude": 4.8686
},
{
"id": "loc-Rijksmuseum",
"latitude": 52.3600,
"longitude": 4.8852
},
{
"id": "loc-Dam Square",
"latitude": 52.3731,
"longitude": 4.8932
},
{
"id": "loc-Van Gogh Museum",
"latitude": 52.3584,
"longitude": 4.8811
},
{
"id": "loc-NEMO Science Museum",
"latitude": 52.3742,
"longitude": 4.9123
}
],
"tasks": [
{
"id": "task-Vondelpark",
"location": "loc-Vondelpark",
"delivery": [1],
"priority": 100
},
{
"id": "task-Rijksmuseum",
"location": "loc-Rijksmuseum",
"delivery": [1],
"priority": 75
},
{
"id": "task-Dam Square",
"location": "loc-Dam Square",
"delivery": [1],
"priority": 50
},
{
"id": "task-Van Gogh Museum",
"location": "loc-Van Gogh Museum",
"delivery": [1],
"priority": 50
},
{
"id": "task-NEMO Science Museum",
"location": "loc-NEMO Science Museum",
"delivery": [1],
"priority": 50
}
],
"depots": [
{
"id": "depot-Central Station",
"location": "loc-Central Station"
}
],
"vehicle_types": [
{
"id": "vehicle_type",
"start_depot": "depot-Central Station",
"end_depot": "depot-Central Station",
"num_available": 1,
"capacity": [3],
"shift": {
"earliest_start": "2025-01-01T08:00:00",
"latest_end": "2025-01-01T18:00:00"
}
}
],
"options": {
"stop": {
"seconds": 1,
"type": "max_runtime"
}
}
}
The solver plans the two highest-priority tasks, Vondelpark and Rijksmuseum, and then chooses to select Van Gogh Museum among the other tasks of equal priority, because it's the closest to Vondelpark and Rijksmuseum.
The solution summary shows num_planned and num_unplanned counts, and the unplanned list contains the task IDs that could not be served.
{
"summary": {
"total_cost": "0.57",
"distance_cost": "0.00",
"duration_cost": "0.57",
"fixed_vehicle_cost": "0.00",
"distance": 12860,
"duration": "PT2052S",
"travel_duration": "PT2052S",
"service_duration": "P0D",
"wait_duration": "P0D",
"num_planned": 3,
"num_unplanned": 2,
"num_routes": 1,
"load_duration": "P0D",
"overtime": "P0D"
},
"routes": ...,
"unplanned": [
"task-Dam Square",
"task-NEMO Science Museum"
],
"job_id": ...,
"technical": ...
}
Conclusion¶
In this tutorial you learned how task priorities influence which tasks get planned when not all tasks can be served. This is useful for ensuring that your most important deliveries are handled first.