#[non_exhaustive]pub struct ShipmentRoute {Show 13 fields
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 vehicle_fullness: Option<VehicleFullness>,
pub route_costs: HashMap<String, f64>,
pub route_total_cost: f64,
/* private fields */
}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 endNote 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].endLastly, 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 (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.vehicle_index: i32Vehicle performing the route, identified by its index in the source
ShipmentModel.
vehicle_label: StringLabel 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: boolWhen 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 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 are summed over all ShipmentRoute.transitions or ShipmentRoute.visits, depending on the context.
vehicle_fullness: Option<VehicleFullness>VehicleFullness field for computing how close the capped metrics are to their respective vehicle limits. Its fields are ratios between a capped metric field (e.g. AggregatedMetrics.travel_distance_meters) and the related vehicle limit (e.g. Vehicle.route_distance_limit).
Experimental: This field’s behavior or existence may change in future.
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: f64Total cost of the route. The sum of all costs in the cost map.
Implementations§
Source§impl ShipmentRoute
impl ShipmentRoute
Sourcepub fn set_vehicle_index<T: Into<i32>>(self, v: T) -> Self
pub fn set_vehicle_index<T: Into<i32>>(self, v: T) -> Self
Sourcepub fn set_vehicle_label<T: Into<String>>(self, v: T) -> Self
pub fn set_vehicle_label<T: Into<String>>(self, v: T) -> Self
Sets the value of vehicle_label.
§Example
let x = ShipmentRoute::new().set_vehicle_label("example");Sourcepub fn set_vehicle_start_time<T>(self, v: T) -> Self
pub fn set_vehicle_start_time<T>(self, v: T) -> Self
Sets the value of vehicle_start_time.
§Example
use wkt::Timestamp;
let x = ShipmentRoute::new().set_vehicle_start_time(Timestamp::default()/* use setters */);Sourcepub fn set_or_clear_vehicle_start_time<T>(self, v: Option<T>) -> Self
pub fn set_or_clear_vehicle_start_time<T>(self, v: Option<T>) -> Self
Sets or clears the value of vehicle_start_time.
§Example
use wkt::Timestamp;
let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(Some(Timestamp::default()/* use setters */));
let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(None::<Timestamp>);Sourcepub fn set_vehicle_end_time<T>(self, v: T) -> Self
pub fn set_vehicle_end_time<T>(self, v: T) -> Self
Sets the value of vehicle_end_time.
§Example
use wkt::Timestamp;
let x = ShipmentRoute::new().set_vehicle_end_time(Timestamp::default()/* use setters */);Sourcepub fn set_or_clear_vehicle_end_time<T>(self, v: Option<T>) -> Self
pub fn set_or_clear_vehicle_end_time<T>(self, v: Option<T>) -> Self
Sets or clears the value of vehicle_end_time.
§Example
use wkt::Timestamp;
let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(Some(Timestamp::default()/* use setters */));
let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(None::<Timestamp>);Sourcepub fn set_visits<T, V>(self, v: T) -> Self
pub fn set_visits<T, V>(self, v: T) -> Self
Sourcepub fn set_transitions<T, V>(self, v: T) -> Self
pub fn set_transitions<T, V>(self, v: T) -> Self
Sets the value of transitions.
§Example
use google_maps_routeoptimization_v1::model::shipment_route::Transition;
let x = ShipmentRoute::new()
.set_transitions([
Transition::default()/* use setters */,
Transition::default()/* use (different) setters */,
]);Sourcepub fn set_has_traffic_infeasibilities<T: Into<bool>>(self, v: T) -> Self
pub fn set_has_traffic_infeasibilities<T: Into<bool>>(self, v: T) -> Self
Sets the value of has_traffic_infeasibilities.
§Example
let x = ShipmentRoute::new().set_has_traffic_infeasibilities(true);Sourcepub fn set_route_polyline<T>(self, v: T) -> Selfwhere
T: Into<EncodedPolyline>,
pub fn set_route_polyline<T>(self, v: T) -> Selfwhere
T: Into<EncodedPolyline>,
Sets the value of route_polyline.
§Example
use google_maps_routeoptimization_v1::model::shipment_route::EncodedPolyline;
let x = ShipmentRoute::new().set_route_polyline(EncodedPolyline::default()/* use setters */);Sourcepub fn set_or_clear_route_polyline<T>(self, v: Option<T>) -> Selfwhere
T: Into<EncodedPolyline>,
pub fn set_or_clear_route_polyline<T>(self, v: Option<T>) -> Selfwhere
T: Into<EncodedPolyline>,
Sets or clears the value of route_polyline.
§Example
use google_maps_routeoptimization_v1::model::shipment_route::EncodedPolyline;
let x = ShipmentRoute::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
let x = ShipmentRoute::new().set_or_clear_route_polyline(None::<EncodedPolyline>);Sourcepub fn set_breaks<T, V>(self, v: T) -> Self
pub fn set_breaks<T, V>(self, v: T) -> Self
Sourcepub fn set_metrics<T>(self, v: T) -> Selfwhere
T: Into<AggregatedMetrics>,
pub fn set_metrics<T>(self, v: T) -> Selfwhere
T: Into<AggregatedMetrics>,
Sourcepub fn set_or_clear_metrics<T>(self, v: Option<T>) -> Selfwhere
T: Into<AggregatedMetrics>,
pub fn set_or_clear_metrics<T>(self, v: Option<T>) -> Selfwhere
T: Into<AggregatedMetrics>,
Sourcepub fn set_vehicle_fullness<T>(self, v: T) -> Selfwhere
T: Into<VehicleFullness>,
pub fn set_vehicle_fullness<T>(self, v: T) -> Selfwhere
T: Into<VehicleFullness>,
Sets the value of vehicle_fullness.
§Example
use google_maps_routeoptimization_v1::model::VehicleFullness;
let x = ShipmentRoute::new().set_vehicle_fullness(VehicleFullness::default()/* use setters */);Sourcepub fn set_or_clear_vehicle_fullness<T>(self, v: Option<T>) -> Selfwhere
T: Into<VehicleFullness>,
pub fn set_or_clear_vehicle_fullness<T>(self, v: Option<T>) -> Selfwhere
T: Into<VehicleFullness>,
Sets or clears the value of vehicle_fullness.
§Example
use google_maps_routeoptimization_v1::model::VehicleFullness;
let x = ShipmentRoute::new().set_or_clear_vehicle_fullness(Some(VehicleFullness::default()/* use setters */));
let x = ShipmentRoute::new().set_or_clear_vehicle_fullness(None::<VehicleFullness>);Sourcepub fn set_route_costs<T, K, V>(self, v: T) -> Self
pub fn set_route_costs<T, K, V>(self, v: T) -> Self
Sets the value of route_costs.
§Example
let x = ShipmentRoute::new().set_route_costs([
("key0", 123.5),
("key1", 456.5),
]);Sourcepub fn set_route_total_cost<T: Into<f64>>(self, v: T) -> Self
pub fn set_route_total_cost<T: Into<f64>>(self, v: T) -> Self
Sets the value of route_total_cost.
§Example
let x = ShipmentRoute::new().set_route_total_cost(42.0);Trait Implementations§
Source§impl Clone for ShipmentRoute
impl Clone for ShipmentRoute
Source§fn clone(&self) -> ShipmentRoute
fn clone(&self) -> ShipmentRoute
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ShipmentRoute
impl Debug for ShipmentRoute
Source§impl Default for ShipmentRoute
impl Default for ShipmentRoute
Source§fn default() -> ShipmentRoute
fn default() -> ShipmentRoute
Source§impl Message for ShipmentRoute
impl Message for ShipmentRoute
Source§impl PartialEq for ShipmentRoute
impl PartialEq for ShipmentRoute
impl StructuralPartialEq for ShipmentRoute
Auto Trait Implementations§
impl Freeze for ShipmentRoute
impl RefUnwindSafe for ShipmentRoute
impl Send for ShipmentRoute
impl Sync for ShipmentRoute
impl Unpin for ShipmentRoute
impl UnsafeUnpin for ShipmentRoute
impl UnwindSafe for ShipmentRoute
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request