Custom Objective Equal Task Distribution
Custom Objective is a valuable feature that empowers users to pursue unique objectives which are significantly different from the typical approach of minimizing travel costs. This feature allows users to tune the optimization algorithm to achieve following objectives:
-
Minimize the number of vehicles used in the solution
-
Minimize the time taken to complete all the tasks
-
Distribute tasks equally among all the routes
-
Distribute
travel_cost
equally among all the routes
The above objectives can be used in conjunction with other constraints of vehicle costs, task time window constraints, re-optimization and other features that are offered by Route Optimization V2.
In this example, we are going to cover the equal task distribution objective. The Custom Objective feature proves highly effective in addressing optimization challenges, especially in business scenarios having a critical need to ensure equal distribution of workload - either in terms of the number of tasks or the travel cost - among all routes. This feature helps in addressing challenges like optimizing resource utilization, better workforce management, better vehicle availability among other benefits.
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 16 jobs. For these jobs we:
Add a unique identifier for each task Provide location indexes for each task Specify the schedule of tasks. This is done by adding time windows within which a task must be completed. Here we have considered the same time window for all tasks for the sake of simplicity, but Route Optimization V2 can handle tighter time windows easily. Configure the actual time taken to complete the tasks once the driver/vehicle is at the task’s location i.e. the service time for each task.
Let’s take a look at the jobs
JSON after the above properties are configured:
1{
2 "jobs": [
3 {
4 "id": 1,
5 "location_index": 0,
6 "service": 120,
7 "time_windows": [
8 [
9 1693386000,
10 1693393200
11 ]
12 ]
13 },
14 {
15 "id": 2,
16 "location_index": 1,
17 "service": 180,
18 "time_windows": [
19 [
20 1693386000,
21 1693393200
22 ]
23 ]
24 },
25 {
26 "id": 3,
27 "location_index": 2,
28 "service": 120,
29 "time_windows": [
30 [
31 1693386000,
32 1693393200
33 ]
34 ]
35 },
36 {
37 "id": 4,
38 "location_index": 3,
39 "service": 120,
40 "time_windows": [
41 [
42 1693386000,
43 1693393200
44 ]
45 ]
46 },
47 {
48 "id": 5,
49 "location_index": 4,
50 "service": 60,
51 "time_windows": [
52 [
53 1693386000,
54 1693393200
55 ]
56 ]
57 },
58 {
59 "id": 6,
60 "location_index": 5,
61 "service": 120,
62 "time_windows": [
63 [
64 1693386000,
65 1693393200
66 ]
67 ]
68 },
69 {
70 "id": 7,
71 "location_index": 6,
72 "service": 120,
73 "time_windows": [
74 [
75 1693386000,
76 1693393200
77 ]
78 ]
79 },
80 {
81 "id": 8,
82 "location_index": 7,
83 "service": 150,
84 "time_windows": [
85 [
86 1693386000,
87 1693393200
88 ]
89 ]
90 },
91 {
92 "id": 9,
93 "location_index": 8,
94 "service": 80,
95 "time_windows": [
96 [
97 1693386000,
98 1693393200
99 ]
100 ]
101 },
102 {
103 "id": 10,
104 "location_index": 9,
105 "service": 120,
106 "time_windows": [
107 [
108 1693386000,
109 1693393200
110 ]
111 ]
112 },
113 {
114 "id": 11,
115 "location_index": 10,
116 "service": 90,
117 "time_windows": [
118 [
119 1693386000,
120 1693393200
121 ]
122 ]
123 },
124 {
125 "id": 12,
126 "location_index": 11,
127 "service": 60,
128 "time_windows": [
129 [
130 1693386000,
131 1693393200
132 ]
133 ]
134 },
135 {
136 "id": 13,
137 "location_index": 12,
138 "service": 120,
139 "time_windows": [
140 [
141 1693386000,
142 1693393200
143 ]
144 ]
145 },
146 {
147 "id": 14,
148 "location_index": 13,
149 "service": 150,
150 "time_windows": [
151 [
152 1693386000,
153 1693393200
154 ]
155 ]
156 },
157 {
158 "id": 15,
159 "location_index": 14,
160 "service": 120,
161 "time_windows": [
162 [
163 1693386000,
164 1693393200
165 ]
166 ]
167 },
168 {
169 "id": 16,
170 "location_index": 15,
171 "service": 120,
172 "time_windows": [
173 [
174 1693386000,
175 1693393200
176 ]
177 ]
178 }
179 ]
180}
Vehicles
Next, we add 2 vehicles that are going to fulfill the tasks. To describe the vehicles and their properties we add: A unique ID for each vehicle
-
Vehicle shift time or the time window
-
Start_index to denote the point from where the vehicle would start.
-
Costs for all vehicles.
Once the vehicle and their properties are defined, the resulting vehicles
JSON is:
1{
2 "vehicles": [
3 {
4 "id": 1,
5 "start_index": 16,
6 "costs": {
7 "fixed": 1000
8 },
9 "time_window": [
10 1693385100,
11 1693397700
12 ]
13 },
14 {
15 "id": 2,
16 "start_index": 17,
17 "costs": {
18 "fixed": 2000
19 },
20 "time_window": [
21 1693385100,
22 1693397700
23 ]
24 }
25 ]
26}
Locations
And lastly, we define the locations
object by adding 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 "locations": {
3 "id": 1,
4 "location": [
5 "34.083950,-118.318640",
6 "34.054927,-118.323726",
7 "34.075525,-118.361588",
8 "34.076350,-118.338519",
9 "34.090425,-118.338933",
10 "34.037925,-118.459842",
11 "34.004364,-118.421170",
12 "34.000215,-118.318803",
13 "33.945884,-118.325628",
14 "34.000895,-118.204929",
15 "34.076646,-118.376969",
16 "34.094986,-118.300885",
17 "34.018780,-118.317919",
18 "33.996658,-118.261708",
19 "33.916595,-118.240132",
20 "33.946275,-118.385486",
21 "34.057106,-118.361326",
22 "33.940407,-118.265196"
23 ]
24 }
25}
Now that we have built the fundamental attributes of a request, readers are encouraged to submit a request containing the above components and analyze the solution returned under default settings. Most likely there will be 2 routes returned with 1 route having decidedly more tasks than the other.
Options
Moving forward we incorporate our objective of equal task distribution, into the request by using the objective
attribute. We set:
-
type
asmin-max
to indicate that we want to invoke the equal distribution algorithm. -
value
astasks
to indicate that we want to apply the algorithm on the number of tasks metric.
The resulting objective
attribute JSON is:
1{
2 "options": {
3 "objective": {
4 "custom": {
5 "type": "min-max",
6 "value": "tasks"
7 }
8 }
9 }
10}
Optimization POST Request
Now let’s put all these components together and create the final POST request that we will submit to the optimizer.
1curl --location 'https://api.nextbillion.io/optimization/v2?key=<your_api_key>' \
2--header 'Content-Type: application/json' \
3--data '{
4 "description": "Custom Objective (task distribution) Example",
5 "jobs": [
6 {
7 "id": 1,
8 "location_index":0,
9 "service": 120,
10 "time_windows": [
11 [
12 1693386000,
13 1693393200
14 ]
15 ]
16 },
17 {
18 "id": 2,
19 "location_index": 1,
20 "service": 180,
21 "time_windows": [
22 [
23 1693386000,
24 1693393200
25 ]
26 ]
27 },
28 {
29 "id": 3,
30 "location_index": 2,
31 "service": 120,
32 "time_windows": [
33 [
34 1693386000,
35 1693393200
36 ]
37 ]
38 },
39 {
40 "id": 4,
41 "location_index": 3,
42 "service": 120,
43 "time_windows": [
44 [
45 1693386000,
46 1693393200
47 ]
48 ]
49 },
50 {
51 "id": 5,
52 "location_index": 4,
53 "service": 60,
54 "time_windows": [
55 [
56 1693386000,
57 1693393200
58 ]
59 ]
60 },
61 {
62 "id": 6,
63 "location_index": 5,
64 "service": 120,
65 "time_windows": [
66 [
67 1693386000,
68 1693393200
69 ]
70 ]
71 },
72 {
73 "id": 7,
74 "location_index": 6,
75 "service": 120,
76 "time_windows": [
77 [
78 1693386000,
79 1693393200
80 ]
81 ]
82 },
83 {
84 "id": 8,
85 "location_index": 7,
86 "service": 150,
87 "time_windows": [
88 [
89 1693386000,
90 1693393200
91 ]
92 ]
93 },
94 {
95 "id": 9,
96 "location_index": 8,
97 "service": 80,
98 "time_windows": [
99 [
100 1693386000,
101 1693393200
102 ]
103 ]
104 },
105 {
106 "id": 10,
107 "location_index": 9,
108 "service": 120,
109 "time_windows": [
110 [
111 1693386000,
112 1693393200
113 ]
114 ]
115 },
116 {
117 "id": 11,
118 "location_index": 10,
119 "service": 90,
120 "time_windows": [
121 [
122 1693386000,
123 1693393200
124 ]
125 ]
126 },
127 {
128 "id": 12,
129 "location_index": 11,
130 "service": 60,
131 "time_windows": [
132 [
133 1693386000,
134 1693393200
135 ]
136 ]
137 },
138 {
139 "id": 13,
140 "location_index": 12,
141 "service": 120,
142 "time_windows": [
143 [
144 1693386000,
145 1693393200
146 ]
147 ]
148 },
149 {
150 "id": 14,
151 "location_index": 13,
152 "service": 150,
153 "time_windows": [
154 [
155 1693386000,
156 1693393200
157 ]
158 ]
159 },
160 {
161 "id": 15,
162 "location_index": 14,
163 "service": 120,
164 "time_windows": [
165 [
166 1693386000,
167 1693393200
168 ]
169 ]
170 },
171 {
172 "id": 16,
173 "location_index": 15,
174 "service": 120,
175 "time_windows": [
176 [
177 1693386000,
178 1693393200
179 ]
180 ]
181 }
182 ],
183 "vehicles": [
184 {
185 "id": 1,
186 "start_index": 16,
187 "costs":{
188 "fixed":1000
189 },
190 "time_window": [
191 1693385100,
192 1693397700
193 ]
194 },
195 {
196 "id": 2,
197 "start_index": 17,
198 "costs":{
199 "fixed":2000
200 },
201 "time_window": [
202 1693385100,
203 1693397700
204 ]
205 }
206 ],
207 "locations":
208 {
209 "id": 1,
210 "location": ["34.083950,-118.318640", "34.054927,-118.323726","34.075525,-118.361588","34.076350,-118.338519","34.090425,-118.338933","34.037925,-118.459842","34.004364,-118.421170", "34.000215,-118.318803","33.945884,-118.325628","34.000895,-118.204929", "34.076646,-118.376969","34.094986,-118.300885","34.018780,-118.317919","33.996658,-118.261708", "33.916595,-118.240132", "33.946275,-118.385486","34.057106,-118.361326","33.940407,-118.265196"]
211 },
212 "options":
213 {
214 "objective": {
215 "custom": {
216 "type": "min-max",
217 "value": "tasks"
218 }
219 }
220 }
221}
222'
Optimization POST Response
Once the request is successfully submitted, we get a unique ID in the API response:
1{
2"id": "682b0756abb75427be030457db66ee5e",
3"message": "Optimization job created",
4"status": "Ok"
5}
Optimization GET Request
We take the ID and use the Optimization GET request to retrieve the result. Here is the GET request:
1curl --location 'https://api.nextbillion.io/optimization/v2/result?id=682b0756abb75427be030457db66ee5e
2&key=<your_api_key>'
Optimization GET Response
Following is the optimized route plan:
1{
2 "description": "Custom Objective (task distribution) Example",
3 "result": {
4 "code": 0,
5 "summary": {
6 "cost": 14061,
7 "routes": 2,
8 "unassigned": 0,
9 "setup": 0,
10 "service": 1850,
11 "duration": 11061,
12 "waiting_time": 0,
13 "priority": 0,
14 "distance": 101643.7
15 },
16 "routes": [
17 {
18 "vehicle": 1,
19 "cost": 5831,
20 "steps": [
21 {
22 "type": "start",
23 "arrival": 1693385396,
24 "duration": 0,
25 "service": 0,
26 "waiting_time": 0,
27 "location": [
28 34.057106,
29 -118.361326
30 ],
31 "location_index": 16
32 },
33 {
34 "type": "job",
35 "arrival": 1693386000,
36 "duration": 604,
37 "service": 90,
38 "waiting_time": 0,
39 "location": [
40 34.076646,
41 -118.376969
42 ],
43 "location_index": 10,
44 "id": 11
45 },
46 {
47 "type": "job",
48 "arrival": 1693386376,
49 "duration": 890,
50 "service": 120,
51 "waiting_time": 0,
52 "location": [
53 34.075525,
54 -118.361588
55 ],
56 "location_index": 2,
57 "id": 3
58 },
59 {
60 "type": "job",
61 "arrival": 1693386861,
62 "duration": 1255,
63 "service": 120,
64 "waiting_time": 0,
65 "location": [
66 34.07635,
67 -118.338519
68 ],
69 "location_index": 3,
70 "id": 4
71 },
72 {
73 "type": "job",
74 "arrival": 1693387247,
75 "duration": 1521,
76 "service": 60,
77 "waiting_time": 0,
78 "location": [
79 34.090425,
80 -118.338933
81 ],
82 "location_index": 4,
83 "id": 5
84 },
85 {
86 "type": "job",
87 "arrival": 1693387922,
88 "duration": 2136,
89 "service": 60,
90 "waiting_time": 0,
91 "location": [
92 34.094986,
93 -118.300885
94 ],
95 "location_index": 11,
96 "id": 12
97 },
98 {
99 "type": "job",
100 "arrival": 1693388485,
101 "duration": 2639,
102 "service": 120,
103 "waiting_time": 0,
104 "location": [
105 34.08395,
106 -118.31864
107 ],
108 "location_index": 0,
109 "id": 1
110 },
111 {
112 "type": "job",
113 "arrival": 1693389225,
114 "duration": 3259,
115 "service": 180,
116 "waiting_time": 0,
117 "location": [
118 34.054927,
119 -118.323726
120 ],
121 "location_index": 1,
122 "id": 2
123 },
124 {
125 "type": "job",
126 "arrival": 1693390977,
127 "duration": 4831,
128 "service": 120,
129 "waiting_time": 0,
130 "location": [
131 34.000895,
132 -118.204929
133 ],
134 "location_index": 9,
135 "id": 10
136 },
137 {
138 "type": "end",
139 "arrival": 1693391097,
140 "duration": 4831,
141 "service": 0,
142 "waiting_time": 0,
143 "location": [
144 34.000895,
145 -118.204929
146 ],
147 "location_index":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DXBPFNFNHLLJLBBFLnAjDb@jAJZVx@@DNj@DN?@BDRN^`ADLJTHNFJJLRTh@f@`@XbAr@LHvA`AVVLJVRZr@@FBJ?PANGp@]t@S`@MVKPMXWh@Ud@OXOXCFS`@iDzGKRc@`Ak@fAsBfEWf@QZKRo@pAoB~DQZi@fA[n@_@t@GJSb@[n@eAtBELCHABAHAHATCf@E|@Eh@EjACVA\\K~BEp@A\\ALKhBMjCC\\AVKlBEfAMrCC`@Cb@KnB?JEx@AREn@Ct@En@Ab@En@KfBATALATObCKtBYhE?LAL?LB|@Hz@Bh@@\\@b@?@@pA?`@@|A?R?b@?\\@rA@TmBB[?A?e@ACA?AEaDCuA?K?kCBGHGPAVK??"
156 },
157 {
158 "vehicle": 2,
159 "cost": 8230,
160 "steps": [
161 {
162 "type": "start",
163 "arrival": 1693385441,
164 "duration": 0,
165 "service": 0,
166 "waiting_time": 0,
167 "location": [
168 33.940407,
169 -118.265196
170 ],
171 "location_index": 17
172 },
173 {
174 "type": "job",
175 "arrival": 1693386000,
176 "duration": 559,
177 "service": 120,
178 "waiting_time": 0,
179 "location": [
180 33.916595,
181 -118.240132
182 ],
183 "location_index": 14,
184 "id": 15
185 },
186 {
187 "type": "job",
188 "arrival": 1693387192,
189 "duration": 1631,
190 "service": 150,
191 "waiting_time": 0,
192 "location": [
193 33.996658,
194 -118.261708
195 ],
196 "location_index": 13,
197 "id": 14
198 },
199 {
200 "type": "job",
201 "arrival": 1693388361,
202 "duration": 2650,
203 "service": 120,
204 "waiting_time": 0,
205 "location": [
206 34.01878,
207 -118.317919
208 ],
209 "location_index": 12,
210 "id": 13
211 },
212 {
213 "type": "job",
214 "arrival": 1693388753,
215 "duration": 2922,
216 "service": 150,
217 "waiting_time": 0,
218 "location": [
219 34.000215,
220 -118.318803
221 ],
222 "location_index": 7,
223 "id": 8
224 },
225 {
226 "type": "job",
227 "arrival": 1693389644,
228 "duration": 3663,
229 "service": 80,
230 "waiting_time": 0,
231 "location": [
232 33.945884,
233 -118.325628
234 ],
235 "location_index": 8,
236 "id": 9
237 },
238 {
239 "type": "job",
240 "arrival": 1693390605,
241 "duration": 4544,
242 "service": 120,
243 "waiting_time": 0,
244 "location": [
245 33.946275,
246 -118.385486
247 ],
248 "location_index": 15,
249 "id": 16
250 },
251 {
252 "type": "job",
253 "arrival": 1693391781,
254 "duration": 5600,
255 "service": 120,
256 "waiting_time": 0,
257 "location": [
258 34.004364,
259 -118.42117
260 ],
261 "location_index": 6,
262 "id": 7
263 },
264 {
265 "type": "job",
266 "arrival": 1693392531,
267 "duration": 6230,
268 "service": 120,
269 "waiting_time": 0,
270 "location": [
271 34.037925,
272 -118.459842
273 ],
274 "location_index": 5,
275 "id": 6
276 },
277 {
278 "type": "end",
279 "arrival": 1693392651,
280 "duration": 6230,
281 "service": 0,
282 "waiting_time": 0,
283 "location": [
284 34.037925,
285 -118.459842
286 ],
287 "location_index": 5
288 }
289 ],
290 "service": 980,
291 "duration": 6230,
292 "waiting_time": 0,
293 "priority": 0,
294 "distance": 59464.2,
295 "geometry": "q~cnEftypUr@?hD@xA?h@?X?PAJ?N?h@?^?dB?X?lA?rA?|C?x@?nB?jA?X?jA@`A@B?zBAbB?`@?ZAf@?b@?R@d@?^?d@?L?@kB?W?k@?c@?w@?y@@mEAiA@cADeF?m@@yA@yE?G?IBO@OBINk@JSJSf@s@~@qAf@q@b@m@d@s@BGDIBG@GDO@M@GD[?M?G@g@@qD?[?W?M?_A?K?K?O?cA?C?[?cA?W?q@?_@?e@?aA?Q?u@?iH?e@?_A?m@@uAAyA?S?{A?cA?k@AwC?kCF?nA?J?H?J?J?P?H?N?F?n@Ap@?J?v@?dA@J?bB?x@?tB@lA?hA?f@?t@@x@?P?V?vA?d@?hAEf@?^AV?b@?|@ArCC|BClA?L?T?n@@B?f@@l@?h@?p@?dC?rB?`B?V?t@?hA?T?h@@R??w@?]?]?_@?_@?Y?S?U?iF?q@?sA?uA?w@?cD?oB?{@?o@?W?m@O?[HWF?@?AVGZIN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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 see that all the tasks are accommodated on the 2 routes with each vehicle taking care of 8 jobs. We can see that the optimizer has favored equal distribution of the task over the cost considerations of the route as is evident from the locations of some of the jobs which were located closer to vehicle 1 than to vehicle 2. NextBillion.ai’s Route Optimization V2 offers a unique feature to tackle the challenges of uniform cost distribution across multiple resources as per the rules defined by the user and prepare the best solution. Readers are encouraged to try the other metric available for equal distribution, travel cost, as well.
We hope this example was helpful. Check out some more use cases that Route Optimization V2 can handle for you!