Job priorities
There are two types of job priorities:
- assignment priority: the solver tries to avoid such jobs to be unassigned by maximizing their total value. Assignment priority is modeled by value property on the job and used within the maximize-value objective.
- order priority: the solver tries to assign such jobs prior others, close to beginning of the route. Order priority is modeled by order property on the job.
Basic job value example
The example below demonstrates how to use assignment priority by defining value on the jobs. The source problem has a single vehicle with limited capacity, therefore one job has to be unassigned. The solver is forced to skip the cheapest one as it has no value associated with it.
Please note, that there is no need to redefine objective to include maximize-value
one as it will be added automatically
on top of default.
Problem
{
"plan": {
"jobs": [
{
"id": "job1",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.52599,
"lng": 13.45413
},
"duration": 300
}
],
"demand": [
1
]
}
],
"value": 50
},
{
"id": "job2",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5225,
"lng": 13.4095
},
"duration": 240
}
],
"demand": [
1
]
}
],
"value": 100
},
{
"id": "job3",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5320,
"lng": 13.3950
},
"duration": 60
}
],
"demand": [
1
]
}
]
}
]
},
"fleet": {
"vehicles": [
{
"typeId": "vehicle",
"vehicleIds": [
"vehicle_1"
],
"profile": {
"matrix": "normal_car"
},
"costs": {
"fixed": 22.0,
"distance": 0.0002,
"time": 0.005
},
"shifts": [
{
"start": {
"earliest": "2019-07-04T09:00:00Z",
"location": {
"lat": 52.5316,
"lng": 13.3884
}
}
}
],
"capacity": [
2
]
}
],
"profiles": [
{
"name": "normal_car"
}
]
}
}
Solution
{
"statistic": {
"cost": 28.060000000000002,
"distance": 4800,
"duration": 1020,
"times": {
"driving": 480,
"serving": 540,
"waiting": 0,
"break": 0
}
},
"tours": [
{
"vehicleId": "vehicle_1",
"typeId": "vehicle",
"shiftIndex": 0,
"stops": [
{
"location": {
"lat": 52.5316,
"lng": 13.3884
},
"time": {
"arrival": "2019-07-04T09:00:00Z",
"departure": "2019-07-04T09:00:00Z"
},
"distance": 0,
"load": [
2
],
"activities": [
{
"jobId": "departure",
"type": "departure"
}
]
},
{
"location": {
"lat": 52.5225,
"lng": 13.4095
},
"time": {
"arrival": "2019-07-04T09:02:55Z",
"departure": "2019-07-04T09:06:55Z"
},
"distance": 1752,
"load": [
1
],
"activities": [
{
"jobId": "job2",
"type": "delivery"
}
]
},
{
"location": {
"lat": 52.52599,
"lng": 13.45413
},
"time": {
"arrival": "2019-07-04T09:12:00Z",
"departure": "2019-07-04T09:17:00Z"
},
"distance": 4800,
"load": [
0
],
"activities": [
{
"jobId": "job1",
"type": "delivery"
}
]
}
],
"statistic": {
"cost": 28.060000000000002,
"distance": 4800,
"duration": 1020,
"times": {
"driving": 480,
"serving": 540,
"waiting": 0,
"break": 0
}
}
}
],
"unassigned": [
{
"jobId": "job3",
"reasons": [
{
"code": "CAPACITY_CONSTRAINT",
"description": "does not fit into any vehicle due to capacity"
}
]
}
]
}
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"stop_idx": "0",
"arrival": "2019-07-04T09:00:00Z",
"marker-symbol": "warehouse",
"marker-size": "medium",
"tour_idx": "0",
"departure": "2019-07-04T09:00:00Z",
"marker-color": "#e6194b",
"jobs_ids": "departure"
},
"geometry": {
"type": "Point",
"coordinates": [
13.3884,
52.5316
]
}
},
{
"type": "Feature",
"properties": {
"tour_idx": "0",
"stop_idx": "1",
"departure": "2019-07-04T09:06:55Z",
"marker-size": "medium",
"jobs_ids": "job2",
"marker-color": "#e6194b",
"marker-symbol": "marker",
"arrival": "2019-07-04T09:02:55Z"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4095,
52.5225
]
}
},
{
"type": "Feature",
"properties": {
"marker-color": "#e6194b",
"departure": "2019-07-04T09:17:00Z",
"marker-size": "medium",
"arrival": "2019-07-04T09:12:00Z",
"marker-symbol": "marker",
"tour_idx": "0",
"stop_idx": "2",
"jobs_ids": "job1"
},
"geometry": {
"type": "Point",
"coordinates": [
13.45413,
52.52599
]
}
},
{
"type": "Feature",
"properties": {
"vehicle_id": "vehicle_1",
"activities": "3",
"departure": "2019-07-04T09:00:00Z",
"distance": "4800",
"stroke-width": "4",
"arrival": "2019-07-04T09:12:00Z",
"shift_idx": "0",
"tour_idx": "0",
"stroke": "#e6194b"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.3884,
52.5316
],
[
13.4095,
52.5225
],
[
13.45413,
52.52599
]
]
}
},
{
"type": "Feature",
"properties": {
"marker-symbol": "roadblock",
"marker-color": "#e6194b",
"reasons": "CAPACITY_CONSTRAINT:does not fit into any vehicle due to capacity",
"job_id": "job3",
"marker-size": "medium"
},
"geometry": {
"type": "Point",
"coordinates": [
13.395,
52.532
]
}
}
]
}