Vicinity clustering with return
This examples demonstrates a return
type of visit: after each job visit, the driver has to return to the stop point.
Check previous example for other details.
Problem
{
"plan": {
"jobs": [
{
"id": "job1",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5253538,
"lng": 13.4525549
},
"duration": 300
}
],
"demand": [
1
]
}
]
},
{
"id": "job2",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5254256,
"lng": 13.4527159
},
"duration": 300
}
],
"demand": [
1
]
}
]
},
{
"id": "job3",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5255366,
"lng": 13.4530162
},
"duration": 300
}
],
"demand": [
1
]
}
]
},
{
"id": "job4",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5253342,
"lng": 13.4533489
},
"duration": 300
}
],
"demand": [
1
]
}
]
},
{
"id": "job5",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5239243,
"lng": 13.4545827
},
"duration": 300
}
],
"demand": [
1
]
}
]
},
{
"id": "job6",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5223315,
"lng": 13.4555697
},
"duration": 300
}
],
"demand": [
1
]
}
]
},
{
"id": "job7",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5240157,
"lng": 13.4572220
},
"duration": 300
}
],
"demand": [
1
]
}
]
},
{
"id": "job8",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5243028,
"lng": 13.45952868
},
"duration": 300
}
],
"demand": [
1
]
}
]
},
{
"id": "job9",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5241593,
"lng": 13.4589815
},
"duration": 300
}
],
"demand": [
1
]
}
]
},
{
"id": "job10",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5239896,
"lng": 13.4600115
},
"duration": 300
}
],
"demand": [
1
]
}
]
},
{
"id": "job11",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5250209,
"lng": 13.4567821
},
"duration": 300
}
],
"demand": [
1
]
}
]
},
{
"id": "job12",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5223184,
"lng": 13.4551942
},
"duration": 300
}
],
"demand": [
1
]
}
]
}
],
"clustering": {
"type": "vicinity",
"profile": {
"matrix": "car",
"scale": 10
},
"threshold": {
"duration": 120,
"distance": 100
},
"visiting": "return",
"serving": {
"type": "fixed",
"value": 180,
"parking": 120
}
}
},
"fleet": {
"vehicles": [
{
"typeId": "vehicle",
"vehicleIds": [
"vehicle_1"
],
"profile": {
"matrix": "car"
},
"costs": {
"fixed": 25,
"distance": 0.0001,
"time": 0.005
},
"shifts": [
{
"start": {
"earliest": "2020-05-01T09:00:00.00Z",
"location": {
"lat": 52.5262872,
"lng": 13.4532952
}
}
}
],
"capacity": [
20
]
}
],
"profiles": [
{
"name": "car",
"type": "car"
}
]
}
}
Solution
{
"statistic": {
"cost": 42.5984,
"distance": 984,
"duration": 3500,
"times": {
"driving": 100,
"serving": 2520,
"waiting": 0,
"break": 0,
"commuting": 520,
"parking": 360
}
},
"tours": [
{
"vehicleId": "vehicle_1",
"typeId": "vehicle",
"shiftIndex": 0,
"stops": [
{
"location": {
"lat": 52.5262872,
"lng": 13.4532952
},
"time": {
"arrival": "2020-05-01T09:00:00Z",
"departure": "2020-05-01T09:00:00Z"
},
"distance": 0,
"load": [
12
],
"activities": [
{
"jobId": "departure",
"type": "departure"
}
]
},
{
"location": {
"lat": 52.5253342,
"lng": 13.4533489
},
"time": {
"arrival": "2020-05-01T09:00:11Z",
"departure": "2020-05-01T09:18:11Z"
},
"distance": 106,
"load": [
8
],
"parking": {
"start": "2020-05-01T09:00:11Z",
"end": "2020-05-01T09:02:11Z"
},
"activities": [
{
"jobId": "job4",
"type": "delivery",
"location": {
"lat": 52.5253342,
"lng": 13.4533489
},
"time": {
"start": "2020-05-01T09:02:11Z",
"end": "2020-05-01T09:05:11Z"
},
"commute": {}
},
{
"jobId": "job3",
"type": "delivery",
"location": {
"lat": 52.5255366,
"lng": 13.4530162
},
"time": {
"start": "2020-05-01T09:05:41Z",
"end": "2020-05-01T09:08:41Z"
},
"commute": {
"forward": {
"location": {
"lat": 52.5253342,
"lng": 13.4533489
},
"distance": 32.0,
"time": {
"start": "2020-05-01T09:05:11Z",
"end": "2020-05-01T09:05:41Z"
}
},
"backward": {
"location": {
"lat": 52.5253342,
"lng": 13.4533489
},
"distance": 32.0,
"time": {
"start": "2020-05-01T09:08:41Z",
"end": "2020-05-01T09:09:11Z"
}
}
}
},
{
"jobId": "job2",
"type": "delivery",
"location": {
"lat": 52.5254256,
"lng": 13.4527159
},
"time": {
"start": "2020-05-01T09:09:51Z",
"end": "2020-05-01T09:12:51Z"
},
"commute": {
"forward": {
"location": {
"lat": 52.5253342,
"lng": 13.4533489
},
"distance": 44.0,
"time": {
"start": "2020-05-01T09:09:11Z",
"end": "2020-05-01T09:09:51Z"
}
},
"backward": {
"location": {
"lat": 52.5253342,
"lng": 13.4533489
},
"distance": 44.0,
"time": {
"start": "2020-05-01T09:12:51Z",
"end": "2020-05-01T09:13:31Z"
}
}
}
},
{
"jobId": "job1",
"type": "delivery",
"location": {
"lat": 52.5253538,
"lng": 13.4525549
},
"time": {
"start": "2020-05-01T09:14:21Z",
"end": "2020-05-01T09:17:21Z"
},
"commute": {
"forward": {
"location": {
"lat": 52.5253342,
"lng": 13.4533489
},
"distance": 54.0,
"time": {
"start": "2020-05-01T09:13:31Z",
"end": "2020-05-01T09:14:21Z"
}
},
"backward": {
"location": {
"lat": 52.5253342,
"lng": 13.4533489
},
"distance": 54.0,
"time": {
"start": "2020-05-01T09:17:21Z",
"end": "2020-05-01T09:18:11Z"
}
}
}
}
]
},
{
"location": {
"lat": 52.5239243,
"lng": 13.4545827
},
"time": {
"arrival": "2020-05-01T09:18:29Z",
"departure": "2020-05-01T09:23:29Z"
},
"distance": 284,
"load": [
7
],
"activities": [
{
"jobId": "job5",
"type": "delivery"
}
]
},
{
"location": {
"lat": 52.5223315,
"lng": 13.4555697
},
"time": {
"arrival": "2020-05-01T09:23:48Z",
"departure": "2020-05-01T09:32:48Z"
},
"distance": 473,
"load": [
5
],
"parking": {
"start": "2020-05-01T09:23:48Z",
"end": "2020-05-01T09:25:48Z"
},
"activities": [
{
"jobId": "job6",
"type": "delivery",
"location": {
"lat": 52.5223315,
"lng": 13.4555697
},
"time": {
"start": "2020-05-01T09:25:48Z",
"end": "2020-05-01T09:28:48Z"
},
"commute": {}
},
{
"jobId": "job12",
"type": "delivery",
"location": {
"lat": 52.5223184,
"lng": 13.4551942
},
"time": {
"start": "2020-05-01T09:29:18Z",
"end": "2020-05-01T09:32:18Z"
},
"commute": {
"forward": {
"location": {
"lat": 52.5223315,
"lng": 13.4555697
},
"distance": 25.0,
"time": {
"start": "2020-05-01T09:28:48Z",
"end": "2020-05-01T09:29:18Z"
}
},
"backward": {
"location": {
"lat": 52.5223315,
"lng": 13.4555697
},
"distance": 25.0,
"time": {
"start": "2020-05-01T09:32:18Z",
"end": "2020-05-01T09:32:48Z"
}
}
}
}
]
},
{
"location": {
"lat": 52.5240157,
"lng": 13.457222
},
"time": {
"arrival": "2020-05-01T09:33:10Z",
"departure": "2020-05-01T09:38:10Z"
},
"distance": 691,
"load": [
4
],
"activities": [
{
"jobId": "job7",
"type": "delivery"
}
]
},
{
"location": {
"lat": 52.5250209,
"lng": 13.4567821
},
"time": {
"arrival": "2020-05-01T09:38:22Z",
"departure": "2020-05-01T09:43:22Z"
},
"distance": 807,
"load": [
3
],
"activities": [
{
"jobId": "job11",
"type": "delivery"
}
]
},
{
"location": {
"lat": 52.5241593,
"lng": 13.4589815
},
"time": {
"arrival": "2020-05-01T09:43:40Z",
"departure": "2020-05-01T09:58:20Z"
},
"distance": 984,
"load": [
0
],
"parking": {
"start": "2020-05-01T09:43:40Z",
"end": "2020-05-01T09:45:40Z"
},
"activities": [
{
"jobId": "job9",
"type": "delivery",
"location": {
"lat": 52.5241593,
"lng": 13.4589815
},
"time": {
"start": "2020-05-01T09:45:40Z",
"end": "2020-05-01T09:48:40Z"
},
"commute": {}
},
{
"jobId": "job8",
"type": "delivery",
"location": {
"lat": 52.5243028,
"lng": 13.45952868
},
"time": {
"start": "2020-05-01T09:49:20Z",
"end": "2020-05-01T09:52:20Z"
},
"commute": {
"forward": {
"location": {
"lat": 52.5241593,
"lng": 13.4589815
},
"distance": 40.0,
"time": {
"start": "2020-05-01T09:48:40Z",
"end": "2020-05-01T09:49:20Z"
}
},
"backward": {
"location": {
"lat": 52.5241593,
"lng": 13.4589815
},
"distance": 40.0,
"time": {
"start": "2020-05-01T09:52:20Z",
"end": "2020-05-01T09:53:00Z"
}
}
}
},
{
"jobId": "job10",
"type": "delivery",
"location": {
"lat": 52.5239896,
"lng": 13.4600115
},
"time": {
"start": "2020-05-01T09:54:10Z",
"end": "2020-05-01T09:57:10Z"
},
"commute": {
"forward": {
"location": {
"lat": 52.5241593,
"lng": 13.4589815
},
"distance": 72.0,
"time": {
"start": "2020-05-01T09:53:00Z",
"end": "2020-05-01T09:54:10Z"
}
},
"backward": {
"location": {
"lat": 52.5241593,
"lng": 13.4589815
},
"distance": 72.0,
"time": {
"start": "2020-05-01T09:57:10Z",
"end": "2020-05-01T09:58:20Z"
}
}
}
}
]
}
],
"statistic": {
"cost": 42.5984,
"distance": 984,
"duration": 3500,
"times": {
"driving": 100,
"serving": 2520,
"waiting": 0,
"break": 0,
"commuting": 520,
"parking": 360
}
}
}
]
}
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"arrival": "2020-05-01T09:00:00Z",
"marker-size": "medium",
"marker-symbol": "warehouse",
"stop_idx": "0",
"marker-color": "#3cb44b",
"tour_idx": "0",
"departure": "2020-05-01T09:00:00Z",
"jobs_ids": "departure"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4532952,
52.5262872
]
}
},
{
"type": "Feature",
"properties": {
"marker-size": "medium",
"marker-symbol": "marker",
"tour_idx": "0",
"stop_idx": "1",
"arrival": "2020-05-01T09:00:11Z",
"departure": "2020-05-01T09:18:11Z",
"jobs_ids": "job4,job3,job2,job1",
"marker-color": "#3cb44b"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4533489,
52.5253342
]
}
},
{
"type": "Feature",
"properties": {
"marker-symbol": "marker",
"jobs_ids": "job5",
"arrival": "2020-05-01T09:18:29Z",
"departure": "2020-05-01T09:23:29Z",
"marker-size": "medium",
"marker-color": "#3cb44b",
"tour_idx": "0",
"stop_idx": "2"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4545827,
52.5239243
]
}
},
{
"type": "Feature",
"properties": {
"jobs_ids": "job6,job12",
"marker-symbol": "marker",
"arrival": "2020-05-01T09:23:48Z",
"marker-color": "#3cb44b",
"tour_idx": "0",
"marker-size": "medium",
"departure": "2020-05-01T09:32:48Z",
"stop_idx": "3"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4555697,
52.5223315
]
}
},
{
"type": "Feature",
"properties": {
"marker-color": "#3cb44b",
"arrival": "2020-05-01T09:33:10Z",
"marker-symbol": "marker",
"tour_idx": "0",
"marker-size": "medium",
"jobs_ids": "job7",
"departure": "2020-05-01T09:38:10Z",
"stop_idx": "4"
},
"geometry": {
"type": "Point",
"coordinates": [
13.457222,
52.5240157
]
}
},
{
"type": "Feature",
"properties": {
"departure": "2020-05-01T09:43:22Z",
"arrival": "2020-05-01T09:38:22Z",
"stop_idx": "5",
"marker-symbol": "marker",
"marker-size": "medium",
"tour_idx": "0",
"marker-color": "#3cb44b",
"jobs_ids": "job11"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4567821,
52.5250209
]
}
},
{
"type": "Feature",
"properties": {
"marker-symbol": "marker",
"jobs_ids": "job9,job8,job10",
"arrival": "2020-05-01T09:43:40Z",
"departure": "2020-05-01T09:58:20Z",
"stop_idx": "6",
"tour_idx": "0",
"marker-size": "medium",
"marker-color": "#3cb44b"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4589815,
52.5241593
]
}
},
{
"type": "Feature",
"properties": {
"shift_idx": "0",
"activities": "13",
"arrival": "2020-05-01T09:43:40Z",
"departure": "2020-05-01T09:00:00Z",
"vehicle_id": "vehicle_1",
"distance": "984",
"stroke-width": "4",
"tour_idx": "0",
"stroke": "#e6194b"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.4532952,
52.5262872
],
[
13.4533489,
52.5253342
],
[
13.4545827,
52.5239243
],
[
13.4555697,
52.5223315
],
[
13.457222,
52.5240157
],
[
13.4567821,
52.5250209
],
[
13.4589815,
52.5241593
]
]
}
},
{
"type": "Feature",
"properties": {
"tour_idx": "0",
"marker-size": "medium",
"jobs_id": "job4",
"marker-color": "#e6194b",
"start": "2020-05-01T09:02:11Z",
"end": "2020-05-01T09:05:11Z",
"marker-symbol": "marker",
"stop_idx": "1",
"activity_idx": "0"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4533489,
52.5253342
]
}
},
{
"type": "Feature",
"properties": {
"marker-size": "medium",
"marker-color": "#e6194b",
"jobs_id": "job3",
"marker-symbol": "marker",
"start": "2020-05-01T09:05:41Z",
"activity_idx": "1",
"tour_idx": "0",
"stop_idx": "1",
"end": "2020-05-01T09:08:41Z"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4530162,
52.5255366
]
}
},
{
"type": "Feature",
"properties": {
"stroke-width": "3",
"stroke": "#3cb44b"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.4533489,
52.5253342
],
[
13.4530162,
52.5255366
]
]
}
},
{
"type": "Feature",
"properties": {
"stroke-width": "3",
"stroke": "#3cb44b"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.4530162,
52.5255366
],
[
13.4533489,
52.5253342
]
]
}
},
{
"type": "Feature",
"properties": {
"marker-symbol": "marker",
"end": "2020-05-01T09:12:51Z",
"tour_idx": "0",
"activity_idx": "2",
"jobs_id": "job2",
"stop_idx": "1",
"marker-color": "#e6194b",
"start": "2020-05-01T09:09:51Z",
"marker-size": "medium"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4527159,
52.5254256
]
}
},
{
"type": "Feature",
"properties": {
"stroke": "#3cb44b",
"stroke-width": "3"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.4533489,
52.5253342
],
[
13.4527159,
52.5254256
]
]
}
},
{
"type": "Feature",
"properties": {
"stroke-width": "3",
"stroke": "#3cb44b"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.4527159,
52.5254256
],
[
13.4533489,
52.5253342
]
]
}
},
{
"type": "Feature",
"properties": {
"activity_idx": "3",
"jobs_id": "job1",
"start": "2020-05-01T09:14:21Z",
"tour_idx": "0",
"marker-symbol": "marker",
"marker-color": "#e6194b",
"marker-size": "medium",
"end": "2020-05-01T09:17:21Z",
"stop_idx": "1"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4525549,
52.5253538
]
}
},
{
"type": "Feature",
"properties": {
"stroke-width": "3",
"stroke": "#3cb44b"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.4533489,
52.5253342
],
[
13.4525549,
52.5253538
]
]
}
},
{
"type": "Feature",
"properties": {
"stroke-width": "3",
"stroke": "#3cb44b"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.4525549,
52.5253538
],
[
13.4533489,
52.5253342
]
]
}
},
{
"type": "Feature",
"properties": {
"end": "2020-05-01T09:28:48Z",
"jobs_id": "job6",
"marker-color": "#e6194b",
"marker-symbol": "marker",
"stop_idx": "3",
"activity_idx": "0",
"marker-size": "medium",
"start": "2020-05-01T09:25:48Z",
"tour_idx": "0"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4555697,
52.5223315
]
}
},
{
"type": "Feature",
"properties": {
"stop_idx": "3",
"marker-symbol": "marker",
"tour_idx": "0",
"activity_idx": "1",
"marker-color": "#e6194b",
"marker-size": "medium",
"end": "2020-05-01T09:32:18Z",
"jobs_id": "job12",
"start": "2020-05-01T09:29:18Z"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4551942,
52.5223184
]
}
},
{
"type": "Feature",
"properties": {
"stroke": "#3cb44b",
"stroke-width": "3"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.4555697,
52.5223315
],
[
13.4551942,
52.5223184
]
]
}
},
{
"type": "Feature",
"properties": {
"stroke-width": "3",
"stroke": "#3cb44b"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.4551942,
52.5223184
],
[
13.4555697,
52.5223315
]
]
}
},
{
"type": "Feature",
"properties": {
"tour_idx": "0",
"end": "2020-05-01T09:48:40Z",
"marker-color": "#e6194b",
"activity_idx": "0",
"marker-size": "medium",
"stop_idx": "6",
"start": "2020-05-01T09:45:40Z",
"marker-symbol": "marker",
"jobs_id": "job9"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4589815,
52.5241593
]
}
},
{
"type": "Feature",
"properties": {
"stop_idx": "6",
"end": "2020-05-01T09:52:20Z",
"jobs_id": "job8",
"activity_idx": "1",
"tour_idx": "0",
"marker-color": "#e6194b",
"marker-size": "medium",
"marker-symbol": "marker",
"start": "2020-05-01T09:49:20Z"
},
"geometry": {
"type": "Point",
"coordinates": [
13.45952868,
52.5243028
]
}
},
{
"type": "Feature",
"properties": {
"stroke": "#3cb44b",
"stroke-width": "3"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.4589815,
52.5241593
],
[
13.45952868,
52.5243028
]
]
}
},
{
"type": "Feature",
"properties": {
"stroke-width": "3",
"stroke": "#3cb44b"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.45952868,
52.5243028
],
[
13.4589815,
52.5241593
]
]
}
},
{
"type": "Feature",
"properties": {
"tour_idx": "0",
"activity_idx": "2",
"marker-color": "#e6194b",
"marker-symbol": "marker",
"start": "2020-05-01T09:54:10Z",
"end": "2020-05-01T09:57:10Z",
"jobs_id": "job10",
"stop_idx": "6",
"marker-size": "medium"
},
"geometry": {
"type": "Point",
"coordinates": [
13.4600115,
52.5239896
]
}
},
{
"type": "Feature",
"properties": {
"stroke-width": "3",
"stroke": "#3cb44b"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.4589815,
52.5241593
],
[
13.4600115,
52.5239896
]
]
}
},
{
"type": "Feature",
"properties": {
"stroke": "#3cb44b",
"stroke-width": "3"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.4600115,
52.5239896
],
[
13.4589815,
52.5241593
]
]
}
}
]
}