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>
			   },
			   "addPoints":<bool>,
			   "priority":{<uint>:{<uint>:<uint>},...},
			   "criterions":{<text>:<uint>,...},
			   "preference":{<uint>:<uint>,...}}

Parameters

Param Description
itemId resource id
orders optimized orders array (orders indexes/orders JSON delimited with comma)
warehouses warehouses array
flags optimization flags
gis card settings
provider maps source: 0 – none, 1 – Google Maps(default)
addPoints return track in response: 1 – yes, 0 – no
speed speed for optimization, km/h(60 on default)
units units array
priority orders priority: {unit index:{order index:orders priority}}
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 order priority in route

:!: JSON format is the same as in Create/update request.

Flags

Flag Description
0x1 optimize by order schedule (order tf and 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 splited to several

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.