AI-generated Key Takeaways
-
Route Optimization requests require defining a
ModelwithShipmentsandVehiclesto represent the optimization problem. -
The
Modelsets global parameters, whileShipmentsandVehicleshave individual properties and constraints for pickups, deliveries, loads, and time windows. -
OptimizeToursRequestallows controlling the search mode, traffic considerations, and response details. -
OptimizeToursandBatchOptimizeToursoffer synchronous and asynchronous request processing, respectively, with key differences in handling large or complex scenarios. -
You can specify global start and end times for all vehicles and shipments within the
ShipmentModel.
As briefly described in Route Optimization Overview, a basic request consists of Model, Shipments, and Vehicles as required entities:
- Model captures settings and constraints for the entire request,
inclusive of both
ShipmentsandVehicles. - Shipments represent tasks or actual shipments that include pickup and
delivery
VisitRequests. Shipments have local settings and constraints. - Vehicles represent vehicles, drivers, or personnel. Vehicles also have local settings and constraints.
Each entity's properties describe part of an optimization problem at a particular level of granularity. Model-wide constraints are applied to all shipments and vehicles, while constraints and properties specified on shipments or vehicles are specific to a single shipment or vehicle.
For complete documentation on each message type, see the reference documentation
for ShipmentModel (REST, gRPC), Shipment (REST, gRPC),
and Vehicle (REST, gRPC) messages.
OptimizeToursRequest properties
Some commonly used properties of the top-level OptimizeToursRequest message
(REST, gRPC) include the following:
searchModeindicates whether to return the first solution that satisfies specified constraints or find the best possible solution within a set deadline.considerRoadTrafficdetermines whether or not live traffic is used for routing and ETA estimation.populateTransitionPolylinesdetermines whether or not route polylines and route tokens are returned in the response.
Model properties
Some commonly used properties of the ShipmentModel message (REST,
gRPC) include:
globalStartTimerepresents the earliest start time of routes across all vehicles and shipments. No vehicle may start its first transitions and shipments before this time.globalEndTimerepresents the latest end time of routes across all vehicles and shipments. All assigned shipments and transitions must be complete before this time.
Shipment properties
Some commonly used properties of the Shipment message (REST, gRPC)
include:
pickups[]anddeliveries[]represent where a shipment can be picked up or dropped off.pickups[]anddeliveries[]properties both use theVisitRequestmessage (REST, gRPC).loadDemandsrepresent the load required for a vehicle to complete a shipment. Vehicles' correspondingload_limits(REST, gRPC) property represents how much load a vehicle can accommodate at one time. Read more about load in Load Demands and Limits.penalty_costrepresents the cost incurred if a shipment is skipped. Read more on costs in Cost Model Parameters.
Vehicle properties
Some commonly used properties of the Vehicle message (REST, gRPC)
include:
startLocationrepresents where a vehicle must start its route. This property is optional. If not specified, the vehicle's route starts at the location of its first assigned shipment.endLocationrepresents where a vehicle must end its route. This property is optional. If not specified, the vehicle's route ends at the location of its last assigned shipment.startTimeWindows[]represents when a vehicle can start its route. This property is optional.endTimeWindows[]represents when a vehicle can start and end its route. Both properties are optional.loadLimitsrepresent the vehicle's capacity available to meet shipments' load demands. Read more about load demands and limits in Load Demands and Limits.
A complete example request in JSON format looks like:
{
"model": {
"shipments": [
{
"pickups": [
{
"arrivalLocation": {
"latitude": 37.73881799999999,
"longitude": -122.4161
}
}
],
"deliveries": [
{
"arrivalLocation": {
"latitude": 37.79581,
"longitude": -122.4218856
}
}
]
}
],
"vehicles": [
{
"startLocation": {
"latitude": 37.73881799999999,
"longitude": -122.4161
},
"endLocation": {
"latitude": 37.73881799999999,
"longitude": -122.4161
},
"costPerKilometer": 1.0
}
],
"globalStartTime": "2024-02-13T00:00:00.000Z",
"globalEndTime": "2024-02-14T06:00:00.000Z"
}
}
OptimizeTours and BatchOptimizeTours both consume request messages like the
example above, but in different ways. Before making a Route Optimization
request, it's important to understand the difference between the two methods:
Comparing OptimizeTours and BatchOptimizeTours