Planning a Round Tour with Multi-depot Assignment

This use case describes how to plan round tours allowing stops at multiple depots during a tour.

VehiclesClosed The term vehicle describes what is being routed or planned for. Vehicles are used in route calculation, distance matrix calculation and effectively also in tour planning. In route calculation, vehicle properties like overall size, weight and speed are in focus. In tour planning, it is vehicle properties like capacity and availability. Commonly a vehicle is motorized, like a truck - including its trailer or a car. However also a bike or even a pedestrian are included in this definition. usually execute the orders of one particular depot site, where they are located. This situation leads to classic round trips in most cases. However, sometimes it might be useful to execute orders of a depot site with a vehicle not located there in a second (or any subsequent) trip of a tour, in order to optimize the use of resources or avoid empty drives on route legsClosed A route leg is a part of a route between two consecutive waypoints..

Example | The following picture shows an example of the desired tour structure

Geographical tour structure and stop sequence for round trips with multi-depot assingment.


  • Users learn how to parametrize the current use-case.
  • Basic insight into how to influence the course of a tour.


Please ensure following prerequisites are fulfilled before you start with the use case:

  • Installed and licensed PTV xTour service
  • License for as many vehicles as the plan should contain


Programming Guide

This example explains how the request has to look like in order to to influence the tour structure as mentioned in the use-case description above.

First we define our locations as OffRoadRouteLocations in the default EPSG:4326 format (see RequestBase.coordinateFormat). You could also use OnRoadRouteLocations, see the technical concept on waypoints and route legs for more information on the different types route locationsClosed A route location is the position of an object to be routed to or from, which contains additional information on how to link this position to the road network and whether or or not this position is actually reached. Route locations are used as the input for route calculation and optimization throughout PTV xServer.. Since the use case describes deliveries from different depots to customers, we define some locations as depot and some as customer sites, see Orders, Locations, and Stops for more details. Most likely the locations have specific opening intervals, which may lead to multiple tours if two locations cannot be served by the same vehicle within their opening hours.

The fleet in this example consists of two types of vehicle, each with one available vehicle instance (defined by the number of vehicle ids). The two types only differ in the start and end locations which are located at different depots. To simplify the example code, we assume that the vehicles use direct distance (can be set in the distance mode of the request).

The last part of the example request are the orders, consisting of pickup and delivery orders that model the transportation of goods from a depot to a customer and visit orders if no goods should be transported to the customer.

We pass the request on to planTours. Once xTour has processed the request a callback is invoked which gives us access to the result of the calculation in form of a ToursResponse object.

The customer sites of the request are displayed in gray, the depot sites in orange. Since the ToursResponse only contains references to the given locations, the corresponding coordinates are taken from the request. The first tour of the result is displayed in gray, the second one in blue.

Each vehicle starts its tour at the assigned start location, which is DepotA for vehicle1 and DepotB for vehicle2. While vehicle2 only serves orders from its home depot (DepotB), vehicle2 also takes some orders from DepotB. This way, all orders can be delivered in 2 tours.

Related Topics

The following topics might be relevant for this use-case.