Setting start and\or end location for a vehicle
Integration API allows to set start and\or end location of the vehicle. Typical use cases include:
Depot-Based Routing:
A delivery company operates from a central warehouse (depot). Trucks leave the depot, deliver goods to multiple customers, and return to the same depot.
- Start Location: The depot's location.
- End Location: The same depot's location.
- Purpose: This is the most common setup, ensuring all routes originate and terminate at the central distribution point.
Multi-Depot Routing:
A large logistics company has multiple warehouses across a region. Trucks may start from one depot and end at a different depot.
- Start Location: The specific depot assigned to a vehicle.
- End Location: Possibly a different depot, or the same one, depending on the operational strategy.
- Purpose: Allows for more flexible routing, balancing workload across depots and optimizing long-haul transportation.
Home-Based Service Technicians:
Field service technicians start their day from their homes, visit customer locations, and may or may not return home at the end of the day.
- Start Location: The technician's home address.
- End Location: Either the technician's home address or a designated location (e.g., a company office).
- Purpose: Models the real-world constraints of technicians' daily routines and travel requirements.
Waste Collection:
Waste collection trucks start from a depot, collect waste from various locations, and then empty the waste at a disposal site, and return to the depot.
- Start Location: The waste collection depot.
- End Location: The waste collection depot.
- Intermediate location: The disposal site.
- Purpose: Models the collection and disposal process, ensuring that trucks follow a defined route and empty their loads at designated sites.
Implementation in the Integration API
SWAT API support configuring start and end locations for a vehicle. Implementation is different between Optimization and Integration API. With Integration API, a new set of nodes need to be created and the preassigned to a vehicle. Since nodes belong to a simulation, preassigned locations can be established at a template level and then the location will be reused for each simulation created from that template.
Each vehicle's starting and ending locations can be configured by assigning a start and end node. Alternatively, the Optimization API can be used to set these locations (see /docs/manuals/concepts/depot.md).
Configuring using nodes
Start and end location (node)
Start location can be added by creating a start node for a vehicle with three additional properties set:
node.status=assignedestablishing that the node is preassigned to a vehiclenode.partial_route_index= 1 establishing that this node should be the first one in a sequence of preassigned node, or -1 for the last onenode.finalization_type=maxrequests as late depature time from the start node as possible to try to avoid slack on the depaturenode.type=pointrequests that the node is considered as a waypoint
A node can be created, for example by:
POST {{base_url}}/api/v2/node
{
"lat": 1.312, // Coordinates of the start location
"lon": 103.8,
"uid": "6f657979-a390-49b6-ab29-8be4d014a63e", // Random unique identifier of the node
"scheduled_ts": "2021-01-01T00:00:00+07:00", // Time windows that can be matched with the simulation time boundaries, if there is no restriction on the depature
"open_time_ts": "2021-01-01T00:00:00+07:00",
"close_time_ts": "2021-01-01T23:59:59+07:00",
"close_time_ts_dynamic": "2021-01-01T23:59:59+07:00",
"location_name": "Somelocation", // Name of the location
"assigned_vehicle": "/api/v2/vehicle/1487568", // ID of the vehicle this start location should be created for
"node_type": "point", // Type of the node
"service_time": 0, // No service is required at this node
"booking_uid": "eb94f0aa-198a-4df5-b0c8-1e286a1bb5ff", // Random booking UID (not used anywhere else)
"status": "assigned", // This node should not be planned for during route optimization
"partial_route_index": 1, // This node should be the first in a sequence of preassigned nodes
"finalization_type": "max", // Try to minimize slack
}
End location
Similarly, for the last node the configuration may look like the following:
{
"lat": 1.312,
"lon": 103.8,
"uid": "3c516dc8-b08e-400e-9322-cf447e6eff28",
"scheduled_ts": "2021-02-01T23:59:59+07:00",
"open_time_ts": "2021-01-01T00:00:00+07:00",
"close_time_ts": "2021-02-01T23:59:59+07:00",
"close_time_ts_dynamic": "2021-02-01T23:59:59+07:00",
"location_name": "Some End location",
"assigned_vehicle": "/api/v2/vehicle/1487568",
"node_type": "point",
"service_time": 0,
"booking_uid": "765ab521-708f-42a1-8fae-c4512ffd9d28",
"status": "assigned",
"partial_route_index": -1, // This node should be the last in sequence (-1 stands for max integer)
"finalization_type": "min", // Try to arrive to this node as early as possible given solution
}