Table of Contents

Optimize order execution

In order to use optimization while executing orders use order/optimize:

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>,...} // DEPRECATED
}

Parameters

Param Description
itemId resource id
orders optimized orders array (orders indexes/orders JSON delimited with comma)
warehouses warehouses array
flags optimization flags
gis gis settings
busyRoutes busy period, next index
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 maps source: 0 - none, 1 - Gurtam Maps(default), 2 - Google
mode transport: driving, walking, bicycling or transit (only for google provider)
avoid restrictions to the route: tolls, highways, ferries and/or indoor (only for google provider)
departure_time desired time of departure (only for google provider)
traffic_model assumptions: best_guess, pessimistic or optimistic (only for google provider)
transit_mode preferred modes: bus, subway, train, tram and/or rail (only for google provider)
transit_routing_preference preferences for transit requests (only for google provider)
addPoints return track in response: 1 - yes, 0 - no
speed speed for optimization, km/h(60 on default)
units units array
priority order of orders: {unit index:{order index:expected index of order in a route}} (index equal to -1 will fix this order as last in a route)
criterions route completion criterions:
max_mileage - maximum mileage, m;
max_duration - maximum duration, sec;
max_order_count - maximum orders count;
max_idling - maximum idle time between orders, sec;
split_intervals - if 1, then split based on intervals
(if the execution time of the order with unloading and moving, misses the next order time interval)
preference DEPRECATED: order priority in route

:!: JSON format is the same as in Update order request.

:!: More about Google provider settings.

Flags

Flag Description
0x1 optimize by order schedule (order tf и tt params are used)
0x2 optimize by all orders completion duration
0x20 optimization by carrying capacity(weight)
0x40 optimization by effective capacity(volume)
0x80 optimize only orders with tt > current time; if tf < current time, then tf = current time
If criterions are exceed:
0x100 order is terminated
0x200 added visit reload warehouse
0x300 route split to several
0x400 split to independent route
0x1000 without optimization
0x2000 calculate predict distance

Response

{
	"1":{				/* 1st units optimization */
		"orders":[
				{
					"ml":<uint>,    /* mileage */
					"tm":<uint>,	/* time to visit order area */
					"id":<uint>	/* order index in array send in request (starts from 0)  */
				},
				{
					"ml":<uint>,    /* mileage */
					"tm":<uint>,	/* time to visit order area */
					"id":<uint>	/* order index in array send in request (starts from 0)  */
				}
		]
		},
	"2":{				/* 2nd unit optimization (if stated unit number is greater than one) */
		"orders":[
				{
					"ml":<uint>,    /* mileage */
					"tm":<uint>,	/* time to visit order area */
					"id":<uint>	/* order index in array send in request (starts from 0)  */
				},
				{
					"ml":<uint>,    /* mileage */
					"tm":<uint>,	/* time to visit order area */
					"id":<uint>	/* order index in array send in request (starts from 0)  */
				}
		]
	},
	...,				/* other unit number optimization (if more than two units optimization stated) */
	"success":<bool>		/* optimization status: 
                                          1 - success (there is solution to meet all requirements),
                                          0 - failed */
}

:!: If only warehouse orders were assigned to unit(0x4 flag) - it will not appear in the response.
:!: If route splited to several, it will be routes array in the response.
:!: “​p”:<text> - order route, google polyline encoding format