Basic job usage

This section demonstrates how to use different job task types.

You can find more details about job type schema on job concept section.

Basic pickup and delivery usage

In this example, there is one delivery, one pickup, and one pickup and delivery job with one dimensional demand.

Problem

{
  "plan": {
    "jobs": [
      {
        "id": "job1",
        "deliveries": [
          {
            "places": [
              {
                "location": {
                  "lat": 52.52599,
                  "lng": 13.45413
                },
                "duration": 300.0,
                "times": [
                  [
                    "2019-07-04T09:00:00Z",
                    "2019-07-04T18:00:00Z"
                  ],
                  [
                    "2019-07-05T09:00:00Z",
                    "2019-07-05T18:00:00Z"
                  ]
                ]
              }
            ],
            "demand": [
              1
            ]
          }
        ]
      },
      {
        "id": "job2",
        "pickups": [
          {
            "places": [
              {
                "location": {
                  "lat": 52.5225,
                  "lng": 13.4095
                },
                "duration": 240.0,
                "times": [
                  [
                    "2019-07-04T10:00:00Z",
                    "2019-07-04T16:00:00Z"
                  ]
                ]
              }
            ],
            "demand": [
              1
            ]
          }
        ]
      },
      {
        "id": "job3",
        "pickups": [
          {
            "places": [
              {
                "location": {
                  "lat": 52.5225,
                  "lng": 13.4095
                },
                "duration": 300.0
              }
            ],
            "demand": [
              1
            ],
            "tag": "p1"
          }
        ],
        "deliveries": [
          {
            "places": [
              {
                "location": {
                  "lat": 52.5165,
                  "lng": 13.3808
                },
                "duration": 300.0
              }
            ],
            "demand": [
              1
            ],
            "tag": "d1"
          }
        ]
      }
    ]
  },
  "fleet": {
    "vehicles": [
      {
        "typeId": "vehicle",
        "vehicleIds": [
          "vehicle_1"
        ],
        "profile": "normal_car",
        "costs": {
          "fixed": 22.0,
          "distance": 0.0002,
          "time": 0.004806
        },
        "shifts": [
          {
            "start": {
              "earliest": "2019-07-04T09:00:00Z",
              "location": {
                "lat": 52.5316,
                "lng": 13.3884
              }
            },
            "end": {
              "latest": "2019-07-04T18:00:00Z",
              "location": {
                "lat": 52.5316,
                "lng": 13.3884
              }
            }
          }
        ],
        "capacity": [
          10
        ]
      }
    ],
    "profiles": [
      {
        "name": "normal_car",
        "type": "car"
      }
    ]
  }
}

Solution

{
  "statistic": {
    "cost": 41.504842000000004,
    "distance": 13251,
    "duration": 3507,
    "times": {
      "driving": 2367,
      "serving": 1140,
      "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:51:29Z"
          },
          "distance": 0,
          "load": [
            1
          ],
          "activities": [
            {
              "jobId": "departure",
              "type": "departure"
            }
          ]
        },
        {
          "location": {
            "lat": 52.52599,
            "lng": 13.45413
          },
          "time": {
            "arrival": "2019-07-04T10:07:17Z",
            "departure": "2019-07-04T10:12:17Z"
          },
          "distance": 5112,
          "load": [
            0
          ],
          "activities": [
            {
              "jobId": "job1",
              "type": "delivery"
            }
          ]
        },
        {
          "location": {
            "lat": 52.5225,
            "lng": 13.4095
          },
          "time": {
            "arrival": "2019-07-04T10:22:26Z",
            "departure": "2019-07-04T10:31:26Z"
          },
          "distance": 8952,
          "load": [
            2
          ],
          "activities": [
            {
              "jobId": "job2",
              "type": "pickup",
              "location": {
                "lat": 52.5225,
                "lng": 13.4095
              },
              "time": {
                "start": "2019-07-04T10:22:26Z",
                "end": "2019-07-04T10:26:26Z"
              }
            },
            {
              "jobId": "job3",
              "type": "pickup",
              "location": {
                "lat": 52.5225,
                "lng": 13.4095
              },
              "time": {
                "start": "2019-07-04T10:26:26Z",
                "end": "2019-07-04T10:31:26Z"
              },
              "jobTag": "p1"
            }
          ]
        },
        {
          "location": {
            "lat": 52.5165,
            "lng": 13.3808
          },
          "time": {
            "arrival": "2019-07-04T10:37:37Z",
            "departure": "2019-07-04T10:42:37Z"
          },
          "distance": 11106,
          "load": [
            1
          ],
          "activities": [
            {
              "jobId": "job3",
              "type": "delivery",
              "jobTag": "d1"
            }
          ]
        },
        {
          "location": {
            "lat": 52.5316,
            "lng": 13.3884
          },
          "time": {
            "arrival": "2019-07-04T10:49:56Z",
            "departure": "2019-07-04T10:49:56Z"
          },
          "distance": 13251,
          "load": [
            0
          ],
          "activities": [
            {
              "jobId": "arrival",
              "type": "arrival"
            }
          ]
        }
      ],
      "statistic": {
        "cost": 41.504842000000004,
        "distance": 13251,
        "duration": 3507,
        "times": {
          "driving": 2367,
          "serving": 1140,
          "waiting": 0,
          "break": 0
        }
      }
    }
  ]
}


As problem has two job task places with exactly same location, solution contains one stop with two activities.

Multiple pickups and deliveries

This example contains two multi jobs with slightly different parameters.

Problem

{
 "plan": {
   "jobs": [
     {
       "id": "multi_job1",
       "pickups": [
         {
           "places": [
             {
               "location": {
                 "lat": 52.5622847,
                 "lng": 13.4023099
               },
               "duration": 240.0
             }
           ],
           "demand": [
             1
           ],
           "tag": "p1"
         },
         {
           "places": [
             {
               "location": {
                 "lat": 52.5330881,
                 "lng": 13.3973059
               },
               "duration": 240.0
             }
           ],
           "demand": [
             1
           ],
           "tag": "p2"
         }
       ],
       "deliveries": [
         {
           "places": [
             {
               "location": {
                 "lat": 52.5252832,
                 "lng": 13.4188422
               },
               "duration": 240.0
             }
           ],
           "demand": [
             2
           ],
           "tag": "d1"
         }
       ]
     },
     {
       "id": "multi_job2",
       "pickups": [
         {
           "places": [
             {
               "location": {
                 "lat": 52.52599,
                 "lng": 13.45413
               },
               "duration": 240.0
             }
           ],
           "demand": [
             2
           ],
           "tag": "p1"
         }
       ],
       "deliveries": [
         {
           "places": [
             {
               "location": {
                 "lat": 52.4928,
                 "lng": 13.4597
               },
               "duration": 240.0
             }
           ],
           "demand": [
             1
           ],
           "tag": "d1"
         },
         {
           "places": [
             {
               "location": {
                 "lat": 52.4989,
                 "lng": 13.3917
               },
               "duration": 240.0
             }
           ],
           "demand": [
             1
           ],
           "tag": "d2"
         }
       ]
     }
   ]
 },
 "fleet": {
   "vehicles": [
     {
       "typeId": "vehicle",
       "vehicleIds": [
         "vehicle_1"
       ],
       "profile": "normal_car",
       "costs": {
         "fixed": 22.0,
         "distance": 0.0002,
         "time": 0.004806
       },
       "shifts": [
         {
           "start": {
             "earliest": "2019-07-04T09:00:00Z",
             "location": {
               "lat": 52.4664257,
               "lng": 13.2812488
             }
           },
           "end": {
             "latest": "2019-07-04T18:00:00Z",
             "location": {
               "lat": 52.4664257,
               "lng": 13.2812488
             }
           }
         }
       ],
       "capacity": [
         10
       ]
     }
   ],
   "profiles": [
     {
       "name": "normal_car",
       "type": "car"
     }
   ]
 }
}

Solution

{
 "statistic": {
   "cost": 74.412666,
   "distance": 52738,
   "duration": 8711,
   "times": {
     "driving": 7271,
     "serving": 1440,
     "waiting": 0,
     "break": 0
   }
 },
 "tours": [
   {
     "vehicleId": "vehicle_1",
     "typeId": "vehicle",
     "shiftIndex": 0,
     "stops": [
       {
         "location": {
           "lat": 52.4664257,
           "lng": 13.2812488
         },
         "time": {
           "arrival": "2019-07-04T09:00:00Z",
           "departure": "2019-07-04T09:00:00Z"
         },
         "distance": 0,
         "load": [
           0
         ],
         "activities": [
           {
             "jobId": "departure",
             "type": "departure"
           }
         ]
       },
       {
         "location": {
           "lat": 52.5622847,
           "lng": 13.4023099
         },
         "time": {
           "arrival": "2019-07-04T09:32:24Z",
           "departure": "2019-07-04T09:36:24Z"
         },
         "distance": 17547,
         "load": [
           1
         ],
         "activities": [
           {
             "jobId": "multi_job1",
             "type": "pickup",
             "tag": "p1"
           }
         ]
       },
       {
         "location": {
           "lat": 52.5330881,
           "lng": 13.3973059
         },
         "time": {
           "arrival": "2019-07-04T09:49:48Z",
           "departure": "2019-07-04T09:53:48Z"
         },
         "distance": 22014,
         "load": [
           2
         ],
         "activities": [
           {
             "jobId": "multi_job1",
             "type": "pickup",
             "tag": "p2"
           }
         ]
       },
       {
         "location": {
           "lat": 52.5252832,
           "lng": 13.4188422
         },
         "time": {
           "arrival": "2019-07-04T10:00:48Z",
           "departure": "2019-07-04T10:04:48Z"
         },
         "distance": 23849,
         "load": [
           0
         ],
         "activities": [
           {
             "jobId": "multi_job1",
             "type": "delivery",
             "tag": "d1"
           }
         ]
       },
       {
         "location": {
           "lat": 52.52599,
           "lng": 13.45413
         },
         "time": {
           "arrival": "2019-07-04T10:12:17Z",
           "departure": "2019-07-04T10:16:17Z"
         },
         "distance": 26552,
         "load": [
           2
         ],
         "activities": [
           {
             "jobId": "multi_job2",
             "type": "pickup",
             "tag": "p1"
           }
         ]
       },
       {
         "location": {
           "lat": 52.4928,
           "lng": 13.4597
         },
         "time": {
           "arrival": "2019-07-04T10:38:25Z",
           "departure": "2019-07-04T10:42:25Z"
         },
         "distance": 35242,
         "load": [
           1
         ],
         "activities": [
           {
             "jobId": "multi_job2",
             "type": "delivery",
             "tag": "d1"
           }
         ]
       },
       {
         "location": {
           "lat": 52.4989,
           "lng": 13.3917
         },
         "time": {
           "arrival": "2019-07-04T10:57:57Z",
           "departure": "2019-07-04T11:01:57Z"
         },
         "distance": 40617,
         "load": [
           0
         ],
         "activities": [
           {
             "jobId": "multi_job2",
             "type": "delivery",
             "tag": "d2"
           }
         ]
       },
       {
         "location": {
           "lat": 52.4664257,
           "lng": 13.2812488
         },
         "time": {
           "arrival": "2019-07-04T11:25:11Z",
           "departure": "2019-07-04T11:25:11Z"
         },
         "distance": 52738,
         "load": [
           0
         ],
         "activities": [
           {
             "jobId": "arrival",
             "type": "arrival"
           }
         ]
       }
     ],
     "statistic": {
       "cost": 74.412666,
       "distance": 52738,
       "duration": 8711,
       "times": {
         "driving": 7271,
         "serving": 1440,
         "waiting": 0,
         "break": 0
       }
     }
   }
 ],
 "unassigned": []
}

Mixing job task types

You can mix job task types in one job:

Problem

{
 "plan": {
   "jobs": [
     {
       "id": "simple_replacement_job",
       "replacements": [
         {
           "places": [
             {
               "location": {
                 "lat": 52.5622847,
                 "lng": 13.4023099
               },
               "duration": 3600.0,
               "times": [
                 [
                   "2019-07-04T09:00:00Z",
                   "2019-07-04T18:00:00Z"
                 ]
               ]
             }
           ],
           "demand": [
             3
           ]
         }
       ]
     },
     {
       "id": "simple_service_job",
       "services": [
         {
           "places": [
             {
               "location": {
                 "lat": 52.5330881,
                 "lng": 13.3973059
               },
               "duration": 3600.0,
               "times": [
                 [
                   "2019-07-04T08:00:00Z",
                   "2019-07-04T12:00:00Z"
                 ],
                 [
                   "2019-07-04T14:00:00Z",
                   "2019-07-04T18:00:00Z"
                 ]
               ]
             }
           ]
         }
       ]
     },
     {
       "id": "mixed_job",
       "pickups": [
         {
           "places": [
             {
               "location": {
                 "lat": 52.5252832,
                 "lng": 13.4188422
               },
               "duration": 240.0
             }
           ],
           "demand": [
             1
           ],
           "tag": "p1"
         }
       ],
       "deliveries": [
         {
           "places": [
             {
               "location": {
                 "lat": 52.52599,
                 "lng": 13.45413
               },
               "duration": 240.0
             }
           ],
           "demand": [
             1
           ],
           "tag": "d1"
         }
       ],
       "replacements": [
         {
           "places": [
             {
               "location": {
                 "lat": 52.4928,
                 "lng": 13.4597
               },
               "duration": 2400.0
             }
           ],
           "demand": [
             2
           ],
           "tag": "r1"
         }
       ],
       "services": [
         {
           "places": [
             {
               "location": {
                 "lat": 52.4989,
                 "lng": 13.3917
               },
               "duration": 1800.0
             }
           ],
           "tag": "s1"
         }
       ]
     }
   ]
 },
 "fleet": {
   "vehicles": [
     {
       "typeId": "vehicle",
       "vehicleIds": [
         "vehicle_1"
       ],
       "profile": "normal_car",
       "costs": {
         "fixed": 22.0,
         "distance": 0.0002,
         "time": 0.004806
       },
       "shifts": [
         {
           "start": {
             "earliest": "2019-07-04T09:00:00Z",
             "location": {
               "lat": 52.4664257,
               "lng": 13.2812488
             }
           },
           "end": {
             "latest": "2019-07-04T18:00:00Z",
             "location": {
               "lat": 52.4664257,
               "lng": 13.2812488
             }
           }
         }
       ],
       "capacity": [
         10
       ]
     }
   ],
   "profiles": [
     {
       "name": "normal_car",
       "type": "car"
     }
   ]
 }
}

Solution

{
 "statistic": {
   "cost": 124.587306,
   "distance": 52738,
   "duration": 19151,
   "times": {
     "driving": 7271,
     "serving": 11880,
     "waiting": 0,
     "break": 0
   }
 },
 "tours": [
   {
     "vehicleId": "vehicle_1",
     "typeId": "vehicle",
     "shiftIndex": 0,
     "stops": [
       {
         "location": {
           "lat": 52.4664257,
           "lng": 13.2812488
         },
         "time": {
           "arrival": "2019-07-04T09:00:00Z",
           "departure": "2019-07-04T09:00:00Z"
         },
         "distance": 0,
         "load": [
           5
         ],
         "activities": [
           {
             "jobId": "departure",
             "type": "departure"
           }
         ]
       },
       {
         "location": {
           "lat": 52.5622847,
           "lng": 13.4023099
         },
         "time": {
           "arrival": "2019-07-04T09:32:24Z",
           "departure": "2019-07-04T10:32:24Z"
         },
         "distance": 17547,
         "load": [
           5
         ],
         "activities": [
           {
             "jobId": "simple_replacement_job",
             "type": "replacement"
           }
         ]
       },
       {
         "location": {
           "lat": 52.5330881,
           "lng": 13.3973059
         },
         "time": {
           "arrival": "2019-07-04T10:45:48Z",
           "departure": "2019-07-04T11:45:48Z"
         },
         "distance": 22014,
         "load": [
           5
         ],
         "activities": [
           {
             "jobId": "simple_service_job",
             "type": "service"
           }
         ]
       },
       {
         "location": {
           "lat": 52.5252832,
           "lng": 13.4188422
         },
         "time": {
           "arrival": "2019-07-04T11:52:48Z",
           "departure": "2019-07-04T11:56:48Z"
         },
         "distance": 23849,
         "load": [
           6
         ],
         "activities": [
           {
             "jobId": "mixed_job",
             "type": "pickup",
             "tag": "p1"
           }
         ]
       },
       {
         "location": {
           "lat": 52.52599,
           "lng": 13.45413
         },
         "time": {
           "arrival": "2019-07-04T12:04:17Z",
           "departure": "2019-07-04T12:08:17Z"
         },
         "distance": 26552,
         "load": [
           5
         ],
         "activities": [
           {
             "jobId": "mixed_job",
             "type": "delivery",
             "tag": "d1"
           }
         ]
       },
       {
         "location": {
           "lat": 52.4928,
           "lng": 13.4597
         },
         "time": {
           "arrival": "2019-07-04T12:30:25Z",
           "departure": "2019-07-04T13:10:25Z"
         },
         "distance": 35242,
         "load": [
           5
         ],
         "activities": [
           {
             "jobId": "mixed_job",
             "type": "replacement",
             "tag": "r1"
           }
         ]
       },
       {
         "location": {
           "lat": 52.4989,
           "lng": 13.3917
         },
         "time": {
           "arrival": "2019-07-04T13:25:57Z",
           "departure": "2019-07-04T13:55:57Z"
         },
         "distance": 40617,
         "load": [
           5
         ],
         "activities": [
           {
             "jobId": "mixed_job",
             "type": "service",
             "tag": "s1"
           }
         ]
       },
       {
         "location": {
           "lat": 52.4664257,
           "lng": 13.2812488
         },
         "time": {
           "arrival": "2019-07-04T14:19:11Z",
           "departure": "2019-07-04T14:19:11Z"
         },
         "distance": 52738,
         "load": [
           0
         ],
         "activities": [
           {
             "jobId": "arrival",
             "type": "arrival"
           }
         ]
       }
     ],
     "statistic": {
       "cost": 124.587306,
       "distance": 52738,
       "duration": 19151,
       "times": {
         "driving": 7271,
         "serving": 11880,
         "waiting": 0,
         "break": 0
       }
     }
   }
 ],
 "unassigned": []
}