API Reference
Contents
API Reference#
Tarot Routing - Route Optimisation API
Request#
RoutingProblem#
- RoutingProblem: JSON Object#
A RoutingObject is the body of the request send to the Route Optimisation API endpoint.
Minimal Example
{
"drivers": [
{
"uid": "drvid1",
"shift_start": 8,
"shift_end": 17,
"location": {"lat": -33.867798, "lon": 151.166256}
}
],
"jobs": [
{
"uid": "uid1",
"duration": 2,
"location": {"lat": -33.849489, "lon": 151.127482}
},
{
"uid": "uid2",
"duration": 2,
"location": {"lat": -33.880661, "lon": 151.183096}
},
{
"uid": "uid3",
"duration": 2,
"location": {"lat": -33.913168, "lon": 151.262267}
}
],
"settings": {}
}
Driver#
- Driver: JSON Object#
A
Driverrepresents a driver, their vehicle, or a theoretical run.- Parameters
uid (str) – A Unique Identifier for this
Driver. No twoDriversmay have the same UIDshift_start (float) – The earliest time this
Drivermay begin their shift. Time of day as float (e.g.8.5) in 24h timeshift_end (float) – The earliest time this
Drivermay begin their shift. Time of day as float (e.g.8.5) in 24h timeend_location (
Location) – (optional, default=driver.location) Where theDriverends their run.capacity (int or str) – (optional) Set the capacity of the vehicle. The algorithm compares the total size of all
Jobsin thisDriver’s run to the capacity of the vehicle. Simple Capacity can be expressed as an integer. For advanced use cases, see Capacity.spec_type (str) – (optional) A
Jobcan only be served by aDriverthat has at least onespec_typein common. Learn how to use Typesterritories (str) – (optional) A
Jobcan only be served by aDriverwith at least one of itsterritoriesin common. Learn how to use Territories.speed_multiplier (float) – (optional, default=
1) Adjust the driving speed of thisDriver. A value of0.5means that thisDriverwill drive half as fast as normal. A value of1.2means that thisDriverwill drive 20% faster than normal.lunch_time (float) – (optional) The earliest time that a
Drivercan start their lunch break. Time is represented as decimal 24h time. So a lunch break starting at 1:15pm is expressed as13.25lunch_duration (float) – (optional) The duration in minutes of the
Driver’s lunch breaklunch_latest_start (float) – (optional, default=
lunch_time + lunch_duration/60) The latest time theDriver’s lunch break my start. To force an exact lunch time, setjob.lunch_latest_start = job.lunch_time
Minimal Example
{
"uid": "unique_driver_id_1",
"location": {"lat": -33.867798, "lon": 151.166256},
"shift_start": 9.5,
"shift_end": 18.5
}
Standard Example
{
"uid": "drvid1",
"location": {
"lat": -33.84948962,
"lon": 151.1274823
},
"shift_start": 9.5,
"shift_end": 18.5,
"speed_multiplier": 0.8,
"lunch_time": 12.5,
"lunch_duration": 45,
"spec_type": "plumber,electrician",
"capacity": 25
}
Job#
- Job: JSON Object#
Jobsrepresent tasks, delivery points, customers etc.- Parameters
uid (str) – A Unique Identifier for this
Job. No twoJobsmay have the same UIDduration (float) – The number of minutes the
Drivermust spend at thisJob. Include parking, doing theJob, getting back to the vehicle, etc. Often called the service timearrive_after (float) – (optional) The earliest time the
Drivermay begin thisJob. Time of day as float (e.g.13.75) in 24h timeleave_by (float) – (optional) The latest time the
Drivermay finish working on thisJob. Time of day as float (e.g.15.5) in 24h timesize (float or str) – (optional) The cumulative
sizes ofJobsare matched against eachDriver`s ``capacity`to ensure that aDriver/vehicle does not exceed her vehicle’s capacity. Units can be whatever syou wish, but must be consistent between allJob'ssizes andDriver'scapacities. If ANYJobhas a size, ALLDriversmust have a capacity. For advanced use cases, see Capacity.spec_type (str) – (optional) A
Jobcan only be served by aDriverthat has at least onespec_typein common. Learn how to use Types.territories (str) – (optional) A
Jobcan only be served by aDriverwith at least one of itsterritoriesin common. Learn how to use Territories.priority (bool) – (optional, default=
false) If someJobsare more important than others, mark them aspriority=true. In Scenarios where not allJobscan be served by your availableDriver`s, these :py:data:`Jobswill be served, even if several others are not.pickup_from (str) – (optional) This creates a Pickup and Delivery constraint by referring to the
uidof anotherJob. Learn about Pickup Delivery.pd_interval_max (bool) – (optional) Sets the maximum time in minutes allowed between a Pickup Delivery pair of jobs. It should be set on the Delivery Job only. Specifically, it sets a constraint on the Job ETAs, equivalent to
delivery_job.eta - pickup_job.eta < pd_interval_maxexclude_period_start (float) – (optional) The start of a negative time window. For example, if you don’t want to visit a
Jobduring their lunch break, you could set anexclude_period_startandexclude_period_endfor it. Time of day as float (e.g.13.75) in 24h timeexclude_period_end (float) – (optional) The end of a negative time window. For example, if you don’t want to visit a
Jobduring their lunch break, you could set anexclude_period_startandexclude_period_endfor it. Time of day as float (e.g.13.75) in 24h timeimmovable (bool) – beta (optional, default=
false) If you are re-optimising a run in real-time (i.e. after theDriverhas already started performing the route), and thisJobhas already been served, you can prevent it from being moved during the optimisation by settingjob.immovable=true. This parameter may only be used if initial_runs are provided.
Minimal Example
{
"uid": "unique_job_id_1",
"duration": 10,
"location": {"lat": -33.849489, "lon": 151.127482}
}
Standard Example
{
"uid": "unique_job_id_2",
"duration": 10,
"arrive_after": 10,
"leave_by": 16.5,
"location": {
"lat": -33.84948962,
"lon": 151.1274823
},
}
Location#
- Location: JSON Object#
A Location defines the geographical position of a
DriverorJob- Parameters
lat (float) – Latitude
lon (float) – Longitude
Example
{
"lat": -33.88066125,
"lon": 151.1830961
}
Settings#
- Settings: JSON Object#
Settings convey parameters which affect the way that the optimisation algorithm runs.
- Parameters
quick_opt (bool) – (optional, default=
true) Should the algorithm stop once it reaches a local minimum to get a reasonably optimal result quickly? If True: The algorithm will stop fairly quickly once it has found a reasonably good solution. Usequick_opt=truewhen it is important to get a solution as fast as possible (e.g. in real time optimisations. If False: The algorithm will run until it reaches theimprovement_threshold_per_secondor themax_opt_time, whichever comes first. Usequick_opt=falsewhen it is important to reach a very optimal solution, but be sure to setmax_opt_timeand/orimprovement_threshold_per_secondmax_opt_time (int) – (optional, default=
450) The maximum number of seconds the algorithm is allowed to spend optimising.improvement_threshold_per_second (float) – (optional, default=
0.00005) he algorithm periodically measures the percentage improvement in the result vs time. If the improvement is less than this threshold, the result is returned instead of continuing the search. Set it to zero for no improvement thresholdmin_time_aboard (bool) – (optional, default=
false) Only applies to Pickup Delivery problems. Ifmin_time_aboard=true, the optimiser will try to minimise the interval between a Pickup and its related Deliveryfirst_solution_most_constrained (bool) – (optional, default=
false) Determines whether the first solution strategy is to create the “most constrained” feasible solution. This is useful if you have a lot of constraints and the algorithm is unable to find a solution otherwise. However, in normal circumstances, you should not use it because it usually creates a worse first solution.
Minimal Example
{}
Standard Example
{
"allocate_fairly": true,
"quick_opt": false,
"max_opt_time": 120,
}
Response#
RoutingSolution#
Run#
- Run: JSON List#
The first object in each Run is the
Driver.All subsequent objects (if any) are
SolutionJobs.If a Run contains only a Driver, then the optimiser has planned for it not to visit any Jobs.
SolutionJob#
- SolutionJob: JSON Object#
Each SolutionJob is identical to the
Jobwhich you sent to the optimiser, but it has a few extra fields to help communicate the solution to you.- Parameters
run (int) – A 1-based index indicating which run this Job is planned in. Unserved Jobs have
run=null.seq (int) – Indicates this Job’s sequence within the
Run. Unserved Jobs haveseq=null.eta (str) – Indicates the Estimated Time of Arrival at that Job as a human-readable string
HH:MM:SS. E.g. 2:30pm is represented as14:30:00. Unserved Jobs haveeta=null.decimal_eta (float) – Indicates the Estimated Time of Arrival at that Job as a float. E.g. 2:30pm is represented as
14.5. Unserved Jobs havedecimal_eta=null.etd (str) – Indicates the Estimated Time of Departure from that Job as a human-readable string
HH:MM:SS. E.g. 2:30pm is represented as14:30:00. Unserved Jobs haveetd=null.decimal_etd (float) – Indicates the Estimated Time of Departure from that Job as a float. E.g. 2:30pm is represented as
14.5. Unserved Jobs havedecimal_eta=null.