optimize

In order to use optimization when planning the route and distributing orders, use order/optimize:

Copied!
svc=order/optimize&params={"itemId":<long>,
			   "orders":[<uint>,{JSOn},...],
			   "warehouses":[<uint>],
			   "units":[<uint>],
			   "flags":<uint>,
			   "gis":{
			       "provider":<uint>,
			       "addPoints":<uint>,
			       "speed":<uint>,
			       "mode":"<text>",
			       "avoid":"<text>",
			       "departure_time":<uint>,
			       "traffic_model":"<text>",
			       "transit_mode":"<text>",
			       "transit_routing_preference":"<text>"
			   },
			   "busyRoutes":{
			       "<uint>":[
				   {
				       "tf":<uint>,
				       "tt":<uint>,
				       "pf":{<uint> || {JSON}},
				       "pt":{<uint> || {JSON}
				   },
				   ...
			       ]
			   },
			   "addPoints":<bool>,
			   "priority":{<uint>:{<uint>:<uint>},...},
			   "criterions":{"<text>":<uint>,...},
			   "preference":{<uint>:<uint>,...}
}

Parameters

The required parameters are marked with an asterisk (*).

ParameterDescription

itemId*

Resource ID.

orders*

Optimized order array (order indexes/order JSON delimited with a comma).

warehouses

Warehouse array.

flags*

Optimization flags.

gis

GIS settings.

busyRoutes

Busy period.

tf

Busy period start time.

tt

Busy period end time.

pf

Busy period start location: order ID or JSON.

pt

Busy period end location: order ID or JSON.

provider

Map source: 0 - none, 1 - Gurtam Maps (default), 2 - Google.

mode

Mode of transportation: driving, walking, bicycling, or transit (only for Google).

avoid

Route restrictions: tolls, highways, ferries and/or indoor (only for Google).

departure_time

Planned time of departure (only for Google).

traffic_model

Assumptions: best guess, pessimistic, or optimistic (only for Google).

transit_mode

Preferred modes: bus, subway, train, tram and/or rail (only for Google).

transit_routing_preference

Preferences for transit requests (only for Google).

addPoints

Return a track in the response: 1 - yes, 0 - no.

speed

Speed which should be used for optimization, km/h (60 by default).

units

Unit array.

priority

Sequence of orders: {unit index:{order index:expected index of order in a route}}

The index equal to -1 makes the order be the last in the route.

criterions

Route completion criteria:

  • max_mileage. The maximum mileage, m.
  • max_duration. The maximum duration, s.
  • max_order_count. The maximum number of orders.
  • max_idling. The maximum idle time between orders, s.

preference

Order priority in the route.

Flags

FlagDescription

0x1

Optimize by order schedule. The order tf and tt parameters are used.

0x2

Optimize by completion duration of all orders.

0x20

Optimize by carrying capacity (weight).

0x40

Optimize by effective capacity (volume).

0x80

Optimize only orders with tt > current time. If tf < current time, then tf = current time.

If the criteria are exceeded:

0x100

The route is terminated.

0x200

An intermediate warehouse is visited.

0x300

The route is divided into several routes.

Response

Copied!
{
	"1":{						  /* optimization for the first unit */
		"orders":[
				{
					"ml":<uint>,	/* mileage */
					"tm":<uint>,	/* time to visit the order area */
					"id":<uint>	/* order index in the array sent in the request (starts from 0)  */
				},
				{
					"ml":<uint>,	/* mileage */
					"tm":<uint>,	/* time to visit the order area */
					"id":<uint>	/* order index in the array sent in the request (starts from 0)  */
				}
		]
	},
	"2":{						  /* optimization for the second unit (if the number of units is greater than one) */
		"orders":[
				{
					"ml":<uint>,	/* mileage */
					"tm":<uint>,	/* time to visit order area */
					"id":<uint>	/* order index in the array sent in the request (starts from 0)  */
				},
				{
					"ml":<uint>,	/* mileage */
					"tm":<uint>,	/* time to visit the order area */
					"id":<uint>	/* order index in the array sent in the request (starts from 0)  */
				}
		]
	},
	...,						  /* optimization for other units (if the number of units is greater than two) */
	"success":<bool>				/* optimization status: 
                                          1 - success (there is a solution which meets all the requirements),
                                          0 - failed */
}

Error codes

Error codeDescription
7Invalid itemId.
6Internal error.
4Logic error. See the reason in the response for more information.
Download PDF file
Download Word document

See also