## OptimizationMvrpService

A service solves for the optimization of a Multi(or single) vehicle routing problem.

### Methods

| Method |  |
| --- | --- |
| postVRP | postVRP(opt: [OptimizationMvrpOrderRequest](#interface-optimizationmvrporderrequest))<br>  <br>Parameters<br>  <br>1.  opt: [OptimizationMvrpOrderRequest](#interface-optimizationmvrporderrequest) Deprecated  <br>      <br>    Notes:  <br>    the expected order for all coordinates arrays is \[lon, lat\]  <br>    all timings are in seconds  <br>    all distances are in meters  <br>    a time_window object is a pair of timestamps in the form \[start, end\]  <br>    cost values in output are the one used in the optimization objective (currently equal to duration)  <br>    a "task" is either a job, a pickup or a delivery<br>  <br>Return Value: Promise |
| retrieve | retrieve(opt: [OptimizationMvrpRetrieveRequest](#interface-optimizationmvrpretrieverequest))<br>  <br>Parameters<br>  <br>1.  opt: [OptimizationMvrpRetrieveRequest](#interface-optimizationmvrpretrieverequest)<br>  <br>Return Value: Promise |

## Interface OptimizationMvrpRetrieveRequest

### Properties

| Name |  |
| --- | --- |
| apiKey Optional | Type: string<br>  <br>api key for the request |
| id | Type: string<br>  <br>Unique Reference ID for the submitted VRP. It is the id returned from optimization POST response. |

## Interface OptimizationMvrpRetrieveResult

Notes:  
the expected order for all coordinates arrays is \[lon, lat\]  
all timings are in seconds  
all distances are in meters  
a time_window object is a pair of timestamps in the form \[start, end\]  
cost values in output are the one used in the optimization objective (currently equal to duration)  
a "task" is either a job, a pickup or a delivery

### Properties

| Name |  |
| --- | --- |
| description Optional | Type: string<br>  <br>This will return a value if it is set in the description top level property. |
| message | Type: string<br>  <br>Describe the error if one occurs during processing data |
| result | Type: [OptimizationMvrpRetrieveResultData](#interface-optimizationmvrpretrieveresultdata) |
| status | Type: NBRequestStatus<br>  <br>Describes the process status |

## Interface OptimizationMvrpRetrieveResultData

### Properties

| Name |  |
| --- | --- |
| code Optional | Type: number<br>  <br>0: no error, 1: internal error, 2: input error, 3: routing error |
| error | Type: string |
| routes | Type: Array<[OptimizationMvrpRoute](#interface-optimizationmvrproute)\> |
| summary | Type: [OptimizationMvrpSummary](#interface-optimizationmvrpsummary) |
| unassigned | Type: Array<[OptimizationMvrpUnassigned](#interface-optimizationmvrpunassigned)\> |

## Interface OptimizationMvrpUnassigned

### Properties

| Name |  |
| --- | --- |
| description Optional | Type: string |
| id Optional | Type: number |
| location Optional | Type: Array<number> |
| task_type Optional | Type: string |

## Interface OptimizationMvrpOrderRequest

Deprecated  
  
Notes:  
the expected order for all coordinates arrays is \[lon, lat\]  
all timings are in seconds  
all distances are in meters  
a time_window object is a pair of timestamps in the form \[start, end\]  
cost values in output are the one used in the optimization objective (currently equal to duration)  
a "task" is either a job, a pickup or a delivery

### Properties

| Name |  |
| --- | --- |
| apiKey Optional | Type: string<br>  <br>api key for the request |
| depots Optional | Type: Array<[OptimizationMvrpOrderDepot](#interface-optimizationmvrporderdepot)\><br>  <br>Describes the locations of depots |
| description Optional | Type: string<br>  <br>Text description of location.If set, this description will be returned in the response |
| jobs Optional | Type: Array<[OptimizationMvrpOrderJob](#interface-optimizationmvrporderjob)\><br>  <br>Array of job objects describing the stops/places to visit. Each Job object has the following parameters |
| locations | Type: [OptimizationMvrpOrderLocation](#interface-optimizationmvrporderlocation)<br>  <br>This indicates the locations that will be used for optimization. The object contains the following parameters. |
| mode Optional | Type: string<br>  <br>A parameter which which sets the transportation mode for the route. PS: Only the 4w/car profile is enabled by default. The other customised routing profiles are only supported in premium plan. |
| shipments Optional | Type: Array<[OptimizationMvrpOrderShipment](#interface-optimizationmvrpordershipment)\><br>  <br>The shipments object describes the pickup and delivery tasks |
| vehicles | Type: Array<[OptimizationMvrpOrderVehicle](#interface-optimizationmvrpordervehicle)\><br>  <br>vehicles is the array of vehicle objects with the following parameters. |

## Interface OptimizationMvrpOrderResult

### Properties

| Name |  |
| --- | --- |
| id | Type: string |
| message | Type: string |
| status | Type: NBRequestStatus |

## Interface OptimizationMvrpOrderJob

### Properties

| Name |  |
| --- | --- |
| delivery Optional | Type: Array<number><br>  <br>an array of integers describing multidimensional quantities for delivery  <br>  <br>Items in the array would refer to types of delivery objects and associated count for that object. For example, if your use case is `flower delivery` , position 0 in the array might be the number of `roses` to be delivered and position 1 in the array might be the number of `tulips` to be delivered at the location. |
| description Optional | Type: string<br>  <br>Description of the job |
| id | Type: number<br>  <br>Unique reference ID for the job |
| location_index | Type: number<br>  <br>Valid values are 0 to (No. of locations in the locations object -1)  <br>  <br>Index of a location in the locations object which marks the latitude, longitude for the job |
| pickup Optional | Type: Array<number><br>  <br>an array of integers describing multidimensional quantities for pickup. Items in the array would refer to types of pickup objects and associated count for that object. For example, if your use case is `flower delivery` , position 0 in the array might be the number of `roses` to be picked up and position 1 in the array might be the number of `tulips` to be picked up at the location. |
| priority Optional | Type: number<br>  <br>Default = 0 Valid values are 0 to 100  <br>  <br>Describe the priority of this job. Priority only decides whether this job will be assigned, but will not necessarily influence the sequencing of the job. |
| service Optional | Type: number<br>  <br>Unit is seconds.  <br>  <br>The service duration for this job (defaults to 0) |
| setup Optional | Type: number<br>  <br>The unit is in second. Its default value is 0.  <br>  <br>Describe the job setup duration. |
| skills Optional | Type: Array<number><br>  <br>An array of integers used to list the capabilities/attributes/skills for the job. These could be used to set a job attribute (EV - possibly in a low-emission zone), capability (cold storage, refuel), or driver skillset. |
| time_windows Optional | Type: Array<Array<number>><br>  <br>An array of time_window objects describing valid slots for job service start. Each time_window object contains a start time and end time for the window.  <br>  <br>Example: \[\[1656487800,1656516600\],\[1656570000,1656620000\]\] |

## Interface OptimizationMvrpOrderLocation

### Properties

| Name |  |
| --- | --- |
| id | Type: number<br>  <br>reference ID for the set of locations |
| location | Type: Array<[LngLatLike](./geography-and-geometry#LngLatLike-lnglatlike)\><br>  <br>The index into the list is used when setting job and vehicle locations. |

## Interface OptimizationMvrpOrderShipment

### Properties

| Name |  |
| --- | --- |
| amount Optional | Type: Array<number> |
| delivery | Type: { id: number,location_index: number,service: number,time_windows: Array<undefined> } |
| description Optional | Type: string<br>  <br>Description of the shipment |
| pickup | Type: { id: number,location_index: number,service: number,time_windows: Array<undefined> } |
| priority Optional | Type: number<br>  <br>Describe the priority of this shipment. The valid value is in range of \[0, 100\]. Its default value is `0` . Priority only decides whether this shipment will be assigned, but has nothing to do with the sequence of shipments. |
| skills Optional | Type: Array<number><br>  <br>Describe the mandatory skills for this shipment |

## Interface OptimizationMvrpOrderVehicle

### Properties

| Name |  |
| --- | --- |
| breaks Optional | Type: { id: number,service: number,time_windows: Array<Array<number>> }<br>  <br>Describe the breaks the driver will take |
| capacity Optional | Type: Array<number> |
| depot Optional | Type: number<br>  <br>Describe the depot assigned to this vehicle |
| description Optional | Type: string<br>  <br>Description of the vehicle |
| end_index Optional | Type: number |
| id | Type: number |
| max_tasks Optional | Type: number |
| skills Optional | Type: Array<number> |
| start_index Optional | Type: number |
| time_window Optional | Type: undefined |

## Interface OptimizationMvrpOrderDepot

### Properties

| Name |  |
| --- | --- |
| description Optional | Type: string<br>  <br>Add a description for this depot |
| id | Type: number<br>  <br>Describe the id of this depot |
| location_index | Type: number<br>  <br>Describe the location of depot |

## Interface OptimizationMvrpSummary

### Properties

| Name |  |
| --- | --- |
| cost Optional | Type: number |
| delivery Optional | Type: Array<number> |
| distance Optional | Type: number |
| duration Optional | Type: number |
| num_late_visits Optional | Type: number |
| num_vehicle_overtime Optional | Type: number |
| pickup Optional | Type: Array<number> |
| prioriy Optional | Type: number |
| routes Optional | Type: number |
| service Optional | Type: number |
| setup Optional | Type: number |
| total_vehicle_overtime Optional | Type: number |
| total_visit_lateness Optional | Type: number |
| unassigned Optional | Type: number |
| violation Optional | Type: { cause: string,duration: number } |
| waiting_time Optional | Type: number |

## Interface OptimizationMvrpRoute

### Properties

| Name |  |
| --- | --- |
| cost Optional | Type: number<br>  <br>Describe the cost of this route. Right now it is equal to duration |
| delivery Optional | Type: Array<number><br>  <br>Describe the total deliveries in this route |
| description Optional | Type: string<br>  <br>Description of the vehicle on the route |
| distance Optional | Type: number<br>  <br>Describe the total distance in this route |
| duration Optional | Type: number<br>  <br>Describe the duration of this route |
| geometry Optional | Type: string<br>  <br>geometry |
| pickup Optional | Type: Array<number><br>  <br>Describe the total pickups in this route |
| priority Optional | Type: number<br>  <br>Describe the sum of priorities for this route |
| service Optional | Type: number<br>  <br>Describe the total service time for this route |
| setup Optional | Type: number<br>  <br>Describe the total setup time for this route |
| steps Optional | Type: Array<[OptimizationMvrpRouteStep](#interface-optimizationmvrproutestep)\><br>  <br>Describe the steps in this route |
| vehicle | Type: number<br>  <br>Describe the vehicle ID |
| vehicle_overtime | Type: number<br>  <br>The vehicle-overtime of this route |
| waiting_time Optional | Type: number<br>  <br>Describe the waiting time at this step |

## Interface OptimizationMvrpRouteStep

### Properties

| Name |  |
| --- | --- |
| arrival Optional | Type: number<br>  <br>Describe the arrival time at this step |
| description Optional | Type: string<br>  <br>Describe this step |
| duration Optional | Type: number<br>  <br>Describe the duration to this step. (The duration is accumulated here which means it includes the time spent on previous steps) |
| id Optional | Type: number<br>  <br>Describe the id of this task |
| late_by Optional | Type: number<br>  <br>Describe the visit-lateness of this step |
| load Optional | Type: Array<number><br>  <br>Describe the load of the vehicle after the completion of this step |
| location Optional | Type: Array<number><br>  <br>Describe the coordinate at this step |
| location_index Optional | Type: number<br>  <br>Describe the location index at this step |
| service | Type: number<br>  <br>Describe the service duration at this step |
| setup | Type: number<br>  <br>Describe the setup duration at this step |
| type | Type: string<br>  <br>Describe the task type of this step |
| violation Optional | Type: Array<{ cause: string,duration: number }><br>  <br>Describe the violations in this step |
| waiting_time Optional | Type: number<br>  <br>Describe the waiting time at this step |

## Constants TravelMode

The transportation mode for the route.

| Constants |  |
| --- | --- |
| AUTO | default mode, same as car |
| CAR | car mode |
| TRUCK | truck mode |
