• Optimization
  • Navigation
  • Tracking
  • Maps
  • Places

Basic Route Optimization

In this example we will play around with basic constraints offered in NextBillion.ai’s Route Optimization Flexible API. The constraints covered here are time windows of jobs, vehicle shift timings, skills needed to complete the tasks and capacities involved to carry out pickup/delivery type tasks. We specifically demonstrate how the time windows are used to determine the job sequence & assignment and if the time windows are such that they could not be honored then the task would be left unassigned. We will also see how the starting and ending stops for the vehicle are configured when they are assigned to depots versus when they are not assigned to depots.

Get Started

Readers would need a valid NextBillion API key to try this example out. If you don’t have one, please contact us to get your API key now!

Setup

Once you have a valid API Key, you can start setting up the components to be used in this example. Let’s take a look at them below.

Jobs & Shipments

We start by defining 5 jobs and 2 shipments. For these tasks we add:

  • A unique identifier for each task

  • Location indexes for each task

  • Specify the schedule of tasks. This is done by adding time windows within which a task must be completed. We have added a 15 min time window for all tasks for the sake of simplicity, but the Route Optimization Flexible API is fully capable of handling much complex task schedules.

  • Skills needed to perform each task

  • Pickup and Delivery amounts for all jobs

  • The actual time taken to complete the task once the driver/vehicle is at the task’s location i.e. the service time for each task. We have added a uniform

service time of 2 mins for all tasks, but the readers can use varying service times instead.

Let’s take a look at the jobs JSON after the above properties are configured:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
 "jobs": [
       {
           "id": 1,
           "location_index": 0,
           "service": 120,
           "pickup":[1],
           "skills": [1],
           "time_windows": [
               [
                   1693393200,
                   1693394100
               ]
           ]
       },
       {
           "id": 2,
           "location_index": 1,
           "service": 120,
           "skills": [1],
           "pickup":[1],
           "time_windows": [
               [
                   1693387800,
                   1693388700
               ]
           ]
       },
       {
           "id": 3,
           "location_index": 2,
           "service": 120,
           "pickup":[1],
           "skills": [2],
           "time_windows": [
               [
                   1693396800,
                   1693397700
               ]
           ]
       },
       {
           "id": 4,
           "location_index": 3,
           "service": 120,
           "skills": [1],
           "pickup":[1],
           "time_windows": [
               [
                   1693402200,
                   1693403100
               ]
           ]
       },
       {
           "id": 5,
           "location_index": 4,
           "service": 120,
           "skills": [2],
           "pickup":[1],
           "time_windows": [
               [
                   1693400400,
                   1693401300
               ]
           ]
       }
   ],
   "shipments": [
       {
        "pickup":{
           "description": "Shipment Pickup 1",
           "id":1,
           "location_index":5,
	"time_windows":[[1693397400,1693397760]]
        },
        "delivery":{
           "description": "Shipment Delivery 1",
           "id":1,
           "location_index":6,
"time_windows":[[1693400700,1693401300]]
        },
"skills":[2,3],
"amount":[3]
        },
        {
         "pickup":{
           "description": "Shipment Pickup 2",
           "id":2,
           "location_index":7,
           "time_windows":[[1693429200,1693430100]]
        },
        "delivery":{
           "description": "Shipment Delivery 2",
           "id":2,
           "location_index":8,
           "time_windows":[[1693432800,1693433700]]
        },
"skills":[2,3],
"amount":[2]
       }
   ]

Depot

Next, we add a depot that we want to assign to one of the vehicles. The assigned vehicle would start from the depot’s location. We assign an ID and a location_index to the depot:

1
2
3
4
5
6
7
"depots": [
       {
           "description":"Depot 1",
           "id":0,
           "location_index":9
       }
   ]

Vehicles

Next, we add 2 vehicles that are responsible for fulfilling the tasks within the defined constraints. To describe the vehicles and their properties we add:

  • A unique ID for each vehicle

  • Vehicle shift time or the time window

  • Capacity to denote the amount of load that the vehicle can take

  • Vehicle’s depot, if any.

  • Start_index to denote the point from where the vehicle would start. It is important to highlight here that we need to add a start point for all vehicles either by specifying the start_index or by assigning them to a depot. In this example, we cover both cases and define a start_index for one vehicle and assign a depot to the other.

  • Skills of the driver or the vehicle

  • We are not mentioning any cost for the vehicles. Please take a look at the Vehicle Cost example to know more about its usage.

Once the vehicle and their properties are defined, the resulting vehicles JSON is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 "vehicles": [
       {
           "id": 1,
           "start_index": 10,
           "skills":[1],
           "capacity":[10],
           "time_window": [
               1693382400,
                   1693411200
           ]
           
       }, {
           "id": 2,
           "depot": 0,
           "skills": [
               2,3
           ],
           "capacity":[10],
           "time_window": [
               1693382400,
            1693411200
           ]
       }
   ]

Locations

And now, lastly we define the locations object and add all the locations used in the problem along with a valid id. The locations object with all the points used in this example:

1
2
3
4
5
 "locations":
        {
            "id": 1,
            "location": ["34.083950,-118.318640","34.054927,-118.323726","34.075525,-118.361588","34.076350,-118.338519","34.090425,-118.338933","34.076646,-118.376969","34.094986,-118.300885","34.018780,-118.317919","33.996658,-118.261708","34.059244,-118.376969","34.057106,-118.361326"]
        }

Optimization POST Request

Bringing all these components together to create the final POST request that we will submit to the optimizer.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
curl --location 'https://api.nextbillion.io/optimization/v2?key=<your_api_key>' 
--header 'Content-Type: application/json' 
--data '{
   "description": "Basic Route Optimization Example",
   "jobs": [
       {
           "id": 1,
           "location_index": 0,
           "service": 120,
           "pickup":[1],
           "skills": [1],
           "time_windows": [
               [
                   1693393200,
                   1693394100
               ]
           ]
       },
       {
           "id": 2,
           "location_index": 1,
           "service": 120,
           "skills": [1],
           "pickup":[1],
           "time_windows": [
               [
                   1693387800,
                   1693388700
               ]
           ]
       },
       {
           "id": 3,
           "location_index": 2,
           "service": 120,
           "pickup":[1],
           "skills": [2],
           "time_windows": [
               [
                   1693396800,
                   1693397700
               ]
           ]
       },
       {
           "id": 4,
           "location_index": 3,
           "service": 120,
           "skills": [1],
           "pickup":[1],
           "time_windows": [
               [
                   1693402200,
                   1693403100
               ]
           ]
       },
       {
           "id": 5,
           "location_index": 4,
           "service": 120,
           "skills": [2],
           "pickup":[1],
           "time_windows": [
               [
                   1693400400,
                   1693401300
               ]
           ]
       }
   ],
   "shipments": [
       {
        "pickup":{
           "description": "Shipment Pickup 1",
           "id":1,
           "location_index":5,
	"time_windows":[[1693397400,1693397760]]
        },
        "delivery":{
           "description": "Shipment Delivery 1",
           "id":1,
           "location_index":6,
"time_windows":[[1693400700,1693401300]]
           },
        "skills":[2,3],
        "amount":[3]
        },
        {
         "pickup":{
           "description": "Shipment Pickup 2",
           "id":2,
           "location_index":7,
           "time_windows":[[1693429200,1693430100]]
        },
        "delivery":{
           "description": "Shipment Delivery 2",
           "id":2,
           "location_index":8,
           "time_windows":[[1693432800,1693433700]]
        },
        "skills":[2,3],
        "amount":[2]
       }
   ],
   "depots": [
       {
           "description":"Depot 1",
           "id":0,
           "location_index":9
       }
   ],
   "vehicles": [
       {
           "id": 1,
           "start_index": 10,
           "skills":[1],
           "capacity":[10],
           "time_window": [
               1693382400,
                   1693411200
           ]
           
       },
       {
           "id": 2,
           "depot": 0,
           "skills": [
               2,3
           ],
           "capacity":[10],
           "time_window": [
               1693382400,
            1693411200
           ]
       }
   ],
    "locations":
        {
            "id": 1,
            "location": ["34.083950,-118.318640","34.054927,-118.323726","34.075525,-118.361588","34.076350,-118.338519","34.090425,-118.338933","34.076646,-118.376969","34.094986,-118.300885","34.018780,-118.317919","33.996658,-118.261708","34.059244,-118.376969","34.057106,-118.361326"]
        }
}
'

Optimization POST Response

Once the request is made, we get a unique ID in the API response:

1
2
3
4
5
{
"id": "777fe88e8748be4f95d478ce657252d8",
"message": "Optimization job created",
"status": "Ok"
}

Optimization GET Request

We take the ID and use the Optimization GET request to retrieve the result. Here is the GET request:

curl --location 'https://api.nextbillion.io/optimization/v2/result?id=777fe88e8748be4f95d478ce657252d8&key=<your_api_key>'

Optimization GET Response

Following is the optimized route plan:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
{
  "description": "Route Optimization Examples",
  "result": {
    "code": 0,
    "summary": {
      "cost": 3723,
      "routes": 2,
      "unassigned": 1,
      "setup": 0,
      "service": 600,
      "duration": 3723,
      "waiting_time": 14550,
      "priority": 0,
      "delivery": [
        0
      ],
      "pickup": [
        5
      ],
      "distance": 33117.399999999994
    },
    "unassigned": [
      {
        "id": 2,
        "type": "pickup",
        "location": [
          34.01878,
          -118.317919
        ]
      },
      {
        "id": 2,
        "type": "delivery",
        "location": [
          33.996658,
          -118.261708
        ]
      }
    ],
    "routes": [
      {
        "vehicle": 1,
        "cost": 1226,
        "steps": [
          {
            "type": "start",
            "arrival": 1693388334,
            "duration": 0,
            "setup": 0,
            "service": 0,
            "waiting_time": 0,
            "location": [
              34.057106,
              -118.361326
            ],
            "location_index": 10,
            "load": [
              0
            ]
          },
          {
            "type": "job",
            "arrival": 1693388700,
            "duration": 366,
            "setup": 0,
            "service": 120,
            "waiting_time": 0,
            "location": [
              34.054927,
              -118.323726
            ],
            "location_index": 1,
            "id": 2,
            "load": [
              1
            ]
          },
          {
            "type": "job",
            "arrival": 1693389357,
            "duration": 903,
            "setup": 0,
            "service": 120,
            "waiting_time": 3843,
            "location": [
              34.08395,
              -118.31864
            ],
            "location_index": 0,
            "id": 1,
            "load": [
              2
            ]
          },
          {
            "type": "job",
            "arrival": 1693393643,
            "duration": 1226,
            "setup": 0,
            "service": 120,
            "waiting_time": 8557,
            "location": [
              34.07635,
              -118.338519
            ],
            "location_index": 3,
            "id": 4,
            "load": [
              3
            ]
          },
          {
            "type": "end",
            "arrival": 1693402320,
            "duration": 1226,
            "setup": 0,
            "service": 0,
            "waiting_time": 0,
            "location": [
              34.07635,
              -118.338519
            ],
            "location_index": 3,
            "load": [
              3
            ]
          }
        ],
        "setup": 0,
        "service": 360,
        "duration": 1226,
        "waiting_time": 12400,
        "priority": 0,
        "delivery": [
          0
        ],
        "pickup": [
          3
        ],
        "distance": 10430.2,
        "geometry": "ywznEjmlqUBG@G@GAEEEMIw@[q@WLoA@KB[JmAB_@?U@[?a@?iABiD?u@@c@@aB@iB@g@?S@_ABsF@aB?s@?k@@o@?m@@g@?UBgBB{EDcF@s@@qD@aB@[@gA?y@?]BuB?}@?W@m@?Q?W@{@?]?K@M?kA?Q?U?I@_@BuE@qA@W?c@DcB?u@?y@?M@}B@mA?]@g@@y@@s@@c@@aA?S?U@aB@g@?e@@s@?c@@uA?m@@o@?cC@u@@{@@o@?sA?Y?Q?I?Y@m@@g@AG?A?g@@[BUBUDUFYVmA@GH_@RgAb@}B\\mB`@sBX{ADUFUNy@ZgBReABQTgADSFYBKFc@BWD[F}@@IHaBZqFLaCPuCDo@D}@BS_@C^B@U@SB]@IBQHa@w@]YMSKICOIQIyAo@uAo@UMcJaE_Bs@[OeAe@w@_@[M]OuGyCYMUKe@Mc@MIC@gA?I?q@S@_A?gA?iE@m@?mB?mC?m@?S?iJ?e@?{A@aD?eA?A_A?}B?u@?g@u@?{J@?nCC`@Ol@M\\[BsBBcB@cAAe@AW?_B?sGDoF@?t@{G@mEAY?]?aP?iJ@?k@?e@?wA?s@_B@A`@@B?@?@?@DDBB@@@B?P?R?N?b@?d@?J?K?e@?c@?O?S?QACAACCEE?A?A?AAC@a@~AA?r@nJCxO?`B?|B?xEAhB??`@?f@?l@?t@?l@?b@?d@?l@@tB?n@?l@?l@@hB?n@?l@?vB?j@A^?T?R?d@?pA?R?bBAf@@T?v@?~@?b@AbC?n@?T?F?F?H@L?DDb@D\\DRDN?BHXJVHVFRJ\\@FH^D`@?B?B@T@L?TENAX?V?LAPCVCVWnC[dDEf@CXCZARAp@?tC@nA?JAN?LA\\DNA~@?nA?^?^AXANANAN?JAJ?N@r@@hA?d@?d@?x@?tC?d@?x@@nA?Z?h@?r@?p@a@???"
      },
      {
        "vehicle": 2,
        "cost": 2497,
        "steps": [
          {
            "type": "start",
            "arrival": 1693397206,
            "duration": 0,
            "setup": 0,
            "service": 0,
            "waiting_time": 0,
            "location": [
              34.059244,
              -118.376969
            ],
            "location_index": 9,
            "load": [
              0
            ]
          },
          {
            "type": "pickup",
            "arrival": 1693397551,
            "duration": 345,
            "setup": 0,
            "service": 0,
            "waiting_time": 0,
            "location": [
              34.076646,
              -118.376969
            ],
            "location_index": 5,
            "id": 1,
            "load": [
              0
            ],
            "description": "Shipment Pickup 1"
          },
          {
            "type": "job",
            "arrival": 1693397700,
            "duration": 494,
            "setup": 0,
            "service": 120,
            "waiting_time": 0,
            "location": [
              34.075525,
              -118.361588
            ],
            "location_index": 2,
            "id": 3,
            "load": [
              1
            ]
          },
          {
            "type": "job",
            "arrival": 1693398250,
            "duration": 924,
            "setup": 0,
            "service": 120,
            "waiting_time": 2150,
            "location": [
              34.090425,
              -118.338933
            ],
            "location_index": 4,
            "id": 5,
            "load": [
              2
            ]
          },
          {
            "type": "delivery",
            "arrival": 1693400965,
            "duration": 1369,
            "setup": 0,
            "service": 0,
            "waiting_time": 0,
            "location": [
              34.094986,
              -118.300885
            ],
            "location_index": 6,
            "id": 1,
            "load": [
              2
            ],
            "description": "Shipment Delivery 1"
          },
          {
            "type": "end",
            "arrival": 1693402093,
            "duration": 2497,
            "setup": 0,
            "service": 0,
            "waiting_time": 0,
            "location": [
              34.059244,
              -118.376969
            ],
            "location_index": 9,
            "load": [
              2
            ]
          }
        ],
        "setup": 0,
        "service": 240,
        "duration": 2497,
        "waiting_time": 2150,
        "priority": 0,
        "delivery": [
          0
        ],
        "pickup": [
          2
        ],
        "distance": 22687.199999999997,
        "geometry": "gf{nEbooqU?DBr@eB?oEFiJAYCKAg@K_@?{IHy@BY?mFFyNN[??_CAi@@UAQm@?M@Y?g@@I?]?a@?OII?[@m@@O?Q?y@Bg@ZWRURMLi@d@OJOHQFWDc@DQBKBMDOFSHOH?@MF_Ad@ULkCrAa@Tk@XYNULaB|@YLw@`@g@Vk@XMAEAGCEAAECGAG?IA_@F[QIGCKGKG?{@BgC?aB?g@AiAP@v@ALAVA?q@AI?O?k@?W?Q?G?_@?M?a@?]?m@?y@?Y?K?W?[?a@?u@?e@?m@?e@?k@?q@?i@?a@?c@Aa@?i@?e@?cA?]?c@Aa@?g@?y@?k@?k@?}@?g@?]?]?e@?m@Ae@?o@?_@Ag@@k@Ag@?w@?a@?_@?S?SAS@Y?c@Au@?m@?aA?S?I?a@?i@?e@?o@?i@?o@?c@?k@Ao@?O?U?o@?e@?e@?[?S?U?O?Y?[?M?o@t@?\\?T?F?G?U?]?u@?u@?S?c@?]?M?W?a@@W?}A@{A?o@?W?mA?[?m@?s@?gA?Q?W?O?U@_@?i@?uB?]?a@@O?Q?C?i@Aa@KkAA_B?[AgAAc@AK?u@?a@AW?o@?}A@a@?c@?UA[@}D?k@?a@?g@?[@S?sA?oB@S?o@?q@?iC@kA@i@?I?g@@m@@?sA?yA?i@?cB?IGO?g@@iAAeC?Y?_@?Y@{B?wC?w@@wC?[?]?Q?W?[@iC@}D?M?i@?aA@_A?a@?U?U?k@@qA?S?c@?wA?W?}A@s@?_A?K@WAM@c@@qA?g@As@B}D?a@DM@M?c@?G@[?A?GGO?g@?aA?_@?W?K?Y?}@@{A?y@?aA@gA?Y?Q?M?QA[AoA?]?U?S?U?g@?MAa@?u@?q@?i@?u@?i@?m@@cA?_@?c@?M?i@?S?O?kA?{@h@?L?M?i@??}@?s@?{@?A?y@Au@?_@?{@?c@?q@?o@?WAiA?s@?uA?_@?cA@yD?s@?m@?sA?K?mA?kA?]?YA_@?s@?mA?q@Ae@?u@?gA?O?i@?WAu@?{@?e@?mA?s@?i@?w@?c@@qA?_A?]?e@?aA?M?mA?MAeC?yE?}@?_A?c@?w@?o@?_@?c@?S?S?Q?O?W?u@?iA?m@@m@AoB?q@?s@?m@?{@?m@?eA?gA?c@?yC?qA?WAeA?o@?}@?Y?wA?y@?m@?_@AiAgB@cBAeE@eE?i@?cA@g@?m@??u@?_@?}BAaC?_A?SCq@AQCa@CSCYCWEq@?Q?OAO@C?I?M?]?M?m@@w@Aw@?g@Ca@IuHAg@EeBAmAC_A?e@EuCAcACkCC_BCcCAs@CyAAeAAc@A_@Ac@@b@@^@b@@dABxA@r@BbCB~ABjC@bADtC?d@B~@@lADdB@f@HtHB`@?f@@v@Av@?l@?L?\\?L?HAB@N?N?PDp@BVBXBRB`@@PBp@?R?~@@`C?|B?^?t@l@?f@?bAAh@?dE?dEAbB@fBA`@?bB?nBAt@?zC?tD?xAAxA@vAA^?z@?|H?b@?|@?f@A\\?\\?X?bA?^?tD?lGAlA?fB?R?hA?vAAf@?lE?|BAN@X?XBH@?jA?P?b@?lA?dA?fA@pA?dA?L?jA?H?`B?R?tA?x@?`@?f@?l@?t@?l@?b@?d@?l@@tB?n@?l@?l@@hB?n@?l@?vB?j@A^?T?R?d@?pA?R?bBAf@@T?v@?~@?b@AbC?n@?T?F?F?H@L?DDb@D\\DRDN?BHX`@HH@VDJBNBH?H?@?X@r@?hBAdC?fD?zG?ZAf@?t@?|@?lA?bB?n@Ah@?J?Z?DAb@A?p@?j@?^?|@?\\?D?^?d@?f@?Z?`@?lA?f@@zA?|B?fB?x@?fA?lA?xA?R@bB?j@?b@?j@?^?nA?lA?h@?dA?d@?b@?bC?b@@l@?n@?V?R?L?j@?P?V?b@?h@?V`@AF?b@?v@?hF@b@?X?xE?pBAb@?^AnA?bC?hD?^?N?N?LAHDPDFBJHFHHV?VAT?L?R?RF?H@H@LFLBNDTF`@LXH^JVHbCn@hI|Bz@VvF~AVFA|B?L?x@?t@EbB?b@AVApACtEA^?H?T?P?jAAL?J?\\Az@?V?PAl@?V?|@CtB?\\?x@AfAAZA`BApDAr@EbFCzECfB?TAf@?l@An@?j@?r@A`BCrFA~@?RAf@AhBA`BAb@?t@ChD?hA?`@AZ?TC^KlACZAJMnAIbAEd@Ir@ADEf@S|BO`BEVCRE^Ef@CVAXGv@AXC^A\\CVEt@I~AA^IrAKbBGbAATAVGbAEd@ARIrAGfAEf@G|AEh@AZEh@AREn@Ch@GfAGbAItAGjAGv@E`AIvAEv@IhACh@MlBE~@Er@Ex@Eb@AVAX?V@ZBf@Bd@@TBn@Bz@@V?F"
      }
    ]
  },
  "status": "Ok",
  "message": ""
}

Following is a visual representation of the initial locations of tasks, vehicles and the routes suggested after optimization as per the given constraints

Analyzing the Solution

Looking at the result we can observe some interesting insights:

  • summary section:

    • We get an overview of the overall result with a total distance of 33117 meters covered within a total duration of 3723 seconds to complete all the assigned tasks.
    • There are 2 routes with a total cost of 3723. This cost is in seconds as we did not explicitly specify any travel_cost, so the solver went with the default setting of duration.
    • Other fields in summary tell us that there is 1 task which remained unassigned, total service time of all the assigned tasks, total waiting_time for the assigned tasks and other details.
  • routes section:

    • Gives step wise and route wise details of each route along with the vehicle which is going to cover each of them.
    • For each route we get details of the steps involved, ID of the vehicle which is going to cover the route, cost of the route, distance of the route and duration needed to cover it, encoded geometry of the route, service and setup times, pickup/delivery amounts involved in the route among other details. Please note the cost value is based on the travel_cost value provided in the input request. In our example, the cost is calculated based on the duration, hence all costs in the solution are in seconds. Consequently, we can see that cost and duration of both routes are the same as no other costs (vehicle costs) were involved.
    • For each step we get details like - step type, arrival time at the location of the step, service time, priority, setup time, location, ID of the job/shipment among others.
    • We can see that vehicle 1 is taking care of job 1, 2 & 4 while vehicle 2 is assigned to fulfill jobs 3 & 5 along with the shipment pickup and delivery. This is because of the skills needed to complete those jobs. Take a look at the skills specified for jobs and 1,2 and 4 and that specified for vehicle 1.
    • The vehicle 1 starts from the provided start point but the vehicle 2 start from the depot location to which it was assigned to
    • On analyzing the routes further we can see that vehicle 1 waited for more than 3 plus hours to complete jobs 1 & 4. This is because vehicle 1, after completing job 1, arrives at the location of job 1 almost an hour earlier than scheduled time to start job 1. The vehicle then waits for the start of the time period when job 1 can be completed. Same happens with job 4 for which the vehicle arrives almost two and half hours earlier than the scheduled start time of the job. If the high waiting time is a concern, we recommend you to look at the max_waiting_time example to understand how you can cut down on the vehicle’s waiting time.
  • unassigned section gives the details of the task that remained unassigned. On digging further, we can notice that this task was scheduled outside the time_window of vehicle 2 and hence remained unassigned. The shift timing of the other vehicle did also not cover the task’s scheduled time, but please note that vehicle 1 could not have fulfilled the task anyway because of the missing skills.

As we witnessed, NextBillion.ai’s Route Optimization Flexible API closely adheres to the time windows, skill constraints of the tasks and returns the best possible routes while keeping other factors into consideration. We encourage you to go ahead and try out different configurations of locations, time windows, skills, number of tasks and explore the powerful Route Optimization Flexible API.

We hope this example was helpful. Check out some more use cases that Route Optimization Flexible API can handle for you!