If you want to solve travelling salesman problem, i.m. to build best route to visit all stated points and to get arrival time into every of them, please use route/optimize command:
svc=route/optimize¶ms={"pathMatrix":[[<uint>,...],...], "pointSchedules": [ { "from":<uint>, "to":<uint>, "waitInterval":<uint> }, ... ], "flags":<uint>}
Params | Description |
---|---|
pathMatrix | that matrix contains movement time (in minutes) between points (see below) |
pointSchedules | that schedule states each point visit and wait time; the number of elements must be equal to pathMatrix elements |
from and to | params give time interval (in minutes) during which the courier is obliged to visit that point |
waitInterval | time which the courier waits in that point after arrival (in minutes) |
flags | problem condition flags (see below) |
Value example:
"pathMatrix":[[0,1,2],[3,0,4],[5,6,0]]
'pathMatrix'-parameter matrix is always square one and it's size is the number of defined points.
Example:
Let's assume that there are 3 points. [ [0,1,2],[3,0,4],[5,6,0] ] as input pathMatrix defines movement time among points, in other words what it takes to reach (in minutes) the 1st, the 2nd and the 3rd point.
Let's investigate the 1st matrix element – [0,1,2]. To get from the 1st point to the 1st one itself it takes 0 minnutes, to reach the 2nd point - 1 minute, to visit the 3rd point - 2 minutes.
For the 2nd matrix element [3,0,4] it takes 3 minutes to reach the 1st point, to visit itself takes 0 minutes, to come to the 3rd point costs 4 minnutes.
The 3rd point – [5,6,0] – costs are: to the 1st point – 5 minutes, to the 2nd point – 6 minutes, to itself – 0 minutes.
Those matrices feature is that there are always zeroes go diagonally (because that cells show time to the point itself).
Flag | Description |
---|---|
0x01 | pointSchedules data becomes mandatory condition |
0x08 | is mandatory to start the route from the 1st point |
0x10 | is mandatory to end the route in the last point |
Flags appear as hexadecimals.
{ success: <bool>, /* 1 - problem is solved, all conditions are met (defined with flags); */ /* 0 - problem is solved, but not all conditions are met/problem isn't solved */ order: [ { tm: 0, /* arrival time, secs */ tmf: <text>, /* formatted arrival time: "hours:minutes" */ id: 0 /* matrix point index, starts with 0 */ }, ... /* other points results */ ] }