pub struct ShipmentRoute {
    pub vehicle_index: i32,
    pub vehicle_label: String,
    pub vehicle_start_time: Option<Timestamp>,
    pub vehicle_end_time: Option<Timestamp>,
    pub visits: Vec<Visit>,
    pub transitions: Vec<Transition>,
    pub has_traffic_infeasibilities: bool,
    pub route_polyline: Option<EncodedPolyline>,
    pub breaks: Vec<Break>,
    pub metrics: Option<AggregatedMetrics>,
    pub route_costs: HashMap<String, f64>,
    pub route_total_cost: f64,
}
Expand description

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     |       |           |         |         ||
   ||     |       |           |       |           |         |         ||
--++-----------------------------------------------------------------++-->

Fields§

§vehicle_index: i32

Vehicle performing the route, identified by its index in the source ShipmentModel.

§vehicle_label: String

Label of the vehicle performing this route, equal to ShipmentModel.vehicles(vehicle_index).label, if specified.

§vehicle_start_time: Option<Timestamp>

Time at which the vehicle starts its route.

§vehicle_end_time: Option<Timestamp>

Time at which the vehicle finishes its route.

§visits: Vec<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: Vec<Transition>

Ordered list of transitions for the route.

§has_traffic_infeasibilities: bool

When [OptimizeToursRequest.consider_road_traffic][google.maps.routeoptimization.v1.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: Option<EncodedPolyline>

The encoded polyline representation of the route. This field is only populated if [OptimizeToursRequest.populate_polylines][google.maps.routeoptimization.v1.OptimizeToursRequest.populate_polylines] is set to true.

§breaks: Vec<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: Option<AggregatedMetrics>

Duration, distance and load metrics for this route. The fields of [AggregatedMetrics][google.maps.routeoptimization.v1.AggregatedMetrics] are summed over all [ShipmentRoute.transitions][google.maps.routeoptimization.v1.ShipmentRoute.transitions] or [ShipmentRoute.visits][google.maps.routeoptimization.v1.ShipmentRoute.visits], depending on the context.

§route_costs: HashMap<String, f64>

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: f64

Total cost of the route. The sum of all costs in the cost map.

Trait Implementations§

Source§

impl Clone for ShipmentRoute

Source§

fn clone(&self) -> ShipmentRoute

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ShipmentRoute

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ShipmentRoute

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Message for ShipmentRoute

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited( &self, buf: &mut impl BufMut, ) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl PartialEq for ShipmentRoute

Source§

fn eq(&self, other: &ShipmentRoute) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ShipmentRoute

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more