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 Flexible API.
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 Flexible API 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 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
{ "jobs": [ { "id": 1, "location_index": 0, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 2, "location_index": 1, "service": 180, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 3, "location_index": 2, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 4, "location_index": 3, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 5, "location_index": 4, "service": 60, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 6, "location_index": 5, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 7, "location_index": 6, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 8, "location_index": 7, "service": 150, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 9, "location_index": 8, "service": 80, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 10, "location_index": 9, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 11, "location_index": 10, "service": 90, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 12, "location_index": 11, "service": 60, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 13, "location_index": 12, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 14, "location_index": 13, "service": 150, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 15, "location_index": 14, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 16, "location_index": 15, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] } ] }
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 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
{ "vehicles": [ { "id": 1, "start_index": 16, "costs": { "fixed": 1000 }, "time_window": [ 1693385100, 1693397700 ] }, { "id": 2, "start_index": 17, "costs": { "fixed": 2000 }, "time_window": [ 1693385100, 1693397700 ] } ] }
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 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
{ "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.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" ] } }
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 3 4 5 6 7 8 9 10
{ "options": { "objective": { "custom": { "type": "min-max", "value": "tasks" } } } }
Optimization POST Request
Now let’s put all these components together and 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 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
curl --location 'https://api.nextbillion.io/optimization/v2?key=<your_api_key>' \ --header 'Content-Type: application/json' \ --data '{ "description": "Custom Objective (task distribution) Example", "jobs": [ { "id": 1, "location_index":0, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 2, "location_index": 1, "service": 180, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 3, "location_index": 2, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 4, "location_index": 3, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 5, "location_index": 4, "service": 60, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 6, "location_index": 5, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 7, "location_index": 6, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 8, "location_index": 7, "service": 150, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 9, "location_index": 8, "service": 80, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 10, "location_index": 9, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 11, "location_index": 10, "service": 90, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 12, "location_index": 11, "service": 60, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 13, "location_index": 12, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 14, "location_index": 13, "service": 150, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 15, "location_index": 14, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] }, { "id": 16, "location_index": 15, "service": 120, "time_windows": [ [ 1693386000, 1693393200 ] ] } ], "vehicles": [ { "id": 1, "start_index": 16, "costs":{ "fixed":1000 }, "time_window": [ 1693385100, 1693397700 ] }, { "id": 2, "start_index": 17, "costs":{ "fixed":2000 }, "time_window": [ 1693385100, 1693397700 ] } ], "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.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"] }, "options": { "objective": { "custom": { "type": "min-max", "value": "tasks" } } } } '
Optimization POST Response
Once the request is successfully submitted, we get a unique ID in the API response:
1 2 3 4 5
{ "id": "682b0756abb75427be030457db66ee5e", "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:
1 2
curl --location 'https://api.nextbillion.io/optimization/v2/result?id=682b0756abb75427be030457db66ee5e &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 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
{ "description": "Custom Objective (task distribution) Example", "result": { "code": 0, "summary": { "cost": 14061, "routes": 2, "unassigned": 0, "setup": 0, "service": 1850, "duration": 11061, "waiting_time": 0, "priority": 0, "distance": 101643.7 }, "routes": [ { "vehicle": 1, "cost": 5831, "steps": [ { "type": "start", "arrival": 1693385396, "duration": 0, "service": 0, "waiting_time": 0, "location": [ 34.057106, -118.361326 ], "location_index": 16 }, { "type": "job", "arrival": 1693386000, "duration": 604, "service": 90, "waiting_time": 0, "location": [ 34.076646, -118.376969 ], "location_index": 10, "id": 11 }, { "type": "job", "arrival": 1693386376, "duration": 890, "service": 120, "waiting_time": 0, "location": [ 34.075525, -118.361588 ], "location_index": 2, "id": 3 }, { "type": "job", "arrival": 1693386861, "duration": 1255, "service": 120, "waiting_time": 0, "location": [ 34.07635, -118.338519 ], "location_index": 3, "id": 4 }, { "type": "job", "arrival": 1693387247, "duration": 1521, "service": 60, "waiting_time": 0, "location": [ 34.090425, -118.338933 ], "location_index": 4, "id": 5 }, { "type": "job", "arrival": 1693387922, "duration": 2136, "service": 60, "waiting_time": 0, "location": [ 34.094986, -118.300885 ], "location_index": 11, "id": 12 }, { "type": "job", "arrival": 1693388485, "duration": 2639, "service": 120, "waiting_time": 0, "location": [ 34.08395, -118.31864 ], "location_index": 0, "id": 1 }, { "type": "job", "arrival": 1693389225, "duration": 3259, "service": 180, "waiting_time": 0, "location": [ 34.054927, -118.323726 ], "location_index": 1, "id": 2 }, { "type": "job", "arrival": 1693390977, "duration": 4831, "service": 120, "waiting_time": 0, "location": [ 34.000895, -118.204929 ], "location_index": 9, "id": 10 }, { "type": "end", "arrival": 1693391097, "duration": 4831, "service": 0, "waiting_time": 0, "location": [ 34.000895, -118.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BBFLnAjDb@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??" }, { "vehicle": 2, "cost": 8230, "steps": [ { "type": "start", "arrival": 1693385441, "duration": 0, "service": 0, "waiting_time": 0, "location": [ 33.940407, -118.265196 ], "location_index": 17 }, { "type": "job", "arrival": 1693386000, "duration": 559, "service": 120, "waiting_time": 0, "location": [ 33.916595, -118.240132 ], "location_index": 14, "id": 15 }, { "type": "job", "arrival": 1693387192, "duration": 1631, "service": 150, "waiting_time": 0, "location": [ 33.996658, -118.261708 ], "location_index": 13, "id": 14 }, { "type": "job", "arrival": 1693388361, "duration": 2650, "service": 120, "waiting_time": 0, "location": [ 34.01878, -118.317919 ], "location_index": 12, "id": 13 }, { "type": "job", "arrival": 1693388753, "duration": 2922, "service": 150, "waiting_time": 0, "location": [ 34.000215, -118.318803 ], "location_index": 7, "id": 8 }, { "type": "job", "arrival": 1693389644, "duration": 3663, "service": 80, "waiting_time": 0, "location": [ 33.945884, -118.325628 ], "location_index": 8, "id": 9 }, { "type": "job", "arrival": 1693390605, "duration": 4544, "service": 120, "waiting_time": 0, "location": [ 33.946275, -118.385486 ], "location_index": 15, "id": 16 }, { "type": "job", "arrival": 1693391781, "duration": 5600, "service": 120, "waiting_time": 0, "location": [ 34.004364, -118.42117 ], "location_index": 6, "id": 7 }, { "type": "job", "arrival": 1693392531, "duration": 6230, "service": 120, "waiting_time": 0, "location": [ 34.037925, -118.459842 ], "location_index": 5, "id": 6 }, { "type": "end", "arrival": 1693392651, "duration": 6230, "service": 0, "waiting_time": 0, "location": [ 34.037925, -118.459842 ], "location_index": 5 } ], "service": 980, "duration": 6230, "waiting_time": 0, "priority": 0, "distance": 59464.2, "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??l@?V?n@?z@?nB?bD?v@?tA?rA?p@?hF?T?R?X?^?^?\\?\\?v@S?i@AU?iA?u@?W?aB?sB?eC?q@?i@?m@?g@AC?o@AU?M?mA?}BBsCB}@@c@?W?_@@g@?iADe@?wA?W?Q?y@?u@Ag@?iA?mA?uBAy@?cB?K?eAAw@?K?q@?o@@G?O?I?Q?K?K?I?K?oA?G??cAAsBAsAAcB?u@?k@AsA?o@?m@@iABgD@oDA}@CsAA_@AwA?{@@[?K@ODgAB_@Bg@Dy@@_@DiAFsB@]FiA@QLiDBg@@e@BeABk@?UB}@BkA?QTBPBPFNFJJHJFLDN@F@H@T?H?TB~CALB|B?b@@j@?\\@n@ApA@tAD~@?HA`@AVAr@AZAZ?LAf@ANAZ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BeAv@o@d@OLMHIF_@XURWRc@^URUNk@`@cAt@}@p@kAz@UPmBvAyBzA_CdBQL]Ro@XWNWPgE|CSLkAx@WPcD~BYTm@b@g@^QLCB]XYRCBOLSPUTOP[^KNOTKPGLOZO^K\\K`@Mj@G^E\\CZC`@GrAA\\EXG`@GV?DKb@Od@GRSh@MVMTOVOTY\\QRURURSNiBpAmE`DmA~@_CbBOJKF{@n@]VKHMJYRMJe@Zi@`@[TYTWRUNiAx@a@Xk@`@{@n@YTyBbBUNEDm@`@YRkAz@UP_GjEWRSNUPWPWPSNUNa@X_@X_@Xu@f@OLMJOJy@n@QLMLu@h@uCrB[T_@XQNIDMJc@ZSLWN}@f@UPQJOHk@`@MHSNO@GDIHa@^IHKJOLi@b@GNMJMHWRURe@`@SNm@h@Vf@LVR\\BFFJFLP\\R\\NXBFJVJT@DDLJVPh@BHHZJZBNFNF^BHBNLr@DXDXHr@BRDf@?FBTHr@LtAFj@Hn@@JBXD\\BVDXBXBX@HW`@W\\]b@[\\MPOPMNOPKLEFo@x@GHOPCDOP[^o@x@gArAeBrBQR[^q@t@s@|@{@hAyAnB}@jA_AhAq@x@KLcAjAEGUc@??" } ] }, "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 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 Flexible API 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 Flexible API can handle for you!