---
metadata:
  - name: generator
    content: Diplodoc Platform v5.19.6
alternate:
  - https://docs.routeq.com/doc/en/vrp/properties-of-vehicles-depot.md
  - https://docs.routeq.com/doc/tr/vrp/properties-of-vehicles-depot.md
---
> **Documentation Index:** Fetch the complete configuration index at https://docs.routeq.com/doc/en/llms.txt


# Working with depots
 
When planning a route, you can use vehicle properties to specify different scenarios for the start and end of the route, [work with multiple depots](#work-from-any), add [intermediate stops and intermediate loading](#visit-additional-depot), or require a [return to a depot](#return-to-depot) or [another location ](#vehicle-finish-at)at the end of the run.

## Load handling time at depot {#depot-extra-service-duration}

The loading or unloading time at a depot may depend both on [orders](https://docs.routeq.com/doc/en/vrp/properties-of-orders.md#order-service-duration-load) and vehicle properties (for example, dimensions or equipment).

To specify the amount of additional time required for loading at the depot, use the `vehicle.depot_extra_service_duration_s` parameter. The time is set in seconds.


{% note info %}

The time assigned in the `vehicle.depot_extra_service_duration_s` parameter is summed up with the [depot handling time](https://docs.routeq.com/doc/en/vrp/properties-of-depot.md#depot-service-duration).

{% endnote %}


**Example**

Two vehicles with the same load capacity are delivering 13 large orders. The handling time at the depot `depot.service_duration_s` is 5 minutes (300 seconds). Additional time is set for loading orders into a vehicle at the depot using the `vehicle.depot_extra_service_duration_s` parameter: 30 minutes (1800 seconds). As a result of planning, each vehicle will spend 35 minutes at the depot before starting their routes.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/183b12cf-13e02676-f8a528b2-6f1847ca) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/183b12cf-13e02676-f8a528b2-6f1847ca) ⋅ [View on map](https://yandex.com/courier/mvrp-map#183b12cf-13e02676-f8a528b2-6f1847ca)


## Start of a loaded vehicle {#loaded-vehicle-start}

If a vehicle is loaded in advance and there is no need to spend time loading it at the beginning of the shift, use the `starts_loaded` = `true` vehicle property. The [handling time](https://docs.routeq.com/doc/en/vrp/properties-of-depot.md#depot-service-duration) before the first run will then be ignored for this vehicle during route planning. 

**Example**

Two vehicles deliver orders: the first one is loaded in advance, and the second one has to be loaded at the start of the shift. The handling time `depot.service_duration_s` is 10 minutes (600 seconds).

As a result of planning, the first vehicle will start the route immediately, and the second vehicle will spend 10 minutes at the depot before departing.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/2d7795b3-79412cf8-cc275b1a-802fe10a) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/2d7795b3-79412cf8-cc275b1a-802fe10a) ⋅ [View on map](https://yandex.com/courier/mvrp-map#2d7795b3-79412cf8-cc275b1a-802fe10a)


## Vehicle started not from the depot  {#vehicle-start-at}

By default, vehicles and couriers start from the depot. However, sometimes they need to start the route from another point (for example, from their home or a parking spot). That's a usual task for sales representatives, service engineers, and other specialists who provide services rather than deliver goods.

You can set this requirement using the `vehicle.start_at`property. In this case, a courier or vehicle will start their route from the specified point with the `garage` type rather than from a depot.


### Visiting the depot before the start of the working day {#visit-depot-at-start}

At the beginning of the working day, couriers may need to visit the depot to get their orders there. Use the property `vehicle.visit_depot_at_start` to enable this. If you set it to `true`, the courier or vehicle should visit the depot before starting the delivery (this is default behavior). Otherwise, they can start delivering orders immediately. For more information, see [Start or end of the route at an arbitrary point](https://docs.routeq.com/doc/en/vrp/supported-use-cases.md#route-start-or-end-at-arbitrary-point).

If couriers start from a `garage` location, but they need to pick up some orders at the depot, enable the option **Can visit the depot at the beginning of the route** (`can_visit_depot_at_start` in the API, set to `false` by default). This option only works for couriers that have the parameter `visit_depot_at_start` = `false`. For orders that need to be picked up from a depot, specify one of the following parameters:

— `depot_id` to [link the order to a depot](https://docs.routeq.com/doc/en/vrp/properties-of-orders.md#linking-order-depot).

— `depot_ready_time`, [the time when the order is ready at the depot](https://docs.routeq.com/doc/en/vrp/properties-of-orders.md#order-time-depot-ready).

— `depot_expiring_time`, [the deadline for picking up the order from the depot](https://docs.routeq.com/doc/en/vrp/properties-of-orders.md#depot-expiring-time).

You can also implicitly allow couriers to visit the depot at the beginning of the route with the `can_visit_depot_at_start` option disabled by explicitly specifying the depot in `planned_route`, [fixed part of the route](#visited-locations), or during [additional planning](https://docs.routeq.com/doc/en/vrp/additional-planning.md).

**Example 1**

Three vehicles deliver orders: The first one starts the delivery from the depot. The second one starts and ends the route without visiting the depot. The starting point for the courier is order 6, which has the `garage` type. The third one starts the route not from the depot, but from order 4 (the `garage` type), but must visit the depot before starting the delivery.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/8a1166fe-4e6160db-945fa1d7-c650d84) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/8a1166fe-4e6160db-945fa1d7-c650d84) ⋅ [View on map](https://yandex.com/courier/mvrp-map#8a1166fe-4e6160db-945fa1d7-c650d84)

**Example 2**

Three vehicles deliver orders: The first one starts the delivery from the depot. The second and third vehicles start and end the route without visiting the depot. Orders 1 and 7 have the `pickup` type, and the algorithm selects them as the first route points.

Three separate routes are planned in the solution because of the orders' priorities.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/c5388858-4672df53-2c760cf3-cdc7f1ab) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/c5388858-4672df53-2c760cf3-cdc7f1ab) ⋅ [View on map](https://yandex.com/courier/mvrp-map#c5388858-4672df53-2c760cf3-cdc7f1ab)

**Example 3**

Two vehicles deliver orders (`visit_depot_at_start` = `false` and `can_visit_depot_at_start` = `true`). The first one starts from a `garage` point and visits the depot to pick up order 1 at the beginning of the route. The second vehicle's route doesn't include a visit to the depot, it goes straight to the delivery. 

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/9f47589d-dc16371a-61c3b8c8-32399a17) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/9f47589d-dc16371a-61c3b8c8-32399a17) ⋅ [View on map](https://yandex.com/courier/mvrp-map#9f47589d-dc16371a-61c3b8c8-32399a17)

## Making stops at multiple depots {#work-from-any}

Couriers can stop at multiple depots along their routes. This is helpful when items are stored in different depots or when the route needs to end at a specific depot.

Specify depots using one of these methods:

1. On the **Vehicles** sheet in the **Depots that the courier can visit** field (`vehicle.depot_id` in the API), you can specify the depots that the courier is allowed to visit while following the route. They have a higher priority, so the algorithm can assign them as start, intermediate, or end depots.
2. In the fields:

  * **Depots to start from** (`vehicle.starting_depot_id` in the API): The depots where the courier starts their route.
  * **Depots for additional loading** (`vehicle.middle_depot_id` in the API): The intermediate depots to pick up additional orders along the route.
  * **Depots to end the route at** (`vehicle.ending_depot_id` in the API): The depots where the courier completes the route.

{% note info %}

The `depot_id` field has a higher priority than `starting_depot_id`, `middle_depot_id`, and `ending_depot_id`. If a depot is specified in the `depot_id` field, values in other depot fields are ignored.

{% endnote %}

To allow a courier to visit any of the depots specified during planning, use the `vehicle.allow_all_depots` parameter. For more information, see [Working with all depots](#all-depots-allowed).

**Example 1**

There are 9 orders in the planning task. Three depots are specified on the **Vehicles** sheet in the `depot_id` field: Depot 1, Depot 2, and Depot 3. The courier is allowed to stop at multiple depots along the route.

As a result of planning, the courier:

* Starts the route from Depot 2, because it is located next to the first order location.
* Ends the route at Depot 3, because the last order location is next to it.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/3645a4a5-e46ba4ac-6bfd18f2-84e7be7e) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/3645a4a5-e46ba4ac-6bfd18f2-84e7be7e) ⋅ [View on map](https://yandex.com/courier/mvrp-map#3645a4a5-e46ba4ac-6bfd18f2-84e7be7e)

**Example 2**

The courier must deliver 9 orders. Planning involves 2 depots:

* Depot 2: a start (`starting_depot_id` = 2) and end (`ending_depot_id` = 2) depot.
* Depot 1: an intermediate depot (`middle_depot_id` = 1).

As a result of planning, the courier starts the route at Depot 2 and delivers 4 orders. Then the courier stops at Depot 1 for reloading, delivers the remaining orders, and ends the route at Depot 2.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/3e55092a-7ba48f9f-c02dc5c8-d3d6885) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/3e55092a-7ba48f9f-c02dc5c8-d3d6885) ⋅ [View on map](https://yandex.com/courier/mvrp-map#3e55092a-7ba48f9f-c02dc5c8-d3d6885)

**Example 3**

The courier must deliver 9 orders. Planning involves 3 depots:

* Depot 1: a start depot (`starting_depot_id` = 1).
* Depot 2: an intermediate depot (`middle_depot_id` = 2).
* Depot 3: an end depot (`ending_depot_id` = 3).

The courier is allowed to visit the intermediate depot for reloading at the beginning of the route only (`vehicle.depots_only_at_run_beginning` = `true`). As a result of planning, the courier starts from Depot 1, then stops at Depot 2 for reloading, and starts delivering orders. Ends the route at Depot 3.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/7437bc58-724e6374-b21ddd80-806e47c) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/7437bc58-724e6374-b21ddd80-806e47c) ⋅ [View on map](https://yandex.com/courier/mvrp-map#7437bc58-724e6374-b21ddd80-806e47c)

### Start from one of multiple depots  {#start-from-any}

To allow a courier to start from one of multiple depots, list them in the **Depots that the courier can visit** (`vehicle.depot_id` in the API) or **Depots to start from** field (`vehicle.starting_depot_id` in the API). If there are several depots, the algorithm will choose the optimal depot to start from. If the `depot_id` and `starting_depot_id` fields aren't filled for the courier, they start from the first depot in the `depots` list.

{% note alert %}

On the **Vehicles** sheet in the **Depots that the courier can visit** (`depot_id`) and **Depots for loading** (`starting_depot_id`) fields, you can't specify both regular and [cross-docking](https://docs.routeq.com/doc/en/vrp/properties-of-depot.md#depot-types) depots at once. On a single route, a courier may only visit either regular depots or cross docks.

{% endnote %}

If you use the [delivery from one of several depots](https://docs.routeq.com/doc/en/vrp/properties-of-depot.md#depot-start-from-any) feature, a courier will be able to pick up orders from any depot they can visit.

For the courier, you can also set the parameters **Allowed to visit multiple depots in one route** (`vehicle.allow_different_depots_in_route` in the API) and **Maximum number of depots for additional loading in one route** (`vehicle.max_middle_depots` in the API). For more information, see [Choosing the optimal depot to start from](https://docs.routeq.com/doc/en/vrp/supported-use-cases.md#optimal-depot).


### Additional loading at an intermediate depot {#visit-additional-depot}

For a courier to be able to visit additional depots for additional loading along the route, set the **Allowed to visit multiple depots in one route** (`vehicle.allow_different_depots_in_route` in the API) parameter to `true`. Specify these depots in the **Depots that the courier can visit** (`vehicle.depot_id` in the API) or **Depots for additional loading** (`vehicle.middle_depot_id` in the API) field. If there are orders in several depots, the algorithm will select the optimal depot for additional loading.

{% note alert %}

On the **Vehicles** sheet in the **Depots that the courier can visit** (`depot_id`) and **Depots for additional loading** (`middle_depot_id`) fields, you can't specify both regular and [cross-docking](https://docs.routeq.com/doc/en/vrp/properties-of-depot.md#depot-types) depots at once. On a single route, a courier may only visit either regular depots or cross docks.

{% endnote %}

If the courier can stop at intermediate depots for additional loading at the beginning of the route only (before completing the first order), set the `vehicle.depots_only_at_run_beginning` parameter to `true` (by default, it's set to `false`).

For the courier, you can also set the **Maximum number of depots for additional loading in one route** parameter (`vehicle.max_middle_depots` in the API). For more information, see [Visiting an additional depot](https://docs.routeq.com/doc/en/vrp/supported-use-cases.md#additional-depot).


### Returning to a depot at the end of the route or run {#return-to-depot}

By default, the courier completes the route at the depot where they started. To allow the courier to stop at multiple depots along the route, set the **Allowed to visit multiple depots in one route** parameter (`vehicle.allow_different_depots_in_route` in the API) to `true`. In this case, the courier can end the route at a depot other than the first one.

Specify the depots where the courier can complete the route in the **Depots that the courier can visit** (`vehicle.depot_id` in the API) or **Depots to end the route at** field (`vehicle.ending_depot_id` in the API). If there are several depots, the algorithm will choose the optimal depot to complete the route at.

{% note alert %}

On the **Vehicles** sheet in the **Depots that the courier can visit** (`depot_id`) and **Depots to end the route at** (`ending_depot_id`) fields, you can't specify both regular and [cross-docking](https://docs.routeq.com/doc/en/vrp/properties-of-depot.md#depot-types) depots at once. On a single route, a courier may only visit either regular depots or cross docks.

{% endnote %}

If you want the courier to end the route at the same depot where they started it, set the `vehicle.finish_route_in_starting_depot` parameter to `true` (by default, it's set to `false`). In this case, if the courier's starting point is not a depot (`vehicle.visit_depot_at_start` = `false`), they will need to return to the depot where they started the second run of the route.

If you want the courier to end each run at the same depot where it was started, set the `vehicle.finish_run_in_starting_depot` parameter to `true` (by default, it's set to `false`). To allow the courier to change depots between runs, set the `vehicle.can_change_depot_between_runs` parameter to `true`. For more information, see [Start of a new run from a different depot](https://docs.routeq.com/doc/en/vrp/supported-use-cases.md#moving-between-depots).

{% note info %}

It only makes sense to set the `vehicle.finish_route_in_starting_depot` and `vehicle.finish_run_in_starting_depot` parameters to `true` if the `vehicle.allow_different_depots_in_route` parameter is also set to `true`.

{% endnote %}

If the courier doesn't have to return to the depot after completing all orders, set **Return to depot at the end of the shift** (`vehicle.return_to_depot` in the API) to `false`.

**Example 1.1**

Two couriers are to deliver two orders: one is a `delivery` order that needs to be picked up from Depot 1, and the other one is a `pickup` order to be delivered to Depot 2. The couriers can only make one run each, starting at any depot and ending the route at any depot. Both couriers are allowed to visit different depots during one run, but they can't stop at intermediate depots.

The solution uses only one courier: they leave Depot 1 after picking up the `delivery` order, deliver it, pick up the `pickup` order, and deliver it to Depot 2, where they end the route.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/9f74f3e8-82ca4296-e1eefda1-6dcee2ad) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/9f74f3e8-82ca4296-e1eefda1-6dcee2ad) ⋅ [View on map](https://yandex.com/courier/mvrp-map#9f74f3e8-82ca4296-e1eefda1-6dcee2ad)

**Example 1.2**

The same as in example 1.1, but the couriers need to end routes at the same depot where they started them (`vehicle.finish_route_in_starting_depot` = `true`).

The solution uses both couriers. Courier 1 leaves Depot 1 after picking up the `delivery` order, delivers it, and returns to Depot 1. The second courier leaves Depot 2, picks up the `pickup` order, and returns with it to Depot 2.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/741f4b8c-327de87b-b7e41138-236a4847) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/741f4b8c-327de87b-b7e41138-236a4847) ⋅ [View on map](https://yandex.com/courier/mvrp-map#741f4b8c-327de87b-b7e41138-236a4847)

## Working with all depots {#all-depots-allowed}

If you use many depots when planning and couriers can visit any of them, use the parameter `vehicle.allow_all_depots` = `true`.

In this case, you can add any depot to the courier's route without specifying it separately in the [vehicle parameters](#work-from-any).

**Example 1**

The courier needs to deliver four orders linked to different depots. The courier has the following parameters specified:

- Depot for visiting: `vehicle.depot_id` = 50.
- Depot to end the route at: `vehicle.ending_depot_id` = 10.
- Intermediate depot: `vehicle.middle_depot_id` = 20.
- Depot for additional loading: `vehicle.starting_depot_id` = 50.

The `vehicle.allow_all_depots` parameter isn't set and has the `false` value by default. As a result of planning, only depots 10, 20, and 50, as well as orders 3 and 4, are included in the route.

The rest of the orders linked to other depots haven't been included in the route because these depots aren't specified in the courier parameters and are considered unavailable to them.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/1b43d35a-dfc5e66-5e532a8d-b7c4ae8) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/1b43d35a-dfc5e66-5e532a8d-b7c4ae8) ⋅ [View on map](https://yandex.com/courier/mvrp-map#1b43d35a-dfc5e66-5e532a8d-b7c4ae8)

**Example 2**

The same as in example 1, but `vehicle.allow_all_depots` = `true`. As a result of planning, all the depots and orders have been included in the route.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/f1686394-ca37d911-cab4a9ed-a7ddc5cd) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/f1686394-ca37d911-cab4a9ed-a7ddc5cd) ⋅ [View on map](https://yandex.com/courier/mvrp-map#f1686394-ca37d911-cab4a9ed-a7ddc5cd)

## Return to any location at the end of the route  {#vehicle-finish-at}

If your work scenario needs to take into account the distance of the last order from the courier's parking spot (or home address, for example), you can implement it as follows:

- Create a point with the `garage` type (the `locations.type` field). This point will only be used to end the routes.

- For a courier who needs to return home or to the parking spot at the end of their working day, enter the ID of this point in the `vehicle.finish_at` field.


In the solution, all vehicles or couriers that have the `finish_at`property specified return to the specified point. If the option to return to the depot is enabled (`vehicle.return_to_depot` = `true`), the route will first go the depot and then to the parking spot.

**Example**

The example below uses two vehicles with different load capacities and four orders with different weights. Two vehicles are used for delivery because of the weight restrictions. Vehicle 2 doesn't have to return to the depot after it delivers the last order.


{% note info %}

Note that in the RouteQ response, vehicle 2 completes the route at the last order location.

{% endnote %}


[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/9d0b43b3-a6132aa2-a4504455-1fa83798) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/9d0b43b3-a6132aa2-a4504455-1fa83798) ⋅ [View on map](https://yandex.com/courier/mvrp-map#9d0b43b3-a6132aa2-a4504455-1fa83798)


## Start or end of the route as close to the depot as possible {#edges}

You can plan a route so that a courier starts or finishes it with the order that is the closest to a depot or the furthest from it. For example, if you expect to get new orders in the morning, then it would be better to start the route with the orders closest to the depot. That way, it will be easier for the courier to return to the depot to pick them up. On the other hand, by starting the route with the farthest order, the courier would finish it closer to the depot in the evening.

If you aren't using [advanced cost settings](#custom-route-cost), set the following parameters:

- `first_edges_penalty_factor`: A penalty for the distance from the depot to the first order, the default is 0. If the value is greater than 0, the algorithm minimizes this distance, and if the value is less than 0, it maximizes the distance.

- `last_edges_penalty_factor`: A penalty for the distance from the depot to the last order, the default is 0. If the value is greater than 0, the algorithm minimizes this distance, and if the value is less than 0, it maximizes the distance.

Penalties are calculated similarly to the duration and length of route segments (see the **Travel between route points** group under [Advanced cost settings](#custom-route-cost)).

If penalty values are high, routes may be suboptimal in terms of mileage. If penalty values are low, then the first or last order of a route may be selected in violation of any requirements provided it saves on mileage.

If you use advanced cost settings, use the keywords from the [Travel from or to the depot](#near-depot) group.

**Example**

In the example below, there is one courier and 10 orders. Two penalties are set: `first_edges_penalty_factor` = 2 and `last_edges_penalty_factor` = -2. Planning produces a route that begins with the order closest to the depot and ends with the furthest order.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/5258725b-1b3a3b5d-30572329-c3c9d936) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/5258725b-1b3a3b5d-30572329-c3c9d936) ⋅ [View on map](https://yandex.com/courier/mvrp-map#5258725b-1b3a3b5d-30572329-c3c9d936)

{% include [warehouse-feedback](_includes/feedback-81845556eeea.md) %}
