Class ShipmentRoute (1.8.5)

ShipmentRoute(mapping=None, *, ignore_unknown_fields=False, **kwargs)

A vehicle's route can be decomposed, along the time axis, like this (we assume there are n visits):

::

 |            |            |          |       |  T[2], |        |      |
 | Transition |  Visit #0  |          |       |  V[2], |        |      |
 |     #0     |    aka     |   T[1]   |  V[1] |  ...   | V[n-1] | T[n] |
 |  aka T[0]  |    V[0]    |          |       | V[n-2],|        |      |
 |            |            |          |       | T[n-1] |        |      |
 ^            ^            ^          ^       ^        ^        ^      ^

vehicle V[0].start V[0].end V[1]. V[1]. V[n]. V[n]. vehicle start (arrival) (departure) start end start end end

Note that we make a difference between:

  • "punctual events", such as the vehicle start and end and each visit's start and end (aka arrival and departure). They happen at a given second.
  • "time intervals", such as the visits themselves, and the transition between visits. Though time intervals can sometimes have zero duration, i.e. start and end at the same second, they often have a positive duration.

Invariants:

  • If there are n visits, there are n+1 transitions.
  • A visit is always surrounded by a transition before it (same index) and a transition after it (index + 1).
  • The vehicle start is always followed by transition #0.
  • The vehicle end is always preceded by transition #n.

Zooming in, here is what happens during a Transition and a Visit:

::

---+-------------------------------------+-----------------------------+--> | TRANSITION[i] | VISIT[i] | | | | | * TRAVEL: the vehicle moves from | PERFORM the visit: | | VISIT[i-1].departure_location to | | | VISIT[i].arrival_location, which | * Spend some time: | | takes a given travel duration | the "visit duration". | | and distance | | | | * Load or unload | | * BREAKS: the driver may have | some quantities from the | | breaks (e.g. lunch break). | vehicle: the "demand". | | | | | * WAIT: the driver/vehicle does | | | nothing. This can happen for | | | many reasons, for example when | | | the vehicle reaches the next | | | event's destination before the | | | start of its time window | | | | | | * DELAY: right before the next | | | arrival. E.g. the vehicle and/or | | | driver spends time unloading. | | | | | ---+-------------------------------------+-----------------------------+--> ^ ^ ^ V[i-1].end V[i].start V[i].end

Lastly, here is how the TRAVEL, BREAKS, DELAY and WAIT can be arranged during a transition.

  • They don't overlap.
  • The DELAY is unique and must be a contiguous period of time right before the next visit (or vehicle end). Thus, it suffice to know the delay duration to know its start and end time.
  • The BREAKS are contiguous, non-overlapping periods of time. The response specifies the start time and duration of each break.
  • TRAVEL and WAIT are "preemptable": they can be interrupted several times during this transition. Clients can assume that travel happens "as soon as possible" and that "wait" fills the remaining time.

A (complex) example:

::

                              TRANSITION[i]

--++-----+-----------------------------------------------------------++--> || | | | | | | || || T | B | T | | B | | D || || r | r | r | W | r | W | e || || a | e | a | a | e | a | l || || v | a | v | i | a | i | a || || e | k | e | t | k | t | y || || l | | l | | | | || || | | | | | | || --++-----------------------------------------------------------------++-->

Attributes

Name Description
vehicle_index int
Vehicle performing the route, identified by its index in the source ShipmentModel.
vehicle_label str
Label of the vehicle performing this route, equal to ShipmentModel.vehicles(vehicle_index).label, if specified.
vehicle_start_time google.protobuf.timestamp_pb2.Timestamp
Time at which the vehicle starts its route.
vehicle_end_time google.protobuf.timestamp_pb2.Timestamp
Time at which the vehicle finishes its route.
visits MutableSequence[google.cloud.optimization_v1.types.ShipmentRoute.Visit]
Ordered sequence of visits representing a route. visits[i] is the i-th visit in the route. If this field is empty, the vehicle is considered as unused.
transitions MutableSequence[google.cloud.optimization_v1.types.ShipmentRoute.Transition]
Ordered list of transitions for the route.
has_traffic_infeasibilities bool
When OptimizeToursRequest.consider_road_traffic, is set to true, this field indicates that inconsistencies in route timings are predicted using traffic-based travel duration estimates. There may be insufficient time to complete traffic-adjusted travel, delays, and breaks between visits, before the first visit, or after the last visit, while still satisfying the visit and vehicle time windows. For example, :: start_time(previous_visit) + duration(previous_visit) + travel_duration(previous_visit, next_visit) > start_time(next_visit) Arrival at next_visit will likely happen later than its current time window due the increased estimate of travel time travel_duration(previous_visit, next_visit) due to traffic. Also, a break may be forced to overlap with a visit due to an increase in travel time estimates and visit or break time window restrictions.
route_polyline google.cloud.optimization_v1.types.ShipmentRoute.EncodedPolyline
The encoded polyline representation of the route. This field is only populated if OptimizeToursRequest.populate_polylines is set to true.
breaks MutableSequence[google.cloud.optimization_v1.types.ShipmentRoute.Break]
Breaks scheduled for the vehicle performing this route. The breaks sequence represents time intervals, each starting at the corresponding start_time and lasting duration seconds.
metrics google.cloud.optimization_v1.types.AggregatedMetrics
Duration, distance and load metrics for this route. The fields of AggregatedMetrics are summed over all ShipmentRoute.transitions or ShipmentRoute.visits, depending on the context.
route_costs MutableMapping[str, float]
Cost of the route, broken down by cost-related request fields. The keys are proto paths, relative to the input OptimizeToursRequest, e.g. "model.shipments.pickups.cost", and the values are the total cost generated by the corresponding cost field, aggregated over the whole route. In other words, costs["model.shipments.pickups.cost"] is the sum of all pickup costs over the route. All costs defined in the model are reported in detail here with the exception of costs related to TransitionAttributes that are only reported in an aggregated way as of 2022/01.
route_total_cost float
Total cost of the route. The sum of all costs in the cost map.
end_loads MutableSequence[google.cloud.optimization_v1.types.CapacityQuantity]
Deprecated: Use Transition.vehicle_loads instead. Vehicle loads upon arrival at its end location, for each type specified in Vehicle.capacities, start_load_intervals, end_load_intervals or demands. Exception: we omit loads for quantity types unconstrained by intervals and that don't have any non-zero demand on the route.
travel_steps MutableSequence[google.cloud.optimization_v1.types.ShipmentRoute.TravelStep]
Deprecated: Use ShipmentRoute.transitions instead. Ordered list of travel steps for the route.
vehicle_detour google.protobuf.duration_pb2.Duration
Deprecated: No longer used. This field will only be populated at the ShipmentRoute.Visit level. This field is the extra detour time due to the shipments visited on the route. It is equal to vehicle_end_time - vehicle_start_time - travel duration from the vehicle's start_location to its end_location.
delay_before_vehicle_end google.cloud.optimization_v1.types.ShipmentRoute.Delay
Deprecated: Delay occurring before the vehicle end. See TransitionAttributes.delay.

Classes

Break

Break(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Data representing the execution of a break.

Delay

Delay(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Deprecated: Use ShipmentRoute.Transition.delay_duration instead. Time interval spent on the route resulting from a TransitionAttributes.delay.

EncodedPolyline

EncodedPolyline(mapping=None, *, ignore_unknown_fields=False, **kwargs)

RouteCostsEntry

RouteCostsEntry(mapping=None, *, ignore_unknown_fields=False, **kwargs)

The abstract base class for a message.

Parameters
Name Description
kwargs dict

Keys and values corresponding to the fields of the message.

mapping Union[dict, .Message]

A dictionary or message to be used to determine the values for this message.

ignore_unknown_fields Optional(bool)

If True, do not raise errors for unknown fields. Only applied if mapping is a mapping type or there are keyword parameters.

Transition

Transition(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Transition between two events on the route. See the description of ShipmentRoute.

If the vehicle does not have a start_location and/or end_location, the corresponding travel metrics are 0.

TravelStep

TravelStep(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Deprecated: Use ShipmentRoute.Transition instead. Travel between each visit along the route: from the vehicle's start_location to the first visit's arrival_location, then from the first visit's departure_location to the second visit's arrival_location, and so on until the vehicle's end_location. This accounts only for the actual travel between visits, not counting the waiting time, the time spent performing a visit, nor the distance covered during a visit.

Invariant: travel_steps_size() == visits_size() + 1.

If the vehicle does not have a start_ and/or end_location, the corresponding travel metrics are 0 and/or empty.

VehicleLoad

VehicleLoad(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Reports the actual load of the vehicle at some point along the route, for a given type (see Transition.vehicle_loads).

Visit

Visit(mapping=None, *, ignore_unknown_fields=False, **kwargs)

A visit performed during a route. This visit corresponds to a pickup or a delivery of a Shipment.