---
metadata:
  - name: generator
    content: Diplodoc Platform v5.64.0
alternate:
  - https://yandex.ru/routing/doc/en/vrp/supported-use-cases.md
  - https://yandex.ru/routing/doc/kk/vrp/supported-use-cases.md
  - https://yandex.ru/routing/doc/ru/vrp/supported-use-cases.md
  - https://yandex.ru/routing/doc/tr/vrp/supported-use-cases.md
  - href: https://yandex.ru/routing/doc/en/vrp/supported-use-cases.md
    type: text/markdown
    title: Markdown version
  - href: https://yandex.ru/routing/doc/en/llms.txt?revision=r21872121
    rel: describedby
title: RouteQ — possible logistic scenarios
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/routing/doc/en/llms.txt?revision=r21872121


# Possible logistic scenarios

For all logistic scenarios, be sure to specify **depots**, **orders**, and **couriers**. The data set is dependent on the couriers and orders in it. If they can be divided into independent parts (so that a group of orders is only carried out by certain vehicles and there's no mixing), we recommend making multiple separate planning runs, each with its own set of orders and couriers. For example, do this if:

- There are several depots, each depot ships its own set of orders, and each depot has its own set of vehicles.

- Cargo is delivered from the depot and taken to the depot by different vehicles (and these are different independent orders).

- A depot has several geographical zones, each of which is served by its own set of vehicles.

The logistic scenarios described below can be combined. If the above examples don't describe your business task, contact your RouteQ manager or support at [routing-support@yandex-team.ru](mailto:routing-support@yandex-team.ru).

## Delivery from a single depot {#delivery-from-depot}

This is the default scenario when you need to plan the delivery of goods to your clients or build a route that visits a specified set of points. It's used if there's only one depot in the request, and orders have the `delivery` type specified in the `location` field, or this field isn't set (see [Order type](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md#order-type)). The algorithm will build a route for delivery of all orders from the specified depot.

**Diagram**

![](_images/uc-delivery-from-one-depot_full.svg)

**Example**

There are 30 orders in this solution. All of them are delivered from a single depot. The order `type` isn't explicitly specified, so its default value is `delivery`.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/8cc4331d-e7e0c3bd-b23981ae-7581deb0) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/8cc4331d-e7e0c3bd-b23981ae-7581deb0) ⋅ [View on map](https://yandex.com/courier/mvrp-map#8cc4331d-e7e0c3bd-b23981ae-7581deb0)


## Cargo collection to the depot {#collection-to-depot}

This is the default scenario when cargo is collected from your clients to be delivered to the depot. For examples, this cargo may include:

- Medical tests that are taken at home.

- Clothes for dry cleaning.

- Goods that your clients return to the depot.

In the last case, this scenario is often combined with [delivery from a single depot](https://yandex.ru/routing/doc/en/vrp/supported-use-cases.md#delivery-from-depot).

To specify pickup points, set the order `type` = `pickup` (see [Order type](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md#order-type)). After that, different options are possible:

1. All couriers should return to the depot at the end of the day (see [Returning to a depot at the end of the working day](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles-depot.md#return-to-depot)), meaning that `return_to_depot` = `true`. In this case, you don't need to configure anything else, and the courier completes the route at the depot by default.

1. The cargo must stay in the courier's vehicle and be returned to the depot the next morning when the courier arrives for their next shift. To do this, set `return_to_depot` = `false`. The route will end at the last `pickup` point. You don't need to configure anything else in this case, either.

1. Not all couriers return to the depot at the end of the day. The algorithm chooses which ones must return. For couriers, the `return_to_depot` = `false` option is used, and for pickup orders, you specify [whether it's mandatory to return to the depot in the current route](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md#pickup-must-reach-depot) `pickup_must_reach_depot` = `true` or set up `delivery_deadline`, which is the [time of order delivery to the depot](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md#order-time-depot-delivery).

    If [an order is linked to a depot](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md#linking-order-depot) (one or more depots are given in the `depot_id` field), the `pickup` order will be delivered to one of these depots in the current route, regardless of the `pickup_must_reach_depot` value.


**Schemes**

- Cargo delivery to the depot.

    ![](_images/uc-pickup-to-depot_full.svg)

- Delivery of cargo to one of several depots.

    ![](_images/uc-pickup-to-any-depot.svg)

**Example 1**

Cargo is picked up and taken to the depot. All vehicles must return to the depot at the end of the day (`return_to_depot` = `true`). There are 30 orders, 1 depot, and 5 cargo pickup points.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/cb4b7d73-b12770ff-e3bc99c-136edbe6) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/cb4b7d73-b12770ff-e3bc99c-136edbe6) ⋅ [View on map](https://yandex.com/courier/mvrp-map#cb4b7d73-b12770ff-e3bc99c-136edbe6)

**Example 2**

The same as example 1. One of the vehicles has `return_to_depot` set to `false`. This means that the cargo will remain in the courier's vehicle and return to the depot the next morning.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/601a259d-3f0d9ef5-28ee1683-75169035) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/601a259d-3f0d9ef5-28ee1683-75169035) ⋅ [View on map](https://yandex.com/courier/mvrp-map#601a259d-3f0d9ef5-28ee1683-75169035)

**Example 3**

The same as example 1, but different pickup points are selected. For all vehicles, `return_to_depot` = `false`, and `delivery_deadline` is specified for the cargo pickup points. At the end of the day, only the vehicle that has all the `pickup` orders will return to the depot.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/ee4390b1-a694dbd6-e20a6e02-77a2b73d) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/ee4390b1-a694dbd6-e20a6e02-77a2b73d) ⋅ [View on map](https://yandex.com/courier/mvrp-map#ee4390b1-a694dbd6-e20a6e02-77a2b73d)


## Start or end of the route at an arbitrary point {#route-start-or-end-at-arbitrary-point}

**What situations to use this in**

By default, the courier route starts and ends at the depot. However, in some cases, you may need to plan a route from the vehicle's parking spot or from the courier's home. Or the other way around: you may need to complete the route closer to these points.

**Implementation**

Start points are defined using the [start_at](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles-depot.md#vehicle-start-at) and [visit_depot_at_start](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles-depot.md#visit-depot-at-start) parameters. End points are defined using the [finish_at](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles-depot.md#vehicle-finish-at) and [return_to_depot](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles-depot.md#return-to-depot) parameters.

{% note tip %}

Not all combinations of these parameters in the solution use a depot (for example, if all couriers start from home and immediately go to order locations), but it is still required in the data scheme. In this case, you can specify the coordinates of the office or city center as a depot.

{% endnote %}

The parameters of the start and end points are independent of each other, so you can configure any combination here:

- Set start and end points separately for each courier.

- Specify the same point for multiple couriers.

- Specify the same start and end points.

The `garage` order type is used to specify the start or end point. If `vehicle.visit_depot_at_start` = `false`, and `vehicle.start_at` isn't specified, the algorithm assumes that the courier can start the route from the first order without visiting the depot.

{% note alert %}

You can use the combination of `start_at` not specified and `visit_depot_at_start` = `false` if there are `pickup` or `pickup & delivery` orders in the route. Orders delivered from the depot aren't planned first and appear in the route only after the courier visits the depot.

{% endnote %}

If `vehicle.visit_depot_at_start` = `false`, but the courier still needs to start the route with visiting the depot (for example, to pick up `delivery` orders), set `vehicle.can_visit_depot_at_start` to `true`. In this case, the courier [can visit the depot](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles-depot.md#visit-depot-at-start).

If `start_at` is also defined, and orders are:

Assigned to the depot (parameter `location.depot_id` specified), the courier will start the route from a `garage` location, then pick up the orders from the depot, and then continue the route. 

Not assigned to the depot (the parameter `location.depot_id` is not set), the courier won't visit the depot and will start working directly from a `garage` location.

**Schemes for start points**

- Starting a route from the order point without going to the depot (`start_at` isn't defined, `visit_depot_at_start` = `false`). The algorithm chooses the start point of the order for the courier.

    ![](_images/uc-start-undefined-wo-depot_full.svg)

- Starting a route from the depot (`start_at` isn't defined, `visit_depot_at_start` = `true`). The algorithm's default behavior.

    ![](_images/uc-start-depot_full.svg)

- Starting a route from a specific point without going to the depot (`start_at` is defined, `visit_depot_at_start` = `false`). Start points may be different for different couriers.

    ![](_images/uc-start-location-wo-depot_full.svg)

- Starting a route from a specific point with a visit to the depot (`start_at` is defined, `visit_depot_at_start` = `true`). Start points may be different for different couriers.

    ![](_images/uc-start-location-w-depot_full.svg)

- Starting a route with `visit_depot_at_start` = `false` and `can_visit_depot_at_start` = `true` (`start_at` is defined, the first order is assigned to the depot using `location.depot_id`).

    ![](_images/uc-start-location-can-visit_full.svg)

**Schemes for end points**

- Ending a route at the last point without returning to the depot (`finish_at` isn't defined, `return_to_depot` = `false`).

    ![](_images/uc-finish-undefined-wo-depot_full.svg)

- Returning to the depot at the end of the route (`finish_at` isn't defined, `return_to_depot` = `true`).

    ![](_images/uc-finish-depot_full.svg)

- Ending a route at a specific point without returning to the depot (`finish_at` is defined, `return_to_depot` = `false`). End points may be different for different couriers.

    ![](_images/uc-finish-location-wo-depot_full.svg)

- Ending the route at a specific point with a visit to the depot before the end point (`finish_at` is defined, `return_to_depot` = `true`). End points may be different for different couriers.

    ![](_images/uc-finish-location-w-depot_full.svg)


## Pickup & delivery: collecting and delivering cargo at arbitrary points  {#pickup-and-delivery}

**What situations to use this in**

This scenario is used for planning door-to-door cargo delivery without involving intermediate depots or reloading points. For example:

- Goods must be picked up from the supplier's depot and taken to the client (multiple `pickup` scenarios are supported for when you need to collect the goods from different suppliers at several depots and deliver them to the same client).

- Goods are returned (you need to pick them up from the client and take them to the depot for returns, not to the main depot).


You can also use this scenario in cases where there are simple dependencies between points. For example, before you get to the client, you need to pick up tools, documents, or keys.

You can use this scenario together with the scenarios for [collecting cargo at the depot](https://yandex.ru/routing/doc/en/vrp/supported-use-cases.md#delivery-from-depot) and [delivery from a single point](https://yandex.ru/routing/doc/en/vrp/supported-use-cases.md#delivery-from-depot).

**Implementation**

The [pickup & delivery](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md#pickup-and-delivery) scenario uses a linked pair of points: `pickup` and `delivery`, and the pickup point is always visited first. The points are linked using the `delivery_to` field: you fill it in for the `pickup` point, specifying the ID of the associated `delivery`.

In a multiple `pickup` scenario for several different `pickup` points, you can specify the same value in the `delivery_to` field. A group of multiple `pickup` orders and one `delivery` order will always be assigned to a single courier.

If you need to deliver orders from one `pickup` point to multiple `delivery` points, specify different `pickup & delivery` pairs (where `pickup` orders have the same coordinates but different IDs). Such `pickup & delivery` pairs may be assigned to different couriers (despite the fact that the `pickup` point is the same). For mandatory planning for one courier, we recommend using [grouping locations](https://yandex.ru/routing/doc/en/vrp/grouping-locations.md).


{% note alert %}

You don't have to specify the weight, volume, and number of places for `delivery` points, but they must be specified for the associated `pickup` order.

If you specify the volume and weight characteristics for a `delivery` point, they must be the same for the associated `pickup` order. That is, in case of more than one `pickup`, it's enough to specify the weight, volume, and number of places only for the `pickup` orders.

{% endnote %}


To manage the sequence of performing `pickup & delivery` pairs, we recommend using the `location.in_lifo_order` feature (for more information, see [Order of reception and delivery](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md#order-reception-and-delivery)).

**Schemes**

- `pickup & delivery`.

    ![](_images/uc-pickup-and-delivery_full.svg)

- Multiple `pickup` for one `delivery` point.

    ![](_images/uc-multi-pickup-to-one-delivery_full.svg)

**Example 1**

We plan 12 different locations. Half the locations are `pickup`, and the other half are `delivery`. In total, we get 6 door-to-door deliveries.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/4a397a25-e1664d02-ee05928b-941d3fef) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/4a397a25-e1664d02-ee05928b-941d3fef) ⋅ [View on map](https://yandex.com/courier/mvrp-map#4a397a25-e1664d02-ee05928b-941d3fef)

**Example 2**

We set 8 different addresses for `pickup` points and specify the same values for them in the `delivery_to` field. As a result, we get a plan in which a courier must pick up orders from different places and bring them all to one place.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/689db8ee-55fe7253-3d74c3a3-5d0bf312) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/689db8ee-55fe7253-3d74c3a3-5d0bf312) ⋅ [View on map](https://yandex.com/courier/mvrp-map#689db8ee-55fe7253-3d74c3a3-5d0bf312)

**Example 3**

Delivery is planned from 1 address to 16 different addresses. We set the `pickup` type for 16 points with the same address and the `delivery` type for the other 16 points.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/f8c285e-5ebc4f35-378e363c-66bece09) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/f8c285e-5ebc4f35-378e363c-66bece09) ⋅ [View on map](https://yandex.com/courier/mvrp-map#f8c285e-5ebc4f35-378e363c-66bece09)


## Delivery from one of several depots  {#delivery-from-one-of-depots}

**What situations to use this in**

This scenario is used when multiple depots have a sufficient quantity of the same goods, and you need to choose which depot to deliver them from when planning.

**Implementation**

{% note alert %}

When using this scenario, list all couriers that start from each depot.

{% endnote %}

When planning, specify multiple depots and which depot each courier is assigned to (which depots they can start from and visit). For more information, see [Delivery from one of several depots](https://yandex.ru/routing/doc/en/vrp/properties-of-depot.md#depot-start-from-any) and [Start from one of several depots](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles-depot.md#start-from-any).

For this scenario, you can also use the function for starting at an arbitrary point without visiting the depot (learn more in [Start or end of the route at an arbitrary point](https://yandex.ru/routing/doc/en/vrp/supported-use-cases.md#route-start-or-end-at-arbitrary-point), when `start_at` is defined and `visit_depot_at_start` = `false`). If you specify the depot as the starting point where shipping must begin for each courier, the planning result will be the same as when planning from several depots.

{% note info %}

If you know which depot a particular order should be shipped from, use the [location.depot_id](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md#linking-order-depot) parameter. Specify the depot `id` or an array of depot `id` in the parameter value.

{% endnote %}

This scenario can be implemented without the service functions, that is, if you create rigid links between an order and a depot. There are several ways to do this:

- **Nearest depot**

    Calculate the distance between the coordinates of the order address and all depots (use the [Distance matrix](https://yandex.com/dev/routing/distance_matrix/) service for making the calculation). The nearest depot is selected for the order.

- **Delivery zone**

    Each depot has a pre-defined delivery zone (drawn using [Yandex Map Constructor](https://yandex.com/map-constructor/)). Each order is pre-checked to see which depot's delivery zone it falls into. Each depot is planned separately and independently following the [Delivery from a single depot](https://yandex.ru/routing/doc/en/vrp/supported-use-cases.md#delivery-from-depot) scenario.


**Diagram**

![](_images/uc-delivery-from-any-depot_full.svg)

**Example 1**

In this example, the `depot_id` parameter is used to specify which depot each courier is linked to. This way, couriers deliver orders from their depots only.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/307f5a5e-9e18f3cf-70f74759-68b0d87b) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/307f5a5e-9e18f3cf-70f74759-68b0d87b) ⋅ [View on map](https://yandex.com/courier/mvrp-map#307f5a5e-9e18f3cf-70f74759-68b0d87b)

**Example 2**

In this example, couriers don't start their route from the depot. They start from one of two [garage](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md#order-type) points. The start point of the route is defined using [start_at](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles-depot.md#vehicle-start-at).

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/dd572af7-fb4e75cc-995940fc-15e9a1ef) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/dd572af7-fb4e75cc-995940fc-15e9a1ef) ⋅ [View on map](https://yandex.com/courier/mvrp-map#dd572af7-fb4e75cc-995940fc-15e9a1ef)

**Example 3**

Three depots, three orders, and three vehicles are given. Each vehicle starts from its own depot. Orders are assigned to depots using `location.depot_id`:

- Order 1 is not assigned to a depot. It can be delivered from any depot.

- Order 2 is assigned to depots 1 and 2. This order can be delivered from one of the two specified depots.

- Order 3 is assigned to depot 3. It is located in a specific depot.

As a result, the algorithm built two routes:

1. One courier handles orders 1 and 2 from depot 2.
2. Another courier handles order 3 from depot 3.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/8921efe8-e66d25f-4992a8a0-6a4991bd) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/8921efe8-e66d25f-4992a8a0-6a4991bd) ⋅ [View on map](https://yandex.com/courier/mvrp-map#8921efe8-e66d25f-4992a8a0-6a4991bd)


## Routes with multiple depots  {#delivery-from-multiple-depots}


### Visit to an additional depot {#additional-depot}

**What situations to use this in**

A frequent planning scenario is visiting an additional depot to [pick up more orders](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles-depot.md#visit-additional-depot):

1. Couriers start from main depot 1.

1. Part of the couriers immediately go to deliver orders.

1. Some couriers visit depot 2 to pick up other parts of clients' orders.

1. The couriers who go to depot 2 can deliver some orders on their way.


**Implementation**

Use the following required fields:

- `vehicle.allow_different_depots_in_route`: The ability to visit multiple depots in one route:

    - If `true`, the courier can visit multiple depots on the same route.
    - If `false` (default value), the courier can only visit the depot where they started the route.

- `vehicle.max_middle_depots`: The maximum number of intermediate depots for the courier in the entire planning. The default value is 0

- If it doesn't matter which depot the routes start from or where they end at, list all depots in the `vehicle.depot_id` field.

    If there needs to be a specific order of visiting depots, fill in the following fields:

    - `vehicle.starting_depot_id`: Depots that the courier can start from.

    - `vehicle.middle_depot_id`: Depots to pick up more orders from (intermediate depots).

    - `vehicle.ending_depot_id`: Depots where the courier can end the route.

    Depot lists can overlap.

    If the courier completes the route not at a depot (`return_to_depot` = `false`), but the `vehicle.starting_depot_id` and `vehicle.middle_depot_id` fields are in use, specify any depot in the `vehicle.ending_depot_id` field — no visit will be planned there.

You can also use the following optional fields:

- `vehicle.depots_only_at_run_beginning`: The courier can make stops at intermediate depots to pick up more orders only at the beginning of the run. The default is `false`.

- `vehicle.finish_route_in_starting_depot` or `vehicle.finish_run_in_starting_depot`: The courier should end the route or run at the same depot where they started. The default is `false`. These parameters are only useful if `allow_different_depots_in_route` = `true`. For more information, see [Returning to a depot at the end of the route or run](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles-depot.md#return-to-depot).

The fields `picked_orders` and `delivered_orders` in the API response show which depot the order was picked up at and where it was delivered to.

**Schemes**

- The courier can stop at an intermediate depot in the middle of the run.

    ![](_images/uc-delivery-from-multiple-depots1-additional-depot_full.svg)

- The courier can visit an intermediate depot only at the beginning of the run (`vehicles.depots_only_at_run_beginning` = `true`).

    ![](_images/uc-delivery-depots-only-at-run.svg)

**Example 1**

The courier has to deliver 4 orders that are stored in 2 depots. The courier:

1. Starts from depot 2, where they pick up orders 2, 3, and 4.
1. Delivers order 3 on the way.
1. Visits depot 1 to pick up the remaining orders.
1. Delivers all the remaining orders.

As a result of planning, the `picked_orders` field will contain the following values:

- `Order 3`, `Order 4`, `Order 2` for `Depot 2`.
- `Order 1` for `Depot 1`.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/f5ce3237-40c94855-f077c8f7-3ec9be46) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/f5ce3237-40c94855-f077c8f7-3ec9be46) ⋅ [View on map](https://yandex.com/courier/mvrp-map#f5ce3237-40c94855-f077c8f7-3ec9be46)

**Example 2**

The same as in example 1, but `depots_only_at_run_beginning` = `true`. As a result of planning, the courier:

1. Starts from depot 2, where they pick up orders 2, 3, and 4.
1. They stop at depot 1 to reload and pick up order 1.
1. Delivers the orders.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/15e25725-cc14d32e-61d3d7bd-8b5e0cd) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/15e25725-cc14d32e-61d3d7bd-8b5e0cd) ⋅ [https://yandex.com/courier/mvrp-map#15e25725-cc14d32e-61d3d7bd-8b5e0cd](https://yandex.com/courier/mvrp-map#15e25725-cc14d32e-61d3d7bd-8b5e0cd)

**Example 3**

You need to deliver 4 orders:

|	Order | Order type | Action	|
|	----- | ----- | -----	|
|	Order 1 | `delivery` | Pick up from depot 1 or 2	|
|	Order 2 | `delivery` | Pick up from depot 3 or 4	|
|	Order 3 | `pickup` | Take to depot 1 or 3	|
|	Order 4 | `pickup` | Take to depot 2 or 4	|

The courier:

1. Starts at depot 2, where they pick up order 1.
1. Proceeds to take `pickup` orders 3 and then 4.
1. Stops at intermediate depot 3 to unload order 3 and pick up order 2.
1. Delivers orders 2 and then 1.
1. Returns to depot 2 and unloads order 4.

The `picked_orders` field of the API response shows which depot the order was picked up at, and the `delivered_orders` field shows which depot it was delivered to.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/1b830823-e6349f64-a59ccae-a6900e6f) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/1b830823-e6349f64-a59ccae-a6900e6f) ⋅ [View on map](https://yandex.com/courier/mvrp-map#1b830823-e6349f64-a59ccae-a6900e6f)


### Start of a new run from a different depot {#moving-between-depots}

**What situations to use this in**

In this scenario, the courier can make several runs. New runs can be started from a different depot, the one specified in `vehicle.starting_depot_id`. An empty run from one depot to another is possible between runs.

**Implementation**

Use the same parameters as when planning a [visit to an additional depot](#additional-depot).

To allow a courier to go from one depot to another between runs, set `can_change_depot_between_runs` = `true` (the default is `false`).

**Diagram**

![](_images/uc-delivery-from-multiple-depots-moving-between-depots.svg)

**Example**

The same as in the example with a visit to an [additional depot](#additional-depot), but there are weight restrictions: only 2 orders can fit in the vehicle. The courier can make 2 runs: `vehicle.max_runs` = 2. Each run must start at depot 2 and end at depot 1. In order for the courier to be able to go from one depot to another between runs, `can_change_depot_between_runs` = `true`. The courier performs the following actions:

1. Starts from depot 2, where they load order 4. Stops at depot 1 to load order 1. Delivers orders 4 and 1. Finishes the first run at depot 1.
1. Travels to depot 2. Loads orders 2 and 3 for the second run. Delivers the loaded orders. Returns to depot 1 at the end of the run.

Route metrics for each run include the ID of the route point most distant from the initial depot (`most_distant_location_id`) and the distance to that point (`max_distance_from_starting_depot_m`).

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/8e250606-1b28ef1-818f8981-9341701f) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/8e250606-1b28ef1-818f8981-9341701f) ⋅  [View on map](https://yandex.com/courier/mvrp-map#8e250606-1b28ef1-818f8981-9341701f)


### Choosing the optimal depot to start from  {#optimal-depot}

**What situations to use this in**

In this scenario, you need to decide how to distribute couriers between depots based on the depots' shipping volume. Conditions:

- There are several depots.

- Vehicle fleet is common for all depots.

This scenario can be used both when there's no need to visit additional depots and when delivery to a single location may require visiting additional depots.

**Implementation**

For each courier in the `vehicle.starting_depot_id` field, specify one or [multiple depots](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles-depot.md#start-from-any), where they can start and pick up orders. The algorithm selects the optimal depot to start from. You also need to specify `vehicle.ending_depot_id` (the depots where the courier can end the route).

If necessary, use the following fields:

- `vehicle.allow_different_depots_in_route`: The ability to visit multiple depots in one route:

    - If `true`, the courier can visit multiple depots on the same route.
    - If `false`, the courier can only visit the depot where they started the route.

- <!-- source: en/vrp/_includes/middle-depot.md -->
  `vehicle.middle_depot_id`: Depots to pick up more orders from (intermediate depots).
  <!-- endsource: en/vrp/_includes/middle-depot.md -->

- `vehicle.max_middle_depots`: The maximum number of intermediate depots for the courier in the entire planning. The default value is 0


{% note info %}

<!-- source: en/vrp/_includes/depot-list.md -->
Depot lists can overlap. If the starting, intermediate, and ending depots are the same, they can be listed in the `vehicle.depot_id` field instead of being specified in three separate fields.
<!-- endsource: en/vrp/_includes/depot-list.md -->

{% endnote %}


**Diagram**

![](_images/uc-delivery-from-multiple-depots2-optimal-depot_full.svg)

**Example**

There are orders waiting for delivery in two depots. Both depots are listed for the courier in the `starting_depot_id` field, but the route must be completed at depot 2. Because depot 2 is further from the delivery addresses, the algorithm selects depot 1 to start from, but ends the route at depot 2.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/db88146f-e5558cf4-ad22dcc3-cf740083) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/db88146f-e5558cf4-ad22dcc3-cf740083) ⋅ [View on map](https://yandex.com/courier/mvrp-map#db88146f-e5558cf4-ad22dcc3-cf740083)


## Delivery to one of multiple points {#delivery-to-any}

**What situations to use this in**

Use this scenario in cases where cargo can be delivered to one of several possible points and you need to choose the optimal one:

- Collecting medical tests from clients' homes to take them to the nearest lab.

- Collecting garbage or scrap metal to take it to the nearest disposal site.

- Picking up a parcel from a client to send it via a third-party transport company, which is why you need to take it to the nearest receiving terminal.

- Courier delivery. You need to plan a meeting between a regular courier and a courier with a fixed route that collects urgent shipments from regular couriers.


**Implementation**

Implement the scenario "delivery to one of multiple possible locations" using the [delivery_to_any](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md) parameter.

You can see where the order was delivered in the API response: in the `delivered_orders` field for depots or `drop_off` orders.

**Diagram**

![](_images/uc-delivery_to_any_full.svg)

**Example**

In this example, a set of `pickup` orders is implemented. For each order, several identical points are specified in `delivery_to_any`. After collecting orders, the courier will take them to the nearest `drop_off` point at the end of their shift. This will be “Laboratory 4” and “Laboratory 2” for the first and second couriers, respectively. In the API response, you can see the orders delivered to these locations in the `delivered_orders` field.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/81ead92c-41c4aedf-fbbcc473-1f0b0ce5) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/81ead92c-41c4aedf-fbbcc473-1f0b0ce5) ⋅ [View on map](https://yandex.com/courier/mvrp-map#81ead92c-41c4aedf-fbbcc473-1f0b0ce5)

## Receiving cargo at one of the possible locations {#pickup-from-any}

**What situations to use this in**

Use this scenario in situations where certain cargo can be received at several points and you need to choose the optimal one among them. For example:

- The goods to be delivered are located at different points (for example, in one of the grocery stores or pharmacies).

- The cargo can be received at one of the terminals of a third-party transport company.

- It's necessary to plan a meeting between a regular courier and a courier with a fixed route that takes urgent shipments to regular couriers.


**Implementation**

Learn more in the description of the [pickup_from_any](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md#pickup-from-any) parameter.

**Diagram**

![](_images/uc-pickup_from_any_full.svg)

**Example**

In this example, there are two `delivery` orders with `pickup_from_any` set to `true`. 2 `pickup` orders are associated with each of these orders.

Please note that all `pickup` orders and the linked `delivery` order must be the same weight.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/4a5fe463-44c130f-f90674ce-299f6701) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/4a5fe463-44c130f-f90674ce-299f6701) ⋅ [View on map](https://yandex.com/courier/mvrp-map#4a5fe463-44c130f-f90674ce-299f6701)


## Planning multiple runs from the depot for one courier  {#multiple-runs}

**What situations to use this in**

- **The shipment volume exceeds available load capacity**

    In this case, all or some of the vehicles must make more than one run to ship all the orders.

- **It's impossible to collect all orders by the time of shipment**

    Sometimes depot capacity doesn't allow you to collect all orders by the time shipment starts, but delivery must start immediately to ensure that order windows are met. In this case, couriers will make their first run not fully loaded, so that they can deliver the orders with earlier delivery windows on time. Meanwhile, the depot will collect orders with later delivery windows, which will be delivered during future runs.


**Implementation**

- To enable multiple runs, use the `max_runs` parameter (for more information, see [Multiple vehicle runs per day](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles.md)).

- To take into account that not all orders will be collected by the time shipment starts, use the `depot_ready_time` parameter (for more information, see [Time when the order is ready at the depot](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md)).


**Diagram**

![](_images/uc-max_runs_full.svg)

**Example 1**

In this example, the total weight of the three orders (3000 kg) exceeds the total load capacity of two vehicles (2500 kg). Courier 2 will make two runs (`max_runs`), delivering the third order during the second run.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/4c8cce05-becb1d52-5dc9d0c6-39c139b4) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/4c8cce05-becb1d52-5dc9d0c6-39c139b4) ⋅ [View on map](https://yandex.com/courier/mvrp-map#4c8cce05-becb1d52-5dc9d0c6-39c139b4)

**Example 2**

In this example, the courier will first deliver the earlier orders (`time_window`), `depot_ready_time` determines if they're ready or not. The `max_runs` parameter will allow them to return to the depot to collect the later orders.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/3de071b-d6c517a3-6f92f1ee-11a2a2e9) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/3de071b-d6c517a3-6f92f1ee-11a2a2e9) ⋅ [View on map](https://yandex.com/courier/mvrp-map#3de071b-d6c517a3-6f92f1ee-11a2a2e9)

## Cross docking {#cross-docking}

A cross-docking depot (cross dock) is a depot for the transshipment, reconsolidation, or reloading of goods. Specify the `crossdock` value in the `type` field for such depots.

Cross docking can be used for part of orders to ensure speedy delivery and reduce transport costs: such orders are taken to cross docks situated closer to distant locations in advance. For example, a depot is located north of the city, and delivery is carried out in the daytime. To deliver orders to the southern part of the city, a cross-docking depot is created there, and part of orders are delivered to this cross dock at night using large vehicles.

{% note alert %}

Exporting solutions with cross-docking depots to [Track & Trace](https://yandex.ru/routing/doc/en/delivery/index.md) through the Planning interface isn't currently supported.

{% endnote %}

Orders aren't stored at cross-docking depots. First, one or more vehicles bring the orders, and then one or more other vehicles pick them up and deliver them to clients. At the moment, different vehicles must transport orders to and from the cross dock.

For vehicles, the restriction on working with cross docks is set using the `crossdock_mode` parameter. It can take the following values:

- `allow`: The vehicle can take orders both to clients and to a cross dock (default value).
- `deny`: The vehicle can only take orders to clients.
- `mandatory`: The vehicle can only take orders to a cross dock.

To specify which depots or cross docks the vehicle visits, use the `vehicle.depot_id`, `vehicle.starting_depot_id`, `vehicle.middle_depot_id`, and `vehicle.ending_depot_id` fields.

{% note alert %}

You can't specify both regular and cross-docking depots in the `vehicle.depot_id`, `vehicle.starting_depot_id`, `vehicle.middle_depot_id`, and `vehicle.ending_depot_id` fields. On a single route, a courier may only visit either regular depots or cross docks.

{% endnote %}

For orders, the `crossdock_mode` parameter is also set with the following values:

- `allow`: The order can be delivered both directly from the depot and via a cross dock (default value).
- `deny`: The order can only be delivered directly from the depot.
- `mandatory`: The order can only be delivered via a cross dock.

To specify which depot the order is stored at or via which cross dock it must be delivered, use the `location.depot_id` field. If multiple depots and cross docks are specified, the order can be picked up from any of them.

For `pickup` orders, you can set the `may_drop_in_crossdock` parameter with the following values:

- `true`: The order can be left in the cross dock (default value).
- `false`: The order must be delivered to a regular depot.

The `may_drop_in_crossdock` parameter can only be used in the [Delivery to one of multiple locations](https://yandex.ru/routing/doc/en/vrp/supported-use-cases.md#delivery-to-any) scenario. If you have `pickup&delivery` order pairs allowing for transshipment at a cross-docking depot, use the [Pickup & delivery via a cross dock](https://yandex.ru/routing/doc/en/vrp/supported-use-cases.md#delivery-to-any) scenario.

{% note info %}

The courier first delivers `delivery` orders to the cross dock and only after that picks up `pickup` orders from the cross dock.

{% endnote %}

**Handling time**

For orders delivered via a cross dock, `location.crossdock_service_duration_s` is taken into account. When a vehicle arrives from a regular depot to a cross dock, the handling time for it is calculated using the formula:

`depot.service_duration_s` + Total{ `location.crossdock_service_duration_s`} for all orders that the vehicle brought.

If you use cross docking, it's a good idea to specify a time buffer: `depot.crossdock_safety_waiting_duration_s`, which is the minimum amount of time between unloading an order at a cross-docking depot and the moment when it can be picked up for delivery (by default, 3600 seconds or 1 hour). This buffer is necessary so that the potential delay of the first vehicle (carrying orders to the cross dock) won't affect the routes of vehicles that pick up orders from the cross dock.

**Diagram**

![](_images/uc-cross-docking-general_full.svg)

To prevent orders from sitting too long, specify `depot.crossdock_max_waiting_duration_s` via the [Planning API](https://yandex.ru/routing/doc/en/vrp/redoc/index.html#operation/addsATask) — the maximum time in seconds that an order can stay at a cross dock, from the moment the courier unloads it to the moment the order is unloaded from the depot. The restriction is soft. For violating it, you'll get `depot.penalty.crossdock_waiting` penalties:

- `fixed` — for the fact of violating the restriction, if at least one order stays at the cross dock longer than the time you specified;
- `per_hour` — for each hour of violation;
- `per_order` — for each order with a violation.

You can see the total penalty for violating the `depot.crossdock_max_waiting_duration_s` restriction in the API response in the `result.metrics._tasks_summary.metrics.crossdock_waiting_penalty` parameter.

{% note warning %}

If you want to set `depot.crossdock_max_waiting_duration_s` to a value less than 1 hour, reduce `depot.crossdock_safety_waiting_duration_s`, otherwise the minimum time of 1 hour will be greater than the maximum.

{% endnote %}

**Example 1**

4 couriers and 6 orders that need to be delivered from 2 depots and partially via a cross dock. The depots are located in the west of Moscow, and the cross dock is in the east of the city. Orders 1, 2 and 3 are located in the west and are delivered from depots. Orders 4, 5, and 6 are in the east and are delivered via a cross dock.

Planning result:

|	Courier | Courier characteristics | Route	|
|	----- | ----- | -----	|
|	Courier 1 | Starts from depot 1. Isn't allowed to take orders to the cross dock. | Picks up orders 1 and 3 from depot 1 and delivers them to clients.	|
|	Courier 2 | Starts from depot 2. All routes are allowed. | Picks up orders 2 and 6 from depot 2. Delivers order 2 to the client and order 6 to the cross dock.	|
|	Courier 3 | Starts from depot 1. Can only take orders to the cross dock. | Picks up orders 4 and 5 at depot 1, takes them to the cross dock, and returns to depot 1.	|
|	Courier 4 | Starts from the cross dock. | Picks up orders 4, 5, and 6 from the cross dock and takes them to clients.	|

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/402d84b2-eebf31d1-1472a96-9c5cf7a6) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/402d84b2-eebf31d1-1472a96-9c5cf7a6) ⋅ [View on map](https://yandex.com/courier/mvrp-map#402d84b2-eebf31d1-1472a96-9c5cf7a6)

**Example 2**

The planning task has 2 couriers, 1 depot in the south of Moscow, and a cross dock in the east. The following conditions are set for orders:

|	Order | Order type | Where it is located | Where it is delivered to | Via cross dock | You can leave it at the cross dock	|
|	----- | ----- | ----- | ----- | ----- | -----	|
|	1 | `delivery` | At the depot | To the client | Yes | -	|
|	2 | `pickup` | From the client | To the cross dock | No | Yes	|
|	3 | `pickup` | From the client | To the cross dock | No | Yes	|
|	4 | `pickup` | From the client | To the depot | Yes | No	|

Planning result:

|	Courier | Courier characteristics | Route	|
|	----- | ----- | -----	|
|	Courier 1 | Starts from depot 1. Can only take orders to the cross dock. | Picks up order 1 from the depot and takes it to the cross-docking depot. After waiting, picks up order 4 from the cross dock and takes it to the depot.	|
|	Courier 2 | Starts from the cross dock. | Picks up order 1 from the cross dock. Picks up orders 2, 3, and 4 from clients and delivers order 1 to the client. Takes orders 2, 3, and 4 to the cross dock.	|

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/108758aa-70b4d8e5-499ebd23-cded0bf5) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/108758aa-70b4d8e5-499ebd23-cded0bf5) ⋅ [View on map](https://yandex.com/courier/mvrp-map#108758aa-70b4d8e5-499ebd23-cded0bf5)

**Example 3**

The same depots and couriers as in example 2. The following conditions are set for orders:

|	Order | Order type | Where it is located | Where it is delivered to | Via cross dock | You can leave it at the cross dock	|
|	----- | ----- | ----- | ----- | ----- | -----	|
|	1 | `delivery` | At the depot | To the client | Yes | -	|
|	2 | `pickup` | From the client | To `drop_off` or `drop_off_2` (`delivery_to_any`) | No | Yes	|
|	3 | `pickup` | From the client | To the cross dock | No | Yes	|
|	4 | `pickup` | From the client | To the depot | Yes | No	|

Planning result:

|	Courier | Courier characteristics | Route	|
|	----- | ----- | -----	|
|	Courier 1 | Starts from depot 1. Can only take orders to the cross dock. | Picks up order 1 from the depot and takes it to the cross-docking depot. Picks up order 4 from the cross dock and takes it to the depot.	|
|	Courier 2 | Starts from the cross dock. | Picks up order 1 from the cross dock. Picks up order 3 from the client, delivers order 1 to the client, picks up orders 2 and 4 from clients, delivers order 2 to `drop_off_2`, takes orders 3 and 4 to the cross dock.	|

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/42a2077b-f1f90993-bbfc446-6a890dd2) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/42a2077b-f1f90993-bbfc446-6a890dd2) ⋅ [View on map](https://yandex.com/courier/mvrp-map#42a2077b-f1f90993-bbfc446-6a890dd2)

**Example 4**

4 couriers deliver 6 orders, 3 of which need to be delivered via a cross dock. You didn't explicitly specify the `depot.crossdock_safety_waiting_duration_s` parameter for the cross dock. By default, it's 1 hour or 3600 seconds.

Planning result:

| Courier | Courier characteristics | Route |
| ----- | ----- | -----	|
| Courier 1 | Starts from depot 1. Can't take orders to the cross dock. | Picks up orders 1, 2, and 3 from depot 1 and delivers them to clients, then returns to depot 1. |
| Courier 2 | Starts from depot 2. All routes are allowed. | Picks up orders 5 and 6 from depot 2, takes them to the cross dock, and returns to depot 2. |
| Courier 3 | Starts from depot 1. Can only take orders to the cross dock. | Picks up order 4 from depot 1, takes it to the cross dock, and returns to depot 1. |
| Courier 4 | Starts from the cross dock. | Picks up orders 4, 5, and 6 from the cross dock and takes them to clients. |

Courier 3 arrives at the cross dock at 07:35, and courier 2 at 07:45. Since you didn't set the `depot.crossdock_safety_waiting_duration_s` value, courier 4 picks up the orders and leaves the cross dock at 08:45 — exactly one hour after courier 2 arrives.

You also didn't set `depot.crossdock_max_waiting_duration_s` and the penalty values, so the orders stay at the cross dock without time restrictions.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/01a10887-4293-86a0-b294-fbec1498c800) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/01a10887-4293-86a0-b294-fbec1498c800) ⋅ [View on map](https://yandex.com/courier/mvrp-map#01a10887-4293-86a0-b294-fbec1498c800)

**Example 5**

The same conditions as in example 4, but for the cross dock you set the `depot.crossdock_max_waiting_duration_s` = 3600 value and the `depot.penalty.crossdock_waiting` penalties via the API:

- `fixed` = 100,000;
- `per_hour` = 50,000;
- `per_order` = 10,000.

Since the `depot.crossdock_max_waiting_duration_s` restriction is soft, courier 4 also leaves the cross dock at 8:45 — one hour after courier 2 arrives. At the same time, order 4, which courier 3 brought, stays at the depot from 07:35 to 08:45, which is 10 minutes longer than the allowed time.

As a result, the API response shows the total penalty of 117,819 in the `result.metrics._tasks_summary.metrics.crossdock_waiting_penalty` parameter. The planning algorithm calculates it as the sum of:

- `depot.penalty.crossdock_waiting.fixed` = 100,000 — the restriction was actually violated;
- `depot.penalty.crossdock_waiting.per_order` = 10,000 — only one order stayed at the depot longer than the allowed time;
- `depot.penalty.crossdock_waiting.per_hour` = 0.156389 * 50,000 = 7819.

    In the API response:

    - `routes[2].route[1].arrival_time_s` = 27,340 — courier 3 arrived at the cross dock at 07:35:40;
    - `routes[3].route[0].departure_time_s` = 31,503 — courier 4 left the cross dock at 08:45:03.

    Order 4 stayed at the depot for 1 hour 9 minutes 23 seconds, which is 9 minutes 23 seconds or 563 seconds longer than the allowed time. In hours, the excess was 0.156389.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/01a108b9-718f-86a0-ad28-70bf952e0100) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/01a108b9-718f-86a0-ad28-70bf952e0100) ⋅ [View on map](https://yandex.com/courier/mvrp-map#01a108b9-718f-86a0-ad28-70bf952e0100)


### Planning without considering the delivery distance to the cross dock {#planning-without-route-to-crossdock}

**What situations to use this in**

Use this option if there is no need to take into account the delivery distance from the main depot to the cross dock.

**Implementation**

This scenario is similar to [Delivery from one of several depots](https://yandex.ru/routing/doc/en/vrp/supported-use-cases.md#delivery-from-one-of-depots), and it can be implemented the same way.

{% note alert %}

Unlike the [cross docking scenario](#cross-docking) described above, delivery of orders to the cross dock isn't included in the routes in this scenario. When planning, it's assumed that any order can be taken to a cross dock, and you need to choose which orders are more profitable to ship from there. You also need to know in advance which vehicles start from the main depot and which ones start from a cross-docking platform.

{% endnote %}

**Diagram**

![](_images/uc-planning-w-choice_full.svg)

**Example**

The 60 `delivery` points are orders to deliver. There is 1 `garage` location, which is a cross-docking depot. One courier must start the route from the depot, and the other one must start from the cross-docking depot.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/16a81909-61b01fad-7275f5d3-5341ced) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/16a81909-61b01fad-7275f5d3-5341ced) ⋅ [View on map](https://yandex.com/courier/mvrp-map#16a81909-61b01fad-7275f5d3-5341ced)

### Pickup & delivery via a cross dock {#cross-docking-pickup-delivery}

**What situations to use this in**

This scenario is used if the orders that need to be delivered from the cross dock must be picked up from `pickup` points in advance.

**Implementation**

Set time limits for routes to bring orders to the cross dock and then deliver them to clients.

- **Pickup and delivery by different vehicles**

    Split delivery to and from the cross dock into different planning runs. You will get one planning according to the [Cargo collection to the depot](https://yandex.ru/routing/doc/en/vrp/supported-use-cases.md#collection-to-depot) scenario and the second according to the [Delivery from a single depot](https://yandex.ru/routing/doc/en/vrp/supported-use-cases.md#delivery-from-depot) scenario.

    **Example**

    Cross docking with two different planning runs: pickup and delivery.

    1\. The first part is the pickup. During the morning shift, one vehicle collects orders from different addresses and returns to the depot.

    [API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/2e09e5b2-a9eed157-86cb817-be3f8cad) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/2e09e5b2-a9eed157-86cb817-be3f8cad) ⋅ [View on map](https://yandex.com/courier/mvrp-map#2e09e5b2-a9eed157-86cb817-be3f8cad)

    2\. The second part is the delivery. During the day shift, another vehicle collects orders from the depot and delivers them to clients.

    [API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/2d09d379-54f76059-ea297d6c-3d33dc3a) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/2d09d379-54f76059-ea297d6c-3d33dc3a) ⋅ [View on map](https://yandex.com/courier/mvrp-map#2d09d379-54f76059-ea297d6c-3d33dc3a)

- **Collection and delivery by a single vehicle**

    Set a time limit for order collection and delivery.

    1\. For orders that need to be collected at a cross dock:
    - Set the `pickup` type.
    - Use the [delivery_deadline](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md#order-time-depot-delivery) parameter.

    2\. For orders that need to be delivered from a cross dock:
    - Set the `delivery` type.
    - Use the [depot_ready_time](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md#order-time-depot-ready) parameter.

    Between the `delivery_deadline` and `depot_ready_time` parameter values, there must be a window to allow for cross-docking operations. For example, collect the cargo before 13:00 and start delivery at 14:00.

    **Example**

    1 courier, 10 `pickup` orders, and 10 `delivery` orders. The orders are not linked. All `pickup` orders need to be delivered to the depot before 13:00, and all `delivery` orders can be picked up from the depot beginning at 14:00. For the courier to carry out the orders in 2 runs, `vehicle.max_runs` = 2 is specified.

    [API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/26f714ab-25d12bd9-6b92ea42-3db447ee) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/26f714ab-25d12bd9-6b92ea42-3db447ee) ⋅ [View on map](https://yandex.com/courier/mvrp-map#26f714ab-25d12bd9-6b92ea42-3db447ee)


**Diagram**

![](_images/uc-cross-docking_full.svg)

## Delivery with vehicle parking before the walking part of the route {#vehicle-walking-courier}

**What situations to use this in**

The scenario is used when there are several closely located orders along the route. The courier can arrive by vehicle, park, and deliver orders on foot. If it's not possible to carry all orders in one run, the courier makes several runs. At the start of each run, the courier takes some of the orders, delivers them, and then gets back to the vehicle and takes the next batch of the orders.

The route may include a few walking parts.

**Implementation**

Set the parameters:

- `location.parking_service_duration_s`: The amount of time that the courier spends parking the vehicle.

    {% note info %}

    For the `walking` and `transit` [transportation methods](https://yandex.ru/routing/doc/en/vrp/routing-mode.md), the `location.parking_service_duration_s` parameter isn't included in the calculations of the time spent.

    For other transportation methods, the time specified in the `location.parking_service_duration_s` parameter will be taken into account only once — before the start of the walking part of the route.

    {% endnote %}

- `vehicle.walking_courier.capacity.units`: The maximum number of [units](https://yandex.ru/routing/doc/en/vrp/properties-of-weight.md) that the courier can carry. To use this feature, specify the number of units for the order using the `location.shipment_size` parameter.

    If the courier needs to carry more units than specified in the `vehicle.walking_courier.capacity.units` parameter, the algorithm can build the route so that the courier makes multiple runs. For example, if the courier needs to visit 10 locations during the walking delivery, and `vehicle.walking_courier.capacity.units` = 5, the courier delivers 5 units first, goes back to the vehicle, and then picks up the remaining 5 units.

    {% note info %}

    RouteQ supports scenarios where only one courier leaves the vehicle and delivers orders on foot.

    {% endnote %}

- `vehicle.walking_courier.cost.hour` and/or `vehicle.walking_courier.cost.km`: The cost of walking delivery per hour and per kilometer. The cost of walking delivery is calculated the same way as the [vehicle or courier cost](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles-cost.md#cost).
- `vehicle.walking_courier.restrictions`: Restrictions for walking parts of routes:
    - `max_walking_edge_distance_m.value` and `max_walking_edge_distance_m.penalty`: The maximum distance (in meters) between two points on walking parts of the route and the penalty for violating the restriction.
    - `max_parking_walking_distance_m.value` and `max_parking_walking_distance_m.penalty`: The maximum walking distance (in meters) in a parking session and the penalty for violating the restriction.
    - `max_parking_duration_s.value` and `max_parking_duration_s.penalty`: The maximum duration (in seconds) of a parking session and the penalty for violating the restriction.
- `vehicle.close_locations`: The array of restrictions for nearby order locations:
    - `duration_till_service_s.value` and `duration_till_service_s.penalty`: The maximum time (in seconds) between handling two nearby orders and the penalty for violating the restriction.
    - `distance_till_service_m.value` and `distance_till_service_m.penalty`: The maximum distance (in meters) walked between two nearby orders and the penalty for violating the restriction.
    - `search_radius_m`: The distance between two orders, which are considered nearby and subject to restrictions.
    - `soft_search_radius_m`: If the value of this parameter exceeds the value of the corresponding `search_radius_m`, orders at a distance from `search_radius_m` to `soft_search_radius_m` are also subject to penalties, but their size decreases linearly depending on the distance. For example, at the distance (`search_radius_m` + `soft_search_radius_m`) / 2, a penalty with a weight of 0.5 applies.

    {% cut "Example of using the settings of nearby orders" %}

    ```json
    "vehicles": [
    {
        ...
        "close_locations": [{
                    "routing_mode": "walking",
                    "search_radius_m": 400,
                    "soft_search_radius_m": 500,
                    "distance_till_service_m":{
                        "penalty": 0.02,
                        "value": 1500
                    }
                }
            ],
        "walking_courier":{
        ...
            "restrictions":{
                "close_locations": [{
                        "routing_mode": "walking",
                        "search_radius_m": 400,
                        "soft_search_radius_m": 500,
                        "distance_till_service_m":{
                            "penalty": 0.02,
                            "value": 1500
                        }
                    },{
                        "routing_mode": "walking",
                        "search_radius_m": 100,
                        "soft_search_radius_m": 160,
                        "duration_till_service_s":{
                            "penalty": 0.02,
                            "value": 1500
                        }
                    }
                    ],
                    ...
                    }
                ...
            },
    ...
    }
    ```

    In the example above, the first restriction is that orders up to 400 meters away from each other must be handled within the next 1500 meters of movement. The penalty for violating the restriction is 0.02 for every meter. For orders 400 to 500 meters away from each other, this restriction also applies, but it decreases linearly depending on the distance. For example, for an order 430 meters away, a penalty equal to 0.7 of the main penalty is applied.

    The second restriction is similar to the first one, but it sets the time between handling orders. Orders within a radius of 100 meters must be handled within 25 minutes with a 0.02 penalty for each second over. Orders at a distance of 100 to 160 meters are subject to the penalty, which decreases linearly as the distance grows.

    {% endcut %}

To balance the cost of visiting orders on foot and vehicle, use `options.average_projection_walking_part_distance_m`. This option sets the average walking distance from the road to the order. When the option is used, for each visit to an order by vehicle, the courier is subject to twice the penalty cost for walking.

For example, if `average_projection_walking_part_distance_m` = 15, the cost of 30 meters of the walking route is added to the cost of each visit. You can use this setting to compensate for the cost of walking part of the way when using the `driving` transportation method compared to the same distance with the `walking` transportation method.

**Diagram**

![](_images/uc-walking-courier_full.svg)

**Example 1**

The route includes 10 orders. Some orders are near each other:

- Orders 1, 2, 3 and 4.
- Orders 5, 7 and 9.
- Orders 8 and 10.

Because the cost of delivery on foot is less than the cost of driving, the courier parks the vehicle and delivers nearby orders on foot. To deliver the remaining orders, the courier travels by vehicle.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/f2db0112-56f75202-fabcc3fe-fafa0028) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/f2db0112-56f75202-fabcc3fe-fafa0028) ⋅ [View on map](https://yandex.com/courier/mvrp-map#f2db0112-56f75202-fabcc3fe-fafa0028)

**Example 2**

The same as example 1, but `vehicle.walking_courier.capacity.units` = 2. To deliver orders located close to each other, the courier parks the vehicle and delivers no more than two units per run.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/3af24ad8-1ad89db1-b60eb732-409db315) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/3af24ad8-1ad89db1-b60eb732-409db315) ⋅ [View on map](https://yandex.com/courier/mvrp-map#3af24ad8-1ad89db1-b60eb732-409db315)


## Using a trailer {#trailer}

**What situations to use this in**

By default, only a truck without a trailer can arrive at the order location. Use this scenario if the order location is available for trucks with a trailer. For settings that affect trucks with a trailer, see [Trailers](https://yandex.ru/routing/doc/en/vrp/properties-of-vehicles.md#coupling).

{% note alert %}

This scenario isn't used for trucks with a semi-trailer.

<!-- source: en/vrp/_includes/restrictions-for-trailers.md -->
Exporting solutions with trailers to [Track & Trace](https://yandex.ru/routing/doc/en/delivery/index.md) through the Planning interface isn't currently supported.
<!-- endsource: en/vrp/_includes/restrictions-for-trailers.md -->

{% endnote %}

**Implementation**

The accessibility of an order location for a truck with a trailer is set in the `location.allow_trailers` field. The default is `location.allow_trailers` = `false`, a non-accessible location where only a truck without a trailer can arrive. To implement a scenario with an accessible location, set `location.allow_trailers` = `true`. In this case, the location is considered accessible for a truck with a trailer.

Types of orders for trucks with trailers:

- `anchor`: Location where you can leave a trailer for some time and perform a rolling if required.

- `parking`: A location where a trailer can only be left for the time needed to unload orders with locations forbidden for trailers.


You can arrive at the point with the `anchor` type with a trailer, leave it for a few hours, and perform rolling. This order must have a unique `id`. If you need to deliver cargo to this point, create another order with the `delivery` type (see [Order type](https://yandex.ru/routing/doc/en/vrp/properties-of-orders.md#order-type)).

The number of vehicles (truck and trailer couplings) that the anchor location can serve is unlimited by default. If necessary, specify the maximum number of vehicles that the anchor location can serve during the planning period in the `max_total_vehicles` parameter.

At a location with the `parking` type, a trailer can only be left for the time needed to unload orders at non-accessible locations.

When performing the planning task for orders with the `anchor` and `parking` type, the following fields are indicated:

#|
||	**Field** | **Description**	||
||	`trailer_used` | Shows whether the truck left the depot with or without a trailer. It may have the values `true`/`false`.
The truck can arrive at a non-accessible location if it left without a trailer (`trailer_used` = `false`).	||
||	`trailer_decoupled` | Describes the case when the truck left the depot with a trailer. Shows whether a trailer was decoupled on the route or not. It may have the values `true`/`false`.
If a trailer is decoupled (`trailer_decoupled` = `true`), the truck can arrive at a non-accessible location.	||
|#

{% cut "Response fragment" %}

```json
{
    "arrival_time_s": 36726.340873455316,
    "node": {
        "type": "location",
        "used_time_window": "12:00:00-18:00:00",
        "value": {
            "anchor_mode": "Decoupling",
            "hard_window": false,
            "id": 1,
            "penalty": {
                "out_of_time": {
                    "fixed": 1000,
                    "minute": 17
                }
            },
            "point": {
                "lat": 55.780426,
                "lon": 37.712129
            },
            "ref": "",
            "service_duration_s": 0,
            "shared_service_duration_s": 0,
            "time_window": "12:00:00-18:00:00",
            "total_service_duration_s": 0,
            "trailer_decoupled": true,
            "trailer_used": true,
            "type": "anchor"
        }
    },
    "transit_distance_m": 4035.227074751774,
    "transit_duration_s": 726.3408734553194,
    "violations": [],
    "waiting_duration_s": 6473.659126544684
  }
```

{% endcut %}

The following fields are indicated in the solution **only** for orders with the `anchor` type:

#|
||	**Field** | **Description**	||
||	`anchor_mode` | The anchor point use mode. It may have the following values:
- `Decoupling`: Decouple a trailer and continue the route.
- `Coupling`: Couple a trailer and continue the route.
- `Rolling`: Reload the cargo from the trailer, decouple it, and continue the route.	||
||	`load_to_head` | Contains a list of orders that need to be moved from the trailer to the truck (only for locations with `anchor_mode = Rolling`).
Note that the order can be partially moved to a truck. In this case, part of the order remains in the trailer if the truck capacity was exceeded after moving the cargo.	||
|#

{% cut " Response fragment" %}

```json
{
    "route": [
        {
            "arrival_time_s": 49003,
            "departure_time_s": 52603,
            "load_to_head": [
                "Order 1",
                "Order 2",
                "Order 3",
                "Order 4"
            ],
            "node": {
                "type": "location",
                "used_time_window": "08:00:00-14:00:00",
                "value": {
                    "anchor_mode": "Rolling",
                    "hard_window": false,
                    "id": "anchor43",
                    "point": {
                        "lat": 52.527983,
                        "lon": 85.227133
                    },
                    "ref": "",
                    "service_duration_s": 3600,
                    "shared_service_duration_s": 0,
                    "time_window": "08:00:00-14:00:00",
                    "total_service_duration_s": 3600,
                    "trailer_decoupled": true,
                    "trailer_used": true,
                    "type": "anchor"
                }
            }
        }
    ]
  }
```

{% endcut %}

When performing the routing task with trailers, the following fields are indicated:

#|
||	**Field** | **Description**	||
||	`trailer_used` | Shows how the truck started a route from a garage: with or without a trailer. It may have the values `true`/`false`.
It may change during the route.	||
||	`trailer_decoupled` | Shows whether the truck left the depot: with or without a trailer. It may have the values `true`/`false`.
It may change during the route.	||
||	`load_to_head` | List of orders that should be loaded into the truck.	||
||	`load_to_trailer` | The list of orders to be loaded into the trailer.	||
|#

{% cut "Response fragment" %}

```json
{
    "route": [
        {
            "arrival_time_s": 0,
            "departure_time_s": 5040,
            "load_to_head": [
                "Order 5",
                "Order 6",
                "Order 7",
                "Order 8"
            ],
            "load_to_trailer": [
                "Order 1",
                "Order 2",
                "Order 3",
                "Order 4"
            ],
            "node": {
                "type": "depot",
                "used_time_window": "00:00:00-1.23:59:59",
                "value": {
                    "finish_service_duration_s": 1800,
                    "flexible_start_time": true,
                    "hard_window": true,
                    "id": "576",
                },
                "point": {
                    "lat": 53.400374288503,
                    "lon": 83.967696868016
                },
                "preliminary_service_duration_s": 0,
                "ref": "",
                "service_duration_s": 5040,
                "time_window": "00:00:00-1.23:59:59",
                "total_service_duration_s": 5040,
                "trailer_decoupled": false,
                "trailer_used": true
            }
        }
    ]
  }
```

{% endcut %}

**Diagram**

![](_images/uc-trailer.svg)

{% note info %}

To have the trailer reloading, decoupling, and coupling locations displayed on the [map](https://yandex.ru/routing/doc/en/vrp/interface-mvrp-map.md), contact support to enable this feature.

{% endnote %}

**Example 1**

In the example, one truck with a trailer must deliver three orders. You can arrive at one of the points with a trailer (`allow_trailers` = `true`), to the other two — no (`allow_trailers` = `false`). The route has locations where you can leave a trailer for some time (`type` = `parking`).

In the resulting solution, the truck first arrives at the parking spot, leaves a trailer there, and then goes to unload the cargo at a non-accessible location. After delivering the cargo, the tractor returns to the parking spot, picks up the trailer, and continues the route.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/840aca11-d577bcbc-53cbd875-2ba5ad6b) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/840aca11-d577bcbc-53cbd875-2ba5ad6b) ⋅ [View on map](https://yandex.com/courier/mvrp-map#840aca11-d577bcbc-53cbd875-2ba5ad6b)

**Example 2**

In the example, one truck with a trailer must deliver four orders. You can't arrive at two points with a trailer (`allow_trailers` = `false`), but you can at the other two (`allow_trailers` = `true`). The route also has an anchor location (`type` = `anchor`), where you can leave a trailer for a long time.

The algorithm builds a route taking non-accessible locations into account. The truck first arrives at the anchor location and leaves the trailer. It delivers orders to the points where trailers are forbidden. Then the truck returns to the anchor location to pick up the trailer and delivers the cargo to where trailers are allowed.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/fdd9edcd-5536fa38-2a8b2555-7c3461fe) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/fdd9edcd-5536fa38-2a8b2555-7c3461fe) ⋅ [View on map](https://yandex.com/courier/mvrp-map#fdd9edcd-5536fa38-2a8b2555-7c3461fe)

**Example 3**

In the example, one truck with a trailer must deliver four orders to points where trailers are forbidden (`allow_trailers` = `false`). The route has an anchor location (`type` = `anchor`). The total weight of orders is much greater than the vehicle capacity. The truck can't deliver all orders without using a trailer.

The truck first arrives at the anchor location, leaves the trailer, and delivers two orders without it. Then, the truck returns to the anchor location, rolls the cargo from the trailer to the truck, and leaves again without the trailer to deliver the remaining orders.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/f75e4a5d-343922dd-93f3e4fe-b42d1589) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/f75e4a5d-343922dd-93f3e4fe-b42d1589) ⋅ [View on map](https://yandex.com/courier/mvrp-map#f75e4a5d-343922dd-93f3e4fe-b42d1589)

**Example 4**

In this example, there are 23 orders with non-accessible locations (`allow_trailers` = `false`) and 4 couriers. The route has two anchor locations (`type` = `anchor`). No throughput capacity limit is set, so all couriers use only one anchor location.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/cc4a248d-d32e00ec-a11dffaa-7e938e87) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/cc4a248d-d32e00ec-a11dffaa-7e938e87) ⋅ [View on map](https://yandex.com/courier/mvrp-map#cc4a248d-d32e00ec-a11dffaa-7e938e87)

**Example 5**

In this example, 1 truck with a trailer must deliver 6 orders. Trailers are allowed (`allow_trailers` = `true`) at three locations. The other three locations are non-accessible to trailers (`allow_trailers` = `false`). The route has a location where the trailer can be left for some time (`type` = `parking`).

As a result, the truck enters the parking, leaves the trailer there, and delivers 3 orders to the locations where trailers are forbidden. After that, the courier returns to the parking, picks up the trailer, and continues delivering orders in accordance with the route.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/5f94ddf3-5ea6e097-5cf3fe5d-69b9d86b) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/5f94ddf3-5ea6e097-5cf3fe5d-69b9d86b) ⋅ [View on map](https://yandex.com/courier/mvrp-map#5f94ddf3-5ea6e097-5cf3fe5d-69b9d86b)

<!-- source: en/vrp/_includes/feedback.md -->
<a href="feedback">
  <span class="button">Contact support</span>
</a>


<!-- endsource: en/vrp/_includes/feedback.md -->
