Include multiple shifts

You can combine multiple shift times for your fleet to manage and optimize vehicle routes more effectively when dealing with complex scenarios.

This feature allows specifying vehicle shifts and job time windows separately for different days within a single problem. For example, if you need to manage deliveries or pickups over a week, and your fleet has vehicles with varying shift times on different days, you can specify these constraints in one problem. This approach not only eliminates the need to create separate problems for each day but also enables optimal tour planning by maximizing fleet utilization. This approach is particularly beneficial for jobs that can be flexibly scheduled across different times or shifts, ensuring efficient and effective use of your resources.

Define multiple shifts in a problem

A common scenario for using multiple shifts involves having a long list of jobs with no time restrictions and a limited number of vehicles to serve them. In such cases, the vehicle can't complete the jobs within a single shift. By setting multiple shifts for your vehicles, you ensure that the vehicle serves the jobs over several shifts in the most efficient way.

📘

Note

  • Each vehicle's shift must have distinct start and end times without any overlap.
  • Different shifts for a vehicle are distinguished by the shiftIndex property in the tour. The vehicle ID remains the same for all shifts of a vehicle. For more information, see the API Reference.

Scenario: handle jobs with no time constraints

Consider a scenario in which you have 15 jobs with no time constraints, a single vehicle with a capacity of 10, and a shift length of only 3 hours per day. The vehicle can't complete all the jobs in one shift. To address this problem, you can specify multiple shifts for the vehicle, which allows that vehicle to complete the jobs over several days.

In this case, add dates to the vehicle's shift times, creating 4 shifts to cover the required work, as shown in the following example:

  • Shift 1: 2021-10-23T09:00:00Z - 2021-10-23T12:00:00Z
  • Shift 2: 2021-10-24T09:00:00Z - 2021-10-24T12:00:00Z
  • Shift 3: 2021-10-25T09:00:00Z - 2021-10-25T12:00:00Z
  • Shift 4: 2021-10-26T09:00:00Z - 2021-10-26T12:00:00Z

Problem

The following problem demonstrates how you can specify multiple shifts for a vehicle, based on the previous sample scenario:

Click to expand/collapse the sample JSON
{
  "fleet": {
    "types": [
      {
        "id": "Vehicle_1",
        "profile": "car",
        "costs": {
          "fixed": 10,
          "distance": 0.002,
          "time": 0.003
        },
        "shifts": [
          {
            "start": {
              "time": "2021-10-23T09:00:00Z",
              "location": {
                "lat": 51.059188,
                "lng": 13.540317
              }
            },
            "end": {
              "time": "2021-10-23T12:00:00Z",
              "location": {
                "lat": 51.059188,
                "lng": 13.540317
              }
            }
          },
          {
            "start": {
              "time": "2021-10-24T09:00:00Z",
              "location": {
                "lat": 51.059188,
                "lng": 13.540317
              }
            },
            "end": {
              "time": "2021-10-24T12:00:00Z",
              "location": {
                "lat": 51.059188,
                "lng": 13.540317
              }
            }
          },
          {
            "start": {
              "time": "2021-10-25T09:00:00Z",
              "location": {
                "lat": 51.059188,
                "lng": 13.540317
              }
            },
            "end": {
              "time": "2021-10-25T12:00:00Z",
              "location": {
                "lat": 51.059188,
                "lng": 13.540317
              }
            }
          },
          {
            "start": {
              "time": "2021-10-26T09:00:00Z",
              "location": {
                "lat": 51.059188,
                "lng": 13.540317
              }
            },
            "end": {
              "time": "2021-10-26T12:00:00Z",
              "location": {
                "lat": 51.059188,
                "lng": 13.540317
              }
            }
          }
        ],
        "capacity": [
          10
        ],
        "amount": 1
      }
    ],
    "profiles": [
      {
        "type": "car",
        "name": "car"
      }
    ]
  },
  "plan": {
    "jobs": [
      {
        "id": "Job_1",
        "tasks": {
          "pickups": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.05238,
                    "lng": 13.74114
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_2",
        "tasks": {
          "pickups": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.06099,
                    "lng": 13.75245
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_3",
        "tasks": {
          "pickups": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.08511,
                    "lng": 13.76875
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_4",
        "tasks": {
          "pickups": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.1323847,
                    "lng": 13.7779515
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_5",
        "tasks": {
          "pickups": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.11716,
                    "lng": 13.73054
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_6",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.12308,
                    "lng": 13.76406
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_7",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.08588,
                    "lng": 13.72637
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_8",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.08588,
                    "lng": 13.72637
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_9",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.08588,
                    "lng": 13.72637
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_10",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.18588,
                    "lng": 13.52637
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_11",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.10588,
                    "lng": 13.79637
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_12",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.01588,
                    "lng": 13.52637
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_13",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.08588,
                    "lng": 13.62637
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_14",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.00088,
                    "lng": 13.02637
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "Job_15",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "location": {
                    "lat": 51.06866,
                    "lng": 13.77273
                  },
                  "duration": 1350
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      }
    ]
  }
}

Solution

The following figure provides a visual breakdown of the resulting solution:

Multiple shifts with no time constraints

As the solution demonstrates, the optimization algorithm distributed jobs across the vehicle's four shifts as follows:

  • Five jobs on October 23
  • Five jobs on October 24
  • One job on October 25
  • Four jobs on October 26

This way, the vehicle was able to complete all its assigned jobs in an efficient way, without violating the shift time windows.

The following section contains the full solution JSON:

Click to expand/collapse the sample JSON
  {
      "statistic": {
          "cost": 673.386,
          "distance": 262603,
          "duration": 36060,
          "times": {
              "driving": 15810,
              "serving": 20250,
              "waiting": 0,
              "break": 0
          }
      },
      "tours": [
          {
              "vehicleId": "Vehicle_1_1",
              "typeId": "Vehicle_1",
              "stops": [
                  {
                      "location": {
                          "lat": 51.059188,
                          "lng": 13.540317
                      },
                      "time": {
                          "arrival": "2021-10-24T09:00:00Z",
                          "departure": "2021-10-24T09:00:00Z"
                      },
                      "load": [
                          2
                      ],
                      "activities": [
                          {
                              "jobId": "departure",
                              "type": "departure"
                          }
                      ],
                      "distance": 0
                  },
                  {
                      "location": {
                          "lat": 51.05238,
                          "lng": 13.74114
                      },
                      "time": {
                          "arrival": "2021-10-24T09:23:14Z",
                          "departure": "2021-10-24T09:45:44Z"
                      },
                      "load": [
                          3
                      ],
                      "activities": [
                          {
                              "jobId": "Job_1",
                              "type": "pickup"
                          }
                      ],
                      "distance": 22782
                  },
                  {
                      "location": {
                          "lat": 51.06099,
                          "lng": 13.75245
                      },
                      "time": {
                          "arrival": "2021-10-24T09:50:59Z",
                          "departure": "2021-10-24T10:13:29Z"
                      },
                      "load": [
                          4
                      ],
                      "activities": [
                          {
                              "jobId": "Job_2",
                              "type": "pickup"
                          }
                      ],
                      "distance": 24694
                  },
                  {
                      "location": {
                          "lat": 51.06866,
                          "lng": 13.77273
                      },
                      "time": {
                          "arrival": "2021-10-24T10:16:40Z",
                          "departure": "2021-10-24T10:39:10Z"
                      },
                      "load": [
                          3
                      ],
                      "activities": [
                          {
                              "jobId": "Job_15",
                              "type": "delivery"
                          }
                      ],
                      "distance": 27864
                  },
                  {
                      "location": {
                          "lat": 51.08511,
                          "lng": 13.76875
                      },
                      "time": {
                          "arrival": "2021-10-24T10:45:22Z",
                          "departure": "2021-10-24T11:07:52Z"
                      },
                      "load": [
                          4
                      ],
                      "activities": [
                          {
                              "jobId": "Job_3",
                              "type": "pickup"
                          }
                      ],
                      "distance": 31892
                  },
                  {
                      "location": {
                          "lat": 51.10588,
                          "lng": 13.79637
                      },
                      "time": {
                          "arrival": "2021-10-24T11:13:48Z",
                          "departure": "2021-10-24T11:36:18Z"
                      },
                      "load": [
                          3
                      ],
                      "activities": [
                          {
                              "jobId": "Job_11",
                              "type": "delivery"
                          }
                      ],
                      "distance": 35237
                  },
                  {
                      "location": {
                          "lat": 51.059188,
                          "lng": 13.540317
                      },
                      "time": {
                          "arrival": "2021-10-24T11:57:06Z",
                          "departure": "2021-10-24T11:57:06Z"
                      },
                      "load": [
                          0
                      ],
                      "activities": [
                          {
                              "jobId": "arrival",
                              "type": "arrival"
                          }
                      ],
                      "distance": 56742
                  }
              ],
              "statistic": {
                  "cost": 152.36999999999998,
                  "distance": 55246,
                  "duration": 10626,
                  "times": {
                      "driving": 3876,
                      "serving": 6750,
                      "waiting": 0,
                      "break": 0
                  }
              },
              "shiftIndex": 1
          },
          {
              "vehicleId": "Vehicle_1_1",
              "typeId": "Vehicle_1",
              "stops": [
                  {
                      "location": {
                          "lat": 51.059188,
                          "lng": 13.540317
                      },
                      "time": {
                          "arrival": "2021-10-26T09:00:00Z",
                          "departure": "2021-10-26T09:00:00Z"
                      },
                      "load": [
                          2
                      ],
                      "activities": [
                          {
                              "jobId": "departure",
                              "type": "departure"
                          }
                      ],
                      "distance": 0
                  },
                  {
                      "location": {
                          "lat": 51.18588,
                          "lng": 13.52637
                      },
                      "time": {
                          "arrival": "2021-10-26T09:28:01Z",
                          "departure": "2021-10-26T09:50:31Z"
                      },
                      "load": [
                          1
                      ],
                      "activities": [
                          {
                              "jobId": "Job_10",
                              "type": "delivery"
                          }
                      ],
                      "distance": 9299
                  },
                  {
                      "location": {
                          "lat": 51.1323847,
                          "lng": 13.7779515
                      },
                      "time": {
                          "arrival": "2021-10-26T10:16:25Z",
                          "departure": "2021-10-26T10:38:55Z"
                      },
                      "load": [
                          2
                      ],
                      "activities": [
                          {
                              "jobId": "Job_4",
                              "type": "pickup"
                          }
                      ],
                      "distance": 22650
                  },
                  {
                      "location": {
                          "lat": 51.12308,
                          "lng": 13.76406
                      },
                      "time": {
                          "arrival": "2021-10-26T10:43:05Z",
                          "departure": "2021-10-26T11:05:35Z"
                      },
                      "load": [
                          1
                      ],
                      "activities": [
                          {
                              "jobId": "Job_6",
                              "type": "delivery"
                          }
                      ],
                      "distance": 27842
                  },
                  {
                      "location": {
                          "lat": 51.11716,
                          "lng": 13.73054
                      },
                      "time": {
                          "arrival": "2021-10-26T11:11:20Z",
                          "departure": "2021-10-26T11:33:50Z"
                      },
                      "load": [
                          2
                      ],
                      "activities": [
                          {
                              "jobId": "Job_5",
                              "type": "pickup"
                          }
                      ],
                      "distance": 48395
                  },
                  {
                      "location": {
                          "lat": 51.059188,
                          "lng": 13.540317
                      },
                      "time": {
                          "arrival": "2021-10-26T11:49:06Z",
                          "departure": "2021-10-26T11:49:06Z"
                      },
                      "load": [
                          0
                      ],
                      "activities": [
                          {
                              "jobId": "arrival",
                              "type": "arrival"
                          }
                      ],
                      "distance": 68746
                  }
              ],
              "statistic": {
                  "cost": 180.524,
                  "distance": 70043,
                  "duration": 10146,
                  "times": {
                      "driving": 4746,
                      "serving": 5400,
                      "waiting": 0,
                      "break": 0
                  }
              },
              "shiftIndex": 3
          },
          {
              "vehicleId": "Vehicle_1_1",
              "typeId": "Vehicle_1",
              "stops": [
                  {
                      "location": {
                          "lat": 51.059188,
                          "lng": 13.540317
                      },
                      "time": {
                          "arrival": "2021-10-23T09:00:00Z",
                          "departure": "2021-10-23T09:00:00Z"
                      },
                      "load": [
                          5
                      ],
                      "activities": [
                          {
                              "jobId": "departure",
                              "type": "departure"
                          }
                      ],
                      "distance": 0
                  },
                  {
                      "location": {
                          "lat": 51.08588,
                          "lng": 13.62637
                      },
                      "time": {
                          "arrival": "2021-10-23T09:13:53Z",
                          "departure": "2021-10-23T09:36:23Z"
                      },
                      "load": [
                          4
                      ],
                      "activities": [
                          {
                              "jobId": "Job_13",
                              "type": "delivery"
                          }
                      ],
                      "distance": 18700
                  },
                  {
                      "location": {
                          "lat": 51.08588,
                          "lng": 13.72637
                      },
                      "time": {
                          "arrival": "2021-10-23T09:51:23Z",
                          "departure": "2021-10-23T10:58:53Z"
                      },
                      "load": [
                          1
                      ],
                      "activities": [
                          {
                              "jobId": "Job_9",
                              "type": "delivery",
                              "location": {
                                  "lat": 51.08588,
                                  "lng": 13.72637
                              },
                              "time": {
                                  "start": "2021-10-23T09:51:23Z",
                                  "end": "2021-10-23T10:13:53Z"
                              }
                          },
                          {
                              "jobId": "Job_7",
                              "type": "delivery",
                              "location": {
                                  "lat": 51.08588,
                                  "lng": 13.72637
                              },
                              "time": {
                                  "start": "2021-10-23T10:13:53Z",
                                  "end": "2021-10-23T10:36:23Z"
                              }
                          },
                          {
                              "jobId": "Job_8",
                              "type": "delivery",
                              "location": {
                                  "lat": 51.08588,
                                  "lng": 13.72637
                              },
                              "time": {
                                  "start": "2021-10-23T10:36:23Z",
                                  "end": "2021-10-23T10:58:53Z"
                              }
                          }
                      ],
                      "distance": 22771
                  },
                  {
                      "location": {
                          "lat": 51.01588,
                          "lng": 13.52637
                      },
                      "time": {
                          "arrival": "2021-10-23T11:20:08Z",
                          "departure": "2021-10-23T11:42:38Z"
                      },
                      "load": [
                          0
                      ],
                      "activities": [
                          {
                              "jobId": "Job_12",
                              "type": "delivery"
                          }
                      ],
                      "distance": 25067
                  },
                  {
                      "location": {
                          "lat": 51.059188,
                          "lng": 13.540317
                      },
                      "time": {
                          "arrival": "2021-10-23T11:55:00Z",
                          "departure": "2021-10-23T11:55:00Z"
                      },
                      "load": [
                          0
                      ],
                      "activities": [
                          {
                              "jobId": "arrival",
                              "type": "arrival"
                          }
                      ],
                    "distance": 44098
                  }
              ],
              "statistic": {
                  "cost": 148.944,
                  "distance": 53722,
                  "duration": 10500,
                  "times": {
                      "driving": 3750,
                      "serving": 6750,
                      "waiting": 0,
                      "break": 0
                  }
              },
              "shiftIndex": 0
          },
          {
              "vehicleId": "Vehicle_1_1",
              "typeId": "Vehicle_1",
              "stops": [
                  {
                      "location": {
                          "lat": 51.059188,
                          "lng": 13.540317
                      },
                      "time": {
                          "arrival": "2021-10-25T09:00:00Z",
                          "departure": "2021-10-25T09:00:00Z"
                      },
                      "load": [
                          1
                      ],
                      "activities": [
                          {
                              "jobId": "departure",
                              "type": "departure"
                          }
                      ],
                      "distance": 0
                  },
                  {
                      "location": {
                          "lat": 51.00088,
                          "lng": 13.02637
                      },
                      "time": {
                          "arrival": "2021-10-25T09:28:45Z",
                          "departure": "2021-10-25T09:51:15Z"
                      },
                      "load": [
                          0
                      ],
                      "activities": [
                          {
                              "jobId": "Job_14",
                              "type": "delivery"
                          }
                      ],
                      "distance": 41711
                  },
                  {
                      "location": {
                          "lat": 51.059188,
                          "lng": 13.540317
                      },
                      "time": {
                          "arrival": "2021-10-25T10:19:48Z",
                          "departure": "2021-10-25T10:19:48Z"
                      },
                      "load": [
                          0
                      ],
                      "activities": [
                          {
                              "jobId": "arrival",
                              "type": "arrival"
                          }
                      ],
                      "distance": 83583
                  }
              ],
              "statistic": {
                  "cost": 191.548,
                  "distance": 83592,
                  "duration": 4788,
                  "times": {
                      "driving": 3438,
                      "serving": 1350,
                      "waiting": 0,
                      "break": 0
                  }
              },
              "shiftIndex": 2
          }
      ]
  }

Scenario: handle jobs with specific time constraints

For jobs with specific time constraints, you add time windows to ensure they are scheduled appropriately. For example, if a job can only be delivered on October 23, you would add a time window for that job on that date, within the corresponding shift time.

You can schedule jobs without specific time constraints on any day by not specifying a time window. The optimization algorithm schedules such jobs in the way that is most efficient for the overall tour.

Consider a scenario where you need to serve 10 jobs using a vehicle with different shift times over three days. Five of these jobs have specific time constraints, while the other five do not.

Vehicle availability:

  • Shift 1: from 8:00 to 14:00 on October 23
  • Shift 2: from 9:00 to 15:00 on October 24
  • Shift 3: from 10:00 to 21:00 on October 25

Jobs with Time Windows:

  • Job 1: Must be started on October 23 between 9:00 and 12:00
  • Job 2: Must be started on October 23 between 12:00 and 14:00
  • Job 3: Must be started on October 24 between 10:00 and 12:00
  • Job 4: Must be started on October 25 between 11:00 and 13:00
  • Job 5: Must be started on October 25 between 15:00 and 18:00

Jobs without Time Windows:

Job 6 through Job 10 can be completed on any day.

Problem

The following section contains a problem JSON reflecting the previously mentioned constraints:

Click to expand/collapse the sample JSON
  {
    "fleet": {
      "types": [
        {
          "id": "Vehicle_1",
          "profile": "car",
          "costs": {
            "fixed": 10,
            "distance": 0.002,
            "time": 0.003
          },
          "shifts": [
            {
              "start": {
                "time": "2021-10-23T08:00:00Z",
                "location": {
                  "lat": 51.059188,
                  "lng": 13.540317
                }
              },
              "end": {
                "time": "2021-10-23T14:00:00Z",
                "location": {
                  "lat": 51.059188,
                  "lng": 13.540317
                }
              }
            },
            {
              "start": {
                "time": "2021-10-24T09:00:00Z",
                "location": {
                  "lat": 51.059188,
                  "lng": 13.540317
                }
              },
              "end": {
                "time": "2021-10-24T15:00:00Z",
                "location": {
                  "lat": 51.059188,
                  "lng": 13.540317
                }
              }
            },
            {
              "start": {
                "time": "2021-10-25T10:00:00Z",
                "location": {
                  "lat": 51.059188,
                  "lng": 13.540317
                }
              },
              "end": {
                "time": "2021-10-25T21:00:00Z",
                "location": {
                  "lat": 51.059188,
                  "lng": 13.540317
                }
              }
            }
          ],
          "capacity": [
            10
          ],
          "amount": 1
        }
      ],
      "profiles": [
        {
          "type": "car",
          "name": "car"
        }
      ]
    },
    "plan": {
      "jobs": [
        {
          "id": "Job_1",
          "tasks": {
            "pickups": [
              {
                "places": [
                  {
                    "times": [
                      [
                        "2021-10-23T09:00:00Z",
                        "2021-10-23T12:00:00Z"
                      ]
                    ],
                    "location": {
                      "lat": 51.05238,
                      "lng": 13.74114
                    },
                    "duration": 1350
                  }
                ],
                "demand": [
                  1
                ]
              }
            ]
          }
        },
        {
          "id": "Job_2",
          "tasks": {
            "pickups": [
              {
                "places": [
                  {
                    "times": [
                      [
                        "2021-10-23T12:00:00Z",
                        "2021-10-23T14:00:00Z"
                      ]
                    ],
                    "location": {
                      "lat": 51.06099,
                      "lng": 13.75245
                    },
                    "duration": 1350
                  }
                ],
                "demand": [
                  1
                ]
              }
            ]
          }
        },
        {
          "id": "Job_3",
          "tasks": {
            "pickups": [
              {
                "places": [
                  {
                    "times": [
                      [
                        "2021-10-24T10:00:00Z",
                        "2021-10-24T12:00:00Z"
                      ]
                    ],
                    "location": {
                      "lat": 51.08511,
                      "lng": 13.76875
                    },
                    "duration": 1350
                  }
                ],
                "demand": [
                  1
                ]
              }
            ]
          }
        },
        {
          "id": "Job_4",
          "tasks": {
            "pickups": [
              {
                "places": [
                  {
                    "times": [
                      [
                        "2021-10-25T11:00:00Z",
                        "2021-10-25T13:00:00Z"
                      ]
                    ],
                    "location": {
                      "lat": 51.1323847,
                      "lng": 13.7779515
                    },
                    "duration": 1350
                  }
                ],
                "demand": [
                  1
                ]
              }
            ]
          }
        },
        {
          "id": "Job_5",
          "tasks": {
            "pickups": [
              {
                "places": [
                  {
                    "times": [
                      [
                        "2021-10-25T15:00:00Z",
                        "2021-10-25T18:00:00Z"
                      ]
                    ],
                    "location": {
                      "lat": 51.11716,
                      "lng": 13.73054
                    },
                    "duration": 1350
                  }
                ],
                "demand": [
                  1
                ]
              }
            ]
          }
        },
        {
          "id": "Job_6",
          "tasks": {
            "deliveries": [
              {
                "places": [
                  {
                    "location": {
                      "lat": 51.12308,
                      "lng": 13.76406
                    },
                    "duration": 1350
                  }
                ],
                "demand": [
                  1
                ]
              }
            ]
          }
        },
        {
          "id": "Job_7",
          "tasks": {
            "deliveries": [
              {
                "places": [
                  {
                    "location": {
                      "lat": 51.08588,
                      "lng": 13.72637
                    },
                    "duration": 1350
                  }
                ],
                "demand": [
                  1
                ]
              }
            ]
          }
        },
        {
          "id": "Job_8",
          "tasks": {
            "deliveries": [
              {
                "places": [
                  {
                    "location": {
                      "lat": 51.08588,
                      "lng": 13.72637
                    },
                    "duration": 1350
                  }
                ],
                "demand": [
                  1
                ]
              }
            ]
          }
        },
        {
          "id": "Job_9",
          "tasks": {
            "deliveries": [
              {
                "places": [
                  {
                    "location": {
                      "lat": 51.08588,
                      "lng": 13.72637
                    },
                    "duration": 1350
                  }
                ],
                "demand": [
                  1
                ]
              }
            ]
          }
        },
        {
          "id": "Job_10",
          "tasks": {
            "deliveries": [
              {
                "places": [
                  {
                    "location": {
                      "lat": 51.06866,
                      "lng": 13.77273
                    },
                    "duration": 1350
                  }
                ],
                "demand": [
                  1
                ]
              }
            ]
          }
        }
      ]
    }
  }

Solution

The following figure provides a visual breakdown of the resulting solution, highlighting the jobs constrained by time windows:

Multiple shifts with time windows

The optimization algorithm successfully scheduled all time-constrained jobs within their specified time windows. The remaining jobs, which were not associated with any time windows, were scheduled flexibly within the shifts to maximize overall tour efficiency.

The following section contains the solution JSON, for reference:

Click to expand/collapse the sample JSON
  {
    "statistic": {
      "cost": 390.953,
      "distance": 141352,
      "duration": 26083,
      "times": {
        "driving": 8644,
        "serving": 13500,
        "waiting": 3939,
        "stopping": 0,
        "break": 0
      }
    },
    "tours": [
      {
        "vehicleId": "Vehicle_1_1",
        "typeId": "Vehicle_1",
        "stops": [
          {
            "time": {
              "arrival": "2021-10-24T09:00:00Z",
              "departure": "2021-10-24T09:00:00Z"
            },
            "load": [
              4
            ],
            "activities": [
              {
                "jobId": "departure",
                "type": "departure",
                "location": {
                  "lat": 51.059188,
                  "lng": 13.540317
                },
                "time": {
                  "start": "2021-10-24T09:00:00Z",
                  "end": "2021-10-24T09:00:00Z"
                }
              }
            ],
            "location": {
              "lat": 51.059188,
              "lng": 13.540317
            },
            "distance": 0
          },
          {
            "time": {
              "arrival": "2021-10-24T09:15:25Z",
              "departure": "2021-10-24T10:22:55Z"
            },
            "load": [
              1
            ],
            "activities": [
              {
                "jobId": "Job_8",
                "type": "delivery",
                "location": {
                  "lat": 51.08588,
                  "lng": 13.72637
                },
                "time": {
                  "start": "2021-10-24T09:15:25Z",
                  "end": "2021-10-24T09:37:55Z"
                }
              },
              {
                "jobId": "Job_9",
                "type": "delivery",
                "location": {
                  "lat": 51.08588,
                  "lng": 13.72637
                },
                "time": {
                  "start": "2021-10-24T09:37:55Z",
                  "end": "2021-10-24T10:00:25Z"
                }
              },
              {
                "jobId": "Job_7",
                "type": "delivery",
                "location": {
                  "lat": 51.08588,
                  "lng": 13.72637
                },
                "time": {
                  "start": "2021-10-24T10:00:25Z",
                  "end": "2021-10-24T10:22:55Z"
                }
              }
            ],
            "location": {
              "lat": 51.08588,
              "lng": 13.72637
            },
            "distance": 18695
          },
          {
            "time": {
              "arrival": "2021-10-24T10:31:12Z",
              "departure": "2021-10-24T10:53:42Z"
            },
            "load": [
              0
            ],
            "activities": [
              {
                "jobId": "Job_10",
                "type": "delivery",
                "location": {
                  "lat": 51.06866,
                  "lng": 13.77273
                },
                "time": {
                  "start": "2021-10-24T10:31:12Z",
                  "end": "2021-10-24T10:53:42Z"
                }
              }
            ],
            "location": {
              "lat": 51.06866,
              "lng": 13.77273
            },
            "distance": 23119
          },
          {
            "time": {
              "arrival": "2021-10-24T10:59:20Z",
              "departure": "2021-10-24T11:21:50Z"
            },
            "load": [
              1
            ],
            "activities": [
              {
                "jobId": "Job_3",
                "type": "pickup",
                "location": {
                  "lat": 51.08511,
                  "lng": 13.76875
                },
                "time": {
                  "start": "2021-10-24T10:59:20Z",
                  "end": "2021-10-24T11:21:50Z"
                }
              }
            ],
            "location": {
              "lat": 51.08511,
              "lng": 13.76875
            },
            "distance": 26548
          },
          {
            "time": {
              "arrival": "2021-10-24T11:44:40Z",
              "departure": "2021-10-24T11:44:40Z"
            },
            "load": [
              0
            ],
            "activities": [
              {
                "jobId": "arrival",
                "type": "arrival",
                "location": {
                  "lat": 51.059188,
                  "lng": 13.540317
                },
                "time": {
                  "start": "2021-10-24T11:44:40Z",
                  "end": "2021-10-24T11:44:40Z"
                }
              }
            ],
            "location": {
              "lat": 51.059188,
              "lng": 13.540317
            },
            "distance": 50767
          }
        ],
        "statistic": {
          "cost": 141.174,
          "distance": 50767,
          "duration": 9880,
          "times": {
            "driving": 3130,
            "serving": 6750,
            "waiting": 0,
            "stopping": 0,
            "break": 0
          }
        },
        "shiftIndex": 1
      },
      {
        "vehicleId": "Vehicle_1_1",
        "typeId": "Vehicle_1",
        "stops": [
          {
            "time": {
              "arrival": "2021-10-25T10:00:00Z",
              "departure": "2021-10-25T12:40:29Z"
            },
            "load": [
              1
            ],
            "activities": [
              {
                "jobId": "departure",
                "type": "departure",
                "location": {
                  "lat": 51.059188,
                  "lng": 13.540317
                },
                "time": {
                  "start": "2021-10-25T10:00:00Z",
                  "end": "2021-10-25T12:40:29Z"
                }
              }
            ],
            "location": {
              "lat": 51.059188,
              "lng": 13.540317
            },
            "distance": 0
          },
          {
            "time": {
              "arrival": "2021-10-25T13:00:00Z",
              "departure": "2021-10-25T13:22:30Z"
            },
            "load": [
              2
            ],
            "activities": [
              {
                "jobId": "Job_4",
                "type": "pickup",
                "location": {
                  "lat": 51.1323847,
                  "lng": 13.7779515
                },
                "time": {
                  "start": "2021-10-25T13:00:00Z",
                  "end": "2021-10-25T13:22:30Z"
                }
              }
            ],
            "location": {
              "lat": 51.1323847,
              "lng": 13.7779515
            },
            "distance": 23558
          },
          {
            "time": {
              "arrival": "2021-10-25T13:26:28Z",
              "departure": "2021-10-25T13:48:58Z"
            },
            "load": [
              1
            ],
            "activities": [
              {
                "jobId": "Job_6",
                "type": "delivery",
                "location": {
                  "lat": 51.12308,
                  "lng": 13.76406
                },
                "time": {
                  "start": "2021-10-25T13:26:28Z",
                  "end": "2021-10-25T13:48:58Z"
                }
              }
            ],
            "location": {
              "lat": 51.12308,
              "lng": 13.76406
            },
            "distance": 25366
          },
          {
            "time": {
              "arrival": "2021-10-25T13:54:21Z",
              "departure": "2021-10-25T15:22:30Z"
            },
            "load": [
              2
            ],
            "activities": [
              {
                "jobId": "Job_5",
                "type": "pickup",
                "location": {
                  "lat": 51.11716,
                  "lng": 13.73054
                },
                "time": {
                  "start": "2021-10-25T15:00:00Z",
                  "end": "2021-10-25T15:22:30Z"
                }
              }
            ],
            "location": {
              "lat": 51.11716,
              "lng": 13.73054
            },
            "distance": 29456
          },
          {
            "time": {
              "arrival": "2021-10-25T15:37:35Z",
              "departure": "2021-10-25T15:37:35Z"
            },
            "load": [
              0
            ],
            "activities": [
              {
                "jobId": "arrival",
                "type": "arrival",
                "location": {
                  "lat": 51.059188,
                  "lng": 13.540317
                },
                "time": {
                  "start": "2021-10-25T15:37:35Z",
                  "end": "2021-10-25T15:37:35Z"
                }
              }
            ],
            "location": {
              "lat": 51.059188,
              "lng": 13.540317
            },
            "distance": 49111
          }
        ],
        "statistic": {
          "cost": 140.10000000000002,
          "distance": 49111,
          "duration": 10626,
          "times": {
            "driving": 2637,
            "serving": 4050,
            "waiting": 3939,
            "stopping": 0,
            "break": 0
          }
        },
        "shiftIndex": 2
      },
      {
        "vehicleId": "Vehicle_1_1",
        "typeId": "Vehicle_1",
        "stops": [
          {
            "time": {
              "arrival": "2021-10-23T08:00:00Z",
              "departure": "2021-10-23T11:10:08Z"
            },
            "load": [
              0
            ],
            "activities": [
              {
                "jobId": "departure",
                "type": "departure",
                "location": {
                  "lat": 51.059188,
                  "lng": 13.540317
                },
                "time": {
                  "start": "2021-10-23T08:00:00Z",
                  "end": "2021-10-23T11:10:08Z"
                }
              }
            ],
            "location": {
              "lat": 51.059188,
              "lng": 13.540317
            },
            "distance": 0
          },
          {
            "time": {
              "arrival": "2021-10-23T11:31:57Z",
              "departure": "2021-10-23T11:54:27Z"
            },
            "load": [
              1
            ],
            "activities": [
              {
                "jobId": "Job_1",
                "type": "pickup",
                "location": {
                  "lat": 51.05238,
                  "lng": 13.74114
                },
                "time": {
                  "start": "2021-10-23T11:31:57Z",
                  "end": "2021-10-23T11:54:27Z"
                }
              }
            ],
            "location": {
              "lat": 51.05238,
              "lng": 13.74114
            },
            "distance": 19038
          },
          {
            "time": {
              "arrival": "2021-10-23T12:00:00Z",
              "departure": "2021-10-23T12:22:30Z"
            },
            "load": [
              2
            ],
            "activities": [
              {
                "jobId": "Job_2",
                "type": "pickup",
                "location": {
                  "lat": 51.06099,
                  "lng": 13.75245
                },
                "time": {
                  "start": "2021-10-23T12:00:00Z",
                  "end": "2021-10-23T12:22:30Z"
                }
              }
            ],
            "location": {
              "lat": 51.06099,
              "lng": 13.75245
            },
            "distance": 21408
          },
          {
            "time": {
              "arrival": "2021-10-23T12:43:05Z",
              "departure": "2021-10-23T12:43:05Z"
            },
            "load": [
              0
            ],
            "activities": [
              {
                "jobId": "arrival",
                "type": "arrival",
                "location": {
                  "lat": 51.059188,
                  "lng": 13.540317
                },
                "time": {
                  "start": "2021-10-23T12:43:05Z",
                  "end": "2021-10-23T12:43:05Z"
                }
              }
            ],
            "location": {
              "lat": 51.059188,
              "lng": 13.540317
            },
            "distance": 41474
          }
        ],
        "statistic": {
          "cost": 109.679,
          "distance": 41474,
          "duration": 5577,
          "times": {
            "driving": 2877,
            "serving": 2700,
            "waiting": 0,
            "stopping": 0,
            "break": 0
          }
        },
        "shiftIndex": 0
      }
    ]
  }

Next steps