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


# Using presets

A preset is a set of settings for implementing a scenario or planning strategy. Presets are stored with RouteQ.

A preset contains parameters and their values in JSON format. Presets use the same [properties and options](https://docs.routeq.com/doc/en/vrp/attribute-and-option-guide_index-page.md) as API requests. You can specify the names (unique IDs) of the presets you use in an API request. When you execute that request, the settings from the specified presets are used (see [Including presets in the request](#include-preset)).

Advantages of using presets:

- Using presets, you can implement different planning scenarios (for example, for high or low demand, for different depots, for weekdays or weekends).
- Presets can be reused, which speeds up and streamlines [making API requests](https://docs.routeq.com/doc/en/vrp/add-task.md) for route planning.
- For [integration](https://docs.routeq.com/doc/en/vrp/integration-variants.md) purposes, you can specify the preset name in the `preset_id` field and then update the preset with new parameters without changing the integration settings. 


Each preset belongs to one of the following types:

- `depot`: Depot settings.
- `location`: Order settings.
- `vehicle`: Courier or vehicle settings.
- `vehicle-shift`: Courier shift settings.
- `options`: Global options.

A preset of a certain type can only be included in the corresponding field of the API request. If the API request field is an array and contains several elements, each element can contain a call to the preset. An object can only contain a call to one preset.

{% cut "API request structure with presets" %}

```json
{
   "depots": [
        {
            "id": "depot1",
            "preset_id": "depot_preset_1",
            ...
        },
    ],
    "locations": [
        {
             "id": "order1",
             "preset_id": "location_preset_1",
             ...
        },
        {
             "id": "order2",
             "preset_id": "location_preset_2",
             ...
        },
        ...
    ],
    "vehicles": [
        {
            "id": "vehicle1",
             "preset_id": "vehicle_preset_1",
             ...
             "shifts": [
                  {
                      "id": "0",
                      "preset_id": "vehicle-shift_preset_fo",
                       ...
                  },
                  ...
              ],
        },
        ...
    ],
    "options": {
        "preset_id": "options_preset_id",
        ...
     }
}
```

{% endcut %}

{% cut "Fields that cannot be used in presets" %}

* **depot**:
    * `address`
    * `description`
    * `id`
    * `point`
    * `ref`
    * `title`
* **location**:
    * `address`
    * `client_id`
    * `comments`
    * `delivery_to`
    * `delivery_to_any`
    * `depot_id`
    * `description`
    * `id`
    * `phone`
    * `pickup_from_any`
    * `point`
    * `ref`
    * `title`
    * `type`
* **vehicle**:
    * `depot_id`
    * `ending_depot_id`
    * `finish_at`
    * `fixed_planned_route`
    * `global_proximity_attraction_point`
    * `id`
    * `imei`
    * `fixed_work_breaks`
    * `middle_depot_id`
    * `phone`
    * `planned_route`
    * `ref`
    * `shifts`
    * `start_at`
    * `starting_depot_id`
    * `visited_locations`
* **vehicle-shift**:
	* `id`
* **options**:
	* `date`
    * `location_groups`

{% endcut %}

{% note info %}

When an API request containing a call to a preset is received, the algorithm integrates parameter values from the preset into the request text and deletes the call.  The resulting request that the algorithm processes has no preset names.

{% endnote %}

## Public presets {#presets-public}

Public presets can be used by all companies, but cannot be edited.

Public presets consist of several parts with the same name, but belonging to different types (for `depots`, `locations`, `vehicles`, `vehicles.shifts`, and `options`). All parts of the preset should be used together, because using them separately is inefficient.

Public presets have been created for specific scenarios. Their settings are based on a large number of tasks and serve to optimize solutions for the majority of cases. For certain tasks, it may be possible to set parameters that would further improve the result.

The service currently has public preset `public_minimize_mileage`, whose settings are optimized for minimizing mileage.

## Including presets in the request {#include-preset}

If the same parameter is defined both in the preset and in the user's request, the user-defined value is given priority. The parameter is used in its entirety, as a single structure with all the nested fields.

For example, if the `penalty.early` parameter is passed in the user request, and at the same time there is an active preset with a defined `penalty.late` parameter, the final request will include the user-defined `penalty` parameter, and all of the preset's nested `penalty` fields will be cleared.

## Example of using presets {#example}

In the example below, the courier is delivering 4 orders. The request body contains all the necessary parameters.

{% cut "Request without presets" %}

```json
{
    "depots": [
        {
            "id": "Depot",
            "point": {
                "lat": 55.733974,
                "lon": 37.587093
            },
            "time_window": "07:00:00-22:00:00",
            "penalty": {
                "out_of_time": {
                    "fixed": 0,
                    "minute": 200
                }
            },
            "hard_window": false
        }
    ],
    "locations": [
        {
            "id": "Order 1",
            "point": {
                "lat": 55.790514,
                "lon": 37.660161
            },
            "shipment_size": {
                "weight_kg": 19
            },
            "time_window": "09:00:00-18:00:00",
            "title": "Client 1",
            "penalty": {
                "out_of_time": {
                    "fixed": 0,
                    "minute": 200
                }
            },
            "hard_window": false
        },
        {
            "id": "Order 2",
            "point": {
                "lat": 55.798874,
                "lon": 37.612227
            },
            "shipment_size": {
                "weight_kg": 61
            },
            "time_window": "09:00:00-18:00:00",
            "title": "Client 2",
            "penalty": {
                "out_of_time": {
                    "fixed": 0,
                    "minute": 200
                }
            },
            "hard_window": false
        },
        {
            "id": "Order 3",
            "point": {
                "lat": 55.734126,
                "lon": 37.671705
            },
            "shipment_size": {
                "weight_kg": 18
            },
            "time_window": "09:00:00-18:00:00",
            "title": "Client 3",
            "penalty": {
                "out_of_time": {
                    "fixed": 0,
                    "minute": 200
                }
            },
            "hard_window": false
        },
        {
            "id": "Order 4",
            "point": {
                "lat": 55.662039,
                "lon": 37.556963
            },
            "shipment_size": {
                "weight_kg": 30
            },
            "time_window": "09:00:00-18:00:00",
            "title": "Client 4",
            "penalty": {
                "out_of_time": {
                    "fixed": 0,
                    "minute": 200
                }
            },
            "hard_window": false
        }
    ],
    "vehicles": [
        {
            "capacity": {
                "weight_kg": 800
            },
            "id": "Courier 1",
            "return_to_depot": false,
            "cost": {
                "km": 60,
                "fixed": 1000
            },
            "shifts": [
                {
                    "id": "0",
                    "time_window": "08:00:00-16:00:00",
                    "penalty": {
                        "out_of_time": {
                            "fixed": 0,
                            "minute": 200
                        }
                    },
                    "hard_window": false
                }
            ]
        }
    ],
    "options": {
        "time_zone": 3,
        "date": "2023-04-28",
        "quality": "normal",
        "proximity_factor": 0.1,
        "post_optimization": true,
        "global_proximity_factor": 0.2
    }
}
```

{% endcut %}

Public preset `public_minimize_mileage` has specific values for cost, penalties, density, and some other settings.

{% cut "Settings in the public_minimize_mileage preset" %}

* **depot**:

    ```json
    "body": {
        "penalty": {
            "out_of_time": {
                "fixed": 0,
                "minute": 200
            }
        }
     ```

* **location**:

    ```json
    "body": {
        "penalty": {
            "out_of_time": {
                "fixed": 0,
                "minute": 200
                }
            },
        "hard_window": false
    }
    ```

* **vehicle**:

    ```json
    "body": {
        "cost": {
            "km": 60,
            "fixed": 1000
        }
    }
    ```

* **vehicle-shift**:

    ```json
    "body": {
        "penalty": {
            "out_of_time": {
                "fixed": 0,
                "minute": 200
            }
        }
    }
    ```

* **options**:

    ```json
    "body": {
        "quality": "normal",
        "proximity_factor": 0.1,
        "post_optimization": true,
        "global_proximity_factor": 0.2
    }
    ```

{% endcut %}

If a request uses the `public_minimize_mileage` preset, the request body will be shorter.

{% cut "Request with preset" %}

```json
{
    "depots": [
        {
            "id": "Depot",
            "preset_id": "public_minimize_mileage",
            "point": {
                "lat": 55.733974,
                "lon": 37.587093
            },
            "time_window": "07:00:00-22:00:00"
        }
    ],
    "locations": [
        {
            "id": "Order 1",
            "preset_id": "public_minimize_mileage",
            "point": {
                "lat": 55.790514,
                "lon": 37.660161
            },
            "shipment_size": {
                "weight_kg": 19
            },
            "time_window": "09:00:00-18:00:00",
            "title": "Client 1"
        },
        {
            "id": "Order 2",
            "preset_id": "public_minimize_mileage",
            "point": {
                "lat": 55.798874,
                "lon": 37.612227
            },
            "shipment_size": {
                "weight_kg": 61
            },
            "time_window": "09:00:00-18:00:00",
            "title": "Client 2"
        },
        {
            "id": "Order 3",
            "preset_id": "public_minimize_mileage",
            "point": {
                "lat": 55.734126,
                "lon": 37.671705
            },
            "shipment_size": {
                "weight_kg": 18
            },
            "time_window": "09:00:00-18:00:00",
            "title": "Client 3"
        },
        {
            "id": "Order 4",
            "preset_id": "public_minimize_mileage",
            "point": {
                "lat": 55.662039,
                "lon": 37.556963
            },
            "shipment_size": {
                "weight_kg": 30
            },
            "time_window": "09:00:00-18:00:00",
            "title": "Client 4"
        }
    ],
    "vehicles": [
        {
            "capacity": {
                "weight_kg": 800
            },
            "id": "Courier 1",
            "preset_id": "public_minimize_mileage",
            "return_to_depot": false,
            "shifts": [
                {
                    "id": "0",
                    "preset_id": "public_minimize_mileage",
                    "time_window": "08:00:00-16:00:00"
                }
            ]
        }
    ],
    "options": {
        "preset_id": "public_minimize_mileage",
        "time_zone": 3,
        "date": "2023-04-28"
    }
}
```

{% endcut %}

## How to create a preset {#create-preset}

You can use the [interface](https://docs.routeq.com/doc/en/vrp/interface-presets.md) or [API methods](https://yandex.ru/routing/doc/en/vrp/redoc/index.html#tag/presets) to work with presets.

{% note info %}

The name for presets of the same type must be unique. It cannot start with `public_` or contain a comma.

{% endnote %}

If you encounter any problems when creating or using presets, contact support.

## Using public presets {#how}

To use presets from the master data and public presets, send a request to the [mvrp resource with OAuth authorization](https://yandex.ru/routing/doc/en/vrp/redoc/index.html#operation/addsATask):

{% include [geozones-reference-book-how-to-use](_includes/how-to-use-8c66d28eba0e.md) %}

**Example 1**

There are 20 orders and 2 couriers, public presets are not used.

As a result of planning, the length of the route is 85 km.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/597af465-7c80ec4-cee7664-dac3c7fb) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/597af465-7c80ec4-cee7664-dac3c7fb) ⋅  [View on map](https://yandex.com/courier/mvrp-map#597af465-7c80ec4-cee7664-dac3c7fb)

**Example 2**

Same as example 1, but public preset `public_minimize_mileage` is used to minimize mileage.

In the request processed by the planning algorithm (to view it, follow the link below), the names of presets from the `public_minimize_mileage` set are replaced with the contents of these presets. To view the contents of the presets from the `public_minimize_mileage` set, see [Example of using presets](#example).

As a result of planning, the length of the route is 79 km.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/cffa61e5-3c83d4c5-618ff6ec-b2313fea) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/cffa61e5-3c83d4c5-618ff6ec-b2313fea) ⋅  [View on map](https://yandex.com/courier/mvrp-map#cffa61e5-3c83d4c5-618ff6ec-b2313fea)

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