google_cloud_optimization_v1/
model.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gax;
23extern crate gaxi;
24extern crate gtype;
25extern crate lazy_static;
26extern crate longrunning;
27extern crate lro;
28extern crate reqwest;
29extern crate serde;
30extern crate serde_json;
31extern crate serde_with;
32extern crate std;
33extern crate tracing;
34extern crate wkt;
35
36/// The desired input location information.
37#[serde_with::serde_as]
38#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
39#[serde(default, rename_all = "camelCase")]
40#[non_exhaustive]
41pub struct InputConfig {
42    /// The input data format that used to store the model in Cloud Storage.
43    pub data_format: crate::model::DataFormat,
44
45    /// The location of the input model in cloud storage.
46    /// Required.
47    #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")]
48    pub source: std::option::Option<crate::model::input_config::Source>,
49
50    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
51    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
52}
53
54impl InputConfig {
55    pub fn new() -> Self {
56        std::default::Default::default()
57    }
58
59    /// Sets the value of [data_format][crate::model::InputConfig::data_format].
60    pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
61        mut self,
62        v: T,
63    ) -> Self {
64        self.data_format = v.into();
65        self
66    }
67
68    /// Sets the value of [source][crate::model::InputConfig::source].
69    ///
70    /// Note that all the setters affecting `source` are mutually
71    /// exclusive.
72    pub fn set_source<
73        T: std::convert::Into<std::option::Option<crate::model::input_config::Source>>,
74    >(
75        mut self,
76        v: T,
77    ) -> Self {
78        self.source = v.into();
79        self
80    }
81
82    /// The value of [source][crate::model::InputConfig::source]
83    /// if it holds a `GcsSource`, `None` if the field is not set or
84    /// holds a different branch.
85    pub fn gcs_source(&self) -> std::option::Option<&std::boxed::Box<crate::model::GcsSource>> {
86        #[allow(unreachable_patterns)]
87        self.source.as_ref().and_then(|v| match v {
88            crate::model::input_config::Source::GcsSource(v) => std::option::Option::Some(v),
89            _ => std::option::Option::None,
90        })
91    }
92
93    /// Sets the value of [source][crate::model::InputConfig::source]
94    /// to hold a `GcsSource`.
95    ///
96    /// Note that all the setters affecting `source` are
97    /// mutually exclusive.
98    pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
99        mut self,
100        v: T,
101    ) -> Self {
102        self.source =
103            std::option::Option::Some(crate::model::input_config::Source::GcsSource(v.into()));
104        self
105    }
106}
107
108impl wkt::message::Message for InputConfig {
109    fn typename() -> &'static str {
110        "type.googleapis.com/google.cloud.optimization.v1.InputConfig"
111    }
112}
113
114/// Defines additional types related to [InputConfig].
115pub mod input_config {
116    #[allow(unused_imports)]
117    use super::*;
118
119    /// The location of the input model in cloud storage.
120    /// Required.
121    #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
122    #[serde(rename_all = "camelCase")]
123    #[non_exhaustive]
124    pub enum Source {
125        /// The Google Cloud Storage location to read the input from. This must be a
126        /// single file.
127        GcsSource(std::boxed::Box<crate::model::GcsSource>),
128    }
129}
130
131/// The desired output location.
132#[serde_with::serde_as]
133#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
134#[serde(default, rename_all = "camelCase")]
135#[non_exhaustive]
136pub struct OutputConfig {
137    /// The output data format that used to store the results in Cloud Storage.
138    pub data_format: crate::model::DataFormat,
139
140    /// The location of the output result in cloud storage.
141    /// Required.
142    #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")]
143    pub destination: std::option::Option<crate::model::output_config::Destination>,
144
145    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
146    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
147}
148
149impl OutputConfig {
150    pub fn new() -> Self {
151        std::default::Default::default()
152    }
153
154    /// Sets the value of [data_format][crate::model::OutputConfig::data_format].
155    pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
156        mut self,
157        v: T,
158    ) -> Self {
159        self.data_format = v.into();
160        self
161    }
162
163    /// Sets the value of [destination][crate::model::OutputConfig::destination].
164    ///
165    /// Note that all the setters affecting `destination` are mutually
166    /// exclusive.
167    pub fn set_destination<
168        T: std::convert::Into<std::option::Option<crate::model::output_config::Destination>>,
169    >(
170        mut self,
171        v: T,
172    ) -> Self {
173        self.destination = v.into();
174        self
175    }
176
177    /// The value of [destination][crate::model::OutputConfig::destination]
178    /// if it holds a `GcsDestination`, `None` if the field is not set or
179    /// holds a different branch.
180    pub fn gcs_destination(
181        &self,
182    ) -> std::option::Option<&std::boxed::Box<crate::model::GcsDestination>> {
183        #[allow(unreachable_patterns)]
184        self.destination.as_ref().and_then(|v| match v {
185            crate::model::output_config::Destination::GcsDestination(v) => {
186                std::option::Option::Some(v)
187            }
188            _ => std::option::Option::None,
189        })
190    }
191
192    /// Sets the value of [destination][crate::model::OutputConfig::destination]
193    /// to hold a `GcsDestination`.
194    ///
195    /// Note that all the setters affecting `destination` are
196    /// mutually exclusive.
197    pub fn set_gcs_destination<
198        T: std::convert::Into<std::boxed::Box<crate::model::GcsDestination>>,
199    >(
200        mut self,
201        v: T,
202    ) -> Self {
203        self.destination = std::option::Option::Some(
204            crate::model::output_config::Destination::GcsDestination(v.into()),
205        );
206        self
207    }
208}
209
210impl wkt::message::Message for OutputConfig {
211    fn typename() -> &'static str {
212        "type.googleapis.com/google.cloud.optimization.v1.OutputConfig"
213    }
214}
215
216/// Defines additional types related to [OutputConfig].
217pub mod output_config {
218    #[allow(unused_imports)]
219    use super::*;
220
221    /// The location of the output result in cloud storage.
222    /// Required.
223    #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
224    #[serde(rename_all = "camelCase")]
225    #[non_exhaustive]
226    pub enum Destination {
227        /// The Google Cloud Storage location to write the output to.
228        GcsDestination(std::boxed::Box<crate::model::GcsDestination>),
229    }
230}
231
232/// The Google Cloud Storage location where the input file will be read from.
233#[serde_with::serde_as]
234#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
235#[serde(default, rename_all = "camelCase")]
236#[non_exhaustive]
237pub struct GcsSource {
238    /// Required. URI of the Google Cloud Storage location.
239    #[serde(skip_serializing_if = "std::string::String::is_empty")]
240    pub uri: std::string::String,
241
242    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
243    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
244}
245
246impl GcsSource {
247    pub fn new() -> Self {
248        std::default::Default::default()
249    }
250
251    /// Sets the value of [uri][crate::model::GcsSource::uri].
252    pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
253        self.uri = v.into();
254        self
255    }
256}
257
258impl wkt::message::Message for GcsSource {
259    fn typename() -> &'static str {
260        "type.googleapis.com/google.cloud.optimization.v1.GcsSource"
261    }
262}
263
264/// The Google Cloud Storage location where the output file will be written to.
265#[serde_with::serde_as]
266#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
267#[serde(default, rename_all = "camelCase")]
268#[non_exhaustive]
269pub struct GcsDestination {
270    /// Required. URI of the Google Cloud Storage location.
271    #[serde(skip_serializing_if = "std::string::String::is_empty")]
272    pub uri: std::string::String,
273
274    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
275    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
276}
277
278impl GcsDestination {
279    pub fn new() -> Self {
280        std::default::Default::default()
281    }
282
283    /// Sets the value of [uri][crate::model::GcsDestination::uri].
284    pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
285        self.uri = v.into();
286        self
287    }
288}
289
290impl wkt::message::Message for GcsDestination {
291    fn typename() -> &'static str {
292        "type.googleapis.com/google.cloud.optimization.v1.GcsDestination"
293    }
294}
295
296/// The long running operation metadata for async model related methods.
297#[serde_with::serde_as]
298#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
299#[serde(default, rename_all = "camelCase")]
300#[non_exhaustive]
301pub struct AsyncModelMetadata {
302    /// The state of the current operation.
303    pub state: crate::model::async_model_metadata::State,
304
305    /// A message providing more details about the current state of the operation.
306    /// For example, the error message if the operation is failed.
307    #[serde(skip_serializing_if = "std::string::String::is_empty")]
308    pub state_message: std::string::String,
309
310    /// The creation time of the operation.
311    #[serde(skip_serializing_if = "std::option::Option::is_none")]
312    pub create_time: std::option::Option<wkt::Timestamp>,
313
314    /// The last update time of the operation.
315    #[serde(skip_serializing_if = "std::option::Option::is_none")]
316    pub update_time: std::option::Option<wkt::Timestamp>,
317
318    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
319    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
320}
321
322impl AsyncModelMetadata {
323    pub fn new() -> Self {
324        std::default::Default::default()
325    }
326
327    /// Sets the value of [state][crate::model::AsyncModelMetadata::state].
328    pub fn set_state<T: std::convert::Into<crate::model::async_model_metadata::State>>(
329        mut self,
330        v: T,
331    ) -> Self {
332        self.state = v.into();
333        self
334    }
335
336    /// Sets the value of [state_message][crate::model::AsyncModelMetadata::state_message].
337    pub fn set_state_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
338        self.state_message = v.into();
339        self
340    }
341
342    /// Sets the value of [create_time][crate::model::AsyncModelMetadata::create_time].
343    pub fn set_create_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
344        mut self,
345        v: T,
346    ) -> Self {
347        self.create_time = v.into();
348        self
349    }
350
351    /// Sets the value of [update_time][crate::model::AsyncModelMetadata::update_time].
352    pub fn set_update_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
353        mut self,
354        v: T,
355    ) -> Self {
356        self.update_time = v.into();
357        self
358    }
359}
360
361impl wkt::message::Message for AsyncModelMetadata {
362    fn typename() -> &'static str {
363        "type.googleapis.com/google.cloud.optimization.v1.AsyncModelMetadata"
364    }
365}
366
367/// Defines additional types related to [AsyncModelMetadata].
368pub mod async_model_metadata {
369    #[allow(unused_imports)]
370    use super::*;
371
372    /// Possible states of the operation.
373    #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
374    pub struct State(i32);
375
376    impl State {
377        /// The default value. This value is used if the state is omitted.
378        pub const STATE_UNSPECIFIED: State = State::new(0);
379
380        /// Request is being processed.
381        pub const RUNNING: State = State::new(1);
382
383        /// The operation completed successfully.
384        pub const SUCCEEDED: State = State::new(2);
385
386        /// The operation was cancelled.
387        pub const CANCELLED: State = State::new(3);
388
389        /// The operation has failed.
390        pub const FAILED: State = State::new(4);
391
392        /// Creates a new State instance.
393        pub(crate) const fn new(value: i32) -> Self {
394            Self(value)
395        }
396
397        /// Gets the enum value.
398        pub fn value(&self) -> i32 {
399            self.0
400        }
401
402        /// Gets the enum value as a string.
403        pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
404            match self.0 {
405                0 => std::borrow::Cow::Borrowed("STATE_UNSPECIFIED"),
406                1 => std::borrow::Cow::Borrowed("RUNNING"),
407                2 => std::borrow::Cow::Borrowed("SUCCEEDED"),
408                3 => std::borrow::Cow::Borrowed("CANCELLED"),
409                4 => std::borrow::Cow::Borrowed("FAILED"),
410                _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
411            }
412        }
413
414        /// Creates an enum value from the value name.
415        pub fn from_str_name(name: &str) -> std::option::Option<Self> {
416            match name {
417                "STATE_UNSPECIFIED" => std::option::Option::Some(Self::STATE_UNSPECIFIED),
418                "RUNNING" => std::option::Option::Some(Self::RUNNING),
419                "SUCCEEDED" => std::option::Option::Some(Self::SUCCEEDED),
420                "CANCELLED" => std::option::Option::Some(Self::CANCELLED),
421                "FAILED" => std::option::Option::Some(Self::FAILED),
422                _ => std::option::Option::None,
423            }
424        }
425    }
426
427    impl std::convert::From<i32> for State {
428        fn from(value: i32) -> Self {
429            Self::new(value)
430        }
431    }
432
433    impl std::default::Default for State {
434        fn default() -> Self {
435            Self::new(0)
436        }
437    }
438}
439
440/// Request to be given to a tour optimization solver which defines the
441/// shipment model to solve as well as optimization parameters.
442#[serde_with::serde_as]
443#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
444#[serde(default, rename_all = "camelCase")]
445#[non_exhaustive]
446pub struct OptimizeToursRequest {
447    /// Required. Target project and location to make a call.
448    ///
449    /// Format: `projects/{project-id}/locations/{location-id}`.
450    ///
451    /// If no location is specified, a region will be chosen automatically.
452    #[serde(skip_serializing_if = "std::string::String::is_empty")]
453    pub parent: std::string::String,
454
455    /// If this timeout is set, the server returns a response before the timeout
456    /// period has elapsed or the server deadline for synchronous requests is
457    /// reached, whichever is sooner.
458    ///
459    /// For asynchronous requests, the server will generate a solution (if
460    /// possible) before the timeout has elapsed.
461    #[serde(skip_serializing_if = "std::option::Option::is_none")]
462    pub timeout: std::option::Option<wkt::Duration>,
463
464    /// Shipment model to solve.
465    #[serde(skip_serializing_if = "std::option::Option::is_none")]
466    pub model: std::option::Option<crate::model::ShipmentModel>,
467
468    /// By default, the solving mode is `DEFAULT_SOLVE` (0).
469    pub solving_mode: crate::model::optimize_tours_request::SolvingMode,
470
471    /// Search mode used to solve the request.
472    pub search_mode: crate::model::optimize_tours_request::SearchMode,
473
474    /// Guide the optimization algorithm in finding a first solution that is
475    /// similar to a previous solution.
476    ///
477    /// The model is constrained when the first solution is built.
478    /// Any shipments not performed on a route are implicitly skipped in the first
479    /// solution, but they may be performed in successive solutions.
480    ///
481    /// The solution must satisfy some basic validity assumptions:
482    ///
483    /// * for all routes, `vehicle_index` must be in range and not be duplicated.
484    /// * for all visits, `shipment_index` and `visit_request_index` must be
485    ///   in range.
486    /// * a shipment may only be referenced on one route.
487    /// * the pickup of a pickup-delivery shipment must be performed before
488    ///   the delivery.
489    /// * no more than one pickup alternative or delivery alternative of
490    ///   a shipment may be performed.
491    /// * for all routes, times are increasing (i.e., `vehicle_start_time
492    ///   <= visits[0].start_time <= visits[1].start_time ...
493    ///   <= vehicle_end_time`).
494    /// * a shipment may only be performed on a vehicle that is allowed. A
495    ///   vehicle is allowed if
496    ///   [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]
497    ///   is empty or its `vehicle_index` is included in
498    ///   [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices].
499    ///
500    /// If the injected solution is not feasible, a validation error is not
501    /// necessarily returned and an error indicating infeasibility may be returned
502    /// instead.
503    ///
504    /// [google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]: crate::model::Shipment::allowed_vehicle_indices
505    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
506    pub injected_first_solution_routes: std::vec::Vec<crate::model::ShipmentRoute>,
507
508    /// Constrain the optimization algorithm to find a final solution that is
509    /// similar to a previous solution. For example, this may be used to freeze
510    /// portions of routes which have already been completed or which are to be
511    /// completed but must not be modified.
512    ///
513    /// If the injected solution is not feasible, a validation error is not
514    /// necessarily returned and an error indicating infeasibility may be returned
515    /// instead.
516    #[serde(skip_serializing_if = "std::option::Option::is_none")]
517    pub injected_solution_constraint: std::option::Option<crate::model::InjectedSolutionConstraint>,
518
519    /// If non-empty, the given routes will be refreshed, without modifying their
520    /// underlying sequence of visits or travel times: only other details will be
521    /// updated. This does not solve the model.
522    ///
523    /// As of 2020/11, this only populates the polylines of non-empty routes and
524    /// requires that `populate_polylines` is true.
525    ///
526    /// The `route_polyline` fields of the passed-in routes may be inconsistent
527    /// with route `transitions`.
528    ///
529    /// This field must not be used together with `injected_first_solution_routes`
530    /// or `injected_solution_constraint`.
531    ///
532    /// `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
533    /// Polylines are still populated between all visits in all non-empty routes
534    /// regardless of whether the related shipments or vehicles are ignored.
535    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
536    pub refresh_details_routes: std::vec::Vec<crate::model::ShipmentRoute>,
537
538    /// If true:
539    ///
540    /// * uses
541    ///   [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label]
542    ///   instead of `vehicle_index` to
543    ///   match routes in an injected solution with vehicles in the request;
544    ///   reuses the mapping of original
545    ///   [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
546    ///   to new
547    ///   [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
548    ///   to update
549    ///   [ConstraintRelaxation.vehicle_indices][google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]
550    ///   if non-empty, but the mapping must be unambiguous (i.e., multiple
551    ///   `ShipmentRoute`s must not share the same original `vehicle_index`).
552    /// * uses
553    ///   [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]
554    ///   instead of `shipment_index`
555    ///   to match visits in an injected solution with shipments in the request;
556    /// * uses
557    ///   [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
558    ///   instead of
559    ///   [SkippedShipment.index][google.cloud.optimization.v1.SkippedShipment.index]
560    ///   to
561    ///   match skipped shipments in the injected solution with request
562    ///   shipments.
563    ///
564    /// This interpretation applies to the `injected_first_solution_routes`,
565    /// `injected_solution_constraint`, and `refresh_details_routes` fields.
566    /// It can be used when shipment or vehicle indices in the request have
567    /// changed since the solution was created, perhaps because shipments or
568    /// vehicles have been removed from or added to the request.
569    ///
570    /// If true, labels in the following categories must appear at most once in
571    /// their category:
572    ///
573    /// * [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] in the
574    ///   request;
575    /// * [Shipment.label][google.cloud.optimization.v1.Shipment.label] in the
576    ///   request;
577    /// * [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label] in the injected solution;
578    /// * [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] and [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label] in
579    ///   the injected solution (except pickup/delivery visit pairs, whose
580    ///   `shipment_label` must appear twice).
581    ///
582    /// If a `vehicle_label` in the injected solution does not correspond to a
583    /// request vehicle, the corresponding route is removed from the solution
584    /// along with its visits. If a `shipment_label` in the injected solution does
585    /// not correspond to a request shipment, the corresponding visit is removed
586    /// from the solution. If a
587    /// [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
588    /// in the injected solution does not correspond to a request shipment, the
589    /// `SkippedShipment` is removed from the solution.
590    ///
591    /// Removing route visits or entire routes from an injected solution may
592    /// have an effect on the implied constraints, which may lead to change in
593    /// solution, validation errors, or infeasibility.
594    ///
595    /// NOTE: The caller must ensure that each
596    /// [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] (resp.
597    /// [Shipment.label][google.cloud.optimization.v1.Shipment.label]) uniquely
598    /// identifies a vehicle (resp. shipment) entity used across the two relevant
599    /// requests: the past request that produced the `OptimizeToursResponse` used
600    /// in the injected solution and the current request that includes the injected
601    /// solution. The uniqueness checks described above are not enough to guarantee
602    /// this requirement.
603    ///
604    /// [google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]: crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices
605    /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
606    /// [google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]: crate::model::shipment_route::Visit::shipment_label
607    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
608    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_label]: crate::model::ShipmentRoute::vehicle_label
609    /// [google.cloud.optimization.v1.SkippedShipment.index]: crate::model::SkippedShipment::index
610    /// [google.cloud.optimization.v1.SkippedShipment.label]: crate::model::SkippedShipment::label
611    /// [google.cloud.optimization.v1.Vehicle.label]: crate::model::Vehicle::label
612    pub interpret_injected_solutions_using_labels: bool,
613
614    /// Consider traffic estimation in calculating `ShipmentRoute` fields
615    /// [Transition.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration],
616    /// [Visit.start_time][google.cloud.optimization.v1.ShipmentRoute.Visit.start_time],
617    /// and `vehicle_end_time`; in setting the
618    /// [ShipmentRoute.has_traffic_infeasibilities][google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]
619    /// field, and in calculating the
620    /// [OptimizeToursResponse.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.total_cost]
621    /// field.
622    ///
623    /// [google.cloud.optimization.v1.OptimizeToursResponse.total_cost]: crate::model::OptimizeToursResponse::total_cost
624    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
625    /// [google.cloud.optimization.v1.ShipmentRoute.Visit.start_time]: crate::model::shipment_route::Visit::start_time
626    /// [google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]: crate::model::ShipmentRoute::has_traffic_infeasibilities
627    pub consider_road_traffic: bool,
628
629    /// If true, polylines will be populated in response `ShipmentRoute`s.
630    pub populate_polylines: bool,
631
632    /// If true, polylines will be populated in response
633    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
634    /// Note that in this case, the polylines will also be populated in the
635    /// deprecated `travel_steps`.
636    ///
637    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
638    pub populate_transition_polylines: bool,
639
640    /// If this is set, then the request can have a deadline
641    /// (see <https://grpc.io/blog/deadlines>) of up to 60 minutes.
642    /// Otherwise, the maximum deadline is only 30 minutes.
643    /// Note that long-lived requests have a significantly larger (but still small)
644    /// risk of interruption.
645    pub allow_large_deadline_despite_interruption_risk: bool,
646
647    /// If true, travel distances will be computed using geodesic distances instead
648    /// of Google Maps distances, and travel times will be computed using geodesic
649    /// distances with a speed defined by `geodesic_meters_per_second`.
650    pub use_geodesic_distances: bool,
651
652    /// When `use_geodesic_distances` is true, this field must be set and defines
653    /// the speed applied to compute travel times. Its value must be at least 1.0
654    /// meters/seconds.
655    #[serde(skip_serializing_if = "std::option::Option::is_none")]
656    pub geodesic_meters_per_second: std::option::Option<f64>,
657
658    /// Truncates the number of validation errors returned. These errors are
659    /// typically attached to an INVALID_ARGUMENT error payload as a BadRequest
660    /// error detail (<https://cloud.google.com/apis/design/errors#error_details>),
661    /// unless solving_mode=VALIDATE_ONLY: see the
662    /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
663    /// field.
664    /// This defaults to 100 and is capped at 10,000.
665    ///
666    /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
667    #[serde(skip_serializing_if = "std::option::Option::is_none")]
668    pub max_validation_errors: std::option::Option<i32>,
669
670    /// Label that may be used to identify this request, reported back in the
671    /// [OptimizeToursResponse.request_label][google.cloud.optimization.v1.OptimizeToursResponse.request_label].
672    ///
673    /// [google.cloud.optimization.v1.OptimizeToursResponse.request_label]: crate::model::OptimizeToursResponse::request_label
674    #[serde(skip_serializing_if = "std::string::String::is_empty")]
675    pub label: std::string::String,
676
677    /// Deprecated: Use
678    /// [OptimizeToursRequest.populate_transition_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
679    /// instead. If true, polylines will be populated in response
680    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
681    /// Note that in this case, the polylines will also be populated in the
682    /// deprecated `travel_steps`.
683    ///
684    /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]: crate::model::OptimizeToursRequest::populate_transition_polylines
685    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
686    pub populate_travel_step_polylines: bool,
687
688    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
689    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
690}
691
692impl OptimizeToursRequest {
693    pub fn new() -> Self {
694        std::default::Default::default()
695    }
696
697    /// Sets the value of [parent][crate::model::OptimizeToursRequest::parent].
698    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
699        self.parent = v.into();
700        self
701    }
702
703    /// Sets the value of [timeout][crate::model::OptimizeToursRequest::timeout].
704    pub fn set_timeout<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
705        mut self,
706        v: T,
707    ) -> Self {
708        self.timeout = v.into();
709        self
710    }
711
712    /// Sets the value of [model][crate::model::OptimizeToursRequest::model].
713    pub fn set_model<T: std::convert::Into<std::option::Option<crate::model::ShipmentModel>>>(
714        mut self,
715        v: T,
716    ) -> Self {
717        self.model = v.into();
718        self
719    }
720
721    /// Sets the value of [solving_mode][crate::model::OptimizeToursRequest::solving_mode].
722    pub fn set_solving_mode<
723        T: std::convert::Into<crate::model::optimize_tours_request::SolvingMode>,
724    >(
725        mut self,
726        v: T,
727    ) -> Self {
728        self.solving_mode = v.into();
729        self
730    }
731
732    /// Sets the value of [search_mode][crate::model::OptimizeToursRequest::search_mode].
733    pub fn set_search_mode<
734        T: std::convert::Into<crate::model::optimize_tours_request::SearchMode>,
735    >(
736        mut self,
737        v: T,
738    ) -> Self {
739        self.search_mode = v.into();
740        self
741    }
742
743    /// Sets the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
744    pub fn set_injected_solution_constraint<
745        T: std::convert::Into<std::option::Option<crate::model::InjectedSolutionConstraint>>,
746    >(
747        mut self,
748        v: T,
749    ) -> Self {
750        self.injected_solution_constraint = v.into();
751        self
752    }
753
754    /// Sets the value of [interpret_injected_solutions_using_labels][crate::model::OptimizeToursRequest::interpret_injected_solutions_using_labels].
755    pub fn set_interpret_injected_solutions_using_labels<T: std::convert::Into<bool>>(
756        mut self,
757        v: T,
758    ) -> Self {
759        self.interpret_injected_solutions_using_labels = v.into();
760        self
761    }
762
763    /// Sets the value of [consider_road_traffic][crate::model::OptimizeToursRequest::consider_road_traffic].
764    pub fn set_consider_road_traffic<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
765        self.consider_road_traffic = v.into();
766        self
767    }
768
769    /// Sets the value of [populate_polylines][crate::model::OptimizeToursRequest::populate_polylines].
770    pub fn set_populate_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
771        self.populate_polylines = v.into();
772        self
773    }
774
775    /// Sets the value of [populate_transition_polylines][crate::model::OptimizeToursRequest::populate_transition_polylines].
776    pub fn set_populate_transition_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
777        self.populate_transition_polylines = v.into();
778        self
779    }
780
781    /// Sets the value of [allow_large_deadline_despite_interruption_risk][crate::model::OptimizeToursRequest::allow_large_deadline_despite_interruption_risk].
782    pub fn set_allow_large_deadline_despite_interruption_risk<T: std::convert::Into<bool>>(
783        mut self,
784        v: T,
785    ) -> Self {
786        self.allow_large_deadline_despite_interruption_risk = v.into();
787        self
788    }
789
790    /// Sets the value of [use_geodesic_distances][crate::model::OptimizeToursRequest::use_geodesic_distances].
791    pub fn set_use_geodesic_distances<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
792        self.use_geodesic_distances = v.into();
793        self
794    }
795
796    /// Sets the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
797    pub fn set_geodesic_meters_per_second<T: std::convert::Into<std::option::Option<f64>>>(
798        mut self,
799        v: T,
800    ) -> Self {
801        self.geodesic_meters_per_second = v.into();
802        self
803    }
804
805    /// Sets the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
806    pub fn set_max_validation_errors<T: std::convert::Into<std::option::Option<i32>>>(
807        mut self,
808        v: T,
809    ) -> Self {
810        self.max_validation_errors = v.into();
811        self
812    }
813
814    /// Sets the value of [label][crate::model::OptimizeToursRequest::label].
815    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
816        self.label = v.into();
817        self
818    }
819
820    /// Sets the value of [populate_travel_step_polylines][crate::model::OptimizeToursRequest::populate_travel_step_polylines].
821    pub fn set_populate_travel_step_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
822        self.populate_travel_step_polylines = v.into();
823        self
824    }
825
826    /// Sets the value of [injected_first_solution_routes][crate::model::OptimizeToursRequest::injected_first_solution_routes].
827    pub fn set_injected_first_solution_routes<T, V>(mut self, v: T) -> Self
828    where
829        T: std::iter::IntoIterator<Item = V>,
830        V: std::convert::Into<crate::model::ShipmentRoute>,
831    {
832        use std::iter::Iterator;
833        self.injected_first_solution_routes = v.into_iter().map(|i| i.into()).collect();
834        self
835    }
836
837    /// Sets the value of [refresh_details_routes][crate::model::OptimizeToursRequest::refresh_details_routes].
838    pub fn set_refresh_details_routes<T, V>(mut self, v: T) -> Self
839    where
840        T: std::iter::IntoIterator<Item = V>,
841        V: std::convert::Into<crate::model::ShipmentRoute>,
842    {
843        use std::iter::Iterator;
844        self.refresh_details_routes = v.into_iter().map(|i| i.into()).collect();
845        self
846    }
847}
848
849impl wkt::message::Message for OptimizeToursRequest {
850    fn typename() -> &'static str {
851        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursRequest"
852    }
853}
854
855/// Defines additional types related to [OptimizeToursRequest].
856pub mod optimize_tours_request {
857    #[allow(unused_imports)]
858    use super::*;
859
860    /// Defines how the solver should handle the request. In all modes but
861    /// `VALIDATE_ONLY`, if the request is invalid, you will receive an
862    /// `INVALID_REQUEST` error. See
863    /// [max_validation_errors][google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]
864    /// to cap the number of errors returned.
865    ///
866    /// [google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]: crate::model::OptimizeToursRequest::max_validation_errors
867    #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
868    pub struct SolvingMode(i32);
869
870    impl SolvingMode {
871        /// Solve the model.
872        pub const DEFAULT_SOLVE: SolvingMode = SolvingMode::new(0);
873
874        /// Only validates the model without solving it: populates as many
875        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
876        /// as possible.
877        ///
878        /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
879        pub const VALIDATE_ONLY: SolvingMode = SolvingMode::new(1);
880
881        /// Only populates
882        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
883        /// or
884        /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments],
885        /// and doesn't actually solve the rest of the request (`status` and `routes`
886        /// are unset in the response).
887        /// If infeasibilities in `injected_solution_constraint` routes are detected
888        /// they are populated in the
889        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
890        /// field and
891        /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]
892        /// is left empty.
893        ///
894        /// *IMPORTANT*: not all infeasible shipments are returned here, but only the
895        /// ones that are detected as infeasible during preprocessing.
896        ///
897        /// [google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]: crate::model::OptimizeToursResponse::skipped_shipments
898        /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
899        pub const DETECT_SOME_INFEASIBLE_SHIPMENTS: SolvingMode = SolvingMode::new(2);
900
901        /// Creates a new SolvingMode instance.
902        pub(crate) const fn new(value: i32) -> Self {
903            Self(value)
904        }
905
906        /// Gets the enum value.
907        pub fn value(&self) -> i32 {
908            self.0
909        }
910
911        /// Gets the enum value as a string.
912        pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
913            match self.0 {
914                0 => std::borrow::Cow::Borrowed("DEFAULT_SOLVE"),
915                1 => std::borrow::Cow::Borrowed("VALIDATE_ONLY"),
916                2 => std::borrow::Cow::Borrowed("DETECT_SOME_INFEASIBLE_SHIPMENTS"),
917                _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
918            }
919        }
920
921        /// Creates an enum value from the value name.
922        pub fn from_str_name(name: &str) -> std::option::Option<Self> {
923            match name {
924                "DEFAULT_SOLVE" => std::option::Option::Some(Self::DEFAULT_SOLVE),
925                "VALIDATE_ONLY" => std::option::Option::Some(Self::VALIDATE_ONLY),
926                "DETECT_SOME_INFEASIBLE_SHIPMENTS" => {
927                    std::option::Option::Some(Self::DETECT_SOME_INFEASIBLE_SHIPMENTS)
928                }
929                _ => std::option::Option::None,
930            }
931        }
932    }
933
934    impl std::convert::From<i32> for SolvingMode {
935        fn from(value: i32) -> Self {
936            Self::new(value)
937        }
938    }
939
940    impl std::default::Default for SolvingMode {
941        fn default() -> Self {
942            Self::new(0)
943        }
944    }
945
946    /// Mode defining the behavior of the search, trading off latency versus
947    /// solution quality. In all modes, the global request deadline is enforced.
948    #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
949    pub struct SearchMode(i32);
950
951    impl SearchMode {
952        /// Unspecified search mode, equivalent to `RETURN_FAST`.
953        pub const SEARCH_MODE_UNSPECIFIED: SearchMode = SearchMode::new(0);
954
955        /// Stop the search after finding the first good solution.
956        pub const RETURN_FAST: SearchMode = SearchMode::new(1);
957
958        /// Spend all the available time to search for better solutions.
959        pub const CONSUME_ALL_AVAILABLE_TIME: SearchMode = SearchMode::new(2);
960
961        /// Creates a new SearchMode instance.
962        pub(crate) const fn new(value: i32) -> Self {
963            Self(value)
964        }
965
966        /// Gets the enum value.
967        pub fn value(&self) -> i32 {
968            self.0
969        }
970
971        /// Gets the enum value as a string.
972        pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
973            match self.0 {
974                0 => std::borrow::Cow::Borrowed("SEARCH_MODE_UNSPECIFIED"),
975                1 => std::borrow::Cow::Borrowed("RETURN_FAST"),
976                2 => std::borrow::Cow::Borrowed("CONSUME_ALL_AVAILABLE_TIME"),
977                _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
978            }
979        }
980
981        /// Creates an enum value from the value name.
982        pub fn from_str_name(name: &str) -> std::option::Option<Self> {
983            match name {
984                "SEARCH_MODE_UNSPECIFIED" => {
985                    std::option::Option::Some(Self::SEARCH_MODE_UNSPECIFIED)
986                }
987                "RETURN_FAST" => std::option::Option::Some(Self::RETURN_FAST),
988                "CONSUME_ALL_AVAILABLE_TIME" => {
989                    std::option::Option::Some(Self::CONSUME_ALL_AVAILABLE_TIME)
990                }
991                _ => std::option::Option::None,
992            }
993        }
994    }
995
996    impl std::convert::From<i32> for SearchMode {
997        fn from(value: i32) -> Self {
998            Self::new(value)
999        }
1000    }
1001
1002    impl std::default::Default for SearchMode {
1003        fn default() -> Self {
1004            Self::new(0)
1005        }
1006    }
1007}
1008
1009/// Response after solving a tour optimization problem containing the routes
1010/// followed by each vehicle, the shipments which have been skipped and the
1011/// overall cost of the solution.
1012#[serde_with::serde_as]
1013#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1014#[serde(default, rename_all = "camelCase")]
1015#[non_exhaustive]
1016pub struct OptimizeToursResponse {
1017    /// Routes computed for each vehicle; the i-th route corresponds to the i-th
1018    /// vehicle in the model.
1019    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1020    pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
1021
1022    /// Copy of the
1023    /// [OptimizeToursRequest.label][google.cloud.optimization.v1.OptimizeToursRequest.label],
1024    /// if a label was specified in the request.
1025    ///
1026    /// [google.cloud.optimization.v1.OptimizeToursRequest.label]: crate::model::OptimizeToursRequest::label
1027    #[serde(skip_serializing_if = "std::string::String::is_empty")]
1028    pub request_label: std::string::String,
1029
1030    /// The list of all shipments skipped.
1031    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1032    pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
1033
1034    /// List of all the validation errors that we were able to detect
1035    /// independently. See the "MULTIPLE ERRORS" explanation for the
1036    /// [OptimizeToursValidationError][google.cloud.optimization.v1.OptimizeToursValidationError]
1037    /// message.
1038    ///
1039    /// [google.cloud.optimization.v1.OptimizeToursValidationError]: crate::model::OptimizeToursValidationError
1040    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1041    pub validation_errors: std::vec::Vec<crate::model::OptimizeToursValidationError>,
1042
1043    /// Duration, distance and usage metrics for this solution.
1044    #[serde(skip_serializing_if = "std::option::Option::is_none")]
1045    pub metrics: std::option::Option<crate::model::optimize_tours_response::Metrics>,
1046
1047    /// Deprecated: Use
1048    /// [Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
1049    /// instead. Total cost of the solution. This takes into account all costs:
1050    /// costs per per hour and travel hour, fixed vehicle costs, unperformed
1051    /// shipment penalty costs, global duration cost, etc.
1052    ///
1053    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
1054    pub total_cost: f64,
1055
1056    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1057    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1058}
1059
1060impl OptimizeToursResponse {
1061    pub fn new() -> Self {
1062        std::default::Default::default()
1063    }
1064
1065    /// Sets the value of [request_label][crate::model::OptimizeToursResponse::request_label].
1066    pub fn set_request_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1067        self.request_label = v.into();
1068        self
1069    }
1070
1071    /// Sets the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1072    pub fn set_metrics<
1073        T: std::convert::Into<std::option::Option<crate::model::optimize_tours_response::Metrics>>,
1074    >(
1075        mut self,
1076        v: T,
1077    ) -> Self {
1078        self.metrics = v.into();
1079        self
1080    }
1081
1082    /// Sets the value of [total_cost][crate::model::OptimizeToursResponse::total_cost].
1083    pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1084        self.total_cost = v.into();
1085        self
1086    }
1087
1088    /// Sets the value of [routes][crate::model::OptimizeToursResponse::routes].
1089    pub fn set_routes<T, V>(mut self, v: T) -> Self
1090    where
1091        T: std::iter::IntoIterator<Item = V>,
1092        V: std::convert::Into<crate::model::ShipmentRoute>,
1093    {
1094        use std::iter::Iterator;
1095        self.routes = v.into_iter().map(|i| i.into()).collect();
1096        self
1097    }
1098
1099    /// Sets the value of [skipped_shipments][crate::model::OptimizeToursResponse::skipped_shipments].
1100    pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
1101    where
1102        T: std::iter::IntoIterator<Item = V>,
1103        V: std::convert::Into<crate::model::SkippedShipment>,
1104    {
1105        use std::iter::Iterator;
1106        self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
1107        self
1108    }
1109
1110    /// Sets the value of [validation_errors][crate::model::OptimizeToursResponse::validation_errors].
1111    pub fn set_validation_errors<T, V>(mut self, v: T) -> Self
1112    where
1113        T: std::iter::IntoIterator<Item = V>,
1114        V: std::convert::Into<crate::model::OptimizeToursValidationError>,
1115    {
1116        use std::iter::Iterator;
1117        self.validation_errors = v.into_iter().map(|i| i.into()).collect();
1118        self
1119    }
1120}
1121
1122impl wkt::message::Message for OptimizeToursResponse {
1123    fn typename() -> &'static str {
1124        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse"
1125    }
1126}
1127
1128/// Defines additional types related to [OptimizeToursResponse].
1129pub mod optimize_tours_response {
1130    #[allow(unused_imports)]
1131    use super::*;
1132
1133    /// Overall metrics, aggregated over all routes.
1134    #[serde_with::serde_as]
1135    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1136    #[serde(default, rename_all = "camelCase")]
1137    #[non_exhaustive]
1138    pub struct Metrics {
1139        /// Aggregated over the routes. Each metric is the sum (or max, for loads)
1140        /// over all
1141        /// [ShipmentRoute.metrics][google.cloud.optimization.v1.ShipmentRoute.metrics]
1142        /// fields of the same name.
1143        ///
1144        /// [google.cloud.optimization.v1.ShipmentRoute.metrics]: crate::model::ShipmentRoute::metrics
1145        #[serde(skip_serializing_if = "std::option::Option::is_none")]
1146        pub aggregated_route_metrics: std::option::Option<crate::model::AggregatedMetrics>,
1147
1148        /// Number of mandatory shipments skipped.
1149        pub skipped_mandatory_shipment_count: i32,
1150
1151        /// Number of vehicles used. Note: if a vehicle route is empty and
1152        /// [Vehicle.used_if_route_is_empty][google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]
1153        /// is true, the vehicle is considered used.
1154        ///
1155        /// [google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]: crate::model::Vehicle::used_if_route_is_empty
1156        pub used_vehicle_count: i32,
1157
1158        /// The earliest start time for a used vehicle, computed as the minimum over
1159        /// all used vehicles of
1160        /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time].
1161        ///
1162        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
1163        #[serde(skip_serializing_if = "std::option::Option::is_none")]
1164        pub earliest_vehicle_start_time: std::option::Option<wkt::Timestamp>,
1165
1166        /// The latest end time for a used vehicle, computed as the maximum over all
1167        /// used vehicles of
1168        /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time].
1169        ///
1170        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
1171        #[serde(skip_serializing_if = "std::option::Option::is_none")]
1172        pub latest_vehicle_end_time: std::option::Option<wkt::Timestamp>,
1173
1174        /// Cost of the solution, broken down by cost-related request fields.
1175        /// The keys are proto paths, relative to the input OptimizeToursRequest,
1176        /// e.g. "model.shipments.pickups.cost", and the values are the total cost
1177        /// generated by the corresponding cost field, aggregated over the whole
1178        /// solution. In other words, costs["model.shipments.pickups.cost"] is the
1179        /// sum of all pickup costs over the solution. All costs defined in the model
1180        /// are reported in detail here with the exception of costs related to
1181        /// TransitionAttributes that are only reported in an aggregated way as of
1182        /// 2022/01.
1183        #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
1184        pub costs: std::collections::HashMap<std::string::String, f64>,
1185
1186        /// Total cost of the solution. The sum of all values in the costs map.
1187        pub total_cost: f64,
1188
1189        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1190        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1191    }
1192
1193    impl Metrics {
1194        pub fn new() -> Self {
1195            std::default::Default::default()
1196        }
1197
1198        /// Sets the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1199        pub fn set_aggregated_route_metrics<
1200            T: std::convert::Into<std::option::Option<crate::model::AggregatedMetrics>>,
1201        >(
1202            mut self,
1203            v: T,
1204        ) -> Self {
1205            self.aggregated_route_metrics = v.into();
1206            self
1207        }
1208
1209        /// Sets the value of [skipped_mandatory_shipment_count][crate::model::optimize_tours_response::Metrics::skipped_mandatory_shipment_count].
1210        pub fn set_skipped_mandatory_shipment_count<T: std::convert::Into<i32>>(
1211            mut self,
1212            v: T,
1213        ) -> Self {
1214            self.skipped_mandatory_shipment_count = v.into();
1215            self
1216        }
1217
1218        /// Sets the value of [used_vehicle_count][crate::model::optimize_tours_response::Metrics::used_vehicle_count].
1219        pub fn set_used_vehicle_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1220            self.used_vehicle_count = v.into();
1221            self
1222        }
1223
1224        /// Sets the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1225        pub fn set_earliest_vehicle_start_time<
1226            T: std::convert::Into<std::option::Option<wkt::Timestamp>>,
1227        >(
1228            mut self,
1229            v: T,
1230        ) -> Self {
1231            self.earliest_vehicle_start_time = v.into();
1232            self
1233        }
1234
1235        /// Sets the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1236        pub fn set_latest_vehicle_end_time<
1237            T: std::convert::Into<std::option::Option<wkt::Timestamp>>,
1238        >(
1239            mut self,
1240            v: T,
1241        ) -> Self {
1242            self.latest_vehicle_end_time = v.into();
1243            self
1244        }
1245
1246        /// Sets the value of [total_cost][crate::model::optimize_tours_response::Metrics::total_cost].
1247        pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1248            self.total_cost = v.into();
1249            self
1250        }
1251
1252        /// Sets the value of [costs][crate::model::optimize_tours_response::Metrics::costs].
1253        pub fn set_costs<T, K, V>(mut self, v: T) -> Self
1254        where
1255            T: std::iter::IntoIterator<Item = (K, V)>,
1256            K: std::convert::Into<std::string::String>,
1257            V: std::convert::Into<f64>,
1258        {
1259            use std::iter::Iterator;
1260            self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1261            self
1262        }
1263    }
1264
1265    impl wkt::message::Message for Metrics {
1266        fn typename() -> &'static str {
1267            "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse.Metrics"
1268        }
1269    }
1270}
1271
1272/// Request to batch optimize tours as an asynchronous operation.
1273/// Each input file should contain one `OptimizeToursRequest`, and each output
1274/// file will contain one `OptimizeToursResponse`. The request contains
1275/// information to read/write and parse the files. All the input and output files
1276/// should be under the same project.
1277#[serde_with::serde_as]
1278#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1279#[serde(default, rename_all = "camelCase")]
1280#[non_exhaustive]
1281pub struct BatchOptimizeToursRequest {
1282    /// Required. Target project and location to make a call.
1283    ///
1284    /// Format: `projects/{project-id}/locations/{location-id}`.
1285    ///
1286    /// If no location is specified, a region will be chosen automatically.
1287    #[serde(skip_serializing_if = "std::string::String::is_empty")]
1288    pub parent: std::string::String,
1289
1290    /// Required. Input/Output information each purchase model, such as file paths
1291    /// and data formats.
1292    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1293    pub model_configs: std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
1294
1295    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1296    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1297}
1298
1299impl BatchOptimizeToursRequest {
1300    pub fn new() -> Self {
1301        std::default::Default::default()
1302    }
1303
1304    /// Sets the value of [parent][crate::model::BatchOptimizeToursRequest::parent].
1305    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1306        self.parent = v.into();
1307        self
1308    }
1309
1310    /// Sets the value of [model_configs][crate::model::BatchOptimizeToursRequest::model_configs].
1311    pub fn set_model_configs<T, V>(mut self, v: T) -> Self
1312    where
1313        T: std::iter::IntoIterator<Item = V>,
1314        V: std::convert::Into<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
1315    {
1316        use std::iter::Iterator;
1317        self.model_configs = v.into_iter().map(|i| i.into()).collect();
1318        self
1319    }
1320}
1321
1322impl wkt::message::Message for BatchOptimizeToursRequest {
1323    fn typename() -> &'static str {
1324        "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest"
1325    }
1326}
1327
1328/// Defines additional types related to [BatchOptimizeToursRequest].
1329pub mod batch_optimize_tours_request {
1330    #[allow(unused_imports)]
1331    use super::*;
1332
1333    /// Information for solving one optimization model asynchronously.
1334    #[serde_with::serde_as]
1335    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1336    #[serde(default, rename_all = "camelCase")]
1337    #[non_exhaustive]
1338    pub struct AsyncModelConfig {
1339        /// User defined model name, can be used as alias by users to keep track of
1340        /// models.
1341        #[serde(skip_serializing_if = "std::string::String::is_empty")]
1342        pub display_name: std::string::String,
1343
1344        /// Required. Information about the input model.
1345        #[serde(skip_serializing_if = "std::option::Option::is_none")]
1346        pub input_config: std::option::Option<crate::model::InputConfig>,
1347
1348        /// Required. The desired output location information.
1349        #[serde(skip_serializing_if = "std::option::Option::is_none")]
1350        pub output_config: std::option::Option<crate::model::OutputConfig>,
1351
1352        /// If this is set, the model will be solved in the checkpoint mode. In this
1353        /// mode, the input model can have a deadline longer than 30 mins without the
1354        /// risk of interruption. The model will be solved in multiple short-running
1355        /// stages. Each stage generates an intermediate checkpoint
1356        /// and stores it in the user's Cloud Storage buckets. The checkpoint
1357        /// mode should be preferred over
1358        /// allow_large_deadline_despite_interruption_risk since it prevents the risk
1359        /// of interruption.
1360        pub enable_checkpoints: bool,
1361
1362        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1363        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1364    }
1365
1366    impl AsyncModelConfig {
1367        pub fn new() -> Self {
1368            std::default::Default::default()
1369        }
1370
1371        /// Sets the value of [display_name][crate::model::batch_optimize_tours_request::AsyncModelConfig::display_name].
1372        pub fn set_display_name<T: std::convert::Into<std::string::String>>(
1373            mut self,
1374            v: T,
1375        ) -> Self {
1376            self.display_name = v.into();
1377            self
1378        }
1379
1380        /// Sets the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
1381        pub fn set_input_config<
1382            T: std::convert::Into<std::option::Option<crate::model::InputConfig>>,
1383        >(
1384            mut self,
1385            v: T,
1386        ) -> Self {
1387            self.input_config = v.into();
1388            self
1389        }
1390
1391        /// Sets the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
1392        pub fn set_output_config<
1393            T: std::convert::Into<std::option::Option<crate::model::OutputConfig>>,
1394        >(
1395            mut self,
1396            v: T,
1397        ) -> Self {
1398            self.output_config = v.into();
1399            self
1400        }
1401
1402        /// Sets the value of [enable_checkpoints][crate::model::batch_optimize_tours_request::AsyncModelConfig::enable_checkpoints].
1403        pub fn set_enable_checkpoints<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1404            self.enable_checkpoints = v.into();
1405            self
1406        }
1407    }
1408
1409    impl wkt::message::Message for AsyncModelConfig {
1410        fn typename() -> &'static str {
1411            "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest.AsyncModelConfig"
1412        }
1413    }
1414}
1415
1416/// Response to a `BatchOptimizeToursRequest`. This is returned in
1417/// the LRO Operation after the operation is complete.
1418#[serde_with::serde_as]
1419#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1420#[serde(default, rename_all = "camelCase")]
1421#[non_exhaustive]
1422pub struct BatchOptimizeToursResponse {
1423    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1424    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1425}
1426
1427impl BatchOptimizeToursResponse {
1428    pub fn new() -> Self {
1429        std::default::Default::default()
1430    }
1431}
1432
1433impl wkt::message::Message for BatchOptimizeToursResponse {
1434    fn typename() -> &'static str {
1435        "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursResponse"
1436    }
1437}
1438
1439/// A shipment model contains a set of shipments which must be performed by a
1440/// set of vehicles, while minimizing the overall cost, which is the sum of:
1441///
1442/// * the cost of routing the vehicles (sum of cost per total time, cost per
1443///   travel time, and fixed cost over all vehicles).
1444/// * the unperformed shipment penalties.
1445/// * the cost of the global duration of the shipments
1446#[serde_with::serde_as]
1447#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1448#[serde(default, rename_all = "camelCase")]
1449#[non_exhaustive]
1450pub struct ShipmentModel {
1451    /// Set of shipments which must be performed in the model.
1452    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1453    pub shipments: std::vec::Vec<crate::model::Shipment>,
1454
1455    /// Set of vehicles which can be used to perform visits.
1456    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1457    pub vehicles: std::vec::Vec<crate::model::Vehicle>,
1458
1459    /// Constrains the maximum number of active vehicles. A vehicle is active if
1460    /// its route performs at least one shipment. This can be used to limit the
1461    /// number of routes in the case where there are fewer drivers than
1462    /// vehicles and that the fleet of vehicles is heterogeneous. The optimization
1463    /// will then select the best subset of vehicles to use.
1464    /// Must be strictly positive.
1465    #[serde(skip_serializing_if = "std::option::Option::is_none")]
1466    pub max_active_vehicles: std::option::Option<i32>,
1467
1468    /// Global start and end time of the model: no times outside of this range
1469    /// can be considered valid.
1470    ///
1471    /// The model's time span must be less than a year, i.e. the `global_end_time`
1472    /// and the `global_start_time` must be within 31536000 seconds of each other.
1473    ///
1474    /// When using `cost_per_*hour` fields, you might want to set this window to a
1475    /// smaller interval to increase performance (eg. if you model a single day,
1476    /// you should set the global time limits to that day).
1477    /// If unset, 00:00:00 UTC, January 1, 1970 (i.e. seconds: 0, nanos: 0) is used
1478    /// as default.
1479    #[serde(skip_serializing_if = "std::option::Option::is_none")]
1480    pub global_start_time: std::option::Option<wkt::Timestamp>,
1481
1482    /// If unset, 00:00:00 UTC, January 1, 1971 (i.e. seconds: 31536000, nanos: 0)
1483    /// is used as default.
1484    #[serde(skip_serializing_if = "std::option::Option::is_none")]
1485    pub global_end_time: std::option::Option<wkt::Timestamp>,
1486
1487    /// The "global duration" of the overall plan is the difference between the
1488    /// earliest effective start time and the latest effective end time of
1489    /// all vehicles. Users can assign a cost per hour to that quantity to try
1490    /// and optimize for earliest job completion, for example. This cost must be in
1491    /// the same unit as
1492    /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
1493    ///
1494    /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
1495    pub global_duration_cost_per_hour: f64,
1496
1497    /// Specifies duration and distance matrices used in the model. If this field
1498    /// is empty, Google Maps or geodesic distances will be used instead, depending
1499    /// on the value of the `use_geodesic_distances` field. If it is not empty,
1500    /// `use_geodesic_distances` cannot be true and neither
1501    /// `duration_distance_matrix_src_tags` nor `duration_distance_matrix_dst_tags`
1502    /// can be empty.
1503    ///
1504    /// Usage examples:
1505    ///
1506    /// * There are two locations: locA and locB.
1507    /// * 1 vehicle starting its route at locA and ending it at locA.
1508    /// * 1 pickup visit request at locB.
1509    ///
1510    /// ```norust
1511    /// model {
1512    ///   vehicles { start_tags: "locA"  end_tags: "locA" }
1513    ///   shipments { pickups { tags: "locB" } }
1514    ///   duration_distance_matrix_src_tags: "locA"
1515    ///   duration_distance_matrix_src_tags: "locB"
1516    ///   duration_distance_matrix_dst_tags: "locA"
1517    ///   duration_distance_matrix_dst_tags: "locB"
1518    ///   duration_distance_matrices {
1519    ///     rows {  # from: locA
1520    ///       durations { seconds: 0 }   meters: 0    # to: locA
1521    ///       durations { seconds: 100 } meters: 1000 # to: locB
1522    ///     }
1523    ///     rows {  # from: locB
1524    ///       durations { seconds: 102 } meters: 990 # to: locA
1525    ///       durations { seconds: 0 }   meters: 0   # to: locB
1526    ///     }
1527    ///   }
1528    /// }
1529    /// ```
1530    ///
1531    /// * There are three locations: locA, locB and locC.
1532    /// * 1 vehicle starting its route at locA and ending it at locB, using
1533    ///   matrix "fast".
1534    /// * 1 vehicle starting its route at locB and ending it at locB, using
1535    ///   matrix "slow".
1536    /// * 1 vehicle starting its route at locB and ending it at locB, using
1537    ///   matrix "fast".
1538    /// * 1 pickup visit request at locC.
1539    ///
1540    /// ```norust
1541    /// model {
1542    ///   vehicles { start_tags: "locA" end_tags: "locB" start_tags: "fast" }
1543    ///   vehicles { start_tags: "locB" end_tags: "locB" start_tags: "slow" }
1544    ///   vehicles { start_tags: "locB" end_tags: "locB" start_tags: "fast" }
1545    ///   shipments { pickups { tags: "locC" } }
1546    ///   duration_distance_matrix_src_tags: "locA"
1547    ///   duration_distance_matrix_src_tags: "locB"
1548    ///   duration_distance_matrix_src_tags: "locC"
1549    ///   duration_distance_matrix_dst_tags: "locB"
1550    ///   duration_distance_matrix_dst_tags: "locC"
1551    ///   duration_distance_matrices {
1552    ///     vehicle_start_tag: "fast"
1553    ///     rows {  # from: locA
1554    ///       durations { seconds: 1000 } meters: 2000 # to: locB
1555    ///       durations { seconds: 600 }  meters: 1000 # to: locC
1556    ///     }
1557    ///     rows {  # from: locB
1558    ///       durations { seconds: 0 }   meters: 0    # to: locB
1559    ///       durations { seconds: 700 } meters: 1200 # to: locC
1560    ///     }
1561    ///     rows {  # from: locC
1562    ///       durations { seconds: 702 } meters: 1190 # to: locB
1563    ///       durations { seconds: 0 }   meters: 0    # to: locC
1564    ///     }
1565    ///   }
1566    ///   duration_distance_matrices {
1567    ///     vehicle_start_tag: "slow"
1568    ///     rows {  # from: locA
1569    ///       durations { seconds: 1800 } meters: 2001 # to: locB
1570    ///       durations { seconds: 900 }  meters: 1002 # to: locC
1571    ///     }
1572    ///     rows {  # from: locB
1573    ///       durations { seconds: 0 }    meters: 0    # to: locB
1574    ///       durations { seconds: 1000 } meters: 1202 # to: locC
1575    ///     }
1576    ///     rows {  # from: locC
1577    ///       durations { seconds: 1001 } meters: 1195 # to: locB
1578    ///       durations { seconds: 0 }    meters: 0    # to: locC
1579    ///     }
1580    ///   }
1581    /// }
1582    /// ```
1583    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1584    pub duration_distance_matrices:
1585        std::vec::Vec<crate::model::shipment_model::DurationDistanceMatrix>,
1586
1587    /// Tags defining the sources of the duration and distance matrices;
1588    /// `duration_distance_matrices(i).rows(j)` defines durations and distances
1589    /// from visits with tag `duration_distance_matrix_src_tags(j)` to other visits
1590    /// in matrix i.
1591    ///
1592    /// Tags correspond to
1593    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
1594    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
1595    /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
1596    /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
1597    /// the same; similarly a `VisitRequest`'s source and destination tags may be
1598    /// the same. All tags must be different and cannot be empty strings. If this
1599    /// field is not empty, then `duration_distance_matrices` must not be empty.
1600    ///
1601    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
1602    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
1603    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1604    pub duration_distance_matrix_src_tags: std::vec::Vec<std::string::String>,
1605
1606    /// Tags defining the destinations of the duration and distance matrices;
1607    /// `duration_distance_matrices(i).rows(j).durations(k)` (resp.
1608    /// `duration_distance_matrices(i).rows(j).meters(k))` defines the duration
1609    /// (resp. the distance) of the travel from visits with tag
1610    /// `duration_distance_matrix_src_tags(j)` to visits with tag
1611    /// `duration_distance_matrix_dst_tags(k)` in matrix i.
1612    ///
1613    /// Tags correspond to
1614    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
1615    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
1616    /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
1617    /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
1618    /// the same; similarly a `VisitRequest`'s source and destination tags may be
1619    /// the same. All tags must be different and cannot be empty strings. If this
1620    /// field is not empty, then `duration_distance_matrices` must not be empty.
1621    ///
1622    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
1623    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
1624    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1625    pub duration_distance_matrix_dst_tags: std::vec::Vec<std::string::String>,
1626
1627    /// Transition attributes added to the model.
1628    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1629    pub transition_attributes: std::vec::Vec<crate::model::TransitionAttributes>,
1630
1631    /// Sets of incompatible shipment_types (see `ShipmentTypeIncompatibility`).
1632    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1633    pub shipment_type_incompatibilities: std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
1634
1635    /// Sets of `shipment_type` requirements (see `ShipmentTypeRequirement`).
1636    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1637    pub shipment_type_requirements: std::vec::Vec<crate::model::ShipmentTypeRequirement>,
1638
1639    /// Set of precedence rules which must be enforced in the model.
1640    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1641    pub precedence_rules: std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
1642
1643    /// Deprecated: No longer used.
1644    /// Set of break rules used in the model.
1645    /// Each vehicle specifies the `BreakRule` that applies to it via the
1646    /// [Vehicle.break_rule_indices][google.cloud.optimization.v1.Vehicle.break_rule_indices]
1647    /// field (which must be a singleton).
1648    ///
1649    /// [google.cloud.optimization.v1.Vehicle.break_rule_indices]: crate::model::Vehicle::break_rule_indices
1650    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1651    pub break_rules: std::vec::Vec<crate::model::shipment_model::BreakRule>,
1652
1653    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1654    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1655}
1656
1657impl ShipmentModel {
1658    pub fn new() -> Self {
1659        std::default::Default::default()
1660    }
1661
1662    /// Sets the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
1663    pub fn set_max_active_vehicles<T: std::convert::Into<std::option::Option<i32>>>(
1664        mut self,
1665        v: T,
1666    ) -> Self {
1667        self.max_active_vehicles = v.into();
1668        self
1669    }
1670
1671    /// Sets the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
1672    pub fn set_global_start_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
1673        mut self,
1674        v: T,
1675    ) -> Self {
1676        self.global_start_time = v.into();
1677        self
1678    }
1679
1680    /// Sets the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
1681    pub fn set_global_end_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
1682        mut self,
1683        v: T,
1684    ) -> Self {
1685        self.global_end_time = v.into();
1686        self
1687    }
1688
1689    /// Sets the value of [global_duration_cost_per_hour][crate::model::ShipmentModel::global_duration_cost_per_hour].
1690    pub fn set_global_duration_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1691        self.global_duration_cost_per_hour = v.into();
1692        self
1693    }
1694
1695    /// Sets the value of [shipments][crate::model::ShipmentModel::shipments].
1696    pub fn set_shipments<T, V>(mut self, v: T) -> Self
1697    where
1698        T: std::iter::IntoIterator<Item = V>,
1699        V: std::convert::Into<crate::model::Shipment>,
1700    {
1701        use std::iter::Iterator;
1702        self.shipments = v.into_iter().map(|i| i.into()).collect();
1703        self
1704    }
1705
1706    /// Sets the value of [vehicles][crate::model::ShipmentModel::vehicles].
1707    pub fn set_vehicles<T, V>(mut self, v: T) -> Self
1708    where
1709        T: std::iter::IntoIterator<Item = V>,
1710        V: std::convert::Into<crate::model::Vehicle>,
1711    {
1712        use std::iter::Iterator;
1713        self.vehicles = v.into_iter().map(|i| i.into()).collect();
1714        self
1715    }
1716
1717    /// Sets the value of [duration_distance_matrices][crate::model::ShipmentModel::duration_distance_matrices].
1718    pub fn set_duration_distance_matrices<T, V>(mut self, v: T) -> Self
1719    where
1720        T: std::iter::IntoIterator<Item = V>,
1721        V: std::convert::Into<crate::model::shipment_model::DurationDistanceMatrix>,
1722    {
1723        use std::iter::Iterator;
1724        self.duration_distance_matrices = v.into_iter().map(|i| i.into()).collect();
1725        self
1726    }
1727
1728    /// Sets the value of [duration_distance_matrix_src_tags][crate::model::ShipmentModel::duration_distance_matrix_src_tags].
1729    pub fn set_duration_distance_matrix_src_tags<T, V>(mut self, v: T) -> Self
1730    where
1731        T: std::iter::IntoIterator<Item = V>,
1732        V: std::convert::Into<std::string::String>,
1733    {
1734        use std::iter::Iterator;
1735        self.duration_distance_matrix_src_tags = v.into_iter().map(|i| i.into()).collect();
1736        self
1737    }
1738
1739    /// Sets the value of [duration_distance_matrix_dst_tags][crate::model::ShipmentModel::duration_distance_matrix_dst_tags].
1740    pub fn set_duration_distance_matrix_dst_tags<T, V>(mut self, v: T) -> Self
1741    where
1742        T: std::iter::IntoIterator<Item = V>,
1743        V: std::convert::Into<std::string::String>,
1744    {
1745        use std::iter::Iterator;
1746        self.duration_distance_matrix_dst_tags = v.into_iter().map(|i| i.into()).collect();
1747        self
1748    }
1749
1750    /// Sets the value of [transition_attributes][crate::model::ShipmentModel::transition_attributes].
1751    pub fn set_transition_attributes<T, V>(mut self, v: T) -> Self
1752    where
1753        T: std::iter::IntoIterator<Item = V>,
1754        V: std::convert::Into<crate::model::TransitionAttributes>,
1755    {
1756        use std::iter::Iterator;
1757        self.transition_attributes = v.into_iter().map(|i| i.into()).collect();
1758        self
1759    }
1760
1761    /// Sets the value of [shipment_type_incompatibilities][crate::model::ShipmentModel::shipment_type_incompatibilities].
1762    pub fn set_shipment_type_incompatibilities<T, V>(mut self, v: T) -> Self
1763    where
1764        T: std::iter::IntoIterator<Item = V>,
1765        V: std::convert::Into<crate::model::ShipmentTypeIncompatibility>,
1766    {
1767        use std::iter::Iterator;
1768        self.shipment_type_incompatibilities = v.into_iter().map(|i| i.into()).collect();
1769        self
1770    }
1771
1772    /// Sets the value of [shipment_type_requirements][crate::model::ShipmentModel::shipment_type_requirements].
1773    pub fn set_shipment_type_requirements<T, V>(mut self, v: T) -> Self
1774    where
1775        T: std::iter::IntoIterator<Item = V>,
1776        V: std::convert::Into<crate::model::ShipmentTypeRequirement>,
1777    {
1778        use std::iter::Iterator;
1779        self.shipment_type_requirements = v.into_iter().map(|i| i.into()).collect();
1780        self
1781    }
1782
1783    /// Sets the value of [precedence_rules][crate::model::ShipmentModel::precedence_rules].
1784    pub fn set_precedence_rules<T, V>(mut self, v: T) -> Self
1785    where
1786        T: std::iter::IntoIterator<Item = V>,
1787        V: std::convert::Into<crate::model::shipment_model::PrecedenceRule>,
1788    {
1789        use std::iter::Iterator;
1790        self.precedence_rules = v.into_iter().map(|i| i.into()).collect();
1791        self
1792    }
1793
1794    /// Sets the value of [break_rules][crate::model::ShipmentModel::break_rules].
1795    pub fn set_break_rules<T, V>(mut self, v: T) -> Self
1796    where
1797        T: std::iter::IntoIterator<Item = V>,
1798        V: std::convert::Into<crate::model::shipment_model::BreakRule>,
1799    {
1800        use std::iter::Iterator;
1801        self.break_rules = v.into_iter().map(|i| i.into()).collect();
1802        self
1803    }
1804}
1805
1806impl wkt::message::Message for ShipmentModel {
1807    fn typename() -> &'static str {
1808        "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel"
1809    }
1810}
1811
1812/// Defines additional types related to [ShipmentModel].
1813pub mod shipment_model {
1814    #[allow(unused_imports)]
1815    use super::*;
1816
1817    /// Specifies a duration and distance matrix from visit and vehicle start
1818    /// locations to visit and vehicle end locations.
1819    #[serde_with::serde_as]
1820    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1821    #[serde(default, rename_all = "camelCase")]
1822    #[non_exhaustive]
1823    pub struct DurationDistanceMatrix {
1824        /// Specifies the rows of the duration and distance matrix. It must have as
1825        /// many elements as
1826        /// [ShipmentModel.duration_distance_matrix_src_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags].
1827        ///
1828        /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags]: crate::model::ShipmentModel::duration_distance_matrix_src_tags
1829        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1830        pub rows: std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>,
1831
1832        /// Tag defining to which vehicles this duration and distance matrix applies.
1833        /// If empty, this applies to all vehicles, and there can only be a single
1834        /// matrix.
1835        ///
1836        /// Each vehicle start must match exactly one matrix, i.e. exactly one of
1837        /// their `start_tags` field must match the `vehicle_start_tag` of a matrix
1838        /// (and of that matrix only).
1839        ///
1840        /// All matrices must have a different `vehicle_start_tag`.
1841        #[serde(skip_serializing_if = "std::string::String::is_empty")]
1842        pub vehicle_start_tag: std::string::String,
1843
1844        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1845        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1846    }
1847
1848    impl DurationDistanceMatrix {
1849        pub fn new() -> Self {
1850            std::default::Default::default()
1851        }
1852
1853        /// Sets the value of [vehicle_start_tag][crate::model::shipment_model::DurationDistanceMatrix::vehicle_start_tag].
1854        pub fn set_vehicle_start_tag<T: std::convert::Into<std::string::String>>(
1855            mut self,
1856            v: T,
1857        ) -> Self {
1858            self.vehicle_start_tag = v.into();
1859            self
1860        }
1861
1862        /// Sets the value of [rows][crate::model::shipment_model::DurationDistanceMatrix::rows].
1863        pub fn set_rows<T, V>(mut self, v: T) -> Self
1864        where
1865            T: std::iter::IntoIterator<Item = V>,
1866            V: std::convert::Into<crate::model::shipment_model::duration_distance_matrix::Row>,
1867        {
1868            use std::iter::Iterator;
1869            self.rows = v.into_iter().map(|i| i.into()).collect();
1870            self
1871        }
1872    }
1873
1874    impl wkt::message::Message for DurationDistanceMatrix {
1875        fn typename() -> &'static str {
1876            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix"
1877        }
1878    }
1879
1880    /// Defines additional types related to [DurationDistanceMatrix].
1881    pub mod duration_distance_matrix {
1882        #[allow(unused_imports)]
1883        use super::*;
1884
1885        /// Specifies a row of the duration and distance matrix.
1886        #[serde_with::serde_as]
1887        #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1888        #[serde(default, rename_all = "camelCase")]
1889        #[non_exhaustive]
1890        pub struct Row {
1891            /// Duration values for a given row. It must have as many elements as
1892            /// [ShipmentModel.duration_distance_matrix_dst_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags].
1893            ///
1894            /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags]: crate::model::ShipmentModel::duration_distance_matrix_dst_tags
1895            #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1896            pub durations: std::vec::Vec<wkt::Duration>,
1897
1898            /// Distance values for a given row. If no costs or constraints refer to
1899            /// distances in the model, this can be left empty; otherwise it must have
1900            /// as many elements as `durations`.
1901            #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1902            pub meters: std::vec::Vec<f64>,
1903
1904            #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1905            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1906        }
1907
1908        impl Row {
1909            pub fn new() -> Self {
1910                std::default::Default::default()
1911            }
1912
1913            /// Sets the value of [durations][crate::model::shipment_model::duration_distance_matrix::Row::durations].
1914            pub fn set_durations<T, V>(mut self, v: T) -> Self
1915            where
1916                T: std::iter::IntoIterator<Item = V>,
1917                V: std::convert::Into<wkt::Duration>,
1918            {
1919                use std::iter::Iterator;
1920                self.durations = v.into_iter().map(|i| i.into()).collect();
1921                self
1922            }
1923
1924            /// Sets the value of [meters][crate::model::shipment_model::duration_distance_matrix::Row::meters].
1925            pub fn set_meters<T, V>(mut self, v: T) -> Self
1926            where
1927                T: std::iter::IntoIterator<Item = V>,
1928                V: std::convert::Into<f64>,
1929            {
1930                use std::iter::Iterator;
1931                self.meters = v.into_iter().map(|i| i.into()).collect();
1932                self
1933            }
1934        }
1935
1936        impl wkt::message::Message for Row {
1937            fn typename() -> &'static str {
1938                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix.Row"
1939            }
1940        }
1941    }
1942
1943    /// A precedence rule between two events (each event is the pickup or the
1944    /// delivery of a shipment): the "second" event has to start at least
1945    /// `offset_duration` after "first" has started.
1946    ///
1947    /// Several precedences can refer to the same (or related) events, e.g.,
1948    /// "pickup of B happens after delivery of A" and "pickup of C happens after
1949    /// pickup of B".
1950    ///
1951    /// Furthermore, precedences only apply when both shipments are performed and
1952    /// are otherwise ignored.
1953    #[serde_with::serde_as]
1954    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1955    #[serde(default, rename_all = "camelCase")]
1956    #[non_exhaustive]
1957    pub struct PrecedenceRule {
1958        /// Shipment index of the "first" event. This field must be specified.
1959        #[serde(skip_serializing_if = "std::option::Option::is_none")]
1960        pub first_index: std::option::Option<i32>,
1961
1962        /// Indicates if the "first" event is a delivery.
1963        pub first_is_delivery: bool,
1964
1965        /// Shipment index of the "second" event. This field must be specified.
1966        #[serde(skip_serializing_if = "std::option::Option::is_none")]
1967        pub second_index: std::option::Option<i32>,
1968
1969        /// Indicates if the "second" event is a delivery.
1970        pub second_is_delivery: bool,
1971
1972        /// The offset between the "first" and "second" event. It can be negative.
1973        #[serde(skip_serializing_if = "std::option::Option::is_none")]
1974        pub offset_duration: std::option::Option<wkt::Duration>,
1975
1976        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1977        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1978    }
1979
1980    impl PrecedenceRule {
1981        pub fn new() -> Self {
1982            std::default::Default::default()
1983        }
1984
1985        /// Sets the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
1986        pub fn set_first_index<T: std::convert::Into<std::option::Option<i32>>>(
1987            mut self,
1988            v: T,
1989        ) -> Self {
1990            self.first_index = v.into();
1991            self
1992        }
1993
1994        /// Sets the value of [first_is_delivery][crate::model::shipment_model::PrecedenceRule::first_is_delivery].
1995        pub fn set_first_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1996            self.first_is_delivery = v.into();
1997            self
1998        }
1999
2000        /// Sets the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2001        pub fn set_second_index<T: std::convert::Into<std::option::Option<i32>>>(
2002            mut self,
2003            v: T,
2004        ) -> Self {
2005            self.second_index = v.into();
2006            self
2007        }
2008
2009        /// Sets the value of [second_is_delivery][crate::model::shipment_model::PrecedenceRule::second_is_delivery].
2010        pub fn set_second_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2011            self.second_is_delivery = v.into();
2012            self
2013        }
2014
2015        /// Sets the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
2016        pub fn set_offset_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
2017            mut self,
2018            v: T,
2019        ) -> Self {
2020            self.offset_duration = v.into();
2021            self
2022        }
2023    }
2024
2025    impl wkt::message::Message for PrecedenceRule {
2026        fn typename() -> &'static str {
2027            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.PrecedenceRule"
2028        }
2029    }
2030
2031    /// Deprecated: Use top level
2032    /// [BreakRule][google.cloud.optimization.v1.ShipmentModel.BreakRule] instead.
2033    /// Rules to generate time breaks for a vehicle (e.g. lunch
2034    /// breaks). A break is a contiguous period of time during which the vehicle
2035    /// remains idle at its current position and cannot perform any visit. A break
2036    /// may occur:
2037    ///
2038    /// * during the travel between two visits (which includes the time right
2039    ///   before or right after a visit, but not in the middle of a visit), in
2040    ///   which case it extends the corresponding transit time between the visits
2041    /// * before the vehicle start (the vehicle may not start in the middle of
2042    ///   a break), in which case it does not affect the vehicle start time.
2043    /// * after the vehicle end (ditto, with the vehicle end time).
2044    ///
2045    /// [google.cloud.optimization.v1.ShipmentModel.BreakRule]: crate::model::shipment_model::BreakRule
2046    #[serde_with::serde_as]
2047    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2048    #[serde(default, rename_all = "camelCase")]
2049    #[non_exhaustive]
2050    pub struct BreakRule {
2051        /// Sequence of breaks. See the `BreakRequest` message.
2052        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2053        pub break_requests: std::vec::Vec<crate::model::shipment_model::break_rule::BreakRequest>,
2054
2055        /// Several `FrequencyConstraint` may apply. They must all be satisfied by
2056        /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
2057        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2058        pub frequency_constraints:
2059            std::vec::Vec<crate::model::shipment_model::break_rule::FrequencyConstraint>,
2060
2061        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
2062        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2063    }
2064
2065    impl BreakRule {
2066        pub fn new() -> Self {
2067            std::default::Default::default()
2068        }
2069
2070        /// Sets the value of [break_requests][crate::model::shipment_model::BreakRule::break_requests].
2071        pub fn set_break_requests<T, V>(mut self, v: T) -> Self
2072        where
2073            T: std::iter::IntoIterator<Item = V>,
2074            V: std::convert::Into<crate::model::shipment_model::break_rule::BreakRequest>,
2075        {
2076            use std::iter::Iterator;
2077            self.break_requests = v.into_iter().map(|i| i.into()).collect();
2078            self
2079        }
2080
2081        /// Sets the value of [frequency_constraints][crate::model::shipment_model::BreakRule::frequency_constraints].
2082        pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
2083        where
2084            T: std::iter::IntoIterator<Item = V>,
2085            V: std::convert::Into<crate::model::shipment_model::break_rule::FrequencyConstraint>,
2086        {
2087            use std::iter::Iterator;
2088            self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
2089            self
2090        }
2091    }
2092
2093    impl wkt::message::Message for BreakRule {
2094        fn typename() -> &'static str {
2095            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule"
2096        }
2097    }
2098
2099    /// Defines additional types related to [BreakRule].
2100    pub mod break_rule {
2101        #[allow(unused_imports)]
2102        use super::*;
2103
2104        /// The sequence of breaks (i.e. their number and order) that apply to each
2105        /// vehicle must be known beforehand. The repeated `BreakRequest`s define
2106        /// that sequence, in the order in which they must occur. Their time windows
2107        /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
2108        /// be compatible with the order (this is checked).
2109        #[serde_with::serde_as]
2110        #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2111        #[serde(default, rename_all = "camelCase")]
2112        #[non_exhaustive]
2113        pub struct BreakRequest {
2114            /// Required. Lower bound (inclusive) on the start of the break.
2115            #[serde(skip_serializing_if = "std::option::Option::is_none")]
2116            pub earliest_start_time: std::option::Option<wkt::Timestamp>,
2117
2118            /// Required. Upper bound (inclusive) on the start of the break.
2119            #[serde(skip_serializing_if = "std::option::Option::is_none")]
2120            pub latest_start_time: std::option::Option<wkt::Timestamp>,
2121
2122            /// Required. Minimum duration of the break. Must be positive.
2123            #[serde(skip_serializing_if = "std::option::Option::is_none")]
2124            pub min_duration: std::option::Option<wkt::Duration>,
2125
2126            #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
2127            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2128        }
2129
2130        impl BreakRequest {
2131            pub fn new() -> Self {
2132                std::default::Default::default()
2133            }
2134
2135            /// Sets the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
2136            pub fn set_earliest_start_time<
2137                T: std::convert::Into<std::option::Option<wkt::Timestamp>>,
2138            >(
2139                mut self,
2140                v: T,
2141            ) -> Self {
2142                self.earliest_start_time = v.into();
2143                self
2144            }
2145
2146            /// Sets the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
2147            pub fn set_latest_start_time<
2148                T: std::convert::Into<std::option::Option<wkt::Timestamp>>,
2149            >(
2150                mut self,
2151                v: T,
2152            ) -> Self {
2153                self.latest_start_time = v.into();
2154                self
2155            }
2156
2157            /// Sets the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
2158            pub fn set_min_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
2159                mut self,
2160                v: T,
2161            ) -> Self {
2162                self.min_duration = v.into();
2163                self
2164            }
2165        }
2166
2167        impl wkt::message::Message for BreakRequest {
2168            fn typename() -> &'static str {
2169                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.BreakRequest"
2170            }
2171        }
2172
2173        /// One may further constrain the frequency and duration of the breaks
2174        /// specified above, by enforcing a minimum break frequency, such as
2175        /// "There must be a break of at least 1 hour every 12 hours". Assuming that
2176        /// this can be interpreted as "Within any sliding time window of 12h, there
2177        /// must be at least one break of at least one hour", that example would
2178        /// translate to the following `FrequencyConstraint`:
2179        ///
2180        /// ```norust
2181        /// {
2182        ///    min_break_duration { seconds: 3600 }         # 1 hour.
2183        ///    max_inter_break_duration { seconds: 39600 }  # 11 hours (12 - 1 = 11).
2184        /// }
2185        /// ```
2186        ///
2187        /// The timing and duration of the breaks in the solution will respect all
2188        /// such constraints, in addition to the time windows and minimum durations
2189        /// already specified in the `BreakRequest`.
2190        ///
2191        /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
2192        /// For example, the following schedule honors the "1h every 12h" example:
2193        ///
2194        /// ```norust
2195        ///   04:00 vehicle start
2196        ///    .. performing travel and visits ..
2197        ///   09:00 1 hour break
2198        ///   10:00 end of the break
2199        ///    .. performing travel and visits ..
2200        ///   12:00 20-min lunch break
2201        ///   12:20 end of the break
2202        ///    .. performing travel and visits ..
2203        ///   21:00 1 hour break
2204        ///   22:00 end of the break
2205        ///    .. performing travel and visits ..
2206        ///   23:59 vehicle end
2207        /// ```
2208        #[serde_with::serde_as]
2209        #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2210        #[serde(default, rename_all = "camelCase")]
2211        #[non_exhaustive]
2212        pub struct FrequencyConstraint {
2213            /// Required. Minimum break duration for this constraint. Nonnegative.
2214            /// See description of `FrequencyConstraint`.
2215            #[serde(skip_serializing_if = "std::option::Option::is_none")]
2216            pub min_break_duration: std::option::Option<wkt::Duration>,
2217
2218            /// Required. Maximum allowed span of any interval of time in the route
2219            /// that does not include at least partially a break of `duration >=
2220            /// min_break_duration`. Must be positive.
2221            #[serde(skip_serializing_if = "std::option::Option::is_none")]
2222            pub max_inter_break_duration: std::option::Option<wkt::Duration>,
2223
2224            #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
2225            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2226        }
2227
2228        impl FrequencyConstraint {
2229            pub fn new() -> Self {
2230                std::default::Default::default()
2231            }
2232
2233            /// Sets the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
2234            pub fn set_min_break_duration<
2235                T: std::convert::Into<std::option::Option<wkt::Duration>>,
2236            >(
2237                mut self,
2238                v: T,
2239            ) -> Self {
2240                self.min_break_duration = v.into();
2241                self
2242            }
2243
2244            /// Sets the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
2245            pub fn set_max_inter_break_duration<
2246                T: std::convert::Into<std::option::Option<wkt::Duration>>,
2247            >(
2248                mut self,
2249                v: T,
2250            ) -> Self {
2251                self.max_inter_break_duration = v.into();
2252                self
2253            }
2254        }
2255
2256        impl wkt::message::Message for FrequencyConstraint {
2257            fn typename() -> &'static str {
2258                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.FrequencyConstraint"
2259            }
2260        }
2261    }
2262}
2263
2264/// The shipment of a single item, from one of its pickups to one of its
2265/// deliveries. For the shipment to be considered as performed, a unique vehicle
2266/// must visit one of its pickup locations (and decrease its spare capacities
2267/// accordingly), then visit one of its delivery locations later on (and
2268/// therefore re-increase its spare capacities accordingly).
2269#[serde_with::serde_as]
2270#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2271#[serde(default, rename_all = "camelCase")]
2272#[non_exhaustive]
2273pub struct Shipment {
2274    /// Set of pickup alternatives associated to the shipment. If not specified,
2275    /// the vehicle only needs to visit a location corresponding to the deliveries.
2276    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2277    pub pickups: std::vec::Vec<crate::model::shipment::VisitRequest>,
2278
2279    /// Set of delivery alternatives associated to the shipment. If not specified,
2280    /// the vehicle only needs to visit a location corresponding to the pickups.
2281    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2282    pub deliveries: std::vec::Vec<crate::model::shipment::VisitRequest>,
2283
2284    /// Load demands of the shipment (for example weight, volume, number of
2285    /// pallets etc). The keys in the map should be identifiers describing the type
2286    /// of the corresponding load, ideally also including the units.
2287    /// For example: "weight_kg", "volume_gallons", "pallet_count", etc.
2288    /// If a given key does not appear in the map, the corresponding load is
2289    /// considered as null.
2290    #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
2291    pub load_demands: std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
2292
2293    /// If the shipment is not completed, this penalty is added to the overall
2294    /// cost of the routes. A shipment is considered completed if one of its pickup
2295    /// and delivery alternatives is visited. The cost may be expressed in the
2296    /// same unit used for all other cost-related fields in the model and must be
2297    /// positive.
2298    ///
2299    /// *IMPORTANT*: If this penalty is not specified, it is considered infinite,
2300    /// i.e. the shipment must be completed.
2301    #[serde(skip_serializing_if = "std::option::Option::is_none")]
2302    pub penalty_cost: std::option::Option<f64>,
2303
2304    /// The set of vehicles that may perform this shipment. If empty, all vehicles
2305    /// may perform it. Vehicles are given by their index in the `ShipmentModel`'s
2306    /// `vehicles` list.
2307    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2308    pub allowed_vehicle_indices: std::vec::Vec<i32>,
2309
2310    /// Specifies the cost that is incurred when this shipment is delivered by each
2311    /// vehicle. If specified, it must have EITHER:
2312    ///
2313    /// * the same number of elements as `costs_per_vehicle_indices`.
2314    ///   `costs_per_vehicle[i]` corresponds to vehicle
2315    ///   `costs_per_vehicle_indices[i]` of the model.
2316    /// * the same number of elements as there are vehicles in the model. The
2317    ///   i-th element corresponds to vehicle #i of the model.
2318    ///
2319    /// These costs must be in the same unit as `penalty_cost` and must not be
2320    /// negative. Leave this field empty, if there are no such costs.
2321    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2322    pub costs_per_vehicle: std::vec::Vec<f64>,
2323
2324    /// Indices of the vehicles to which `costs_per_vehicle` applies. If non-empty,
2325    /// it must have the same number of elements as `costs_per_vehicle`. A vehicle
2326    /// index may not be specified more than once. If a vehicle is excluded from
2327    /// `costs_per_vehicle_indices`, its cost is zero.
2328    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2329    pub costs_per_vehicle_indices: std::vec::Vec<i32>,
2330
2331    /// Specifies the maximum relative detour time compared to the shortest path
2332    /// from pickup to delivery. If specified, it must be nonnegative, and the
2333    /// shipment must contain at least a pickup and a delivery.
2334    ///
2335    /// For example, let t be the shortest time taken to go from the selected
2336    /// pickup alternative directly to the selected delivery alternative. Then
2337    /// setting `pickup_to_delivery_relative_detour_limit` enforces:
2338    ///
2339    /// ```norust
2340    /// start_time(delivery) - start_time(pickup) <=
2341    /// std::ceil(t * (1.0 + pickup_to_delivery_relative_detour_limit))
2342    /// ```
2343    ///
2344    /// If both relative and absolute limits are specified on the same shipment,
2345    /// the more constraining limit is used for each possible pickup/delivery pair.
2346    /// As of 2017/10, detours are only supported when travel durations do not
2347    /// depend on vehicles.
2348    #[serde(skip_serializing_if = "std::option::Option::is_none")]
2349    pub pickup_to_delivery_relative_detour_limit: std::option::Option<f64>,
2350
2351    /// Specifies the maximum absolute detour time compared to the shortest path
2352    /// from pickup to delivery. If specified, it must be nonnegative, and the
2353    /// shipment must contain at least a pickup and a delivery.
2354    ///
2355    /// For example, let t be the shortest time taken to go from the selected
2356    /// pickup alternative directly to the selected delivery alternative. Then
2357    /// setting `pickup_to_delivery_absolute_detour_limit` enforces:
2358    ///
2359    /// ```norust
2360    /// start_time(delivery) - start_time(pickup) <=
2361    /// t + pickup_to_delivery_absolute_detour_limit
2362    /// ```
2363    ///
2364    /// If both relative and absolute limits are specified on the same shipment,
2365    /// the more constraining limit is used for each possible pickup/delivery pair.
2366    /// As of 2017/10, detours are only supported when travel durations do not
2367    /// depend on vehicles.
2368    #[serde(skip_serializing_if = "std::option::Option::is_none")]
2369    pub pickup_to_delivery_absolute_detour_limit: std::option::Option<wkt::Duration>,
2370
2371    /// Specifies the maximum duration from start of pickup to start of delivery of
2372    /// a shipment. If specified, it must be nonnegative, and the shipment must
2373    /// contain at least a pickup and a delivery. This does not depend on which
2374    /// alternatives are selected for pickup and delivery, nor on vehicle speed.
2375    /// This can be specified alongside maximum detour constraints: the solution
2376    /// will respect both specifications.
2377    #[serde(skip_serializing_if = "std::option::Option::is_none")]
2378    pub pickup_to_delivery_time_limit: std::option::Option<wkt::Duration>,
2379
2380    /// Non-empty string specifying a "type" for this shipment.
2381    /// This feature can be used to define incompatibilities or requirements
2382    /// between `shipment_types` (see `shipment_type_incompatibilities` and
2383    /// `shipment_type_requirements` in `ShipmentModel`).
2384    ///
2385    /// Differs from `visit_types` which is specified for a single visit: All
2386    /// pickup/deliveries belonging to the same shipment share the same
2387    /// `shipment_type`.
2388    #[serde(skip_serializing_if = "std::string::String::is_empty")]
2389    pub shipment_type: std::string::String,
2390
2391    /// Specifies a label for this shipment. This label is reported in the response
2392    /// in the `shipment_label` of the corresponding
2393    /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
2394    ///
2395    /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
2396    #[serde(skip_serializing_if = "std::string::String::is_empty")]
2397    pub label: std::string::String,
2398
2399    /// If true, skip this shipment, but don't apply a `penalty_cost`.
2400    ///
2401    /// Ignoring a shipment results in a validation error when there are any
2402    /// `shipment_type_requirements` in the model.
2403    ///
2404    /// Ignoring a shipment that is performed in `injected_first_solution_routes`
2405    /// or `injected_solution_constraint` is permitted; the solver removes the
2406    /// related pickup/delivery visits from the performing route.
2407    /// `precedence_rules` that reference ignored shipments will also be ignored.
2408    pub ignore: bool,
2409
2410    /// Deprecated: Use
2411    /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
2412    /// instead.
2413    ///
2414    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
2415    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2416    pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
2417
2418    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
2419    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2420}
2421
2422impl Shipment {
2423    pub fn new() -> Self {
2424        std::default::Default::default()
2425    }
2426
2427    /// Sets the value of [penalty_cost][crate::model::Shipment::penalty_cost].
2428    pub fn set_penalty_cost<T: std::convert::Into<std::option::Option<f64>>>(
2429        mut self,
2430        v: T,
2431    ) -> Self {
2432        self.penalty_cost = v.into();
2433        self
2434    }
2435
2436    /// Sets the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
2437    pub fn set_pickup_to_delivery_relative_detour_limit<
2438        T: std::convert::Into<std::option::Option<f64>>,
2439    >(
2440        mut self,
2441        v: T,
2442    ) -> Self {
2443        self.pickup_to_delivery_relative_detour_limit = v.into();
2444        self
2445    }
2446
2447    /// Sets the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
2448    pub fn set_pickup_to_delivery_absolute_detour_limit<
2449        T: std::convert::Into<std::option::Option<wkt::Duration>>,
2450    >(
2451        mut self,
2452        v: T,
2453    ) -> Self {
2454        self.pickup_to_delivery_absolute_detour_limit = v.into();
2455        self
2456    }
2457
2458    /// Sets the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
2459    pub fn set_pickup_to_delivery_time_limit<
2460        T: std::convert::Into<std::option::Option<wkt::Duration>>,
2461    >(
2462        mut self,
2463        v: T,
2464    ) -> Self {
2465        self.pickup_to_delivery_time_limit = v.into();
2466        self
2467    }
2468
2469    /// Sets the value of [shipment_type][crate::model::Shipment::shipment_type].
2470    pub fn set_shipment_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2471        self.shipment_type = v.into();
2472        self
2473    }
2474
2475    /// Sets the value of [label][crate::model::Shipment::label].
2476    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2477        self.label = v.into();
2478        self
2479    }
2480
2481    /// Sets the value of [ignore][crate::model::Shipment::ignore].
2482    pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2483        self.ignore = v.into();
2484        self
2485    }
2486
2487    /// Sets the value of [pickups][crate::model::Shipment::pickups].
2488    pub fn set_pickups<T, V>(mut self, v: T) -> Self
2489    where
2490        T: std::iter::IntoIterator<Item = V>,
2491        V: std::convert::Into<crate::model::shipment::VisitRequest>,
2492    {
2493        use std::iter::Iterator;
2494        self.pickups = v.into_iter().map(|i| i.into()).collect();
2495        self
2496    }
2497
2498    /// Sets the value of [deliveries][crate::model::Shipment::deliveries].
2499    pub fn set_deliveries<T, V>(mut self, v: T) -> Self
2500    where
2501        T: std::iter::IntoIterator<Item = V>,
2502        V: std::convert::Into<crate::model::shipment::VisitRequest>,
2503    {
2504        use std::iter::Iterator;
2505        self.deliveries = v.into_iter().map(|i| i.into()).collect();
2506        self
2507    }
2508
2509    /// Sets the value of [allowed_vehicle_indices][crate::model::Shipment::allowed_vehicle_indices].
2510    pub fn set_allowed_vehicle_indices<T, V>(mut self, v: T) -> Self
2511    where
2512        T: std::iter::IntoIterator<Item = V>,
2513        V: std::convert::Into<i32>,
2514    {
2515        use std::iter::Iterator;
2516        self.allowed_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
2517        self
2518    }
2519
2520    /// Sets the value of [costs_per_vehicle][crate::model::Shipment::costs_per_vehicle].
2521    pub fn set_costs_per_vehicle<T, V>(mut self, v: T) -> Self
2522    where
2523        T: std::iter::IntoIterator<Item = V>,
2524        V: std::convert::Into<f64>,
2525    {
2526        use std::iter::Iterator;
2527        self.costs_per_vehicle = v.into_iter().map(|i| i.into()).collect();
2528        self
2529    }
2530
2531    /// Sets the value of [costs_per_vehicle_indices][crate::model::Shipment::costs_per_vehicle_indices].
2532    pub fn set_costs_per_vehicle_indices<T, V>(mut self, v: T) -> Self
2533    where
2534        T: std::iter::IntoIterator<Item = V>,
2535        V: std::convert::Into<i32>,
2536    {
2537        use std::iter::Iterator;
2538        self.costs_per_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
2539        self
2540    }
2541
2542    /// Sets the value of [demands][crate::model::Shipment::demands].
2543    pub fn set_demands<T, V>(mut self, v: T) -> Self
2544    where
2545        T: std::iter::IntoIterator<Item = V>,
2546        V: std::convert::Into<crate::model::CapacityQuantity>,
2547    {
2548        use std::iter::Iterator;
2549        self.demands = v.into_iter().map(|i| i.into()).collect();
2550        self
2551    }
2552
2553    /// Sets the value of [load_demands][crate::model::Shipment::load_demands].
2554    pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
2555    where
2556        T: std::iter::IntoIterator<Item = (K, V)>,
2557        K: std::convert::Into<std::string::String>,
2558        V: std::convert::Into<crate::model::shipment::Load>,
2559    {
2560        use std::iter::Iterator;
2561        self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2562        self
2563    }
2564}
2565
2566impl wkt::message::Message for Shipment {
2567    fn typename() -> &'static str {
2568        "type.googleapis.com/google.cloud.optimization.v1.Shipment"
2569    }
2570}
2571
2572/// Defines additional types related to [Shipment].
2573pub mod shipment {
2574    #[allow(unused_imports)]
2575    use super::*;
2576
2577    /// Request for a visit which can be done by a vehicle: it has a geo-location
2578    /// (or two, see below), opening and closing times represented by time windows,
2579    /// and a service duration time (time spent by the vehicle once it has arrived
2580    /// to pickup or drop off goods).
2581    #[serde_with::serde_as]
2582    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2583    #[serde(default, rename_all = "camelCase")]
2584    #[non_exhaustive]
2585    pub struct VisitRequest {
2586        /// The geo-location where the vehicle arrives when performing this
2587        /// `VisitRequest`. If the shipment model has duration distance matrices,
2588        /// `arrival_location` must not be specified.
2589        #[serde(skip_serializing_if = "std::option::Option::is_none")]
2590        pub arrival_location: std::option::Option<gtype::model::LatLng>,
2591
2592        /// The waypoint where the vehicle arrives when performing this
2593        /// `VisitRequest`. If the shipment model has duration distance matrices,
2594        /// `arrival_waypoint` must not be specified.
2595        #[serde(skip_serializing_if = "std::option::Option::is_none")]
2596        pub arrival_waypoint: std::option::Option<crate::model::Waypoint>,
2597
2598        /// The geo-location where the vehicle departs after completing this
2599        /// `VisitRequest`. Can be omitted if it is the same as `arrival_location`.
2600        /// If the shipment model has duration distance matrices,
2601        /// `departure_location` must not be specified.
2602        #[serde(skip_serializing_if = "std::option::Option::is_none")]
2603        pub departure_location: std::option::Option<gtype::model::LatLng>,
2604
2605        /// The waypoint where the vehicle departs after completing this
2606        /// `VisitRequest`. Can be omitted if it is the same as `arrival_waypoint`.
2607        /// If the shipment model has duration distance matrices,
2608        /// `departure_waypoint` must not be specified.
2609        #[serde(skip_serializing_if = "std::option::Option::is_none")]
2610        pub departure_waypoint: std::option::Option<crate::model::Waypoint>,
2611
2612        /// Specifies tags attached to the visit request.
2613        /// Empty or duplicate strings are not allowed.
2614        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2615        pub tags: std::vec::Vec<std::string::String>,
2616
2617        /// Time windows which constrain the arrival time at a visit.
2618        /// Note that a vehicle may depart outside of the arrival time window, i.e.
2619        /// arrival time + duration do not need to be inside a time window. This can
2620        /// result in waiting time if the vehicle arrives before
2621        /// [TimeWindow.start_time][google.cloud.optimization.v1.TimeWindow.start_time].
2622        ///
2623        /// The absence of `TimeWindow` means that the vehicle can perform this visit
2624        /// at any time.
2625        ///
2626        /// Time windows must be disjoint, i.e. no time window must overlap with or
2627        /// be adjacent to another, and they must be in increasing order.
2628        ///
2629        /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only
2630        /// be set if there is a single time window.
2631        ///
2632        /// [google.cloud.optimization.v1.TimeWindow.start_time]: crate::model::TimeWindow::start_time
2633        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2634        pub time_windows: std::vec::Vec<crate::model::TimeWindow>,
2635
2636        /// Duration of the visit, i.e. time spent by the vehicle between arrival
2637        /// and departure (to be added to the possible waiting time; see
2638        /// `time_windows`).
2639        #[serde(skip_serializing_if = "std::option::Option::is_none")]
2640        pub duration: std::option::Option<wkt::Duration>,
2641
2642        /// Cost to service this visit request on a vehicle route. This can be used
2643        /// to pay different costs for each alternative pickup or delivery of a
2644        /// shipment. This cost must be in the same unit as `Shipment.penalty_cost`
2645        /// and must not be negative.
2646        pub cost: f64,
2647
2648        /// Load demands of this visit request. This is just like
2649        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
2650        /// field, except that it only applies to this
2651        /// [VisitRequest][google.cloud.optimization.v1.Shipment.VisitRequest]
2652        /// instead of the whole [Shipment][google.cloud.optimization.v1.Shipment].
2653        /// The demands listed here are added to the demands listed in
2654        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands].
2655        ///
2656        /// [google.cloud.optimization.v1.Shipment]: crate::model::Shipment
2657        /// [google.cloud.optimization.v1.Shipment.VisitRequest]: crate::model::shipment::VisitRequest
2658        /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
2659        #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
2660        pub load_demands:
2661            std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
2662
2663        /// Specifies the types of the visit. This may be used to allocate additional
2664        /// time required for a vehicle to complete this visit (see
2665        /// [Vehicle.extra_visit_duration_for_visit_type][google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]).
2666        ///
2667        /// A type can only appear once.
2668        ///
2669        /// [google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]: crate::model::Vehicle::extra_visit_duration_for_visit_type
2670        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2671        pub visit_types: std::vec::Vec<std::string::String>,
2672
2673        /// Specifies a label for this `VisitRequest`. This label is reported in the
2674        /// response as `visit_label` in the corresponding
2675        /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
2676        ///
2677        /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
2678        #[serde(skip_serializing_if = "std::string::String::is_empty")]
2679        pub label: std::string::String,
2680
2681        /// Deprecated: Use
2682        /// [VisitRequest.load_demands][google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]
2683        /// instead.
2684        ///
2685        /// [google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]: crate::model::shipment::VisitRequest::load_demands
2686        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2687        pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
2688
2689        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
2690        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2691    }
2692
2693    impl VisitRequest {
2694        pub fn new() -> Self {
2695            std::default::Default::default()
2696        }
2697
2698        /// Sets the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
2699        pub fn set_arrival_location<
2700            T: std::convert::Into<std::option::Option<gtype::model::LatLng>>,
2701        >(
2702            mut self,
2703            v: T,
2704        ) -> Self {
2705            self.arrival_location = v.into();
2706            self
2707        }
2708
2709        /// Sets the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
2710        pub fn set_arrival_waypoint<
2711            T: std::convert::Into<std::option::Option<crate::model::Waypoint>>,
2712        >(
2713            mut self,
2714            v: T,
2715        ) -> Self {
2716            self.arrival_waypoint = v.into();
2717            self
2718        }
2719
2720        /// Sets the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
2721        pub fn set_departure_location<
2722            T: std::convert::Into<std::option::Option<gtype::model::LatLng>>,
2723        >(
2724            mut self,
2725            v: T,
2726        ) -> Self {
2727            self.departure_location = v.into();
2728            self
2729        }
2730
2731        /// Sets the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
2732        pub fn set_departure_waypoint<
2733            T: std::convert::Into<std::option::Option<crate::model::Waypoint>>,
2734        >(
2735            mut self,
2736            v: T,
2737        ) -> Self {
2738            self.departure_waypoint = v.into();
2739            self
2740        }
2741
2742        /// Sets the value of [duration][crate::model::shipment::VisitRequest::duration].
2743        pub fn set_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
2744            mut self,
2745            v: T,
2746        ) -> Self {
2747            self.duration = v.into();
2748            self
2749        }
2750
2751        /// Sets the value of [cost][crate::model::shipment::VisitRequest::cost].
2752        pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2753            self.cost = v.into();
2754            self
2755        }
2756
2757        /// Sets the value of [label][crate::model::shipment::VisitRequest::label].
2758        pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2759            self.label = v.into();
2760            self
2761        }
2762
2763        /// Sets the value of [tags][crate::model::shipment::VisitRequest::tags].
2764        pub fn set_tags<T, V>(mut self, v: T) -> Self
2765        where
2766            T: std::iter::IntoIterator<Item = V>,
2767            V: std::convert::Into<std::string::String>,
2768        {
2769            use std::iter::Iterator;
2770            self.tags = v.into_iter().map(|i| i.into()).collect();
2771            self
2772        }
2773
2774        /// Sets the value of [time_windows][crate::model::shipment::VisitRequest::time_windows].
2775        pub fn set_time_windows<T, V>(mut self, v: T) -> Self
2776        where
2777            T: std::iter::IntoIterator<Item = V>,
2778            V: std::convert::Into<crate::model::TimeWindow>,
2779        {
2780            use std::iter::Iterator;
2781            self.time_windows = v.into_iter().map(|i| i.into()).collect();
2782            self
2783        }
2784
2785        /// Sets the value of [visit_types][crate::model::shipment::VisitRequest::visit_types].
2786        pub fn set_visit_types<T, V>(mut self, v: T) -> Self
2787        where
2788            T: std::iter::IntoIterator<Item = V>,
2789            V: std::convert::Into<std::string::String>,
2790        {
2791            use std::iter::Iterator;
2792            self.visit_types = v.into_iter().map(|i| i.into()).collect();
2793            self
2794        }
2795
2796        /// Sets the value of [demands][crate::model::shipment::VisitRequest::demands].
2797        pub fn set_demands<T, V>(mut self, v: T) -> Self
2798        where
2799            T: std::iter::IntoIterator<Item = V>,
2800            V: std::convert::Into<crate::model::CapacityQuantity>,
2801        {
2802            use std::iter::Iterator;
2803            self.demands = v.into_iter().map(|i| i.into()).collect();
2804            self
2805        }
2806
2807        /// Sets the value of [load_demands][crate::model::shipment::VisitRequest::load_demands].
2808        pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
2809        where
2810            T: std::iter::IntoIterator<Item = (K, V)>,
2811            K: std::convert::Into<std::string::String>,
2812            V: std::convert::Into<crate::model::shipment::Load>,
2813        {
2814            use std::iter::Iterator;
2815            self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2816            self
2817        }
2818    }
2819
2820    impl wkt::message::Message for VisitRequest {
2821        fn typename() -> &'static str {
2822            "type.googleapis.com/google.cloud.optimization.v1.Shipment.VisitRequest"
2823        }
2824    }
2825
2826    /// When performing a visit, a predefined amount may be added to the vehicle
2827    /// load if it's a pickup, or subtracted if it's a delivery. This message
2828    /// defines such amount. See
2829    /// [load_demands][google.cloud.optimization.v1.Shipment.load_demands].
2830    ///
2831    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
2832    #[serde_with::serde_as]
2833    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2834    #[serde(default, rename_all = "camelCase")]
2835    #[non_exhaustive]
2836    pub struct Load {
2837        /// The amount by which the load of the vehicle performing the corresponding
2838        /// visit will vary. Since it is an integer, users are advised to choose an
2839        /// appropriate unit to avoid loss of precision. Must be ≥ 0.
2840        #[serde_as(as = "serde_with::DisplayFromStr")]
2841        pub amount: i64,
2842
2843        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
2844        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2845    }
2846
2847    impl Load {
2848        pub fn new() -> Self {
2849            std::default::Default::default()
2850        }
2851
2852        /// Sets the value of [amount][crate::model::shipment::Load::amount].
2853        pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
2854            self.amount = v.into();
2855            self
2856        }
2857    }
2858
2859    impl wkt::message::Message for Load {
2860        fn typename() -> &'static str {
2861            "type.googleapis.com/google.cloud.optimization.v1.Shipment.Load"
2862        }
2863    }
2864}
2865
2866/// Specifies incompatibilties between shipments depending on their
2867/// shipment_type. The appearance of incompatible shipments on the same route is
2868/// restricted based on the incompatibility mode.
2869#[serde_with::serde_as]
2870#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2871#[serde(default, rename_all = "camelCase")]
2872#[non_exhaustive]
2873pub struct ShipmentTypeIncompatibility {
2874    /// List of incompatible types. Two shipments having different `shipment_types`
2875    /// among those listed are "incompatible".
2876    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2877    pub types: std::vec::Vec<std::string::String>,
2878
2879    /// Mode applied to the incompatibility.
2880    pub incompatibility_mode: crate::model::shipment_type_incompatibility::IncompatibilityMode,
2881
2882    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
2883    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2884}
2885
2886impl ShipmentTypeIncompatibility {
2887    pub fn new() -> Self {
2888        std::default::Default::default()
2889    }
2890
2891    /// Sets the value of [incompatibility_mode][crate::model::ShipmentTypeIncompatibility::incompatibility_mode].
2892    pub fn set_incompatibility_mode<
2893        T: std::convert::Into<crate::model::shipment_type_incompatibility::IncompatibilityMode>,
2894    >(
2895        mut self,
2896        v: T,
2897    ) -> Self {
2898        self.incompatibility_mode = v.into();
2899        self
2900    }
2901
2902    /// Sets the value of [types][crate::model::ShipmentTypeIncompatibility::types].
2903    pub fn set_types<T, V>(mut self, v: T) -> Self
2904    where
2905        T: std::iter::IntoIterator<Item = V>,
2906        V: std::convert::Into<std::string::String>,
2907    {
2908        use std::iter::Iterator;
2909        self.types = v.into_iter().map(|i| i.into()).collect();
2910        self
2911    }
2912}
2913
2914impl wkt::message::Message for ShipmentTypeIncompatibility {
2915    fn typename() -> &'static str {
2916        "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeIncompatibility"
2917    }
2918}
2919
2920/// Defines additional types related to [ShipmentTypeIncompatibility].
2921pub mod shipment_type_incompatibility {
2922    #[allow(unused_imports)]
2923    use super::*;
2924
2925    /// Modes defining how the appearance of incompatible shipments are restricted
2926    /// on the same route.
2927    #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
2928    pub struct IncompatibilityMode(i32);
2929
2930    impl IncompatibilityMode {
2931        /// Unspecified incompatibility mode. This value should never be used.
2932        pub const INCOMPATIBILITY_MODE_UNSPECIFIED: IncompatibilityMode =
2933            IncompatibilityMode::new(0);
2934
2935        /// In this mode, two shipments with incompatible types can never share the
2936        /// same vehicle.
2937        pub const NOT_PERFORMED_BY_SAME_VEHICLE: IncompatibilityMode = IncompatibilityMode::new(1);
2938
2939        /// For two shipments with incompatible types with the
2940        /// `NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY` incompatibility mode:
2941        ///
2942        /// * If both are pickups only (no deliveries) or deliveries only (no
2943        ///   pickups), they cannot share the same vehicle at all.
2944        /// * If one of the shipments has a delivery and the other a pickup, the two
2945        ///   shipments can share the same vehicle iff the former shipment is
2946        ///   delivered before the latter is picked up.
2947        pub const NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY: IncompatibilityMode =
2948            IncompatibilityMode::new(2);
2949
2950        /// Creates a new IncompatibilityMode instance.
2951        pub(crate) const fn new(value: i32) -> Self {
2952            Self(value)
2953        }
2954
2955        /// Gets the enum value.
2956        pub fn value(&self) -> i32 {
2957            self.0
2958        }
2959
2960        /// Gets the enum value as a string.
2961        pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
2962            match self.0 {
2963                0 => std::borrow::Cow::Borrowed("INCOMPATIBILITY_MODE_UNSPECIFIED"),
2964                1 => std::borrow::Cow::Borrowed("NOT_PERFORMED_BY_SAME_VEHICLE"),
2965                2 => std::borrow::Cow::Borrowed("NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY"),
2966                _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
2967            }
2968        }
2969
2970        /// Creates an enum value from the value name.
2971        pub fn from_str_name(name: &str) -> std::option::Option<Self> {
2972            match name {
2973                "INCOMPATIBILITY_MODE_UNSPECIFIED" => {
2974                    std::option::Option::Some(Self::INCOMPATIBILITY_MODE_UNSPECIFIED)
2975                }
2976                "NOT_PERFORMED_BY_SAME_VEHICLE" => {
2977                    std::option::Option::Some(Self::NOT_PERFORMED_BY_SAME_VEHICLE)
2978                }
2979                "NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY" => {
2980                    std::option::Option::Some(Self::NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY)
2981                }
2982                _ => std::option::Option::None,
2983            }
2984        }
2985    }
2986
2987    impl std::convert::From<i32> for IncompatibilityMode {
2988        fn from(value: i32) -> Self {
2989            Self::new(value)
2990        }
2991    }
2992
2993    impl std::default::Default for IncompatibilityMode {
2994        fn default() -> Self {
2995            Self::new(0)
2996        }
2997    }
2998}
2999
3000/// Specifies requirements between shipments based on their shipment_type.
3001/// The specifics of the requirement are defined by the requirement mode.
3002#[serde_with::serde_as]
3003#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
3004#[serde(default, rename_all = "camelCase")]
3005#[non_exhaustive]
3006pub struct ShipmentTypeRequirement {
3007    /// List of alternative shipment types required by the
3008    /// `dependent_shipment_types`.
3009    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
3010    pub required_shipment_type_alternatives: std::vec::Vec<std::string::String>,
3011
3012    /// All shipments with a type in the `dependent_shipment_types` field require
3013    /// at least one shipment of type `required_shipment_type_alternatives` to be
3014    /// visited on the same route.
3015    ///
3016    /// NOTE: Chains of requirements such that a `shipment_type` depends on itself
3017    /// are not allowed.
3018    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
3019    pub dependent_shipment_types: std::vec::Vec<std::string::String>,
3020
3021    /// Mode applied to the requirement.
3022    pub requirement_mode: crate::model::shipment_type_requirement::RequirementMode,
3023
3024    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
3025    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3026}
3027
3028impl ShipmentTypeRequirement {
3029    pub fn new() -> Self {
3030        std::default::Default::default()
3031    }
3032
3033    /// Sets the value of [requirement_mode][crate::model::ShipmentTypeRequirement::requirement_mode].
3034    pub fn set_requirement_mode<
3035        T: std::convert::Into<crate::model::shipment_type_requirement::RequirementMode>,
3036    >(
3037        mut self,
3038        v: T,
3039    ) -> Self {
3040        self.requirement_mode = v.into();
3041        self
3042    }
3043
3044    /// Sets the value of [required_shipment_type_alternatives][crate::model::ShipmentTypeRequirement::required_shipment_type_alternatives].
3045    pub fn set_required_shipment_type_alternatives<T, V>(mut self, v: T) -> Self
3046    where
3047        T: std::iter::IntoIterator<Item = V>,
3048        V: std::convert::Into<std::string::String>,
3049    {
3050        use std::iter::Iterator;
3051        self.required_shipment_type_alternatives = v.into_iter().map(|i| i.into()).collect();
3052        self
3053    }
3054
3055    /// Sets the value of [dependent_shipment_types][crate::model::ShipmentTypeRequirement::dependent_shipment_types].
3056    pub fn set_dependent_shipment_types<T, V>(mut self, v: T) -> Self
3057    where
3058        T: std::iter::IntoIterator<Item = V>,
3059        V: std::convert::Into<std::string::String>,
3060    {
3061        use std::iter::Iterator;
3062        self.dependent_shipment_types = v.into_iter().map(|i| i.into()).collect();
3063        self
3064    }
3065}
3066
3067impl wkt::message::Message for ShipmentTypeRequirement {
3068    fn typename() -> &'static str {
3069        "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeRequirement"
3070    }
3071}
3072
3073/// Defines additional types related to [ShipmentTypeRequirement].
3074pub mod shipment_type_requirement {
3075    #[allow(unused_imports)]
3076    use super::*;
3077
3078    /// Modes defining the appearance of dependent shipments on a route.
3079    #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
3080    pub struct RequirementMode(i32);
3081
3082    impl RequirementMode {
3083        /// Unspecified requirement mode. This value should never be used.
3084        pub const REQUIREMENT_MODE_UNSPECIFIED: RequirementMode = RequirementMode::new(0);
3085
3086        /// In this mode, all "dependent" shipments must share the same vehicle as at
3087        /// least one of their "required" shipments.
3088        pub const PERFORMED_BY_SAME_VEHICLE: RequirementMode = RequirementMode::new(1);
3089
3090        /// With the `IN_SAME_VEHICLE_AT_PICKUP_TIME` mode, all "dependent"
3091        /// shipments need to have at least one "required" shipment on their vehicle
3092        /// at the time of their pickup.
3093        ///
3094        /// A "dependent" shipment pickup must therefore have either:
3095        ///
3096        /// * A delivery-only "required" shipment delivered on the route after, or
3097        /// * A "required" shipment picked up on the route before it, and if the
3098        ///   "required" shipment has a delivery, this delivery must be performed
3099        ///   after the "dependent" shipment's pickup.
3100        pub const IN_SAME_VEHICLE_AT_PICKUP_TIME: RequirementMode = RequirementMode::new(2);
3101
3102        /// Same as before, except the "dependent" shipments need to have a
3103        /// "required" shipment on their vehicle at the time of their *delivery*.
3104        pub const IN_SAME_VEHICLE_AT_DELIVERY_TIME: RequirementMode = RequirementMode::new(3);
3105
3106        /// Creates a new RequirementMode instance.
3107        pub(crate) const fn new(value: i32) -> Self {
3108            Self(value)
3109        }
3110
3111        /// Gets the enum value.
3112        pub fn value(&self) -> i32 {
3113            self.0
3114        }
3115
3116        /// Gets the enum value as a string.
3117        pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
3118            match self.0 {
3119                0 => std::borrow::Cow::Borrowed("REQUIREMENT_MODE_UNSPECIFIED"),
3120                1 => std::borrow::Cow::Borrowed("PERFORMED_BY_SAME_VEHICLE"),
3121                2 => std::borrow::Cow::Borrowed("IN_SAME_VEHICLE_AT_PICKUP_TIME"),
3122                3 => std::borrow::Cow::Borrowed("IN_SAME_VEHICLE_AT_DELIVERY_TIME"),
3123                _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
3124            }
3125        }
3126
3127        /// Creates an enum value from the value name.
3128        pub fn from_str_name(name: &str) -> std::option::Option<Self> {
3129            match name {
3130                "REQUIREMENT_MODE_UNSPECIFIED" => {
3131                    std::option::Option::Some(Self::REQUIREMENT_MODE_UNSPECIFIED)
3132                }
3133                "PERFORMED_BY_SAME_VEHICLE" => {
3134                    std::option::Option::Some(Self::PERFORMED_BY_SAME_VEHICLE)
3135                }
3136                "IN_SAME_VEHICLE_AT_PICKUP_TIME" => {
3137                    std::option::Option::Some(Self::IN_SAME_VEHICLE_AT_PICKUP_TIME)
3138                }
3139                "IN_SAME_VEHICLE_AT_DELIVERY_TIME" => {
3140                    std::option::Option::Some(Self::IN_SAME_VEHICLE_AT_DELIVERY_TIME)
3141                }
3142                _ => std::option::Option::None,
3143            }
3144        }
3145    }
3146
3147    impl std::convert::From<i32> for RequirementMode {
3148        fn from(value: i32) -> Self {
3149            Self::new(value)
3150        }
3151    }
3152
3153    impl std::default::Default for RequirementMode {
3154        fn default() -> Self {
3155            Self::new(0)
3156        }
3157    }
3158}
3159
3160/// Encapsulates a set of optional conditions to satisfy when calculating
3161/// vehicle routes. This is similar to `RouteModifiers` in the Google Maps
3162/// Platform API; see:
3163/// <https://developers.google.com/maps/documentation/routes/reference/rest/v2/RouteModifiers>.
3164#[serde_with::serde_as]
3165#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
3166#[serde(default, rename_all = "camelCase")]
3167#[non_exhaustive]
3168pub struct RouteModifiers {
3169    /// Specifies whether to avoid toll roads where reasonable. Preference will be
3170    /// given to routes not containing toll roads. Applies only to motorized travel
3171    /// modes.
3172    pub avoid_tolls: bool,
3173
3174    /// Specifies whether to avoid highways where reasonable. Preference will be
3175    /// given to routes not containing highways. Applies only to motorized travel
3176    /// modes.
3177    pub avoid_highways: bool,
3178
3179    /// Specifies whether to avoid ferries where reasonable. Preference will be
3180    /// given to routes not containing travel by ferries. Applies only to motorized
3181    /// travel modes.
3182    pub avoid_ferries: bool,
3183
3184    /// Optional. Specifies whether to avoid navigating indoors where reasonable.
3185    /// Preference will be given to routes not containing indoor navigation.
3186    /// Applies only to the `WALKING` travel mode.
3187    pub avoid_indoor: bool,
3188
3189    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
3190    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3191}
3192
3193impl RouteModifiers {
3194    pub fn new() -> Self {
3195        std::default::Default::default()
3196    }
3197
3198    /// Sets the value of [avoid_tolls][crate::model::RouteModifiers::avoid_tolls].
3199    pub fn set_avoid_tolls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3200        self.avoid_tolls = v.into();
3201        self
3202    }
3203
3204    /// Sets the value of [avoid_highways][crate::model::RouteModifiers::avoid_highways].
3205    pub fn set_avoid_highways<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3206        self.avoid_highways = v.into();
3207        self
3208    }
3209
3210    /// Sets the value of [avoid_ferries][crate::model::RouteModifiers::avoid_ferries].
3211    pub fn set_avoid_ferries<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3212        self.avoid_ferries = v.into();
3213        self
3214    }
3215
3216    /// Sets the value of [avoid_indoor][crate::model::RouteModifiers::avoid_indoor].
3217    pub fn set_avoid_indoor<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3218        self.avoid_indoor = v.into();
3219        self
3220    }
3221}
3222
3223impl wkt::message::Message for RouteModifiers {
3224    fn typename() -> &'static str {
3225        "type.googleapis.com/google.cloud.optimization.v1.RouteModifiers"
3226    }
3227}
3228
3229/// Models a vehicle in a shipment problem. Solving a shipment problem will
3230/// build a route starting from `start_location` and ending at `end_location`
3231/// for this vehicle. A route is a sequence of visits (see `ShipmentRoute`).
3232#[serde_with::serde_as]
3233#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
3234#[serde(default, rename_all = "camelCase")]
3235#[non_exhaustive]
3236pub struct Vehicle {
3237    /// The travel mode which affects the roads usable by the vehicle and its
3238    /// speed. See also `travel_duration_multiple`.
3239    pub travel_mode: crate::model::vehicle::TravelMode,
3240
3241    /// Optional. A set of conditions to satisfy that affect the way routes are
3242    /// calculated for the given vehicle.
3243    #[serde(skip_serializing_if = "std::option::Option::is_none")]
3244    pub route_modifiers: std::option::Option<crate::model::RouteModifiers>,
3245
3246    /// Geographic location where the vehicle starts before picking up any
3247    /// shipments. If not specified, the vehicle starts at its first pickup.
3248    /// If the shipment model has duration and distance matrices, `start_location`
3249    /// must not be specified.
3250    #[serde(skip_serializing_if = "std::option::Option::is_none")]
3251    pub start_location: std::option::Option<gtype::model::LatLng>,
3252
3253    /// Waypoint representing a geographic location where the vehicle starts before
3254    /// picking up any shipments. If neither `start_waypoint` nor `start_location`
3255    /// is specified, the vehicle starts at its first pickup.
3256    /// If the shipment model has duration and distance matrices, `start_waypoint`
3257    /// must not be specified.
3258    #[serde(skip_serializing_if = "std::option::Option::is_none")]
3259    pub start_waypoint: std::option::Option<crate::model::Waypoint>,
3260
3261    /// Geographic location where the vehicle ends after it has completed its last
3262    /// `VisitRequest`. If not specified the vehicle's `ShipmentRoute` ends
3263    /// immediately when it completes its last `VisitRequest`.
3264    /// If the shipment model has duration and distance matrices, `end_location`
3265    /// must not be specified.
3266    #[serde(skip_serializing_if = "std::option::Option::is_none")]
3267    pub end_location: std::option::Option<gtype::model::LatLng>,
3268
3269    /// Waypoint representing a geographic location where the vehicle ends after
3270    /// it has completed its last `VisitRequest`. If neither `end_waypoint` nor
3271    /// `end_location` is specified, the vehicle's `ShipmentRoute` ends immediately
3272    /// when it completes its last `VisitRequest`.
3273    /// If the shipment model has duration and distance matrices, `end_waypoint`
3274    /// must not be specified.
3275    #[serde(skip_serializing_if = "std::option::Option::is_none")]
3276    pub end_waypoint: std::option::Option<crate::model::Waypoint>,
3277
3278    /// Specifies tags attached to the start of the vehicle's route.
3279    ///
3280    /// Empty or duplicate strings are not allowed.
3281    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
3282    pub start_tags: std::vec::Vec<std::string::String>,
3283
3284    /// Specifies tags attached to the end of the vehicle's route.
3285    ///
3286    /// Empty or duplicate strings are not allowed.
3287    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
3288    pub end_tags: std::vec::Vec<std::string::String>,
3289
3290    /// Time windows during which the vehicle may depart its start location.
3291    /// They must be within the global time limits (see
3292    /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
3293    /// fields). If unspecified, there is no limitation besides those global time
3294    /// limits.
3295    ///
3296    /// Time windows belonging to the same repeated field must be disjoint, i.e. no
3297    /// time window can overlap with or be adjacent to another, and they must be in
3298    /// chronological order.
3299    ///
3300    /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
3301    /// there is a single time window.
3302    ///
3303    /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
3304    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
3305    pub start_time_windows: std::vec::Vec<crate::model::TimeWindow>,
3306
3307    /// Time windows during which the vehicle may arrive at its end location.
3308    /// They must be within the global time limits (see
3309    /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
3310    /// fields). If unspecified, there is no limitation besides those global time
3311    /// limits.
3312    ///
3313    /// Time windows belonging to the same repeated field must be disjoint, i.e. no
3314    /// time window can overlap with or be adjacent to another, and they must be in
3315    /// chronological order.
3316    ///
3317    /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
3318    /// there is a single time window.
3319    ///
3320    /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
3321    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
3322    pub end_time_windows: std::vec::Vec<crate::model::TimeWindow>,
3323
3324    /// Specifies a multiplicative factor that can be used to increase or decrease
3325    /// travel times of this vehicle. For example, setting this to 2.0 means
3326    /// that this vehicle is slower and has travel times that are twice what they
3327    /// are for standard vehicles. This multiple does not affect visit durations.
3328    /// It does affect cost if `cost_per_hour` or `cost_per_traveled_hour` are
3329    /// specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle
3330    /// is standard, and this multiple is considered 1.0.
3331    ///
3332    /// WARNING: Travel times will be rounded to the nearest second after this
3333    /// multiple is applied but before performing any numerical operations, thus,
3334    /// a small multiple may result in a loss of precision.
3335    ///
3336    /// See also `extra_visit_duration_for_visit_type` below.
3337    #[serde(skip_serializing_if = "std::option::Option::is_none")]
3338    pub travel_duration_multiple: std::option::Option<f64>,
3339
3340    /// Unloading policy enforced on the vehicle.
3341    pub unloading_policy: crate::model::vehicle::UnloadingPolicy,
3342
3343    /// Capacities of the vehicle (weight, volume, # of pallets for example).
3344    /// The keys in the map are the identifiers of the type of load, consistent
3345    /// with the keys of the
3346    /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
3347    /// field. If a given key is absent from this map, the corresponding capacity
3348    /// is considered to be limitless.
3349    ///
3350    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3351    #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
3352    pub load_limits:
3353        std::collections::HashMap<std::string::String, crate::model::vehicle::LoadLimit>,
3354
3355    /// Vehicle costs: all costs add up and must be in the same unit as
3356    /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
3357    ///
3358    /// Cost per hour of the vehicle route. This cost is applied to the total time
3359    /// taken by the route, and includes travel time, waiting time, and visit time.
3360    /// Using `cost_per_hour` instead of just `cost_per_traveled_hour` may result
3361    /// in additional latency.
3362    ///
3363    /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
3364    pub cost_per_hour: f64,
3365
3366    /// Cost per traveled hour of the vehicle route. This cost is applied only to
3367    /// travel time taken by the route (i.e., that reported in
3368    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]),
3369    /// and excludes waiting time and visit time.
3370    ///
3371    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
3372    pub cost_per_traveled_hour: f64,
3373
3374    /// Cost per kilometer of the vehicle route. This cost is applied to the
3375    /// distance reported in the
3376    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
3377    /// and does not apply to any distance implicitly traveled from the
3378    /// `arrival_location` to the `departure_location` of a single `VisitRequest`.
3379    ///
3380    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
3381    pub cost_per_kilometer: f64,
3382
3383    /// Fixed cost applied if this vehicle is used to handle a shipment.
3384    pub fixed_cost: f64,
3385
3386    /// This field only applies to vehicles when their route does not serve any
3387    /// shipments. It indicates if the vehicle should be considered as used or not
3388    /// in this case.
3389    ///
3390    /// If true, the vehicle goes from its start to its end location even if it
3391    /// doesn't serve any shipments, and time and distance costs resulting from its
3392    /// start --> end travel are taken into account.
3393    ///
3394    /// Otherwise, it doesn't travel from its start to its end location, and no
3395    /// `break_rule` or delay (from `TransitionAttributes`) are scheduled for this
3396    /// vehicle. In this case, the vehicle's `ShipmentRoute` doesn't contain any
3397    /// information except for the vehicle index and label.
3398    pub used_if_route_is_empty: bool,
3399
3400    /// Limit applied to the total duration of the vehicle's route. In a given
3401    /// `OptimizeToursResponse`, the route duration of a vehicle is the
3402    /// difference between its `vehicle_end_time` and `vehicle_start_time`.
3403    #[serde(skip_serializing_if = "std::option::Option::is_none")]
3404    pub route_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
3405
3406    /// Limit applied to the travel duration of the vehicle's route. In a given
3407    /// `OptimizeToursResponse`, the route travel duration is the sum of all its
3408    /// [transitions.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration].
3409    ///
3410    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
3411    #[serde(skip_serializing_if = "std::option::Option::is_none")]
3412    pub travel_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
3413
3414    /// Limit applied to the total distance of the vehicle's route. In a given
3415    /// `OptimizeToursResponse`, the route distance is the sum of all its
3416    /// [transitions.travel_distance_meters][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters].
3417    ///
3418    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters]: crate::model::shipment_route::Transition::travel_distance_meters
3419    #[serde(skip_serializing_if = "std::option::Option::is_none")]
3420    pub route_distance_limit: std::option::Option<crate::model::DistanceLimit>,
3421
3422    /// Specifies a map from visit_types strings to durations. The duration is time
3423    /// in addition to
3424    /// [VisitRequest.duration][google.cloud.optimization.v1.Shipment.VisitRequest.duration]
3425    /// to be taken at visits with the specified `visit_types`. This extra visit
3426    /// duration adds cost if `cost_per_hour` is specified. Keys (i.e.
3427    /// `visit_types`) cannot be empty strings.
3428    ///
3429    /// If a visit request has multiple types, a duration will be added for each
3430    /// type in the map.
3431    ///
3432    /// [google.cloud.optimization.v1.Shipment.VisitRequest.duration]: crate::model::shipment::VisitRequest::duration
3433    #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
3434    pub extra_visit_duration_for_visit_type:
3435        std::collections::HashMap<std::string::String, wkt::Duration>,
3436
3437    /// Describes the break schedule to be enforced on this vehicle.
3438    /// If empty, no breaks will be scheduled for this vehicle.
3439    #[serde(skip_serializing_if = "std::option::Option::is_none")]
3440    pub break_rule: std::option::Option<crate::model::BreakRule>,
3441
3442    /// Specifies a label for this vehicle. This label is reported in the response
3443    /// as the `vehicle_label` of the corresponding
3444    /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
3445    ///
3446    /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
3447    #[serde(skip_serializing_if = "std::string::String::is_empty")]
3448    pub label: std::string::String,
3449
3450    /// If true, `used_if_route_is_empty` must be false, and this vehicle will
3451    /// remain unused.
3452    ///
3453    /// If a shipment is performed by an ignored vehicle in
3454    /// `injected_first_solution_routes`, it is skipped in the first solution but
3455    /// is free to be performed in the response.
3456    ///
3457    /// If a shipment is performed by an ignored vehicle in
3458    /// `injected_solution_constraint` and any related pickup/delivery is
3459    /// constrained to remain on the vehicle (i.e., not relaxed to level
3460    /// `RELAX_ALL_AFTER_THRESHOLD`), it is skipped in the response.
3461    /// If a shipment has a non-empty `allowed_vehicle_indices` field and all of
3462    /// the allowed vehicles are ignored, it is skipped in the response.
3463    pub ignore: bool,
3464
3465    /// Deprecated: No longer used.
3466    /// Indices in the `break_rule` field in the source
3467    /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel]. They
3468    /// correspond to break rules enforced on the vehicle.
3469    ///
3470    /// As of 2018/03, at most one rule index per vehicle can be specified.
3471    ///
3472    /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
3473    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
3474    pub break_rule_indices: std::vec::Vec<i32>,
3475
3476    /// Deprecated: Use
3477    /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits]
3478    /// instead.
3479    ///
3480    /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
3481    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
3482    pub capacities: std::vec::Vec<crate::model::CapacityQuantity>,
3483
3484    /// Deprecated: Use
3485    /// [Vehicle.LoadLimit.start_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]
3486    /// instead.
3487    ///
3488    /// [google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]: crate::model::vehicle::LoadLimit::start_load_interval
3489    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
3490    pub start_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
3491
3492    /// Deprecated: Use
3493    /// [Vehicle.LoadLimit.end_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]
3494    /// instead.
3495    ///
3496    /// [google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]: crate::model::vehicle::LoadLimit::end_load_interval
3497    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
3498    pub end_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
3499
3500    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
3501    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3502}
3503
3504impl Vehicle {
3505    pub fn new() -> Self {
3506        std::default::Default::default()
3507    }
3508
3509    /// Sets the value of [travel_mode][crate::model::Vehicle::travel_mode].
3510    pub fn set_travel_mode<T: std::convert::Into<crate::model::vehicle::TravelMode>>(
3511        mut self,
3512        v: T,
3513    ) -> Self {
3514        self.travel_mode = v.into();
3515        self
3516    }
3517
3518    /// Sets the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
3519    pub fn set_route_modifiers<
3520        T: std::convert::Into<std::option::Option<crate::model::RouteModifiers>>,
3521    >(
3522        mut self,
3523        v: T,
3524    ) -> Self {
3525        self.route_modifiers = v.into();
3526        self
3527    }
3528
3529    /// Sets the value of [start_location][crate::model::Vehicle::start_location].
3530    pub fn set_start_location<T: std::convert::Into<std::option::Option<gtype::model::LatLng>>>(
3531        mut self,
3532        v: T,
3533    ) -> Self {
3534        self.start_location = v.into();
3535        self
3536    }
3537
3538    /// Sets the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
3539    pub fn set_start_waypoint<
3540        T: std::convert::Into<std::option::Option<crate::model::Waypoint>>,
3541    >(
3542        mut self,
3543        v: T,
3544    ) -> Self {
3545        self.start_waypoint = v.into();
3546        self
3547    }
3548
3549    /// Sets the value of [end_location][crate::model::Vehicle::end_location].
3550    pub fn set_end_location<T: std::convert::Into<std::option::Option<gtype::model::LatLng>>>(
3551        mut self,
3552        v: T,
3553    ) -> Self {
3554        self.end_location = v.into();
3555        self
3556    }
3557
3558    /// Sets the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
3559    pub fn set_end_waypoint<T: std::convert::Into<std::option::Option<crate::model::Waypoint>>>(
3560        mut self,
3561        v: T,
3562    ) -> Self {
3563        self.end_waypoint = v.into();
3564        self
3565    }
3566
3567    /// Sets the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
3568    pub fn set_travel_duration_multiple<T: std::convert::Into<std::option::Option<f64>>>(
3569        mut self,
3570        v: T,
3571    ) -> Self {
3572        self.travel_duration_multiple = v.into();
3573        self
3574    }
3575
3576    /// Sets the value of [unloading_policy][crate::model::Vehicle::unloading_policy].
3577    pub fn set_unloading_policy<T: std::convert::Into<crate::model::vehicle::UnloadingPolicy>>(
3578        mut self,
3579        v: T,
3580    ) -> Self {
3581        self.unloading_policy = v.into();
3582        self
3583    }
3584
3585    /// Sets the value of [cost_per_hour][crate::model::Vehicle::cost_per_hour].
3586    pub fn set_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3587        self.cost_per_hour = v.into();
3588        self
3589    }
3590
3591    /// Sets the value of [cost_per_traveled_hour][crate::model::Vehicle::cost_per_traveled_hour].
3592    pub fn set_cost_per_traveled_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3593        self.cost_per_traveled_hour = v.into();
3594        self
3595    }
3596
3597    /// Sets the value of [cost_per_kilometer][crate::model::Vehicle::cost_per_kilometer].
3598    pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3599        self.cost_per_kilometer = v.into();
3600        self
3601    }
3602
3603    /// Sets the value of [fixed_cost][crate::model::Vehicle::fixed_cost].
3604    pub fn set_fixed_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3605        self.fixed_cost = v.into();
3606        self
3607    }
3608
3609    /// Sets the value of [used_if_route_is_empty][crate::model::Vehicle::used_if_route_is_empty].
3610    pub fn set_used_if_route_is_empty<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3611        self.used_if_route_is_empty = v.into();
3612        self
3613    }
3614
3615    /// Sets the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
3616    pub fn set_route_duration_limit<
3617        T: std::convert::Into<std::option::Option<crate::model::vehicle::DurationLimit>>,
3618    >(
3619        mut self,
3620        v: T,
3621    ) -> Self {
3622        self.route_duration_limit = v.into();
3623        self
3624    }
3625
3626    /// Sets the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
3627    pub fn set_travel_duration_limit<
3628        T: std::convert::Into<std::option::Option<crate::model::vehicle::DurationLimit>>,
3629    >(
3630        mut self,
3631        v: T,
3632    ) -> Self {
3633        self.travel_duration_limit = v.into();
3634        self
3635    }
3636
3637    /// Sets the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
3638    pub fn set_route_distance_limit<
3639        T: std::convert::Into<std::option::Option<crate::model::DistanceLimit>>,
3640    >(
3641        mut self,
3642        v: T,
3643    ) -> Self {
3644        self.route_distance_limit = v.into();
3645        self
3646    }
3647
3648    /// Sets the value of [break_rule][crate::model::Vehicle::break_rule].
3649    pub fn set_break_rule<T: std::convert::Into<std::option::Option<crate::model::BreakRule>>>(
3650        mut self,
3651        v: T,
3652    ) -> Self {
3653        self.break_rule = v.into();
3654        self
3655    }
3656
3657    /// Sets the value of [label][crate::model::Vehicle::label].
3658    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3659        self.label = v.into();
3660        self
3661    }
3662
3663    /// Sets the value of [ignore][crate::model::Vehicle::ignore].
3664    pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3665        self.ignore = v.into();
3666        self
3667    }
3668
3669    /// Sets the value of [start_tags][crate::model::Vehicle::start_tags].
3670    pub fn set_start_tags<T, V>(mut self, v: T) -> Self
3671    where
3672        T: std::iter::IntoIterator<Item = V>,
3673        V: std::convert::Into<std::string::String>,
3674    {
3675        use std::iter::Iterator;
3676        self.start_tags = v.into_iter().map(|i| i.into()).collect();
3677        self
3678    }
3679
3680    /// Sets the value of [end_tags][crate::model::Vehicle::end_tags].
3681    pub fn set_end_tags<T, V>(mut self, v: T) -> Self
3682    where
3683        T: std::iter::IntoIterator<Item = V>,
3684        V: std::convert::Into<std::string::String>,
3685    {
3686        use std::iter::Iterator;
3687        self.end_tags = v.into_iter().map(|i| i.into()).collect();
3688        self
3689    }
3690
3691    /// Sets the value of [start_time_windows][crate::model::Vehicle::start_time_windows].
3692    pub fn set_start_time_windows<T, V>(mut self, v: T) -> Self
3693    where
3694        T: std::iter::IntoIterator<Item = V>,
3695        V: std::convert::Into<crate::model::TimeWindow>,
3696    {
3697        use std::iter::Iterator;
3698        self.start_time_windows = v.into_iter().map(|i| i.into()).collect();
3699        self
3700    }
3701
3702    /// Sets the value of [end_time_windows][crate::model::Vehicle::end_time_windows].
3703    pub fn set_end_time_windows<T, V>(mut self, v: T) -> Self
3704    where
3705        T: std::iter::IntoIterator<Item = V>,
3706        V: std::convert::Into<crate::model::TimeWindow>,
3707    {
3708        use std::iter::Iterator;
3709        self.end_time_windows = v.into_iter().map(|i| i.into()).collect();
3710        self
3711    }
3712
3713    /// Sets the value of [break_rule_indices][crate::model::Vehicle::break_rule_indices].
3714    pub fn set_break_rule_indices<T, V>(mut self, v: T) -> Self
3715    where
3716        T: std::iter::IntoIterator<Item = V>,
3717        V: std::convert::Into<i32>,
3718    {
3719        use std::iter::Iterator;
3720        self.break_rule_indices = v.into_iter().map(|i| i.into()).collect();
3721        self
3722    }
3723
3724    /// Sets the value of [capacities][crate::model::Vehicle::capacities].
3725    pub fn set_capacities<T, V>(mut self, v: T) -> Self
3726    where
3727        T: std::iter::IntoIterator<Item = V>,
3728        V: std::convert::Into<crate::model::CapacityQuantity>,
3729    {
3730        use std::iter::Iterator;
3731        self.capacities = v.into_iter().map(|i| i.into()).collect();
3732        self
3733    }
3734
3735    /// Sets the value of [start_load_intervals][crate::model::Vehicle::start_load_intervals].
3736    pub fn set_start_load_intervals<T, V>(mut self, v: T) -> Self
3737    where
3738        T: std::iter::IntoIterator<Item = V>,
3739        V: std::convert::Into<crate::model::CapacityQuantityInterval>,
3740    {
3741        use std::iter::Iterator;
3742        self.start_load_intervals = v.into_iter().map(|i| i.into()).collect();
3743        self
3744    }
3745
3746    /// Sets the value of [end_load_intervals][crate::model::Vehicle::end_load_intervals].
3747    pub fn set_end_load_intervals<T, V>(mut self, v: T) -> Self
3748    where
3749        T: std::iter::IntoIterator<Item = V>,
3750        V: std::convert::Into<crate::model::CapacityQuantityInterval>,
3751    {
3752        use std::iter::Iterator;
3753        self.end_load_intervals = v.into_iter().map(|i| i.into()).collect();
3754        self
3755    }
3756
3757    /// Sets the value of [load_limits][crate::model::Vehicle::load_limits].
3758    pub fn set_load_limits<T, K, V>(mut self, v: T) -> Self
3759    where
3760        T: std::iter::IntoIterator<Item = (K, V)>,
3761        K: std::convert::Into<std::string::String>,
3762        V: std::convert::Into<crate::model::vehicle::LoadLimit>,
3763    {
3764        use std::iter::Iterator;
3765        self.load_limits = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3766        self
3767    }
3768
3769    /// Sets the value of [extra_visit_duration_for_visit_type][crate::model::Vehicle::extra_visit_duration_for_visit_type].
3770    pub fn set_extra_visit_duration_for_visit_type<T, K, V>(mut self, v: T) -> Self
3771    where
3772        T: std::iter::IntoIterator<Item = (K, V)>,
3773        K: std::convert::Into<std::string::String>,
3774        V: std::convert::Into<wkt::Duration>,
3775    {
3776        use std::iter::Iterator;
3777        self.extra_visit_duration_for_visit_type =
3778            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3779        self
3780    }
3781}
3782
3783impl wkt::message::Message for Vehicle {
3784    fn typename() -> &'static str {
3785        "type.googleapis.com/google.cloud.optimization.v1.Vehicle"
3786    }
3787}
3788
3789/// Defines additional types related to [Vehicle].
3790pub mod vehicle {
3791    #[allow(unused_imports)]
3792    use super::*;
3793
3794    /// Defines a load limit applying to a vehicle, e.g. "this truck may only
3795    /// carry up to 3500 kg". See
3796    /// [load_limits][google.cloud.optimization.v1.Vehicle.load_limits].
3797    ///
3798    /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
3799    #[serde_with::serde_as]
3800    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
3801    #[serde(default, rename_all = "camelCase")]
3802    #[non_exhaustive]
3803    pub struct LoadLimit {
3804        /// The maximum acceptable amount of load.
3805        #[serde(skip_serializing_if = "std::option::Option::is_none")]
3806        #[serde_as(as = "std::option::Option<serde_with::DisplayFromStr>")]
3807        pub max_load: std::option::Option<i64>,
3808
3809        /// A soft limit of the load. See
3810        /// [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max].
3811        ///
3812        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
3813        #[serde_as(as = "serde_with::DisplayFromStr")]
3814        pub soft_max_load: i64,
3815
3816        /// If the load ever exceeds
3817        /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]
3818        /// along this vehicle's route, the following cost penalty applies (only once
3819        /// per vehicle): (load -
3820        /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load])
3821        ///
3822        /// * [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. All costs
3823        ///   add up and must be in the same unit as
3824        ///   [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
3825        ///
3826        /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
3827        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
3828        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]: crate::model::vehicle::LoadLimit::soft_max_load
3829        pub cost_per_unit_above_soft_max: f64,
3830
3831        /// The acceptable load interval of the vehicle at the start of the route.
3832        #[serde(skip_serializing_if = "std::option::Option::is_none")]
3833        pub start_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
3834
3835        /// The acceptable load interval of the vehicle at the end of the route.
3836        #[serde(skip_serializing_if = "std::option::Option::is_none")]
3837        pub end_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
3838
3839        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
3840        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3841    }
3842
3843    impl LoadLimit {
3844        pub fn new() -> Self {
3845            std::default::Default::default()
3846        }
3847
3848        /// Sets the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
3849        pub fn set_max_load<T: std::convert::Into<std::option::Option<i64>>>(
3850            mut self,
3851            v: T,
3852        ) -> Self {
3853            self.max_load = v.into();
3854            self
3855        }
3856
3857        /// Sets the value of [soft_max_load][crate::model::vehicle::LoadLimit::soft_max_load].
3858        pub fn set_soft_max_load<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
3859            self.soft_max_load = v.into();
3860            self
3861        }
3862
3863        /// Sets the value of [cost_per_unit_above_soft_max][crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max].
3864        pub fn set_cost_per_unit_above_soft_max<T: std::convert::Into<f64>>(
3865            mut self,
3866            v: T,
3867        ) -> Self {
3868            self.cost_per_unit_above_soft_max = v.into();
3869            self
3870        }
3871
3872        /// Sets the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
3873        pub fn set_start_load_interval<
3874            T: std::convert::Into<std::option::Option<crate::model::vehicle::load_limit::Interval>>,
3875        >(
3876            mut self,
3877            v: T,
3878        ) -> Self {
3879            self.start_load_interval = v.into();
3880            self
3881        }
3882
3883        /// Sets the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
3884        pub fn set_end_load_interval<
3885            T: std::convert::Into<std::option::Option<crate::model::vehicle::load_limit::Interval>>,
3886        >(
3887            mut self,
3888            v: T,
3889        ) -> Self {
3890            self.end_load_interval = v.into();
3891            self
3892        }
3893    }
3894
3895    impl wkt::message::Message for LoadLimit {
3896        fn typename() -> &'static str {
3897            "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit"
3898        }
3899    }
3900
3901    /// Defines additional types related to [LoadLimit].
3902    pub mod load_limit {
3903        #[allow(unused_imports)]
3904        use super::*;
3905
3906        /// Interval of acceptable load amounts.
3907        #[serde_with::serde_as]
3908        #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
3909        #[serde(default, rename_all = "camelCase")]
3910        #[non_exhaustive]
3911        pub struct Interval {
3912            /// A minimum acceptable load. Must be ≥ 0.
3913            /// If they're both specified,
3914            /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
3915            /// be ≤
3916            /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
3917            ///
3918            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
3919            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
3920            #[serde_as(as = "serde_with::DisplayFromStr")]
3921            pub min: i64,
3922
3923            /// A maximum acceptable load. Must be ≥ 0. If unspecified, the maximum
3924            /// load is unrestricted by this message.
3925            /// If they're both specified,
3926            /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
3927            /// be ≤
3928            /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
3929            ///
3930            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
3931            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
3932            #[serde(skip_serializing_if = "std::option::Option::is_none")]
3933            #[serde_as(as = "std::option::Option<serde_with::DisplayFromStr>")]
3934            pub max: std::option::Option<i64>,
3935
3936            #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
3937            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3938        }
3939
3940        impl Interval {
3941            pub fn new() -> Self {
3942                std::default::Default::default()
3943            }
3944
3945            /// Sets the value of [min][crate::model::vehicle::load_limit::Interval::min].
3946            pub fn set_min<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
3947                self.min = v.into();
3948                self
3949            }
3950
3951            /// Sets the value of [max][crate::model::vehicle::load_limit::Interval::max].
3952            pub fn set_max<T: std::convert::Into<std::option::Option<i64>>>(
3953                mut self,
3954                v: T,
3955            ) -> Self {
3956                self.max = v.into();
3957                self
3958            }
3959        }
3960
3961        impl wkt::message::Message for Interval {
3962            fn typename() -> &'static str {
3963                "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit.Interval"
3964            }
3965        }
3966    }
3967
3968    /// A limit defining a maximum duration of the route of a vehicle. It can be
3969    /// either hard or soft.
3970    ///
3971    /// When a soft limit field is defined, both the soft max threshold and its
3972    /// associated cost must be defined together.
3973    #[serde_with::serde_as]
3974    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
3975    #[serde(default, rename_all = "camelCase")]
3976    #[non_exhaustive]
3977    pub struct DurationLimit {
3978        /// A hard limit constraining the duration to be at most max_duration.
3979        #[serde(skip_serializing_if = "std::option::Option::is_none")]
3980        pub max_duration: std::option::Option<wkt::Duration>,
3981
3982        /// A soft limit not enforcing a maximum duration limit, but when violated
3983        /// makes the route incur a cost. This cost adds up to other costs defined in
3984        /// the model, with the same unit.
3985        ///
3986        /// If defined, `soft_max_duration` must be nonnegative. If max_duration is
3987        /// also defined, `soft_max_duration` must be less than max_duration.
3988        #[serde(skip_serializing_if = "std::option::Option::is_none")]
3989        pub soft_max_duration: std::option::Option<wkt::Duration>,
3990
3991        /// Cost per hour incurred if the `soft_max_duration` threshold is violated.
3992        /// The additional cost is 0 if the duration is under the threshold,
3993        /// otherwise the cost depends on the duration as follows:
3994        ///
3995        /// ```norust
3996        ///   cost_per_hour_after_soft_max * (duration - soft_max_duration)
3997        /// ```
3998        ///
3999        /// The cost must be nonnegative.
4000        #[serde(skip_serializing_if = "std::option::Option::is_none")]
4001        pub cost_per_hour_after_soft_max: std::option::Option<f64>,
4002
4003        /// A soft limit not enforcing a maximum duration limit, but when violated
4004        /// makes the route incur a cost, quadratic in the duration. This cost adds
4005        /// up to other costs defined in the model, with the same unit.
4006        ///
4007        /// If defined, `quadratic_soft_max_duration` must be nonnegative. If
4008        /// `max_duration` is also defined, `quadratic_soft_max_duration` must be
4009        /// less than `max_duration`, and the difference must be no larger than one
4010        /// day:
4011        ///
4012        /// `max_duration - quadratic_soft_max_duration <= 86400 seconds`
4013        #[serde(skip_serializing_if = "std::option::Option::is_none")]
4014        pub quadratic_soft_max_duration: std::option::Option<wkt::Duration>,
4015
4016        /// Cost per square hour incurred if the
4017        /// `quadratic_soft_max_duration` threshold is violated.
4018        ///
4019        /// The additional cost is 0 if the duration is under the threshold,
4020        /// otherwise the cost depends on the duration as follows:
4021        ///
4022        /// ```norust
4023        ///   cost_per_square_hour_after_quadratic_soft_max *
4024        ///   (duration - quadratic_soft_max_duration)^2
4025        /// ```
4026        ///
4027        /// The cost must be nonnegative.
4028        #[serde(skip_serializing_if = "std::option::Option::is_none")]
4029        pub cost_per_square_hour_after_quadratic_soft_max: std::option::Option<f64>,
4030
4031        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
4032        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4033    }
4034
4035    impl DurationLimit {
4036        pub fn new() -> Self {
4037            std::default::Default::default()
4038        }
4039
4040        /// Sets the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
4041        pub fn set_max_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
4042            mut self,
4043            v: T,
4044        ) -> Self {
4045            self.max_duration = v.into();
4046            self
4047        }
4048
4049        /// Sets the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
4050        pub fn set_soft_max_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
4051            mut self,
4052            v: T,
4053        ) -> Self {
4054            self.soft_max_duration = v.into();
4055            self
4056        }
4057
4058        /// Sets the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
4059        pub fn set_cost_per_hour_after_soft_max<T: std::convert::Into<std::option::Option<f64>>>(
4060            mut self,
4061            v: T,
4062        ) -> Self {
4063            self.cost_per_hour_after_soft_max = v.into();
4064            self
4065        }
4066
4067        /// Sets the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
4068        pub fn set_quadratic_soft_max_duration<
4069            T: std::convert::Into<std::option::Option<wkt::Duration>>,
4070        >(
4071            mut self,
4072            v: T,
4073        ) -> Self {
4074            self.quadratic_soft_max_duration = v.into();
4075            self
4076        }
4077
4078        /// Sets the value of [cost_per_square_hour_after_quadratic_soft_max][crate::model::vehicle::DurationLimit::cost_per_square_hour_after_quadratic_soft_max].
4079        pub fn set_cost_per_square_hour_after_quadratic_soft_max<
4080            T: std::convert::Into<std::option::Option<f64>>,
4081        >(
4082            mut self,
4083            v: T,
4084        ) -> Self {
4085            self.cost_per_square_hour_after_quadratic_soft_max = v.into();
4086            self
4087        }
4088    }
4089
4090    impl wkt::message::Message for DurationLimit {
4091        fn typename() -> &'static str {
4092            "type.googleapis.com/google.cloud.optimization.v1.Vehicle.DurationLimit"
4093        }
4094    }
4095
4096    /// Travel modes which can be used by vehicles.
4097    ///
4098    /// These should be a subset of the Google Maps Platform Routes Preferred API
4099    /// travel modes, see:
4100    /// <https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelMode>.
4101    #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
4102    pub struct TravelMode(i32);
4103
4104    impl TravelMode {
4105        /// Unspecified travel mode, equivalent to `DRIVING`.
4106        pub const TRAVEL_MODE_UNSPECIFIED: TravelMode = TravelMode::new(0);
4107
4108        /// Travel mode corresponding to driving directions (car, ...).
4109        pub const DRIVING: TravelMode = TravelMode::new(1);
4110
4111        /// Travel mode corresponding to walking directions.
4112        pub const WALKING: TravelMode = TravelMode::new(2);
4113
4114        /// Creates a new TravelMode instance.
4115        pub(crate) const fn new(value: i32) -> Self {
4116            Self(value)
4117        }
4118
4119        /// Gets the enum value.
4120        pub fn value(&self) -> i32 {
4121            self.0
4122        }
4123
4124        /// Gets the enum value as a string.
4125        pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
4126            match self.0 {
4127                0 => std::borrow::Cow::Borrowed("TRAVEL_MODE_UNSPECIFIED"),
4128                1 => std::borrow::Cow::Borrowed("DRIVING"),
4129                2 => std::borrow::Cow::Borrowed("WALKING"),
4130                _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
4131            }
4132        }
4133
4134        /// Creates an enum value from the value name.
4135        pub fn from_str_name(name: &str) -> std::option::Option<Self> {
4136            match name {
4137                "TRAVEL_MODE_UNSPECIFIED" => {
4138                    std::option::Option::Some(Self::TRAVEL_MODE_UNSPECIFIED)
4139                }
4140                "DRIVING" => std::option::Option::Some(Self::DRIVING),
4141                "WALKING" => std::option::Option::Some(Self::WALKING),
4142                _ => std::option::Option::None,
4143            }
4144        }
4145    }
4146
4147    impl std::convert::From<i32> for TravelMode {
4148        fn from(value: i32) -> Self {
4149            Self::new(value)
4150        }
4151    }
4152
4153    impl std::default::Default for TravelMode {
4154        fn default() -> Self {
4155            Self::new(0)
4156        }
4157    }
4158
4159    /// Policy on how a vehicle can be unloaded. Applies only to shipments having
4160    /// both a pickup and a delivery.
4161    ///
4162    /// Other shipments are free to occur anywhere on the route independent of
4163    /// `unloading_policy`.
4164    #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
4165    pub struct UnloadingPolicy(i32);
4166
4167    impl UnloadingPolicy {
4168        /// Unspecified unloading policy; deliveries must just occur after their
4169        /// corresponding pickups.
4170        pub const UNLOADING_POLICY_UNSPECIFIED: UnloadingPolicy = UnloadingPolicy::new(0);
4171
4172        /// Deliveries must occur in reverse order of pickups
4173        pub const LAST_IN_FIRST_OUT: UnloadingPolicy = UnloadingPolicy::new(1);
4174
4175        /// Deliveries must occur in the same order as pickups
4176        pub const FIRST_IN_FIRST_OUT: UnloadingPolicy = UnloadingPolicy::new(2);
4177
4178        /// Creates a new UnloadingPolicy instance.
4179        pub(crate) const fn new(value: i32) -> Self {
4180            Self(value)
4181        }
4182
4183        /// Gets the enum value.
4184        pub fn value(&self) -> i32 {
4185            self.0
4186        }
4187
4188        /// Gets the enum value as a string.
4189        pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
4190            match self.0 {
4191                0 => std::borrow::Cow::Borrowed("UNLOADING_POLICY_UNSPECIFIED"),
4192                1 => std::borrow::Cow::Borrowed("LAST_IN_FIRST_OUT"),
4193                2 => std::borrow::Cow::Borrowed("FIRST_IN_FIRST_OUT"),
4194                _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
4195            }
4196        }
4197
4198        /// Creates an enum value from the value name.
4199        pub fn from_str_name(name: &str) -> std::option::Option<Self> {
4200            match name {
4201                "UNLOADING_POLICY_UNSPECIFIED" => {
4202                    std::option::Option::Some(Self::UNLOADING_POLICY_UNSPECIFIED)
4203                }
4204                "LAST_IN_FIRST_OUT" => std::option::Option::Some(Self::LAST_IN_FIRST_OUT),
4205                "FIRST_IN_FIRST_OUT" => std::option::Option::Some(Self::FIRST_IN_FIRST_OUT),
4206                _ => std::option::Option::None,
4207            }
4208        }
4209    }
4210
4211    impl std::convert::From<i32> for UnloadingPolicy {
4212        fn from(value: i32) -> Self {
4213            Self::new(value)
4214        }
4215    }
4216
4217    impl std::default::Default for UnloadingPolicy {
4218        fn default() -> Self {
4219            Self::new(0)
4220        }
4221    }
4222}
4223
4224/// Time windows constrain the time of an event, such as the arrival time at a
4225/// visit, or the start and end time of a vehicle.
4226///
4227/// Hard time window bounds, `start_time` and `end_time`, enforce the earliest
4228/// and latest time of the event, such that `start_time <= event_time <=
4229/// end_time`. The soft time window lower bound, `soft_start_time`, expresses a
4230/// preference for the event to happen at or after `soft_start_time` by incurring
4231/// a cost proportional to how long before soft_start_time the event occurs. The
4232/// soft time window upper bound, `soft_end_time`, expresses a preference for the
4233/// event to happen at or before `soft_end_time` by incurring a cost proportional
4234/// to how long after `soft_end_time` the event occurs. `start_time`, `end_time`,
4235/// `soft_start_time` and `soft_end_time` should be within the global time limits
4236/// (see
4237/// [ShipmentModel.global_start_time][google.cloud.optimization.v1.ShipmentModel.global_start_time]
4238/// and
4239/// [ShipmentModel.global_end_time][google.cloud.optimization.v1.ShipmentModel.global_end_time])
4240/// and should respect:
4241///
4242/// ```norust
4243///   0 <= `start_time` <= `soft_start_time` <= `end_time` and
4244///   0 <= `start_time` <= `soft_end_time` <= `end_time`.
4245/// ```
4246///
4247/// [google.cloud.optimization.v1.ShipmentModel.global_end_time]: crate::model::ShipmentModel::global_end_time
4248/// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
4249#[serde_with::serde_as]
4250#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
4251#[serde(default, rename_all = "camelCase")]
4252#[non_exhaustive]
4253pub struct TimeWindow {
4254    /// The hard time window start time. If unspecified it will be set to
4255    /// `ShipmentModel.global_start_time`.
4256    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4257    pub start_time: std::option::Option<wkt::Timestamp>,
4258
4259    /// The hard time window end time. If unspecified it will be set to
4260    /// `ShipmentModel.global_end_time`.
4261    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4262    pub end_time: std::option::Option<wkt::Timestamp>,
4263
4264    /// The soft start time of the time window.
4265    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4266    pub soft_start_time: std::option::Option<wkt::Timestamp>,
4267
4268    /// The soft end time of the time window.
4269    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4270    pub soft_end_time: std::option::Option<wkt::Timestamp>,
4271
4272    /// A cost per hour added to other costs in the model if the event occurs
4273    /// before soft_start_time, computed as:
4274    ///
4275    /// ```norust
4276    ///    max(0, soft_start_time - t.seconds)
4277    ///                           * cost_per_hour_before_soft_start_time / 3600,
4278    /// t being the time of the event.
4279    /// ```
4280    ///
4281    /// This cost must be positive, and the field can only be set if
4282    /// soft_start_time has been set.
4283    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4284    pub cost_per_hour_before_soft_start_time: std::option::Option<f64>,
4285
4286    /// A cost per hour added to other costs in the model if the event occurs after
4287    /// `soft_end_time`, computed as:
4288    ///
4289    /// ```norust
4290    ///    max(0, t.seconds - soft_end_time.seconds)
4291    ///                     * cost_per_hour_after_soft_end_time / 3600,
4292    /// t being the time of the event.
4293    /// ```
4294    ///
4295    /// This cost must be positive, and the field can only be set if
4296    /// `soft_end_time` has been set.
4297    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4298    pub cost_per_hour_after_soft_end_time: std::option::Option<f64>,
4299
4300    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
4301    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4302}
4303
4304impl TimeWindow {
4305    pub fn new() -> Self {
4306        std::default::Default::default()
4307    }
4308
4309    /// Sets the value of [start_time][crate::model::TimeWindow::start_time].
4310    pub fn set_start_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
4311        mut self,
4312        v: T,
4313    ) -> Self {
4314        self.start_time = v.into();
4315        self
4316    }
4317
4318    /// Sets the value of [end_time][crate::model::TimeWindow::end_time].
4319    pub fn set_end_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
4320        mut self,
4321        v: T,
4322    ) -> Self {
4323        self.end_time = v.into();
4324        self
4325    }
4326
4327    /// Sets the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
4328    pub fn set_soft_start_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
4329        mut self,
4330        v: T,
4331    ) -> Self {
4332        self.soft_start_time = v.into();
4333        self
4334    }
4335
4336    /// Sets the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
4337    pub fn set_soft_end_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
4338        mut self,
4339        v: T,
4340    ) -> Self {
4341        self.soft_end_time = v.into();
4342        self
4343    }
4344
4345    /// Sets the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
4346    pub fn set_cost_per_hour_before_soft_start_time<
4347        T: std::convert::Into<std::option::Option<f64>>,
4348    >(
4349        mut self,
4350        v: T,
4351    ) -> Self {
4352        self.cost_per_hour_before_soft_start_time = v.into();
4353        self
4354    }
4355
4356    /// Sets the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
4357    pub fn set_cost_per_hour_after_soft_end_time<
4358        T: std::convert::Into<std::option::Option<f64>>,
4359    >(
4360        mut self,
4361        v: T,
4362    ) -> Self {
4363        self.cost_per_hour_after_soft_end_time = v.into();
4364        self
4365    }
4366}
4367
4368impl wkt::message::Message for TimeWindow {
4369    fn typename() -> &'static str {
4370        "type.googleapis.com/google.cloud.optimization.v1.TimeWindow"
4371    }
4372}
4373
4374/// Deprecated: Use
4375/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
4376/// instead.
4377///
4378/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
4379#[serde_with::serde_as]
4380#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
4381#[serde(default, rename_all = "camelCase")]
4382#[non_exhaustive]
4383pub struct CapacityQuantity {
4384    #[serde(rename = "type")]
4385    #[serde(skip_serializing_if = "std::string::String::is_empty")]
4386    pub r#type: std::string::String,
4387
4388    #[serde_as(as = "serde_with::DisplayFromStr")]
4389    pub value: i64,
4390
4391    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
4392    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4393}
4394
4395impl CapacityQuantity {
4396    pub fn new() -> Self {
4397        std::default::Default::default()
4398    }
4399
4400    /// Sets the value of [r#type][crate::model::CapacityQuantity::type].
4401    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4402        self.r#type = v.into();
4403        self
4404    }
4405
4406    /// Sets the value of [value][crate::model::CapacityQuantity::value].
4407    pub fn set_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
4408        self.value = v.into();
4409        self
4410    }
4411}
4412
4413impl wkt::message::Message for CapacityQuantity {
4414    fn typename() -> &'static str {
4415        "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantity"
4416    }
4417}
4418
4419/// Deprecated: Use
4420/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
4421/// instead.
4422///
4423/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
4424#[serde_with::serde_as]
4425#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
4426#[serde(default, rename_all = "camelCase")]
4427#[non_exhaustive]
4428pub struct CapacityQuantityInterval {
4429    #[serde(rename = "type")]
4430    #[serde(skip_serializing_if = "std::string::String::is_empty")]
4431    pub r#type: std::string::String,
4432
4433    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4434    #[serde_as(as = "std::option::Option<serde_with::DisplayFromStr>")]
4435    pub min_value: std::option::Option<i64>,
4436
4437    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4438    #[serde_as(as = "std::option::Option<serde_with::DisplayFromStr>")]
4439    pub max_value: std::option::Option<i64>,
4440
4441    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
4442    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4443}
4444
4445impl CapacityQuantityInterval {
4446    pub fn new() -> Self {
4447        std::default::Default::default()
4448    }
4449
4450    /// Sets the value of [r#type][crate::model::CapacityQuantityInterval::type].
4451    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4452        self.r#type = v.into();
4453        self
4454    }
4455
4456    /// Sets the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
4457    pub fn set_min_value<T: std::convert::Into<std::option::Option<i64>>>(mut self, v: T) -> Self {
4458        self.min_value = v.into();
4459        self
4460    }
4461
4462    /// Sets the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
4463    pub fn set_max_value<T: std::convert::Into<std::option::Option<i64>>>(mut self, v: T) -> Self {
4464        self.max_value = v.into();
4465        self
4466    }
4467}
4468
4469impl wkt::message::Message for CapacityQuantityInterval {
4470    fn typename() -> &'static str {
4471        "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantityInterval"
4472    }
4473}
4474
4475/// A limit defining a maximum distance which can be traveled. It can be either
4476/// hard or soft.
4477///
4478/// If a soft limit is defined, both `soft_max_meters` and
4479/// `cost_per_kilometer_above_soft_max` must be defined and be nonnegative.
4480#[serde_with::serde_as]
4481#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
4482#[serde(default, rename_all = "camelCase")]
4483#[non_exhaustive]
4484pub struct DistanceLimit {
4485    /// A hard limit constraining the distance to be at most max_meters. The limit
4486    /// must be nonnegative.
4487    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4488    #[serde_as(as = "std::option::Option<serde_with::DisplayFromStr>")]
4489    pub max_meters: std::option::Option<i64>,
4490
4491    /// A soft limit not enforcing a maximum distance limit, but when violated
4492    /// results in a cost which adds up to other costs defined in the model,
4493    /// with the same unit.
4494    ///
4495    /// If defined soft_max_meters must be less than max_meters and must be
4496    /// nonnegative.
4497    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4498    #[serde_as(as = "std::option::Option<serde_with::DisplayFromStr>")]
4499    pub soft_max_meters: std::option::Option<i64>,
4500
4501    /// Cost per kilometer incurred, increasing up to `soft_max_meters`, with
4502    /// formula:
4503    ///
4504    /// ```norust
4505    ///   min(distance_meters, soft_max_meters) / 1000.0 *
4506    ///   cost_per_kilometer_below_soft_max.
4507    /// ```
4508    ///
4509    /// This cost is not supported in `route_distance_limit`.
4510    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4511    pub cost_per_kilometer_below_soft_max: std::option::Option<f64>,
4512
4513    /// Cost per kilometer incurred if distance is above `soft_max_meters` limit.
4514    /// The additional cost is 0 if the distance is under the limit, otherwise the
4515    /// formula used to compute the cost is the following:
4516    ///
4517    /// ```norust
4518    ///   (distance_meters - soft_max_meters) / 1000.0 *
4519    ///   cost_per_kilometer_above_soft_max.
4520    /// ```
4521    ///
4522    /// The cost must be nonnegative.
4523    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4524    pub cost_per_kilometer_above_soft_max: std::option::Option<f64>,
4525
4526    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
4527    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4528}
4529
4530impl DistanceLimit {
4531    pub fn new() -> Self {
4532        std::default::Default::default()
4533    }
4534
4535    /// Sets the value of [max_meters][crate::model::DistanceLimit::max_meters].
4536    pub fn set_max_meters<T: std::convert::Into<std::option::Option<i64>>>(mut self, v: T) -> Self {
4537        self.max_meters = v.into();
4538        self
4539    }
4540
4541    /// Sets the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
4542    pub fn set_soft_max_meters<T: std::convert::Into<std::option::Option<i64>>>(
4543        mut self,
4544        v: T,
4545    ) -> Self {
4546        self.soft_max_meters = v.into();
4547        self
4548    }
4549
4550    /// Sets the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
4551    pub fn set_cost_per_kilometer_below_soft_max<
4552        T: std::convert::Into<std::option::Option<f64>>,
4553    >(
4554        mut self,
4555        v: T,
4556    ) -> Self {
4557        self.cost_per_kilometer_below_soft_max = v.into();
4558        self
4559    }
4560
4561    /// Sets the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
4562    pub fn set_cost_per_kilometer_above_soft_max<
4563        T: std::convert::Into<std::option::Option<f64>>,
4564    >(
4565        mut self,
4566        v: T,
4567    ) -> Self {
4568        self.cost_per_kilometer_above_soft_max = v.into();
4569        self
4570    }
4571}
4572
4573impl wkt::message::Message for DistanceLimit {
4574    fn typename() -> &'static str {
4575        "type.googleapis.com/google.cloud.optimization.v1.DistanceLimit"
4576    }
4577}
4578
4579/// Specifies attributes of transitions between two consecutive visits on a
4580/// route. Several `TransitionAttributes` may apply to the same transition: in
4581/// that case, all extra costs add up and the strictest constraint or limit
4582/// applies (following natural "AND" semantics).
4583#[serde_with::serde_as]
4584#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
4585#[serde(default, rename_all = "camelCase")]
4586#[non_exhaustive]
4587pub struct TransitionAttributes {
4588    /// Tags defining the set of (src->dst) transitions these attributes apply to.
4589    ///
4590    /// A source visit or vehicle start matches iff its
4591    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
4592    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags]
4593    /// either contains `src_tag` or does not contain `excluded_src_tag` (depending
4594    /// on which of these two fields is non-empty).
4595    ///
4596    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
4597    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
4598    #[serde(skip_serializing_if = "std::string::String::is_empty")]
4599    pub src_tag: std::string::String,
4600
4601    /// See `src_tag`. Exactly one of `src_tag` and `excluded_src_tag` must be
4602    /// non-empty.
4603    #[serde(skip_serializing_if = "std::string::String::is_empty")]
4604    pub excluded_src_tag: std::string::String,
4605
4606    /// A destination visit or vehicle end matches iff its
4607    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
4608    /// or [Vehicle.end_tags][google.cloud.optimization.v1.Vehicle.end_tags] either
4609    /// contains `dst_tag` or does not contain `excluded_dst_tag` (depending on
4610    /// which of these two fields is non-empty).
4611    ///
4612    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
4613    /// [google.cloud.optimization.v1.Vehicle.end_tags]: crate::model::Vehicle::end_tags
4614    #[serde(skip_serializing_if = "std::string::String::is_empty")]
4615    pub dst_tag: std::string::String,
4616
4617    /// See `dst_tag`. Exactly one of `dst_tag` and `excluded_dst_tag` must be
4618    /// non-empty.
4619    #[serde(skip_serializing_if = "std::string::String::is_empty")]
4620    pub excluded_dst_tag: std::string::String,
4621
4622    /// Specifies a cost for performing this transition. This is in the same unit
4623    /// as all other costs in the model and must not be negative. It is applied on
4624    /// top of all other existing costs.
4625    pub cost: f64,
4626
4627    /// Specifies a cost per kilometer applied to the distance traveled while
4628    /// performing this transition. It adds up to any
4629    /// [Vehicle.cost_per_kilometer][google.cloud.optimization.v1.Vehicle.cost_per_kilometer]
4630    /// specified on vehicles.
4631    ///
4632    /// [google.cloud.optimization.v1.Vehicle.cost_per_kilometer]: crate::model::Vehicle::cost_per_kilometer
4633    pub cost_per_kilometer: f64,
4634
4635    /// Specifies a limit on the distance traveled while performing this
4636    /// transition.
4637    ///
4638    /// As of 2021/06, only soft limits are supported.
4639    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4640    pub distance_limit: std::option::Option<crate::model::DistanceLimit>,
4641
4642    /// Specifies a delay incurred when performing this transition.
4643    ///
4644    /// This delay always occurs *after* finishing the source visit and *before*
4645    /// starting the destination visit.
4646    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4647    pub delay: std::option::Option<wkt::Duration>,
4648
4649    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
4650    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4651}
4652
4653impl TransitionAttributes {
4654    pub fn new() -> Self {
4655        std::default::Default::default()
4656    }
4657
4658    /// Sets the value of [src_tag][crate::model::TransitionAttributes::src_tag].
4659    pub fn set_src_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4660        self.src_tag = v.into();
4661        self
4662    }
4663
4664    /// Sets the value of [excluded_src_tag][crate::model::TransitionAttributes::excluded_src_tag].
4665    pub fn set_excluded_src_tag<T: std::convert::Into<std::string::String>>(
4666        mut self,
4667        v: T,
4668    ) -> Self {
4669        self.excluded_src_tag = v.into();
4670        self
4671    }
4672
4673    /// Sets the value of [dst_tag][crate::model::TransitionAttributes::dst_tag].
4674    pub fn set_dst_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4675        self.dst_tag = v.into();
4676        self
4677    }
4678
4679    /// Sets the value of [excluded_dst_tag][crate::model::TransitionAttributes::excluded_dst_tag].
4680    pub fn set_excluded_dst_tag<T: std::convert::Into<std::string::String>>(
4681        mut self,
4682        v: T,
4683    ) -> Self {
4684        self.excluded_dst_tag = v.into();
4685        self
4686    }
4687
4688    /// Sets the value of [cost][crate::model::TransitionAttributes::cost].
4689    pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4690        self.cost = v.into();
4691        self
4692    }
4693
4694    /// Sets the value of [cost_per_kilometer][crate::model::TransitionAttributes::cost_per_kilometer].
4695    pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4696        self.cost_per_kilometer = v.into();
4697        self
4698    }
4699
4700    /// Sets the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
4701    pub fn set_distance_limit<
4702        T: std::convert::Into<std::option::Option<crate::model::DistanceLimit>>,
4703    >(
4704        mut self,
4705        v: T,
4706    ) -> Self {
4707        self.distance_limit = v.into();
4708        self
4709    }
4710
4711    /// Sets the value of [delay][crate::model::TransitionAttributes::delay].
4712    pub fn set_delay<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
4713        mut self,
4714        v: T,
4715    ) -> Self {
4716        self.delay = v.into();
4717        self
4718    }
4719}
4720
4721impl wkt::message::Message for TransitionAttributes {
4722    fn typename() -> &'static str {
4723        "type.googleapis.com/google.cloud.optimization.v1.TransitionAttributes"
4724    }
4725}
4726
4727/// Encapsulates a waypoint. Waypoints mark arrival and departure locations of
4728/// VisitRequests, and start and end locations of Vehicles.
4729#[serde_with::serde_as]
4730#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
4731#[serde(default, rename_all = "camelCase")]
4732#[non_exhaustive]
4733pub struct Waypoint {
4734    /// Indicates that the location of this waypoint is meant to have a preference
4735    /// for the vehicle to stop at a particular side of road. When you set this
4736    /// value, the route will pass through the location so that the vehicle can
4737    /// stop at the side of road that the location is biased towards from the
4738    /// center of the road. This option works only for the 'DRIVING' travel mode,
4739    /// and when the 'location_type' is set to 'location'.
4740    pub side_of_road: bool,
4741
4742    /// Different ways to represent a location.
4743    #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")]
4744    pub location_type: std::option::Option<crate::model::waypoint::LocationType>,
4745
4746    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
4747    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4748}
4749
4750impl Waypoint {
4751    pub fn new() -> Self {
4752        std::default::Default::default()
4753    }
4754
4755    /// Sets the value of [side_of_road][crate::model::Waypoint::side_of_road].
4756    pub fn set_side_of_road<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4757        self.side_of_road = v.into();
4758        self
4759    }
4760
4761    /// Sets the value of [location_type][crate::model::Waypoint::location_type].
4762    ///
4763    /// Note that all the setters affecting `location_type` are mutually
4764    /// exclusive.
4765    pub fn set_location_type<
4766        T: std::convert::Into<std::option::Option<crate::model::waypoint::LocationType>>,
4767    >(
4768        mut self,
4769        v: T,
4770    ) -> Self {
4771        self.location_type = v.into();
4772        self
4773    }
4774
4775    /// The value of [location_type][crate::model::Waypoint::location_type]
4776    /// if it holds a `Location`, `None` if the field is not set or
4777    /// holds a different branch.
4778    pub fn location(&self) -> std::option::Option<&std::boxed::Box<crate::model::Location>> {
4779        #[allow(unreachable_patterns)]
4780        self.location_type.as_ref().and_then(|v| match v {
4781            crate::model::waypoint::LocationType::Location(v) => std::option::Option::Some(v),
4782            _ => std::option::Option::None,
4783        })
4784    }
4785
4786    /// The value of [location_type][crate::model::Waypoint::location_type]
4787    /// if it holds a `PlaceId`, `None` if the field is not set or
4788    /// holds a different branch.
4789    pub fn place_id(&self) -> std::option::Option<&std::string::String> {
4790        #[allow(unreachable_patterns)]
4791        self.location_type.as_ref().and_then(|v| match v {
4792            crate::model::waypoint::LocationType::PlaceId(v) => std::option::Option::Some(v),
4793            _ => std::option::Option::None,
4794        })
4795    }
4796
4797    /// Sets the value of [location_type][crate::model::Waypoint::location_type]
4798    /// to hold a `Location`.
4799    ///
4800    /// Note that all the setters affecting `location_type` are
4801    /// mutually exclusive.
4802    pub fn set_location<T: std::convert::Into<std::boxed::Box<crate::model::Location>>>(
4803        mut self,
4804        v: T,
4805    ) -> Self {
4806        self.location_type =
4807            std::option::Option::Some(crate::model::waypoint::LocationType::Location(v.into()));
4808        self
4809    }
4810
4811    /// Sets the value of [location_type][crate::model::Waypoint::location_type]
4812    /// to hold a `PlaceId`.
4813    ///
4814    /// Note that all the setters affecting `location_type` are
4815    /// mutually exclusive.
4816    pub fn set_place_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4817        self.location_type =
4818            std::option::Option::Some(crate::model::waypoint::LocationType::PlaceId(v.into()));
4819        self
4820    }
4821}
4822
4823impl wkt::message::Message for Waypoint {
4824    fn typename() -> &'static str {
4825        "type.googleapis.com/google.cloud.optimization.v1.Waypoint"
4826    }
4827}
4828
4829/// Defines additional types related to [Waypoint].
4830pub mod waypoint {
4831    #[allow(unused_imports)]
4832    use super::*;
4833
4834    /// Different ways to represent a location.
4835    #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
4836    #[serde(rename_all = "camelCase")]
4837    #[non_exhaustive]
4838    pub enum LocationType {
4839        /// A point specified using geographic coordinates, including an optional
4840        /// heading.
4841        Location(std::boxed::Box<crate::model::Location>),
4842        /// The POI Place ID associated with the waypoint.
4843        PlaceId(std::string::String),
4844    }
4845}
4846
4847/// Encapsulates a location (a geographic point, and an optional heading).
4848#[serde_with::serde_as]
4849#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
4850#[serde(default, rename_all = "camelCase")]
4851#[non_exhaustive]
4852pub struct Location {
4853    /// The waypoint's geographic coordinates.
4854    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4855    pub lat_lng: std::option::Option<gtype::model::LatLng>,
4856
4857    /// The compass heading associated with the direction of the flow of traffic.
4858    /// This value is used to specify the side of the road to use for pickup and
4859    /// drop-off. Heading values can be from 0 to 360, where 0 specifies a heading
4860    /// of due North, 90 specifies a heading of due East, etc.
4861    #[serde(skip_serializing_if = "std::option::Option::is_none")]
4862    pub heading: std::option::Option<i32>,
4863
4864    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
4865    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4866}
4867
4868impl Location {
4869    pub fn new() -> Self {
4870        std::default::Default::default()
4871    }
4872
4873    /// Sets the value of [lat_lng][crate::model::Location::lat_lng].
4874    pub fn set_lat_lng<T: std::convert::Into<std::option::Option<gtype::model::LatLng>>>(
4875        mut self,
4876        v: T,
4877    ) -> Self {
4878        self.lat_lng = v.into();
4879        self
4880    }
4881
4882    /// Sets the value of [heading][crate::model::Location::heading].
4883    pub fn set_heading<T: std::convert::Into<std::option::Option<i32>>>(mut self, v: T) -> Self {
4884        self.heading = v.into();
4885        self
4886    }
4887}
4888
4889impl wkt::message::Message for Location {
4890    fn typename() -> &'static str {
4891        "type.googleapis.com/google.cloud.optimization.v1.Location"
4892    }
4893}
4894
4895/// Rules to generate time breaks for a vehicle (e.g. lunch breaks). A break
4896/// is a contiguous period of time during which the vehicle remains idle at its
4897/// current position and cannot perform any visit. A break may occur:
4898///
4899/// * during the travel between two visits (which includes the time right
4900///   before or right after a visit, but not in the middle of a visit), in
4901///   which case it extends the corresponding transit time between the visits,
4902/// * or before the vehicle start (the vehicle may not start in the middle of
4903///   a break), in which case it does not affect the vehicle start time.
4904/// * or after the vehicle end (ditto, with the vehicle end time).
4905#[serde_with::serde_as]
4906#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
4907#[serde(default, rename_all = "camelCase")]
4908#[non_exhaustive]
4909pub struct BreakRule {
4910    /// Sequence of breaks. See the `BreakRequest` message.
4911    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
4912    pub break_requests: std::vec::Vec<crate::model::break_rule::BreakRequest>,
4913
4914    /// Several `FrequencyConstraint` may apply. They must all be satisfied by
4915    /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
4916    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
4917    pub frequency_constraints: std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
4918
4919    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
4920    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4921}
4922
4923impl BreakRule {
4924    pub fn new() -> Self {
4925        std::default::Default::default()
4926    }
4927
4928    /// Sets the value of [break_requests][crate::model::BreakRule::break_requests].
4929    pub fn set_break_requests<T, V>(mut self, v: T) -> Self
4930    where
4931        T: std::iter::IntoIterator<Item = V>,
4932        V: std::convert::Into<crate::model::break_rule::BreakRequest>,
4933    {
4934        use std::iter::Iterator;
4935        self.break_requests = v.into_iter().map(|i| i.into()).collect();
4936        self
4937    }
4938
4939    /// Sets the value of [frequency_constraints][crate::model::BreakRule::frequency_constraints].
4940    pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
4941    where
4942        T: std::iter::IntoIterator<Item = V>,
4943        V: std::convert::Into<crate::model::break_rule::FrequencyConstraint>,
4944    {
4945        use std::iter::Iterator;
4946        self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
4947        self
4948    }
4949}
4950
4951impl wkt::message::Message for BreakRule {
4952    fn typename() -> &'static str {
4953        "type.googleapis.com/google.cloud.optimization.v1.BreakRule"
4954    }
4955}
4956
4957/// Defines additional types related to [BreakRule].
4958pub mod break_rule {
4959    #[allow(unused_imports)]
4960    use super::*;
4961
4962    /// The sequence of breaks (i.e. their number and order) that apply to each
4963    /// vehicle must be known beforehand. The repeated `BreakRequest`s define
4964    /// that sequence, in the order in which they must occur. Their time windows
4965    /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
4966    /// be compatible with the order (this is checked).
4967    #[serde_with::serde_as]
4968    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
4969    #[serde(default, rename_all = "camelCase")]
4970    #[non_exhaustive]
4971    pub struct BreakRequest {
4972        /// Required. Lower bound (inclusive) on the start of the break.
4973        #[serde(skip_serializing_if = "std::option::Option::is_none")]
4974        pub earliest_start_time: std::option::Option<wkt::Timestamp>,
4975
4976        /// Required. Upper bound (inclusive) on the start of the break.
4977        #[serde(skip_serializing_if = "std::option::Option::is_none")]
4978        pub latest_start_time: std::option::Option<wkt::Timestamp>,
4979
4980        /// Required. Minimum duration of the break. Must be positive.
4981        #[serde(skip_serializing_if = "std::option::Option::is_none")]
4982        pub min_duration: std::option::Option<wkt::Duration>,
4983
4984        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
4985        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4986    }
4987
4988    impl BreakRequest {
4989        pub fn new() -> Self {
4990            std::default::Default::default()
4991        }
4992
4993        /// Sets the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
4994        pub fn set_earliest_start_time<
4995            T: std::convert::Into<std::option::Option<wkt::Timestamp>>,
4996        >(
4997            mut self,
4998            v: T,
4999        ) -> Self {
5000            self.earliest_start_time = v.into();
5001            self
5002        }
5003
5004        /// Sets the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
5005        pub fn set_latest_start_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
5006            mut self,
5007            v: T,
5008        ) -> Self {
5009            self.latest_start_time = v.into();
5010            self
5011        }
5012
5013        /// Sets the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
5014        pub fn set_min_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
5015            mut self,
5016            v: T,
5017        ) -> Self {
5018            self.min_duration = v.into();
5019            self
5020        }
5021    }
5022
5023    impl wkt::message::Message for BreakRequest {
5024        fn typename() -> &'static str {
5025            "type.googleapis.com/google.cloud.optimization.v1.BreakRule.BreakRequest"
5026        }
5027    }
5028
5029    /// One may further constrain the frequency and duration of the breaks
5030    /// specified above, by enforcing a minimum break frequency, such as
5031    /// "There must be a break of at least 1 hour every 12 hours". Assuming that
5032    /// this can be interpreted as "Within any sliding time window of 12h, there
5033    /// must be at least one break of at least one hour", that example would
5034    /// translate to the following `FrequencyConstraint`:
5035    ///
5036    /// ```norust
5037    /// {
5038    ///    min_break_duration { seconds: 3600 }         # 1 hour.
5039    ///    max_inter_break_duration { seconds: 39600 }  # 11 hours (12 - 1 = 11).
5040    /// }
5041    /// ```
5042    ///
5043    /// The timing and duration of the breaks in the solution will respect all
5044    /// such constraints, in addition to the time windows and minimum durations
5045    /// already specified in the `BreakRequest`.
5046    ///
5047    /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
5048    /// For example, the following schedule honors the "1h every 12h" example:
5049    ///
5050    /// ```norust
5051    ///   04:00 vehicle start
5052    ///    .. performing travel and visits ..
5053    ///   09:00 1 hour break
5054    ///   10:00 end of the break
5055    ///    .. performing travel and visits ..
5056    ///   12:00 20-min lunch break
5057    ///   12:20 end of the break
5058    ///    .. performing travel and visits ..
5059    ///   21:00 1 hour break
5060    ///   22:00 end of the break
5061    ///    .. performing travel and visits ..
5062    ///   23:59 vehicle end
5063    /// ```
5064    #[serde_with::serde_as]
5065    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
5066    #[serde(default, rename_all = "camelCase")]
5067    #[non_exhaustive]
5068    pub struct FrequencyConstraint {
5069        /// Required. Minimum break duration for this constraint. Nonnegative.
5070        /// See description of `FrequencyConstraint`.
5071        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5072        pub min_break_duration: std::option::Option<wkt::Duration>,
5073
5074        /// Required. Maximum allowed span of any interval of time in the route that
5075        /// does not include at least partially a break of `duration >=
5076        /// min_break_duration`. Must be positive.
5077        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5078        pub max_inter_break_duration: std::option::Option<wkt::Duration>,
5079
5080        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
5081        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5082    }
5083
5084    impl FrequencyConstraint {
5085        pub fn new() -> Self {
5086            std::default::Default::default()
5087        }
5088
5089        /// Sets the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
5090        pub fn set_min_break_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
5091            mut self,
5092            v: T,
5093        ) -> Self {
5094            self.min_break_duration = v.into();
5095            self
5096        }
5097
5098        /// Sets the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
5099        pub fn set_max_inter_break_duration<
5100            T: std::convert::Into<std::option::Option<wkt::Duration>>,
5101        >(
5102            mut self,
5103            v: T,
5104        ) -> Self {
5105            self.max_inter_break_duration = v.into();
5106            self
5107        }
5108    }
5109
5110    impl wkt::message::Message for FrequencyConstraint {
5111        fn typename() -> &'static str {
5112            "type.googleapis.com/google.cloud.optimization.v1.BreakRule.FrequencyConstraint"
5113        }
5114    }
5115}
5116
5117/// A vehicle's route can be decomposed, along the time axis, like this (we
5118/// assume there are n visits):
5119///
5120/// ```norust
5121///   |            |            |          |       |  T[2], |        |      |
5122///   | Transition |  Visit #0  |          |       |  V[2], |        |      |
5123///   |     #0     |    aka     |   T[1]   |  V[1] |  ...   | V[n-1] | T[n] |
5124///   |  aka T[0]  |    V[0]    |          |       | V[n-2],|        |      |
5125///   |            |            |          |       | T[n-1] |        |      |
5126///   ^            ^            ^          ^       ^        ^        ^      ^
5127/// vehicle    V[0].start   V[0].end     V[1].   V[1].    V[n].    V[n]. vehicle
5128///  start     (arrival)   (departure)   start   end      start    end     end
5129/// ```
5130///
5131/// Note that we make a difference between:
5132///
5133/// * "punctual events", such as the vehicle start and end and each visit's start
5134///   and end (aka arrival and departure). They happen at a given second.
5135/// * "time intervals", such as the visits themselves, and the transition between
5136///   visits. Though time intervals can sometimes have zero duration, i.e. start
5137///   and end at the same second, they often have a positive duration.
5138///
5139/// Invariants:
5140///
5141/// * If there are n visits, there are n+1 transitions.
5142/// * A visit is always surrounded by a transition before it (same index) and a
5143///   transition after it (index + 1).
5144/// * The vehicle start is always followed by transition #0.
5145/// * The vehicle end is always preceded by transition #n.
5146///
5147/// Zooming in, here is what happens during a `Transition` and a `Visit`:
5148///
5149/// ```norust
5150/// ---+-------------------------------------+-----------------------------+-->
5151///    |           TRANSITION[i]             |           VISIT[i]          |
5152///    |                                     |                             |
5153///    |  * TRAVEL: the vehicle moves from   |      PERFORM the visit:     |
5154///    |    VISIT[i-1].departure_location to |                             |
5155///    |    VISIT[i].arrival_location, which |  * Spend some time:         |
5156///    |    takes a given travel duration    |    the "visit duration".    |
5157///    |    and distance                     |                             |
5158///    |                                     |  * Load or unload           |
5159///    |  * BREAKS: the driver may have      |    some quantities from the |
5160///    |    breaks (e.g. lunch break).       |    vehicle: the "demand".   |
5161///    |                                     |                             |
5162///    |  * WAIT: the driver/vehicle does    |                             |
5163///    |    nothing. This can happen for     |                             |
5164///    |    many reasons, for example when   |                             |
5165///    |    the vehicle reaches the next     |                             |
5166///    |    event's destination before the   |                             |
5167///    |    start of its time window         |                             |
5168///    |                                     |                             |
5169///    |  * DELAY: *right before* the next   |                             |
5170///    |    arrival. E.g. the vehicle and/or |                             |
5171///    |    driver spends time unloading.    |                             |
5172///    |                                     |                             |
5173/// ---+-------------------------------------+-----------------------------+-->
5174///    ^                                     ^                             ^
5175/// V[i-1].end                           V[i].start                    V[i].end
5176/// ```
5177///
5178/// Lastly, here is how the TRAVEL, BREAKS, DELAY and WAIT can be arranged
5179/// during a transition.
5180///
5181/// * They don't overlap.
5182/// * The DELAY is unique and *must* be a contiguous period of time right
5183///   before the next visit (or vehicle end). Thus, it suffice to know the
5184///   delay duration to know its start and end time.
5185/// * The BREAKS are contiguous, non-overlapping periods of time. The
5186///   response specifies the start time and duration of each break.
5187/// * TRAVEL and WAIT are "preemptable": they can be interrupted several times
5188///   during this transition. Clients can assume that travel happens "as soon as
5189///   possible" and that "wait" fills the remaining time.
5190///
5191/// A (complex) example:
5192///
5193/// ```norust
5194///                                TRANSITION[i]
5195/// --++-----+-----------------------------------------------------------++-->
5196///   ||     |       |           |       |           |         |         ||
5197///   ||  T  |   B   |     T     |       |     B     |         |    D    ||
5198///   ||  r  |   r   |     r     |   W   |     r     |    W    |    e    ||
5199///   ||  a  |   e   |     a     |   a   |     e     |    a    |    l    ||
5200///   ||  v  |   a   |     v     |   i   |     a     |    i    |    a    ||
5201///   ||  e  |   k   |     e     |   t   |     k     |    t    |    y    ||
5202///   ||  l  |       |     l     |       |           |         |         ||
5203///   ||     |       |           |       |           |         |         ||
5204/// --++-----------------------------------------------------------------++-->
5205/// ```
5206#[serde_with::serde_as]
5207#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
5208#[serde(default, rename_all = "camelCase")]
5209#[non_exhaustive]
5210pub struct ShipmentRoute {
5211    /// Vehicle performing the route, identified by its index in the source
5212    /// `ShipmentModel`.
5213    pub vehicle_index: i32,
5214
5215    /// Label of the vehicle performing this route, equal to
5216    /// `ShipmentModel.vehicles(vehicle_index).label`, if specified.
5217    #[serde(skip_serializing_if = "std::string::String::is_empty")]
5218    pub vehicle_label: std::string::String,
5219
5220    /// Time at which the vehicle starts its route.
5221    #[serde(skip_serializing_if = "std::option::Option::is_none")]
5222    pub vehicle_start_time: std::option::Option<wkt::Timestamp>,
5223
5224    /// Time at which the vehicle finishes its route.
5225    #[serde(skip_serializing_if = "std::option::Option::is_none")]
5226    pub vehicle_end_time: std::option::Option<wkt::Timestamp>,
5227
5228    /// Ordered sequence of visits representing a route.
5229    /// visits[i] is the i-th visit in the route.
5230    /// If this field is empty, the vehicle is considered as unused.
5231    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
5232    pub visits: std::vec::Vec<crate::model::shipment_route::Visit>,
5233
5234    /// Ordered list of transitions for the route.
5235    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
5236    pub transitions: std::vec::Vec<crate::model::shipment_route::Transition>,
5237
5238    /// When
5239    /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
5240    /// is set to true, this field indicates that inconsistencies in route timings
5241    /// are predicted using traffic-based travel duration estimates. There may be
5242    /// insufficient time to complete traffic-adjusted travel, delays, and breaks
5243    /// between visits, before the first visit, or after the last visit, while
5244    /// still satisfying the visit and vehicle time windows. For example,
5245    ///
5246    /// ```norust
5247    ///   start_time(previous_visit) + duration(previous_visit) +
5248    ///   travel_duration(previous_visit, next_visit) > start_time(next_visit)
5249    /// ```
5250    ///
5251    /// Arrival at next_visit will likely happen later than its current
5252    /// time window due the increased estimate of travel time
5253    /// `travel_duration(previous_visit, next_visit)` due to traffic. Also, a break
5254    /// may be forced to overlap with a visit due to an increase in travel time
5255    /// estimates and visit or break time window restrictions.
5256    ///
5257    /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
5258    pub has_traffic_infeasibilities: bool,
5259
5260    /// The encoded polyline representation of the route.
5261    /// This field is only populated if
5262    /// [OptimizeToursRequest.populate_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]
5263    /// is set to true.
5264    ///
5265    /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]: crate::model::OptimizeToursRequest::populate_polylines
5266    #[serde(skip_serializing_if = "std::option::Option::is_none")]
5267    pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
5268
5269    /// Breaks scheduled for the vehicle performing this route.
5270    /// The `breaks` sequence represents time intervals, each starting at the
5271    /// corresponding `start_time` and lasting `duration` seconds.
5272    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
5273    pub breaks: std::vec::Vec<crate::model::shipment_route::Break>,
5274
5275    /// Duration, distance and load metrics for this route. The fields of
5276    /// [AggregatedMetrics][google.cloud.optimization.v1.AggregatedMetrics] are
5277    /// summed over all
5278    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
5279    /// or
5280    /// [ShipmentRoute.visits][google.cloud.optimization.v1.ShipmentRoute.visits],
5281    /// depending on the context.
5282    ///
5283    /// [google.cloud.optimization.v1.AggregatedMetrics]: crate::model::AggregatedMetrics
5284    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
5285    /// [google.cloud.optimization.v1.ShipmentRoute.visits]: crate::model::ShipmentRoute::visits
5286    #[serde(skip_serializing_if = "std::option::Option::is_none")]
5287    pub metrics: std::option::Option<crate::model::AggregatedMetrics>,
5288
5289    /// Cost of the route, broken down by cost-related request fields.
5290    /// The keys are proto paths, relative to the input OptimizeToursRequest, e.g.
5291    /// "model.shipments.pickups.cost", and the values are the total cost
5292    /// generated by the corresponding cost field, aggregated over the whole route.
5293    /// In other words, costs["model.shipments.pickups.cost"] is the sum of all
5294    /// pickup costs over the route. All costs defined in the model are reported in
5295    /// detail here with the exception of costs related to TransitionAttributes
5296    /// that are only reported in an aggregated way as of 2022/01.
5297    #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
5298    pub route_costs: std::collections::HashMap<std::string::String, f64>,
5299
5300    /// Total cost of the route. The sum of all costs in the cost map.
5301    pub route_total_cost: f64,
5302
5303    /// Deprecated: Use
5304    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
5305    /// instead. Vehicle loads upon arrival at its end location, for each type
5306    /// specified in
5307    /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
5308    /// `start_load_intervals`, `end_load_intervals` or demands. Exception: we omit
5309    /// loads for quantity types unconstrained by intervals and that don't have any
5310    /// non-zero demand on the route.
5311    ///
5312    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
5313    /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
5314    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
5315    pub end_loads: std::vec::Vec<crate::model::CapacityQuantity>,
5316
5317    /// Deprecated: Use
5318    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
5319    /// instead. Ordered list of travel steps for the route.
5320    ///
5321    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
5322    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
5323    pub travel_steps: std::vec::Vec<crate::model::shipment_route::TravelStep>,
5324
5325    /// Deprecated: No longer used.
5326    /// This field will only be populated at the
5327    /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit]
5328    /// level.
5329    ///
5330    /// This field is the extra detour time due to the shipments visited on the
5331    /// route.
5332    ///
5333    /// It is equal to `vehicle_end_time` - `vehicle_start_time` - travel duration
5334    /// from the vehicle's start_location to its `end_location`.
5335    ///
5336    /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
5337    #[serde(skip_serializing_if = "std::option::Option::is_none")]
5338    pub vehicle_detour: std::option::Option<wkt::Duration>,
5339
5340    /// Deprecated: Delay occurring before the vehicle end. See
5341    /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
5342    ///
5343    /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
5344    #[serde(skip_serializing_if = "std::option::Option::is_none")]
5345    pub delay_before_vehicle_end: std::option::Option<crate::model::shipment_route::Delay>,
5346
5347    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
5348    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5349}
5350
5351impl ShipmentRoute {
5352    pub fn new() -> Self {
5353        std::default::Default::default()
5354    }
5355
5356    /// Sets the value of [vehicle_index][crate::model::ShipmentRoute::vehicle_index].
5357    pub fn set_vehicle_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
5358        self.vehicle_index = v.into();
5359        self
5360    }
5361
5362    /// Sets the value of [vehicle_label][crate::model::ShipmentRoute::vehicle_label].
5363    pub fn set_vehicle_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5364        self.vehicle_label = v.into();
5365        self
5366    }
5367
5368    /// Sets the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
5369    pub fn set_vehicle_start_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
5370        mut self,
5371        v: T,
5372    ) -> Self {
5373        self.vehicle_start_time = v.into();
5374        self
5375    }
5376
5377    /// Sets the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
5378    pub fn set_vehicle_end_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
5379        mut self,
5380        v: T,
5381    ) -> Self {
5382        self.vehicle_end_time = v.into();
5383        self
5384    }
5385
5386    /// Sets the value of [has_traffic_infeasibilities][crate::model::ShipmentRoute::has_traffic_infeasibilities].
5387    pub fn set_has_traffic_infeasibilities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5388        self.has_traffic_infeasibilities = v.into();
5389        self
5390    }
5391
5392    /// Sets the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
5393    pub fn set_route_polyline<
5394        T: std::convert::Into<std::option::Option<crate::model::shipment_route::EncodedPolyline>>,
5395    >(
5396        mut self,
5397        v: T,
5398    ) -> Self {
5399        self.route_polyline = v.into();
5400        self
5401    }
5402
5403    /// Sets the value of [metrics][crate::model::ShipmentRoute::metrics].
5404    pub fn set_metrics<
5405        T: std::convert::Into<std::option::Option<crate::model::AggregatedMetrics>>,
5406    >(
5407        mut self,
5408        v: T,
5409    ) -> Self {
5410        self.metrics = v.into();
5411        self
5412    }
5413
5414    /// Sets the value of [route_total_cost][crate::model::ShipmentRoute::route_total_cost].
5415    pub fn set_route_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5416        self.route_total_cost = v.into();
5417        self
5418    }
5419
5420    /// Sets the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
5421    pub fn set_vehicle_detour<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
5422        mut self,
5423        v: T,
5424    ) -> Self {
5425        self.vehicle_detour = v.into();
5426        self
5427    }
5428
5429    /// Sets the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
5430    pub fn set_delay_before_vehicle_end<
5431        T: std::convert::Into<std::option::Option<crate::model::shipment_route::Delay>>,
5432    >(
5433        mut self,
5434        v: T,
5435    ) -> Self {
5436        self.delay_before_vehicle_end = v.into();
5437        self
5438    }
5439
5440    /// Sets the value of [visits][crate::model::ShipmentRoute::visits].
5441    pub fn set_visits<T, V>(mut self, v: T) -> Self
5442    where
5443        T: std::iter::IntoIterator<Item = V>,
5444        V: std::convert::Into<crate::model::shipment_route::Visit>,
5445    {
5446        use std::iter::Iterator;
5447        self.visits = v.into_iter().map(|i| i.into()).collect();
5448        self
5449    }
5450
5451    /// Sets the value of [transitions][crate::model::ShipmentRoute::transitions].
5452    pub fn set_transitions<T, V>(mut self, v: T) -> Self
5453    where
5454        T: std::iter::IntoIterator<Item = V>,
5455        V: std::convert::Into<crate::model::shipment_route::Transition>,
5456    {
5457        use std::iter::Iterator;
5458        self.transitions = v.into_iter().map(|i| i.into()).collect();
5459        self
5460    }
5461
5462    /// Sets the value of [breaks][crate::model::ShipmentRoute::breaks].
5463    pub fn set_breaks<T, V>(mut self, v: T) -> Self
5464    where
5465        T: std::iter::IntoIterator<Item = V>,
5466        V: std::convert::Into<crate::model::shipment_route::Break>,
5467    {
5468        use std::iter::Iterator;
5469        self.breaks = v.into_iter().map(|i| i.into()).collect();
5470        self
5471    }
5472
5473    /// Sets the value of [end_loads][crate::model::ShipmentRoute::end_loads].
5474    pub fn set_end_loads<T, V>(mut self, v: T) -> Self
5475    where
5476        T: std::iter::IntoIterator<Item = V>,
5477        V: std::convert::Into<crate::model::CapacityQuantity>,
5478    {
5479        use std::iter::Iterator;
5480        self.end_loads = v.into_iter().map(|i| i.into()).collect();
5481        self
5482    }
5483
5484    /// Sets the value of [travel_steps][crate::model::ShipmentRoute::travel_steps].
5485    pub fn set_travel_steps<T, V>(mut self, v: T) -> Self
5486    where
5487        T: std::iter::IntoIterator<Item = V>,
5488        V: std::convert::Into<crate::model::shipment_route::TravelStep>,
5489    {
5490        use std::iter::Iterator;
5491        self.travel_steps = v.into_iter().map(|i| i.into()).collect();
5492        self
5493    }
5494
5495    /// Sets the value of [route_costs][crate::model::ShipmentRoute::route_costs].
5496    pub fn set_route_costs<T, K, V>(mut self, v: T) -> Self
5497    where
5498        T: std::iter::IntoIterator<Item = (K, V)>,
5499        K: std::convert::Into<std::string::String>,
5500        V: std::convert::Into<f64>,
5501    {
5502        use std::iter::Iterator;
5503        self.route_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5504        self
5505    }
5506}
5507
5508impl wkt::message::Message for ShipmentRoute {
5509    fn typename() -> &'static str {
5510        "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute"
5511    }
5512}
5513
5514/// Defines additional types related to [ShipmentRoute].
5515pub mod shipment_route {
5516    #[allow(unused_imports)]
5517    use super::*;
5518
5519    /// Deprecated: Use
5520    /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
5521    /// instead. Time interval spent on the route resulting from a
5522    /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
5523    ///
5524    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
5525    /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
5526    #[serde_with::serde_as]
5527    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
5528    #[serde(default, rename_all = "camelCase")]
5529    #[non_exhaustive]
5530    pub struct Delay {
5531        /// Start of the delay.
5532        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5533        pub start_time: std::option::Option<wkt::Timestamp>,
5534
5535        /// Duration of the delay.
5536        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5537        pub duration: std::option::Option<wkt::Duration>,
5538
5539        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
5540        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5541    }
5542
5543    impl Delay {
5544        pub fn new() -> Self {
5545            std::default::Default::default()
5546        }
5547
5548        /// Sets the value of [start_time][crate::model::shipment_route::Delay::start_time].
5549        pub fn set_start_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
5550            mut self,
5551            v: T,
5552        ) -> Self {
5553            self.start_time = v.into();
5554            self
5555        }
5556
5557        /// Sets the value of [duration][crate::model::shipment_route::Delay::duration].
5558        pub fn set_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
5559            mut self,
5560            v: T,
5561        ) -> Self {
5562            self.duration = v.into();
5563            self
5564        }
5565    }
5566
5567    impl wkt::message::Message for Delay {
5568        fn typename() -> &'static str {
5569            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Delay"
5570        }
5571    }
5572
5573    /// A visit performed during a route. This visit corresponds to a pickup or a
5574    /// delivery of a `Shipment`.
5575    #[serde_with::serde_as]
5576    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
5577    #[serde(default, rename_all = "camelCase")]
5578    #[non_exhaustive]
5579    pub struct Visit {
5580        /// Index of the `shipments` field in the source
5581        /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel].
5582        ///
5583        /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
5584        pub shipment_index: i32,
5585
5586        /// If true the visit corresponds to a pickup of a `Shipment`. Otherwise, it
5587        /// corresponds to a delivery.
5588        pub is_pickup: bool,
5589
5590        /// Index of `VisitRequest` in either the pickup or delivery field of the
5591        /// `Shipment` (see `is_pickup`).
5592        pub visit_request_index: i32,
5593
5594        /// Time at which the visit starts. Note that the vehicle may arrive earlier
5595        /// than this at the visit location. Times are consistent with the
5596        /// `ShipmentModel`.
5597        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5598        pub start_time: std::option::Option<wkt::Timestamp>,
5599
5600        /// Total visit load demand as the sum of the shipment and the visit request
5601        /// `load_demands`. The values are negative if the visit is a delivery.
5602        /// Demands are reported for the same types as the
5603        /// [Transition.loads][google.cloud.optimization.v1.ShipmentRoute.Transition]
5604        /// (see this field).
5605        ///
5606        /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
5607        #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
5608        pub load_demands:
5609            std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
5610
5611        /// Extra detour time due to the shipments visited on the route before the
5612        /// visit and to the potential waiting time induced by time windows.
5613        /// If the visit is a delivery, the detour is computed from the corresponding
5614        /// pickup visit and is equal to:
5615        ///
5616        /// ```norust
5617        /// start_time(delivery) - start_time(pickup)
5618        /// - (duration(pickup) + travel duration from the pickup location
5619        /// to the delivery location).
5620        /// ```
5621        ///
5622        /// Otherwise, it is computed from the vehicle `start_location` and is equal
5623        /// to:
5624        ///
5625        /// ```norust
5626        /// start_time - vehicle_start_time - travel duration from
5627        /// the vehicle's `start_location` to the visit.
5628        /// ```
5629        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5630        pub detour: std::option::Option<wkt::Duration>,
5631
5632        /// Copy of the corresponding `Shipment.label`, if specified in the
5633        /// `Shipment`.
5634        #[serde(skip_serializing_if = "std::string::String::is_empty")]
5635        pub shipment_label: std::string::String,
5636
5637        /// Copy of the corresponding
5638        /// [VisitRequest.label][google.cloud.optimization.v1.Shipment.VisitRequest.label],
5639        /// if specified in the `VisitRequest`.
5640        ///
5641        /// [google.cloud.optimization.v1.Shipment.VisitRequest.label]: crate::model::shipment::VisitRequest::label
5642        #[serde(skip_serializing_if = "std::string::String::is_empty")]
5643        pub visit_label: std::string::String,
5644
5645        /// Deprecated: Use
5646        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
5647        /// instead. Vehicle loads upon arrival at the visit location, for each type
5648        /// specified in
5649        /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
5650        /// `start_load_intervals`, `end_load_intervals` or `demands`.
5651        ///
5652        /// Exception: we omit loads for quantity types unconstrained by intervals
5653        /// and that don't have any non-zero demand on the route.
5654        ///
5655        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
5656        /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
5657        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
5658        pub arrival_loads: std::vec::Vec<crate::model::CapacityQuantity>,
5659
5660        /// Deprecated: Use
5661        /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
5662        /// instead. Delay occurring before the visit starts.
5663        ///
5664        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
5665        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5666        pub delay_before_start: std::option::Option<crate::model::shipment_route::Delay>,
5667
5668        /// Deprecated: Use
5669        /// [Visit.load_demands][google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]
5670        /// instead.
5671        ///
5672        /// [google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]: crate::model::shipment_route::Visit::load_demands
5673        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
5674        pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
5675
5676        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
5677        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5678    }
5679
5680    impl Visit {
5681        pub fn new() -> Self {
5682            std::default::Default::default()
5683        }
5684
5685        /// Sets the value of [shipment_index][crate::model::shipment_route::Visit::shipment_index].
5686        pub fn set_shipment_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
5687            self.shipment_index = v.into();
5688            self
5689        }
5690
5691        /// Sets the value of [is_pickup][crate::model::shipment_route::Visit::is_pickup].
5692        pub fn set_is_pickup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5693            self.is_pickup = v.into();
5694            self
5695        }
5696
5697        /// Sets the value of [visit_request_index][crate::model::shipment_route::Visit::visit_request_index].
5698        pub fn set_visit_request_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
5699            self.visit_request_index = v.into();
5700            self
5701        }
5702
5703        /// Sets the value of [start_time][crate::model::shipment_route::Visit::start_time].
5704        pub fn set_start_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
5705            mut self,
5706            v: T,
5707        ) -> Self {
5708            self.start_time = v.into();
5709            self
5710        }
5711
5712        /// Sets the value of [detour][crate::model::shipment_route::Visit::detour].
5713        pub fn set_detour<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
5714            mut self,
5715            v: T,
5716        ) -> Self {
5717            self.detour = v.into();
5718            self
5719        }
5720
5721        /// Sets the value of [shipment_label][crate::model::shipment_route::Visit::shipment_label].
5722        pub fn set_shipment_label<T: std::convert::Into<std::string::String>>(
5723            mut self,
5724            v: T,
5725        ) -> Self {
5726            self.shipment_label = v.into();
5727            self
5728        }
5729
5730        /// Sets the value of [visit_label][crate::model::shipment_route::Visit::visit_label].
5731        pub fn set_visit_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5732            self.visit_label = v.into();
5733            self
5734        }
5735
5736        /// Sets the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
5737        pub fn set_delay_before_start<
5738            T: std::convert::Into<std::option::Option<crate::model::shipment_route::Delay>>,
5739        >(
5740            mut self,
5741            v: T,
5742        ) -> Self {
5743            self.delay_before_start = v.into();
5744            self
5745        }
5746
5747        /// Sets the value of [arrival_loads][crate::model::shipment_route::Visit::arrival_loads].
5748        pub fn set_arrival_loads<T, V>(mut self, v: T) -> Self
5749        where
5750            T: std::iter::IntoIterator<Item = V>,
5751            V: std::convert::Into<crate::model::CapacityQuantity>,
5752        {
5753            use std::iter::Iterator;
5754            self.arrival_loads = v.into_iter().map(|i| i.into()).collect();
5755            self
5756        }
5757
5758        /// Sets the value of [demands][crate::model::shipment_route::Visit::demands].
5759        pub fn set_demands<T, V>(mut self, v: T) -> Self
5760        where
5761            T: std::iter::IntoIterator<Item = V>,
5762            V: std::convert::Into<crate::model::CapacityQuantity>,
5763        {
5764            use std::iter::Iterator;
5765            self.demands = v.into_iter().map(|i| i.into()).collect();
5766            self
5767        }
5768
5769        /// Sets the value of [load_demands][crate::model::shipment_route::Visit::load_demands].
5770        pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
5771        where
5772            T: std::iter::IntoIterator<Item = (K, V)>,
5773            K: std::convert::Into<std::string::String>,
5774            V: std::convert::Into<crate::model::shipment::Load>,
5775        {
5776            use std::iter::Iterator;
5777            self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5778            self
5779        }
5780    }
5781
5782    impl wkt::message::Message for Visit {
5783        fn typename() -> &'static str {
5784            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Visit"
5785        }
5786    }
5787
5788    /// Transition between two events on the route. See the description of
5789    /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
5790    ///
5791    /// If the vehicle does not have a `start_location` and/or `end_location`, the
5792    /// corresponding travel metrics are 0.
5793    ///
5794    /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
5795    #[serde_with::serde_as]
5796    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
5797    #[serde(default, rename_all = "camelCase")]
5798    #[non_exhaustive]
5799    pub struct Transition {
5800        /// Travel duration during this transition.
5801        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5802        pub travel_duration: std::option::Option<wkt::Duration>,
5803
5804        /// Distance traveled during the transition.
5805        pub travel_distance_meters: f64,
5806
5807        /// When traffic is requested via
5808        /// [OptimizeToursRequest.consider_road_traffic]
5809        /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
5810        /// and the traffic info couldn't be retrieved for a `Transition`, this
5811        /// boolean is set to true. This may be temporary (rare hiccup in the
5812        /// realtime traffic servers) or permanent (no data for this location).
5813        pub traffic_info_unavailable: bool,
5814
5815        /// Sum of the delay durations applied to this transition. If any, the delay
5816        /// starts exactly `delay_duration` seconds before the next event (visit or
5817        /// vehicle end). See
5818        /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
5819        ///
5820        /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
5821        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5822        pub delay_duration: std::option::Option<wkt::Duration>,
5823
5824        /// Sum of the duration of the breaks occurring during this transition, if
5825        /// any. Details about each break's start time and duration are stored in
5826        /// [ShipmentRoute.breaks][google.cloud.optimization.v1.ShipmentRoute.breaks].
5827        ///
5828        /// [google.cloud.optimization.v1.ShipmentRoute.breaks]: crate::model::ShipmentRoute::breaks
5829        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5830        pub break_duration: std::option::Option<wkt::Duration>,
5831
5832        /// Time spent waiting during this transition. Wait duration corresponds to
5833        /// idle time and does not include break time. Also note that this wait time
5834        /// may be split into several non-contiguous intervals.
5835        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5836        pub wait_duration: std::option::Option<wkt::Duration>,
5837
5838        /// Total duration of the transition, provided for convenience. It is equal
5839        /// to:
5840        ///
5841        /// * next visit `start_time` (or `vehicle_end_time` if this is the last
5842        ///   transition) - this transition's `start_time`;
5843        /// * if `ShipmentRoute.has_traffic_infeasibilities` is false, the following
5844        ///   additionally holds: `total_duration = travel_duration + delay_duration
5845        ///
5846        /// + break_duration + wait_duration`.
5847        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5848        pub total_duration: std::option::Option<wkt::Duration>,
5849
5850        /// Start time of this transition.
5851        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5852        pub start_time: std::option::Option<wkt::Timestamp>,
5853
5854        /// The encoded polyline representation of the route followed during the
5855        /// transition.
5856        /// This field is only populated if [populate_transition_polylines]
5857        /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
5858        /// is set to true.
5859        #[serde(skip_serializing_if = "std::option::Option::is_none")]
5860        pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
5861
5862        /// Vehicle loads during this transition, for each type that either appears
5863        /// in this vehicle's
5864        /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits],
5865        /// or that have non-zero
5866        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
5867        /// on some shipment performed on this route.
5868        ///
5869        /// The loads during the first transition are the starting loads of the
5870        /// vehicle route. Then, after each visit, the visit's `load_demands` are
5871        /// either added or subtracted to get the next transition's loads, depending
5872        /// on whether the visit was a pickup or a delivery.
5873        ///
5874        /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
5875        /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
5876        #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
5877        pub vehicle_loads: std::collections::HashMap<
5878            std::string::String,
5879            crate::model::shipment_route::VehicleLoad,
5880        >,
5881
5882        /// Deprecated: Use
5883        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
5884        /// instead.
5885        ///
5886        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
5887        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
5888        pub loads: std::vec::Vec<crate::model::CapacityQuantity>,
5889
5890        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
5891        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5892    }
5893
5894    impl Transition {
5895        pub fn new() -> Self {
5896            std::default::Default::default()
5897        }
5898
5899        /// Sets the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
5900        pub fn set_travel_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
5901            mut self,
5902            v: T,
5903        ) -> Self {
5904            self.travel_duration = v.into();
5905            self
5906        }
5907
5908        /// Sets the value of [travel_distance_meters][crate::model::shipment_route::Transition::travel_distance_meters].
5909        pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5910            self.travel_distance_meters = v.into();
5911            self
5912        }
5913
5914        /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::Transition::traffic_info_unavailable].
5915        pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5916            self.traffic_info_unavailable = v.into();
5917            self
5918        }
5919
5920        /// Sets the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
5921        pub fn set_delay_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
5922            mut self,
5923            v: T,
5924        ) -> Self {
5925            self.delay_duration = v.into();
5926            self
5927        }
5928
5929        /// Sets the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
5930        pub fn set_break_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
5931            mut self,
5932            v: T,
5933        ) -> Self {
5934            self.break_duration = v.into();
5935            self
5936        }
5937
5938        /// Sets the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
5939        pub fn set_wait_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
5940            mut self,
5941            v: T,
5942        ) -> Self {
5943            self.wait_duration = v.into();
5944            self
5945        }
5946
5947        /// Sets the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
5948        pub fn set_total_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
5949            mut self,
5950            v: T,
5951        ) -> Self {
5952            self.total_duration = v.into();
5953            self
5954        }
5955
5956        /// Sets the value of [start_time][crate::model::shipment_route::Transition::start_time].
5957        pub fn set_start_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
5958            mut self,
5959            v: T,
5960        ) -> Self {
5961            self.start_time = v.into();
5962            self
5963        }
5964
5965        /// Sets the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
5966        pub fn set_route_polyline<
5967            T: std::convert::Into<std::option::Option<crate::model::shipment_route::EncodedPolyline>>,
5968        >(
5969            mut self,
5970            v: T,
5971        ) -> Self {
5972            self.route_polyline = v.into();
5973            self
5974        }
5975
5976        /// Sets the value of [loads][crate::model::shipment_route::Transition::loads].
5977        pub fn set_loads<T, V>(mut self, v: T) -> Self
5978        where
5979            T: std::iter::IntoIterator<Item = V>,
5980            V: std::convert::Into<crate::model::CapacityQuantity>,
5981        {
5982            use std::iter::Iterator;
5983            self.loads = v.into_iter().map(|i| i.into()).collect();
5984            self
5985        }
5986
5987        /// Sets the value of [vehicle_loads][crate::model::shipment_route::Transition::vehicle_loads].
5988        pub fn set_vehicle_loads<T, K, V>(mut self, v: T) -> Self
5989        where
5990            T: std::iter::IntoIterator<Item = (K, V)>,
5991            K: std::convert::Into<std::string::String>,
5992            V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
5993        {
5994            use std::iter::Iterator;
5995            self.vehicle_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5996            self
5997        }
5998    }
5999
6000    impl wkt::message::Message for Transition {
6001        fn typename() -> &'static str {
6002            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Transition"
6003        }
6004    }
6005
6006    /// Reports the actual load of the vehicle at some point along the route,
6007    /// for a given type (see
6008    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]).
6009    ///
6010    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
6011    #[serde_with::serde_as]
6012    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
6013    #[serde(default, rename_all = "camelCase")]
6014    #[non_exhaustive]
6015    pub struct VehicleLoad {
6016        /// The amount of load on the vehicle, for the given type. The unit of load
6017        /// is usually indicated by the type. See
6018        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads].
6019        ///
6020        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
6021        #[serde_as(as = "serde_with::DisplayFromStr")]
6022        pub amount: i64,
6023
6024        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
6025        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6026    }
6027
6028    impl VehicleLoad {
6029        pub fn new() -> Self {
6030            std::default::Default::default()
6031        }
6032
6033        /// Sets the value of [amount][crate::model::shipment_route::VehicleLoad::amount].
6034        pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6035            self.amount = v.into();
6036            self
6037        }
6038    }
6039
6040    impl wkt::message::Message for VehicleLoad {
6041        fn typename() -> &'static str {
6042            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.VehicleLoad"
6043        }
6044    }
6045
6046    /// The encoded representation of a polyline. More information on polyline
6047    /// encoding can be found here:
6048    /// <https://developers.google.com/maps/documentation/utilities/polylinealgorithm>
6049    /// <https://developers.google.com/maps/documentation/javascript/reference/geometry#encoding>.
6050    #[serde_with::serde_as]
6051    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
6052    #[serde(default, rename_all = "camelCase")]
6053    #[non_exhaustive]
6054    pub struct EncodedPolyline {
6055        /// String representing encoded points of the polyline.
6056        #[serde(skip_serializing_if = "std::string::String::is_empty")]
6057        pub points: std::string::String,
6058
6059        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
6060        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6061    }
6062
6063    impl EncodedPolyline {
6064        pub fn new() -> Self {
6065            std::default::Default::default()
6066        }
6067
6068        /// Sets the value of [points][crate::model::shipment_route::EncodedPolyline::points].
6069        pub fn set_points<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6070            self.points = v.into();
6071            self
6072        }
6073    }
6074
6075    impl wkt::message::Message for EncodedPolyline {
6076        fn typename() -> &'static str {
6077            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.EncodedPolyline"
6078        }
6079    }
6080
6081    /// Data representing the execution of a break.
6082    #[serde_with::serde_as]
6083    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
6084    #[serde(default, rename_all = "camelCase")]
6085    #[non_exhaustive]
6086    pub struct Break {
6087        /// Start time of a break.
6088        #[serde(skip_serializing_if = "std::option::Option::is_none")]
6089        pub start_time: std::option::Option<wkt::Timestamp>,
6090
6091        /// Duration of a break.
6092        #[serde(skip_serializing_if = "std::option::Option::is_none")]
6093        pub duration: std::option::Option<wkt::Duration>,
6094
6095        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
6096        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6097    }
6098
6099    impl Break {
6100        pub fn new() -> Self {
6101            std::default::Default::default()
6102        }
6103
6104        /// Sets the value of [start_time][crate::model::shipment_route::Break::start_time].
6105        pub fn set_start_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
6106            mut self,
6107            v: T,
6108        ) -> Self {
6109            self.start_time = v.into();
6110            self
6111        }
6112
6113        /// Sets the value of [duration][crate::model::shipment_route::Break::duration].
6114        pub fn set_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
6115            mut self,
6116            v: T,
6117        ) -> Self {
6118            self.duration = v.into();
6119            self
6120        }
6121    }
6122
6123    impl wkt::message::Message for Break {
6124        fn typename() -> &'static str {
6125            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Break"
6126        }
6127    }
6128
6129    /// Deprecated: Use
6130    /// [ShipmentRoute.Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
6131    /// instead. Travel between each visit along the route: from the vehicle's
6132    /// `start_location` to the first visit's `arrival_location`, then from the
6133    /// first visit's `departure_location` to the second visit's
6134    /// `arrival_location`, and so on until the vehicle's `end_location`. This
6135    /// accounts only for the actual travel between visits, not counting the
6136    /// waiting time, the time spent performing a visit, nor the distance covered
6137    /// during a visit.
6138    ///
6139    /// Invariant: `travel_steps_size() == visits_size() + 1`.
6140    ///
6141    /// If the vehicle does not have a start_ and/or end_location, the
6142    /// corresponding travel metrics are 0 and/or empty.
6143    ///
6144    /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
6145    #[serde_with::serde_as]
6146    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
6147    #[serde(default, rename_all = "camelCase")]
6148    #[non_exhaustive]
6149    pub struct TravelStep {
6150        /// Duration of the travel step.
6151        #[serde(skip_serializing_if = "std::option::Option::is_none")]
6152        pub duration: std::option::Option<wkt::Duration>,
6153
6154        /// Distance traveled during the step.
6155        pub distance_meters: f64,
6156
6157        /// When traffic is requested via
6158        /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
6159        /// and the traffic info couldn't be retrieved for a TravelStep, this boolean
6160        /// is set to true. This may be temporary (rare hiccup in the realtime
6161        /// traffic servers) or permanent (no data for this location).
6162        ///
6163        /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
6164        pub traffic_info_unavailable: bool,
6165
6166        /// The encoded polyline representation of the route followed during the
6167        /// step.
6168        ///
6169        /// This field is only populated if
6170        /// [OptimizeToursRequest.populate_travel_step_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]
6171        /// is set to true.
6172        ///
6173        /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]: crate::model::OptimizeToursRequest::populate_travel_step_polylines
6174        #[serde(skip_serializing_if = "std::option::Option::is_none")]
6175        pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
6176
6177        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
6178        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6179    }
6180
6181    impl TravelStep {
6182        pub fn new() -> Self {
6183            std::default::Default::default()
6184        }
6185
6186        /// Sets the value of [duration][crate::model::shipment_route::TravelStep::duration].
6187        pub fn set_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
6188            mut self,
6189            v: T,
6190        ) -> Self {
6191            self.duration = v.into();
6192            self
6193        }
6194
6195        /// Sets the value of [distance_meters][crate::model::shipment_route::TravelStep::distance_meters].
6196        pub fn set_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
6197            self.distance_meters = v.into();
6198            self
6199        }
6200
6201        /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::TravelStep::traffic_info_unavailable].
6202        pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6203            self.traffic_info_unavailable = v.into();
6204            self
6205        }
6206
6207        /// Sets the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
6208        pub fn set_route_polyline<
6209            T: std::convert::Into<std::option::Option<crate::model::shipment_route::EncodedPolyline>>,
6210        >(
6211            mut self,
6212            v: T,
6213        ) -> Self {
6214            self.route_polyline = v.into();
6215            self
6216        }
6217    }
6218
6219    impl wkt::message::Message for TravelStep {
6220        fn typename() -> &'static str {
6221            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.TravelStep"
6222        }
6223    }
6224}
6225
6226/// Specifies details of unperformed shipments in a solution. For trivial cases
6227/// and/or if we are able to identify the cause for skipping, we report the
6228/// reason here.
6229#[serde_with::serde_as]
6230#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
6231#[serde(default, rename_all = "camelCase")]
6232#[non_exhaustive]
6233pub struct SkippedShipment {
6234    /// The index corresponds to the index of the shipment in the source
6235    /// `ShipmentModel`.
6236    pub index: i32,
6237
6238    /// Copy of the corresponding
6239    /// [Shipment.label][google.cloud.optimization.v1.Shipment.label], if specified
6240    /// in the `Shipment`.
6241    ///
6242    /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
6243    #[serde(skip_serializing_if = "std::string::String::is_empty")]
6244    pub label: std::string::String,
6245
6246    /// A list of reasons that explain why the shipment was skipped. See comment
6247    /// above `Reason`.
6248    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
6249    pub reasons: std::vec::Vec<crate::model::skipped_shipment::Reason>,
6250
6251    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
6252    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6253}
6254
6255impl SkippedShipment {
6256    pub fn new() -> Self {
6257        std::default::Default::default()
6258    }
6259
6260    /// Sets the value of [index][crate::model::SkippedShipment::index].
6261    pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
6262        self.index = v.into();
6263        self
6264    }
6265
6266    /// Sets the value of [label][crate::model::SkippedShipment::label].
6267    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6268        self.label = v.into();
6269        self
6270    }
6271
6272    /// Sets the value of [reasons][crate::model::SkippedShipment::reasons].
6273    pub fn set_reasons<T, V>(mut self, v: T) -> Self
6274    where
6275        T: std::iter::IntoIterator<Item = V>,
6276        V: std::convert::Into<crate::model::skipped_shipment::Reason>,
6277    {
6278        use std::iter::Iterator;
6279        self.reasons = v.into_iter().map(|i| i.into()).collect();
6280        self
6281    }
6282}
6283
6284impl wkt::message::Message for SkippedShipment {
6285    fn typename() -> &'static str {
6286        "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment"
6287    }
6288}
6289
6290/// Defines additional types related to [SkippedShipment].
6291pub mod skipped_shipment {
6292    #[allow(unused_imports)]
6293    use super::*;
6294
6295    /// If we can explain why the shipment was skipped, reasons will be listed
6296    /// here. If the reason is not the same for all vehicles, `reason` will have
6297    /// more than 1 element. A skipped shipment cannot have duplicate reasons,
6298    /// i.e. where all fields are the same except for `example_vehicle_index`.
6299    /// Example:
6300    ///
6301    /// ```norust
6302    /// reasons {
6303    ///   code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
6304    ///   example_vehicle_index: 1
6305    ///   example_exceeded_capacity_type: "Apples"
6306    /// }
6307    /// reasons {
6308    ///   code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
6309    ///   example_vehicle_index: 3
6310    ///   example_exceeded_capacity_type: "Pears"
6311    /// }
6312    /// reasons {
6313    ///   code: CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT
6314    ///   example_vehicle_index: 1
6315    /// }
6316    /// ```
6317    ///
6318    /// The skipped shipment is incompatible with all vehicles. The reasons may
6319    /// be different for all vehicles but at least one vehicle's "Apples"
6320    /// capacity would be exceeded (including vehicle 1), at least one vehicle's
6321    /// "Pears" capacity would be exceeded (including vehicle 3) and at least one
6322    /// vehicle's distance limit would be exceeded (including vehicle 1).
6323    #[serde_with::serde_as]
6324    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
6325    #[serde(default, rename_all = "camelCase")]
6326    #[non_exhaustive]
6327    pub struct Reason {
6328        /// Refer to the comments of Code.
6329        pub code: crate::model::skipped_shipment::reason::Code,
6330
6331        /// If the reason is related to a shipment-vehicle incompatibility, this
6332        /// field provides the index of one relevant vehicle.
6333        #[serde(skip_serializing_if = "std::option::Option::is_none")]
6334        pub example_vehicle_index: std::option::Option<i32>,
6335
6336        /// If the reason code is `DEMAND_EXCEEDS_VEHICLE_CAPACITY`, documents one
6337        /// capacity type that is exceeded.
6338        #[serde(skip_serializing_if = "std::string::String::is_empty")]
6339        pub example_exceeded_capacity_type: std::string::String,
6340
6341        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
6342        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6343    }
6344
6345    impl Reason {
6346        pub fn new() -> Self {
6347            std::default::Default::default()
6348        }
6349
6350        /// Sets the value of [code][crate::model::skipped_shipment::Reason::code].
6351        pub fn set_code<T: std::convert::Into<crate::model::skipped_shipment::reason::Code>>(
6352            mut self,
6353            v: T,
6354        ) -> Self {
6355            self.code = v.into();
6356            self
6357        }
6358
6359        /// Sets the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
6360        pub fn set_example_vehicle_index<T: std::convert::Into<std::option::Option<i32>>>(
6361            mut self,
6362            v: T,
6363        ) -> Self {
6364            self.example_vehicle_index = v.into();
6365            self
6366        }
6367
6368        /// Sets the value of [example_exceeded_capacity_type][crate::model::skipped_shipment::Reason::example_exceeded_capacity_type].
6369        pub fn set_example_exceeded_capacity_type<T: std::convert::Into<std::string::String>>(
6370            mut self,
6371            v: T,
6372        ) -> Self {
6373            self.example_exceeded_capacity_type = v.into();
6374            self
6375        }
6376    }
6377
6378    impl wkt::message::Message for Reason {
6379        fn typename() -> &'static str {
6380            "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment.Reason"
6381        }
6382    }
6383
6384    /// Defines additional types related to [Reason].
6385    pub mod reason {
6386        #[allow(unused_imports)]
6387        use super::*;
6388
6389        /// Code identifying the reason type. The order here is meaningless. In
6390        /// particular, it gives no indication of whether a given reason will
6391        /// appear before another in the solution, if both apply.
6392        #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
6393        pub struct Code(i32);
6394
6395        impl Code {
6396            /// This should never be used. If we are unable to understand why a
6397            /// shipment was skipped, we simply return an empty set of reasons.
6398            pub const CODE_UNSPECIFIED: Code = Code::new(0);
6399
6400            /// There is no vehicle in the model making all shipments infeasible.
6401            pub const NO_VEHICLE: Code = Code::new(1);
6402
6403            /// The demand of the shipment exceeds a vehicle's capacity for some
6404            /// capacity types, one of which is `example_exceeded_capacity_type`.
6405            pub const DEMAND_EXCEEDS_VEHICLE_CAPACITY: Code = Code::new(2);
6406
6407            /// The minimum distance necessary to perform this shipment, i.e. from
6408            /// the vehicle's `start_location` to the shipment's pickup and/or delivery
6409            /// locations and to the vehicle's end location exceeds the vehicle's
6410            /// `route_distance_limit`.
6411            ///
6412            /// Note that for this computation we use the geodesic distances.
6413            pub const CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT: Code = Code::new(3);
6414
6415            /// The minimum time necessary to perform this shipment, including travel
6416            /// time, wait time and service time exceeds the vehicle's
6417            /// `route_duration_limit`.
6418            ///
6419            /// Note: travel time is computed in the best-case scenario, namely as
6420            /// geodesic distance x 36 m/s (roughly 130 km/hour).
6421            pub const CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT: Code = Code::new(4);
6422
6423            /// Same as above but we only compare minimum travel time and the
6424            /// vehicle's `travel_duration_limit`.
6425            pub const CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT: Code = Code::new(5);
6426
6427            /// The vehicle cannot perform this shipment in the best-case scenario
6428            /// (see `CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT` for time
6429            /// computation) if it starts at its earliest start time: the total time
6430            /// would make the vehicle end after its latest end time.
6431            pub const CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS: Code = Code::new(6);
6432
6433            /// The `allowed_vehicle_indices` field of the shipment is not empty and
6434            /// this vehicle does not belong to it.
6435            pub const VEHICLE_NOT_ALLOWED: Code = Code::new(7);
6436
6437            /// Creates a new Code instance.
6438            pub(crate) const fn new(value: i32) -> Self {
6439                Self(value)
6440            }
6441
6442            /// Gets the enum value.
6443            pub fn value(&self) -> i32 {
6444                self.0
6445            }
6446
6447            /// Gets the enum value as a string.
6448            pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
6449                match self.0 {
6450                    0 => std::borrow::Cow::Borrowed("CODE_UNSPECIFIED"),
6451                    1 => std::borrow::Cow::Borrowed("NO_VEHICLE"),
6452                    2 => std::borrow::Cow::Borrowed("DEMAND_EXCEEDS_VEHICLE_CAPACITY"),
6453                    3 => std::borrow::Cow::Borrowed(
6454                        "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT",
6455                    ),
6456                    4 => std::borrow::Cow::Borrowed(
6457                        "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT",
6458                    ),
6459                    5 => std::borrow::Cow::Borrowed(
6460                        "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT",
6461                    ),
6462                    6 => std::borrow::Cow::Borrowed(
6463                        "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS",
6464                    ),
6465                    7 => std::borrow::Cow::Borrowed("VEHICLE_NOT_ALLOWED"),
6466                    _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
6467                }
6468            }
6469
6470            /// Creates an enum value from the value name.
6471            pub fn from_str_name(name: &str) -> std::option::Option<Self> {
6472                match name {
6473                    "CODE_UNSPECIFIED" => std::option::Option::Some(Self::CODE_UNSPECIFIED),
6474                    "NO_VEHICLE" => std::option::Option::Some(Self::NO_VEHICLE),
6475                    "DEMAND_EXCEEDS_VEHICLE_CAPACITY" => {
6476                        std::option::Option::Some(Self::DEMAND_EXCEEDS_VEHICLE_CAPACITY)
6477                    }
6478                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT" => {
6479                        std::option::Option::Some(
6480                            Self::CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT,
6481                        )
6482                    }
6483                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT" => {
6484                        std::option::Option::Some(
6485                            Self::CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT,
6486                        )
6487                    }
6488                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT" => {
6489                        std::option::Option::Some(
6490                            Self::CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT,
6491                        )
6492                    }
6493                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS" => std::option::Option::Some(
6494                        Self::CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS,
6495                    ),
6496                    "VEHICLE_NOT_ALLOWED" => std::option::Option::Some(Self::VEHICLE_NOT_ALLOWED),
6497                    _ => std::option::Option::None,
6498                }
6499            }
6500        }
6501
6502        impl std::convert::From<i32> for Code {
6503            fn from(value: i32) -> Self {
6504                Self::new(value)
6505            }
6506        }
6507
6508        impl std::default::Default for Code {
6509            fn default() -> Self {
6510                Self::new(0)
6511            }
6512        }
6513    }
6514}
6515
6516/// Aggregated metrics for
6517/// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute] (resp. for
6518/// [OptimizeToursResponse][google.cloud.optimization.v1.OptimizeToursResponse]
6519/// over all [Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
6520/// and/or [Visit][google.cloud.optimization.v1.ShipmentRoute.Visit] (resp. over
6521/// all [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]) elements.
6522///
6523/// [google.cloud.optimization.v1.OptimizeToursResponse]: crate::model::OptimizeToursResponse
6524/// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
6525/// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
6526/// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
6527#[serde_with::serde_as]
6528#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
6529#[serde(default, rename_all = "camelCase")]
6530#[non_exhaustive]
6531pub struct AggregatedMetrics {
6532    /// Number of shipments performed. Note that a pickup and delivery pair only
6533    /// counts once.
6534    pub performed_shipment_count: i32,
6535
6536    /// Total travel duration for a route or a solution.
6537    #[serde(skip_serializing_if = "std::option::Option::is_none")]
6538    pub travel_duration: std::option::Option<wkt::Duration>,
6539
6540    /// Total wait duration for a route or a solution.
6541    #[serde(skip_serializing_if = "std::option::Option::is_none")]
6542    pub wait_duration: std::option::Option<wkt::Duration>,
6543
6544    /// Total delay duration for a route or a solution.
6545    #[serde(skip_serializing_if = "std::option::Option::is_none")]
6546    pub delay_duration: std::option::Option<wkt::Duration>,
6547
6548    /// Total break duration for a route or a solution.
6549    #[serde(skip_serializing_if = "std::option::Option::is_none")]
6550    pub break_duration: std::option::Option<wkt::Duration>,
6551
6552    /// Total visit duration for a route or a solution.
6553    #[serde(skip_serializing_if = "std::option::Option::is_none")]
6554    pub visit_duration: std::option::Option<wkt::Duration>,
6555
6556    /// The total duration should be equal to the sum of all durations above.
6557    /// For routes, it also corresponds to:
6558    /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]
6559    /// `-`
6560    /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]
6561    ///
6562    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
6563    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
6564    #[serde(skip_serializing_if = "std::option::Option::is_none")]
6565    pub total_duration: std::option::Option<wkt::Duration>,
6566
6567    /// Total travel distance for a route or a solution.
6568    pub travel_distance_meters: f64,
6569
6570    /// Maximum load achieved over the entire route (resp. solution), for each of
6571    /// the quantities on this route (resp. solution), computed as the maximum over
6572    /// all
6573    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
6574    /// (resp.
6575    /// [ShipmentRoute.metrics.max_loads][google.cloud.optimization.v1.AggregatedMetrics.max_loads].
6576    ///
6577    /// [google.cloud.optimization.v1.AggregatedMetrics.max_loads]: crate::model::AggregatedMetrics::max_loads
6578    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
6579    #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
6580    pub max_loads:
6581        std::collections::HashMap<std::string::String, crate::model::shipment_route::VehicleLoad>,
6582
6583    /// Deprecated: Use
6584    /// [ShipmentRoute.route_costs][google.cloud.optimization.v1.ShipmentRoute.route_costs]
6585    /// and
6586    /// [OptimizeToursResponse.Metrics.costs][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]
6587    /// instead.
6588    ///
6589    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]: crate::model::optimize_tours_response::Metrics::costs
6590    /// [google.cloud.optimization.v1.ShipmentRoute.route_costs]: crate::model::ShipmentRoute::route_costs
6591    #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
6592    pub costs: std::collections::HashMap<std::string::String, f64>,
6593
6594    /// Deprecated: Use
6595    /// [ShipmentRoute.route_total_cost][google.cloud.optimization.v1.ShipmentRoute.route_total_cost]
6596    /// and
6597    /// [OptimizeToursResponse.Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
6598    /// instead.
6599    ///
6600    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
6601    /// [google.cloud.optimization.v1.ShipmentRoute.route_total_cost]: crate::model::ShipmentRoute::route_total_cost
6602    pub total_cost: f64,
6603
6604    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
6605    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6606}
6607
6608impl AggregatedMetrics {
6609    pub fn new() -> Self {
6610        std::default::Default::default()
6611    }
6612
6613    /// Sets the value of [performed_shipment_count][crate::model::AggregatedMetrics::performed_shipment_count].
6614    pub fn set_performed_shipment_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
6615        self.performed_shipment_count = v.into();
6616        self
6617    }
6618
6619    /// Sets the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
6620    pub fn set_travel_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
6621        mut self,
6622        v: T,
6623    ) -> Self {
6624        self.travel_duration = v.into();
6625        self
6626    }
6627
6628    /// Sets the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
6629    pub fn set_wait_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
6630        mut self,
6631        v: T,
6632    ) -> Self {
6633        self.wait_duration = v.into();
6634        self
6635    }
6636
6637    /// Sets the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
6638    pub fn set_delay_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
6639        mut self,
6640        v: T,
6641    ) -> Self {
6642        self.delay_duration = v.into();
6643        self
6644    }
6645
6646    /// Sets the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
6647    pub fn set_break_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
6648        mut self,
6649        v: T,
6650    ) -> Self {
6651        self.break_duration = v.into();
6652        self
6653    }
6654
6655    /// Sets the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
6656    pub fn set_visit_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
6657        mut self,
6658        v: T,
6659    ) -> Self {
6660        self.visit_duration = v.into();
6661        self
6662    }
6663
6664    /// Sets the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
6665    pub fn set_total_duration<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
6666        mut self,
6667        v: T,
6668    ) -> Self {
6669        self.total_duration = v.into();
6670        self
6671    }
6672
6673    /// Sets the value of [travel_distance_meters][crate::model::AggregatedMetrics::travel_distance_meters].
6674    pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
6675        self.travel_distance_meters = v.into();
6676        self
6677    }
6678
6679    /// Sets the value of [total_cost][crate::model::AggregatedMetrics::total_cost].
6680    pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
6681        self.total_cost = v.into();
6682        self
6683    }
6684
6685    /// Sets the value of [max_loads][crate::model::AggregatedMetrics::max_loads].
6686    pub fn set_max_loads<T, K, V>(mut self, v: T) -> Self
6687    where
6688        T: std::iter::IntoIterator<Item = (K, V)>,
6689        K: std::convert::Into<std::string::String>,
6690        V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
6691    {
6692        use std::iter::Iterator;
6693        self.max_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6694        self
6695    }
6696
6697    /// Sets the value of [costs][crate::model::AggregatedMetrics::costs].
6698    pub fn set_costs<T, K, V>(mut self, v: T) -> Self
6699    where
6700        T: std::iter::IntoIterator<Item = (K, V)>,
6701        K: std::convert::Into<std::string::String>,
6702        V: std::convert::Into<f64>,
6703    {
6704        use std::iter::Iterator;
6705        self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6706        self
6707    }
6708}
6709
6710impl wkt::message::Message for AggregatedMetrics {
6711    fn typename() -> &'static str {
6712        "type.googleapis.com/google.cloud.optimization.v1.AggregatedMetrics"
6713    }
6714}
6715
6716/// Solution injected in the request including information about which visits
6717/// must be constrained and how they must be constrained.
6718#[serde_with::serde_as]
6719#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
6720#[serde(default, rename_all = "camelCase")]
6721#[non_exhaustive]
6722pub struct InjectedSolutionConstraint {
6723    /// Routes of the solution to inject. Some routes may be omitted from the
6724    /// original solution. The routes and skipped shipments must satisfy the basic
6725    /// validity assumptions listed for `injected_first_solution_routes`.
6726    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
6727    pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
6728
6729    /// Skipped shipments of the solution to inject. Some may be omitted from the
6730    /// original solution. See the `routes` field.
6731    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
6732    pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
6733
6734    /// For zero or more groups of vehicles, specifies when and how much to relax
6735    /// constraints. If this field is empty, all non-empty vehicle routes are
6736    /// fully constrained.
6737    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
6738    pub constraint_relaxations:
6739        std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>,
6740
6741    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
6742    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6743}
6744
6745impl InjectedSolutionConstraint {
6746    pub fn new() -> Self {
6747        std::default::Default::default()
6748    }
6749
6750    /// Sets the value of [routes][crate::model::InjectedSolutionConstraint::routes].
6751    pub fn set_routes<T, V>(mut self, v: T) -> Self
6752    where
6753        T: std::iter::IntoIterator<Item = V>,
6754        V: std::convert::Into<crate::model::ShipmentRoute>,
6755    {
6756        use std::iter::Iterator;
6757        self.routes = v.into_iter().map(|i| i.into()).collect();
6758        self
6759    }
6760
6761    /// Sets the value of [skipped_shipments][crate::model::InjectedSolutionConstraint::skipped_shipments].
6762    pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
6763    where
6764        T: std::iter::IntoIterator<Item = V>,
6765        V: std::convert::Into<crate::model::SkippedShipment>,
6766    {
6767        use std::iter::Iterator;
6768        self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
6769        self
6770    }
6771
6772    /// Sets the value of [constraint_relaxations][crate::model::InjectedSolutionConstraint::constraint_relaxations].
6773    pub fn set_constraint_relaxations<T, V>(mut self, v: T) -> Self
6774    where
6775        T: std::iter::IntoIterator<Item = V>,
6776        V: std::convert::Into<crate::model::injected_solution_constraint::ConstraintRelaxation>,
6777    {
6778        use std::iter::Iterator;
6779        self.constraint_relaxations = v.into_iter().map(|i| i.into()).collect();
6780        self
6781    }
6782}
6783
6784impl wkt::message::Message for InjectedSolutionConstraint {
6785    fn typename() -> &'static str {
6786        "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint"
6787    }
6788}
6789
6790/// Defines additional types related to [InjectedSolutionConstraint].
6791pub mod injected_solution_constraint {
6792    #[allow(unused_imports)]
6793    use super::*;
6794
6795    /// For a group of vehicles, specifies at what threshold(s) constraints on
6796    /// visits will be relaxed and to which level. Shipments listed in
6797    /// the `skipped_shipment` field are constrained to be skipped; i.e., they
6798    /// cannot be performed.
6799    #[serde_with::serde_as]
6800    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
6801    #[serde(default, rename_all = "camelCase")]
6802    #[non_exhaustive]
6803    pub struct ConstraintRelaxation {
6804        /// All the visit constraint relaxations that will apply to visits on
6805        /// routes with vehicles in `vehicle_indices`.
6806        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
6807        pub relaxations: std::vec::Vec<
6808            crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
6809        >,
6810
6811        /// Specifies the vehicle indices to which the visit constraint
6812        /// `relaxations` apply. If empty, this is considered the default and the
6813        /// `relaxations` apply to all vehicles that are not specified in other
6814        /// `constraint_relaxations`. There can be at most one default, i.e., at
6815        /// most one constraint relaxation field is allowed empty
6816        /// `vehicle_indices`. A vehicle index can only be listed once, even within
6817        /// several `constraint_relaxations`.
6818        ///
6819        /// A vehicle index is mapped the same as
6820        /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index],
6821        /// if `interpret_injected_solutions_using_labels` is true (see `fields`
6822        /// comment).
6823        ///
6824        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
6825        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
6826        pub vehicle_indices: std::vec::Vec<i32>,
6827
6828        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
6829        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6830    }
6831
6832    impl ConstraintRelaxation {
6833        pub fn new() -> Self {
6834            std::default::Default::default()
6835        }
6836
6837        /// Sets the value of [relaxations][crate::model::injected_solution_constraint::ConstraintRelaxation::relaxations].
6838        pub fn set_relaxations<T, V>(mut self, v: T) -> Self
6839        where
6840            T: std::iter::IntoIterator<Item = V>,
6841            V: std::convert::Into<
6842                    crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
6843                >,
6844        {
6845            use std::iter::Iterator;
6846            self.relaxations = v.into_iter().map(|i| i.into()).collect();
6847            self
6848        }
6849
6850        /// Sets the value of [vehicle_indices][crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices].
6851        pub fn set_vehicle_indices<T, V>(mut self, v: T) -> Self
6852        where
6853            T: std::iter::IntoIterator<Item = V>,
6854            V: std::convert::Into<i32>,
6855        {
6856            use std::iter::Iterator;
6857            self.vehicle_indices = v.into_iter().map(|i| i.into()).collect();
6858            self
6859        }
6860    }
6861
6862    impl wkt::message::Message for ConstraintRelaxation {
6863        fn typename() -> &'static str {
6864            "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation"
6865        }
6866    }
6867
6868    /// Defines additional types related to [ConstraintRelaxation].
6869    pub mod constraint_relaxation {
6870        #[allow(unused_imports)]
6871        use super::*;
6872
6873        /// If `relaxations` is empty, the start time and sequence of all visits
6874        /// on `routes` are fully constrained and no new visits may be inserted or
6875        /// added to those routes. Also, a vehicle's start and end time in
6876        /// `routes` is fully constrained, unless the vehicle is empty (i.e., has no
6877        /// visits and has `used_if_route_is_empty` set to false in the model).
6878        ///
6879        /// `relaxations(i).level` specifies the constraint relaxation level applied
6880        /// to a visit #j that satisfies:
6881        ///
6882        /// * `route.visits(j).start_time >= relaxations(i).threshold_time` AND
6883        /// * `j + 1 >= relaxations(i).threshold_visit_count`
6884        ///
6885        /// Similarly, the vehicle start is relaxed to `relaxations(i).level` if it
6886        /// satisfies:
6887        ///
6888        /// * `vehicle_start_time >= relaxations(i).threshold_time` AND
6889        /// * `relaxations(i).threshold_visit_count == 0`
6890        ///   and the vehicle end is relaxed to `relaxations(i).level` if it satisfies:
6891        /// * `vehicle_end_time >= relaxations(i).threshold_time` AND
6892        /// * `route.visits_size() + 1 >= relaxations(i).threshold_visit_count`
6893        ///
6894        /// To apply a relaxation level if a visit meets the `threshold_visit_count`
6895        /// OR the `threshold_time` add two `relaxations` with the same `level`:
6896        /// one with only `threshold_visit_count` set and the other with only
6897        /// `threshold_time` set. If a visit satisfies the conditions of multiple
6898        /// `relaxations`, the most relaxed level applies. As a result, from the
6899        /// vehicle start through the route visits in order to the vehicle end, the
6900        /// relaxation level becomes more relaxed: i.e., the relaxation level is
6901        /// non-decreasing as the route progresses.
6902        ///
6903        /// The timing and sequence of route visits that do not satisfy the
6904        /// threshold conditions of any `relaxations` are fully constrained
6905        /// and no visits may be inserted into these sequences. Also, if a
6906        /// vehicle start or end does not satisfy the conditions of any
6907        /// relaxation the time is fixed, unless the vehicle is empty.
6908        #[serde_with::serde_as]
6909        #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
6910        #[serde(default, rename_all = "camelCase")]
6911        #[non_exhaustive]
6912        pub struct Relaxation {
6913
6914            /// The constraint relaxation level that applies when the conditions
6915            /// at or after `threshold_time` AND at least `threshold_visit_count` are
6916            /// satisfied.
6917            pub level: crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level,
6918
6919            /// The time at or after which the relaxation `level` may be applied.
6920            #[serde(skip_serializing_if = "std::option::Option::is_none")]
6921            pub threshold_time: std::option::Option<wkt::Timestamp>,
6922
6923            /// The number of visits at or after which the relaxation `level` may be
6924            /// applied. If `threshold_visit_count` is 0 (or unset), the `level` may be
6925            /// applied directly at the vehicle start.
6926            ///
6927            /// If it is `route.visits_size() + 1`, the `level` may only be applied to
6928            /// the vehicle end. If it is more than `route.visits_size() + 1`,
6929            /// `level` is not applied at all for that route.
6930            pub threshold_visit_count: i32,
6931
6932            #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
6933            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6934        }
6935
6936        impl Relaxation {
6937            pub fn new() -> Self {
6938                std::default::Default::default()
6939            }
6940
6941            /// Sets the value of [level][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::level].
6942            pub fn set_level<T: std::convert::Into<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>(mut self, v: T) -> Self{
6943                self.level = v.into();
6944                self
6945            }
6946
6947            /// Sets the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
6948            pub fn set_threshold_time<
6949                T: std::convert::Into<std::option::Option<wkt::Timestamp>>,
6950            >(
6951                mut self,
6952                v: T,
6953            ) -> Self {
6954                self.threshold_time = v.into();
6955                self
6956            }
6957
6958            /// Sets the value of [threshold_visit_count][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_visit_count].
6959            pub fn set_threshold_visit_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
6960                self.threshold_visit_count = v.into();
6961                self
6962            }
6963        }
6964
6965        impl wkt::message::Message for Relaxation {
6966            fn typename() -> &'static str {
6967                "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation"
6968            }
6969        }
6970
6971        /// Defines additional types related to [Relaxation].
6972        pub mod relaxation {
6973            #[allow(unused_imports)]
6974            use super::*;
6975
6976            /// Expresses the different constraint relaxation levels, which are
6977            /// applied for a visit and those that follow when it satisfies the
6978            /// threshold conditions.
6979            ///
6980            /// The enumeration below is in order of increasing relaxation.
6981            #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
6982            pub struct Level(i32);
6983
6984            impl Level {
6985                /// Implicit default relaxation level: no constraints are relaxed,
6986                /// i.e., all visits are fully constrained.
6987                ///
6988                /// This value must not be explicitly used in `level`.
6989                pub const LEVEL_UNSPECIFIED: Level = Level::new(0);
6990
6991                /// Visit start times and vehicle start/end times will be relaxed, but
6992                /// each visit remains bound to the same vehicle and the visit sequence
6993                /// must be observed: no visit can be inserted between them or before
6994                /// them.
6995                pub const RELAX_VISIT_TIMES_AFTER_THRESHOLD: Level = Level::new(1);
6996
6997                /// Same as `RELAX_VISIT_TIMES_AFTER_THRESHOLD`, but the visit sequence
6998                /// is also relaxed: visits can only be performed by this vehicle, but
6999                /// can potentially become unperformed.
7000                pub const RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD: Level = Level::new(2);
7001
7002                /// Same as `RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD`, but the
7003                /// vehicle is also relaxed: visits are completely free at or after the
7004                /// threshold time and can potentially become unperformed.
7005                pub const RELAX_ALL_AFTER_THRESHOLD: Level = Level::new(3);
7006
7007                /// Creates a new Level instance.
7008                pub(crate) const fn new(value: i32) -> Self {
7009                    Self(value)
7010                }
7011
7012                /// Gets the enum value.
7013                pub fn value(&self) -> i32 {
7014                    self.0
7015                }
7016
7017                /// Gets the enum value as a string.
7018                pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
7019                    match self.0 {
7020                        0 => std::borrow::Cow::Borrowed("LEVEL_UNSPECIFIED"),
7021                        1 => std::borrow::Cow::Borrowed("RELAX_VISIT_TIMES_AFTER_THRESHOLD"),
7022                        2 => std::borrow::Cow::Borrowed(
7023                            "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD",
7024                        ),
7025                        3 => std::borrow::Cow::Borrowed("RELAX_ALL_AFTER_THRESHOLD"),
7026                        _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
7027                    }
7028                }
7029
7030                /// Creates an enum value from the value name.
7031                pub fn from_str_name(name: &str) -> std::option::Option<Self> {
7032                    match name {
7033                        "LEVEL_UNSPECIFIED" => std::option::Option::Some(Self::LEVEL_UNSPECIFIED),
7034                        "RELAX_VISIT_TIMES_AFTER_THRESHOLD" => {
7035                            std::option::Option::Some(Self::RELAX_VISIT_TIMES_AFTER_THRESHOLD)
7036                        }
7037                        "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD" => {
7038                            std::option::Option::Some(
7039                                Self::RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD,
7040                            )
7041                        }
7042                        "RELAX_ALL_AFTER_THRESHOLD" => {
7043                            std::option::Option::Some(Self::RELAX_ALL_AFTER_THRESHOLD)
7044                        }
7045                        _ => std::option::Option::None,
7046                    }
7047                }
7048            }
7049
7050            impl std::convert::From<i32> for Level {
7051                fn from(value: i32) -> Self {
7052                    Self::new(value)
7053                }
7054            }
7055
7056            impl std::default::Default for Level {
7057                fn default() -> Self {
7058                    Self::new(0)
7059                }
7060            }
7061        }
7062    }
7063}
7064
7065/// Describes an error encountered when validating an `OptimizeToursRequest`.
7066#[serde_with::serde_as]
7067#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
7068#[serde(default, rename_all = "camelCase")]
7069#[non_exhaustive]
7070pub struct OptimizeToursValidationError {
7071    /// A validation error is defined by the pair (`code`, `display_name`) which
7072    /// are always present.
7073    ///
7074    /// Other fields (below) provide more context about the error.
7075    ///
7076    /// *MULTIPLE ERRORS*:
7077    /// When there are multiple errors, the validation process tries to output
7078    /// several of them. Much like a compiler, this is an imperfect process. Some
7079    /// validation errors will be "fatal", meaning that they stop the entire
7080    /// validation process. This is the case for `display_name="UNSPECIFIED"`
7081    /// errors, among others. Some may cause the validation process to skip other
7082    /// errors.
7083    ///
7084    /// *STABILITY*:
7085    /// `code` and `display_name` should be very stable. But new codes and
7086    /// display names may appear over time, which may cause a given (invalid)
7087    /// request to yield a different (`code`, `display_name`) pair because the new
7088    /// error hid the old one (see "MULTIPLE ERRORS").
7089    ///
7090    /// *REFERENCE*: A list of all (code, name) pairs:
7091    ///
7092    /// * UNSPECIFIED = 0;
7093    ///
7094    /// * VALIDATION_TIMEOUT_ERROR = 10; Validation couldn't be completed within
7095    ///   the deadline.
7096    ///
7097    /// * REQUEST_OPTIONS_ERROR = 12;
7098    ///
7099    ///   * REQUEST_OPTIONS_INVALID_SOLVING_MODE = 1201;
7100    ///   * REQUEST_OPTIONS_INVALID_MAX_VALIDATION_ERRORS = 1203;
7101    ///   * REQUEST_OPTIONS_INVALID_GEODESIC_METERS_PER_SECOND = 1204;
7102    ///   * REQUEST_OPTIONS_GEODESIC_METERS_PER_SECOND_TOO_SMALL = 1205;
7103    ///   * REQUEST_OPTIONS_MISSING_GEODESIC_METERS_PER_SECOND = 1206;
7104    ///   * REQUEST_OPTIONS_POPULATE_PATHFINDER_TRIPS_AND_GEODESIC_DISTANCE
7105    ///     = 1207;
7106    ///   * REQUEST_OPTIONS_COST_MODEL_OPTIONS_AND_GEODESIC_DISTANCE = 1208;
7107    ///   * REQUEST_OPTIONS_TRAVEL_MODE_INCOMPATIBLE_WITH_TRAFFIC = 1211;
7108    ///   * REQUEST_OPTIONS_MULTIPLE_TRAFFIC_FLAVORS = 1212;
7109    ///   * REQUEST_OPTIONS_INVALID_TRAFFIC_FLAVOR = 1213;
7110    ///   * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITHOUT_GLOBAL_START_TIME = 1214;
7111    ///   * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITH_PRECEDENCES = 1215;
7112    ///   * REQUEST_OPTIONS_TRAFFIC_PREFILL_MODE_INVALID = 1216;
7113    ///   * REQUEST_OPTIONS_TRAFFIC_PREFILL_ENABLED_WITHOUT_TRAFFIC = 1217;
7114    /// * INJECTED_SOLUTION_ERROR = 20;
7115    ///
7116    ///   * INJECTED_SOLUTION_MISSING_LABEL = 2000;
7117    ///   * INJECTED_SOLUTION_DUPLICATE_LABEL = 2001;
7118    ///   * INJECTED_SOLUTION_AMBIGUOUS_INDEX = 2002;
7119    ///   * INJECTED_SOLUTION_INFEASIBLE_AFTER_GETTING_TRAVEL_TIMES = 2003;
7120    ///   * INJECTED_SOLUTION_TRANSITION_INCONSISTENT_WITH_ACTUAL_TRAVEL = 2004;
7121    ///   * INJECTED_SOLUTION_CONCURRENT_SOLUTION_TYPES = 2005;
7122    ///   * INJECTED_SOLUTION_MORE_THAN_ONE_PER_TYPE = 2006;
7123    ///   * INJECTED_SOLUTION_REFRESH_WITHOUT_POPULATE = 2008;
7124    ///   * INJECTED_SOLUTION_CONSTRAINED_ROUTE_PORTION_INFEASIBLE = 2010;
7125    /// * SHIPMENT_MODEL_ERROR = 22;
7126    ///
7127    ///   * SHIPMENT_MODEL_TOO_LARGE = 2200;
7128    ///   * SHIPMENT_MODEL_TOO_MANY_CAPACITY_TYPES = 2201;
7129    ///   * SHIPMENT_MODEL_GLOBAL_START_TIME_NEGATIVE_OR_NAN = 2202;
7130    ///   * SHIPMENT_MODEL_GLOBAL_END_TIME_TOO_LARGE_OR_NAN = 2203;
7131    ///   * SHIPMENT_MODEL_GLOBAL_START_TIME_AFTER_GLOBAL_END_TIME = 2204;
7132    ///   * SHIPMENT_MODEL_GLOBAL_DURATION_TOO_LONG = 2205;
7133    ///   * SHIPMENT_MODEL_MAX_ACTIVE_VEHICLES_NOT_POSITIVE = 2206;
7134    ///   * SHIPMENT_MODEL_DURATION_MATRIX_TOO_LARGE = 2207;
7135    /// * INDEX_ERROR = 24;
7136    ///
7137    /// * TAG_ERROR = 26;
7138    ///
7139    /// * TIME_WINDOW_ERROR = 28;
7140    ///
7141    ///   * TIME_WINDOW_INVALID_START_TIME = 2800;
7142    ///   * TIME_WINDOW_INVALID_END_TIME = 2801;
7143    ///   * TIME_WINDOW_INVALID_SOFT_START_TIME = 2802;
7144    ///   * TIME_WINDOW_INVALID_SOFT_END_TIME = 2803;
7145    ///   * TIME_WINDOW_OUTSIDE_GLOBAL_TIME_WINDOW = 2804;
7146    ///   * TIME_WINDOW_START_TIME_AFTER_END_TIME = 2805;
7147    ///   * TIME_WINDOW_INVALID_COST_PER_HOUR_BEFORE_SOFT_START_TIME = 2806;
7148    ///   * TIME_WINDOW_INVALID_COST_PER_HOUR_AFTER_SOFT_END_TIME = 2807;
7149    ///   * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_WITHOUT_SOFT_START_TIME
7150    ///     = 2808;
7151    ///   * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_WITHOUT_SOFT_END_TIME = 2809;
7152    ///   * TIME_WINDOW_SOFT_START_TIME_WITHOUT_COST_BEFORE_SOFT_START_TIME
7153    ///     = 2810;
7154    ///   * TIME_WINDOW_SOFT_END_TIME_WITHOUT_COST_AFTER_SOFT_END_TIME = 2811;
7155    ///   * TIME_WINDOW_OVERLAPPING_ADJACENT_OR_EARLIER_THAN_PREVIOUS = 2812;
7156    ///   * TIME_WINDOW_START_TIME_AFTER_SOFT_START_TIME = 2813;
7157    ///   * TIME_WINDOW_SOFT_START_TIME_AFTER_END_TIME = 2814;
7158    ///   * TIME_WINDOW_START_TIME_AFTER_SOFT_END_TIME = 2815;
7159    ///   * TIME_WINDOW_SOFT_END_TIME_AFTER_END_TIME = 2816;
7160    ///   * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_SET_AND_MULTIPLE_WINDOWS
7161    ///     = 2817;
7162    ///   * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_SET_AND_MULTIPLE_WINDOWS = 2818;
7163    ///   * TRANSITION_ATTRIBUTES_ERROR = 30;
7164    ///   * TRANSITION_ATTRIBUTES_INVALID_COST = 3000;
7165    ///   * TRANSITION_ATTRIBUTES_INVALID_COST_PER_KILOMETER = 3001;
7166    ///   * TRANSITION_ATTRIBUTES_DUPLICATE_TAG_PAIR = 3002;
7167    ///   * TRANSITION_ATTRIBUTES_DISTANCE_LIMIT_MAX_METERS_UNSUPPORTED = 3003;
7168    ///   * TRANSITION_ATTRIBUTES_UNSPECIFIED_SOURCE_TAGS = 3004;
7169    ///   * TRANSITION_ATTRIBUTES_CONFLICTING_SOURCE_TAGS_FIELDS = 3005;
7170    ///   * TRANSITION_ATTRIBUTES_UNSPECIFIED_DESTINATION_TAGS = 3006;
7171    ///   * TRANSITION_ATTRIBUTES_CONFLICTING_DESTINATION_TAGS_FIELDS = 3007;
7172    ///   * TRANSITION_ATTRIBUTES_DELAY_DURATION_NEGATIVE_OR_NAN = 3008;
7173    ///   * TRANSITION_ATTRIBUTES_DELAY_DURATION_EXCEEDS_GLOBAL_DURATION = 3009;
7174    /// * AMOUNT_ERROR = 31;
7175    ///
7176    ///   * AMOUNT_NEGATIVE_VALUE = 3100;
7177    /// * LOAD_LIMIT_ERROR = 33;
7178    ///
7179    ///   * LOAD_LIMIT_INVALID_COST_ABOVE_SOFT_MAX = 3303;
7180    ///   * LOAD_LIMIT_SOFT_MAX_WITHOUT_COST_ABOVE_SOFT_MAX = 3304;
7181    ///   * LOAD_LIMIT_COST_ABOVE_SOFT_MAX_WITHOUT_SOFT_MAX = 3305;
7182    ///   * LOAD_LIMIT_NEGATIVE_SOFT_MAX = 3306;
7183    ///   * LOAD_LIMIT_MIXED_DEMAND_TYPE = 3307;
7184    ///   * LOAD_LIMIT_MAX_LOAD_NEGATIVE_VALUE = 3308;
7185    ///   * LOAD_LIMIT_SOFT_MAX_ABOVE_MAX = 3309;
7186    /// * INTERVAL_ERROR = 34;
7187    ///
7188    ///   * INTERVAL_MIN_EXCEEDS_MAX = 3401;
7189    ///   * INTERVAL_NEGATIVE_MIN = 3402;
7190    ///   * INTERVAL_NEGATIVE_MAX = 3403;
7191    ///   * INTERVAL_MIN_EXCEEDS_CAPACITY = 3404;
7192    ///   * INTERVAL_MAX_EXCEEDS_CAPACITY = 3405;
7193    /// * DISTANCE_LIMIT_ERROR = 36;
7194    ///
7195    ///   * DISTANCE_LIMIT_INVALID_COST_AFTER_SOFT_MAX = 3601;
7196    ///   * DISTANCE_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3602;
7197    ///   * DISTANCE_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3603;
7198    ///   * DISTANCE_LIMIT_NEGATIVE_MAX = 3604;
7199    ///   * DISTANCE_LIMIT_NEGATIVE_SOFT_MAX = 3605;
7200    ///   * DISTANCE_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3606;
7201    /// * DURATION_LIMIT_ERROR = 38;
7202    ///
7203    ///   * DURATION_LIMIT_MAX_DURATION_NEGATIVE_OR_NAN = 3800;
7204    ///   * DURATION_LIMIT_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3801;
7205    ///   * DURATION_LIMIT_INVALID_COST_PER_HOUR_AFTER_SOFT_MAX = 3802;
7206    ///   * DURATION_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3803;
7207    ///   * DURATION_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3804;
7208    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3805;
7209    ///   * DURATION_LIMIT_INVALID_COST_AFTER_QUADRATIC_SOFT_MAX = 3806;
7210    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_COST_PER_SQUARE_HOUR
7211    ///     = 3807;
7212    ///   * DURATION_LIMIT_COST_PER_SQUARE_HOUR_WITHOUT_QUADRATIC_SOFT_MAX
7213    ///     = 3808;
7214    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_MAX = 3809;
7215    ///   * DURATION_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3810;
7216    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_LARGER_THAN_MAX = 3811;
7217    ///   * DURATION_LIMIT_DIFF_BETWEEN_MAX_AND_QUADRATIC_SOFT_MAX_TOO_LARGE
7218    ///     = 3812;
7219    ///   * DURATION_LIMIT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3813;
7220    ///   * DURATION_LIMIT_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3814;
7221    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION
7222    ///     = 3815;
7223    /// * SHIPMENT_ERROR = 40;
7224    ///
7225    ///   * SHIPMENT_PD_LIMIT_WITHOUT_PICKUP_AND_DELIVERY = 4014;
7226    ///   * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_NEGATIVE_OR_NAN = 4000;
7227    ///   * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION
7228    ///     = 4001;
7229    ///   * SHIPMENT_PD_RELATIVE_DETOUR_LIMIT_INVALID = 4015;
7230    ///   * SHIPMENT_PD_DETOUR_LIMIT_AND_EXTRA_VISIT_DURATION = 4016;
7231    ///   * SHIPMENT_PD_TIME_LIMIT_DURATION_NEGATIVE_OR_NAN = 4002;
7232    ///   * SHIPMENT_PD_TIME_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4003;
7233    ///   * SHIPMENT_EMPTY_SHIPMENT_TYPE = 4004;
7234    ///   * SHIPMENT_NO_PICKUP_NO_DELIVERY = 4005;
7235    ///   * SHIPMENT_INVALID_PENALTY_COST = 4006;
7236    ///   * SHIPMENT_ALLOWED_VEHICLE_INDEX_OUT_OF_BOUNDS = 4007;
7237    ///   * SHIPMENT_DUPLICATE_ALLOWED_VEHICLE_INDEX = 4008;
7238    ///   * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITHOUT_INDEX = 4009;
7239    ///   * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITH_INDEX = 4010;
7240    ///   * SHIPMENT_INVALID_COST_FOR_VEHICLE = 4011;
7241    ///   * SHIPMENT_COST_FOR_VEHICLE_INDEX_OUT_OF_BOUNDS = 4012;
7242    ///   * SHIPMENT_DUPLICATE_COST_FOR_VEHICLE_INDEX = 4013;
7243    /// * VEHICLE_ERROR = 42;
7244    ///
7245    ///   * VEHICLE_EMPTY_REQUIRED_OPERATOR_TYPE = 4200;
7246    ///   * VEHICLE_DUPLICATE_REQUIRED_OPERATOR_TYPE = 4201;
7247    ///   * VEHICLE_NO_OPERATOR_WITH_REQUIRED_OPERATOR_TYPE = 4202;
7248    ///   * VEHICLE_EMPTY_START_TAG = 4203;
7249    ///   * VEHICLE_DUPLICATE_START_TAG = 4204;
7250    ///   * VEHICLE_EMPTY_END_TAG = 4205;
7251    ///   * VEHICLE_DUPLICATE_END_TAG = 4206;
7252    ///   * VEHICLE_EXTRA_VISIT_DURATION_NEGATIVE_OR_NAN = 4207;
7253    ///   * VEHICLE_EXTRA_VISIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4208;
7254    ///   * VEHICLE_EXTRA_VISIT_DURATION_EMPTY_KEY = 4209;
7255    ///   * VEHICLE_FIRST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4210;
7256    ///   * VEHICLE_FIRST_SHIPMENT_IGNORED = 4211;
7257    ///   * VEHICLE_FIRST_SHIPMENT_NOT_BOUND = 4212;
7258    ///   * VEHICLE_LAST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4213;
7259    ///   * VEHICLE_LAST_SHIPMENT_IGNORED = 4214;
7260    ///   * VEHICLE_LAST_SHIPMENT_NOT_BOUND = 4215;
7261    ///   * VEHICLE_IGNORED_WITH_USED_IF_ROUTE_IS_EMPTY = 4216;
7262    ///   * VEHICLE_INVALID_COST_PER_KILOMETER = 4217;
7263    ///   * VEHICLE_INVALID_COST_PER_HOUR = 4218;
7264    ///   * VEHICLE_INVALID_COST_PER_TRAVELED_HOUR = 4219;
7265    ///   * VEHICLE_INVALID_FIXED_COST = 4220;
7266    ///   * VEHICLE_INVALID_TRAVEL_DURATION_MULTIPLE = 4221;
7267    ///   * VEHICLE_TRAVEL_DURATION_MULTIPLE_WITH_SHIPMENT_PD_DETOUR_LIMITS
7268    ///     = 4223;
7269    ///   * VEHICLE_MATRIX_INDEX_WITH_SHIPMENT_PD_DETOUR_LIMITS = 4224;
7270    ///   * VEHICLE_MINIMUM_DURATION_LONGER_THAN_DURATION_LIMIT = 4222;
7271    /// * VISIT_REQUEST_ERROR = 44;
7272    ///
7273    ///   * VISIT_REQUEST_EMPTY_TAG = 4400;
7274    ///   * VISIT_REQUEST_DUPLICATE_TAG = 4401;
7275    ///   * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404;
7276    ///   * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405;
7277    /// * PRECEDENCE_ERROR = 46;
7278    ///
7279    ///   * PRECEDENCE_RULE_MISSING_FIRST_INDEX = 4600;
7280    ///   * PRECEDENCE_RULE_MISSING_SECOND_INDEX = 4601;
7281    ///   * PRECEDENCE_RULE_FIRST_INDEX_OUT_OF_BOUNDS = 4602;
7282    ///   * PRECEDENCE_RULE_SECOND_INDEX_OUT_OF_BOUNDS = 4603;
7283    ///   * PRECEDENCE_RULE_DUPLICATE_INDEX = 4604;
7284    ///   * PRECEDENCE_RULE_INEXISTENT_FIRST_VISIT_REQUEST = 4605;
7285    ///   * PRECEDENCE_RULE_INEXISTENT_SECOND_VISIT_REQUEST = 4606;
7286    /// * BREAK_ERROR = 48;
7287    ///
7288    ///   * BREAK_RULE_EMPTY = 4800;
7289    ///   * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801;
7290    ///   * BREAK_REQUEST_UNSPECIFIED_EARLIEST_START_TIME = 4802;
7291    ///   * BREAK_REQUEST_UNSPECIFIED_LATEST_START_TIME = 4803;
7292    ///   * BREAK_REQUEST_DURATION_NEGATIVE_OR_NAN = 4804; = 4804;
7293    ///   * BREAK_REQUEST_LATEST_START_TIME_BEFORE_EARLIEST_START_TIME = 4805;
7294    ///   * BREAK_REQUEST_EARLIEST_START_TIME_BEFORE_GLOBAL_START_TIME = 4806;
7295    ///   * BREAK_REQUEST_LATEST_END_TIME_AFTER_GLOBAL_END_TIME = 4807;
7296    ///   * BREAK_REQUEST_NON_SCHEDULABLE = 4808;
7297    ///   * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_NEGATIVE_OR_NAN = 4809;
7298    ///   * BREAK_FREQUENCY_MIN_BREAK_DURATION_NEGATIVE_OR_NAN = 4810;
7299    ///   * BREAK_FREQUENCY_MIN_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION = 4811;
7300    ///   * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION
7301    ///     = 4812;
7302    ///   * BREAK_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4813;
7303    ///   * BREAK_FREQUENCY_MISSING_MAX_INTER_BREAK_DURATION = 4814;
7304    ///   * BREAK_FREQUENCY_MISSING_MIN_BREAK_DURATION = 4815;
7305    /// * SHIPMENT_TYPE_INCOMPATIBILITY_ERROR = 50;
7306    ///
7307    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_EMPTY_TYPE = 5001;
7308    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_LESS_THAN_TWO_TYPES = 5002;
7309    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_DUPLICATE_TYPE = 5003;
7310    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_INVALID_INCOMPATIBILITY_MODE = 5004;
7311    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_TOO_MANY_INCOMPATIBILITIES = 5005;
7312    /// * SHIPMENT_TYPE_REQUIREMENT_ERROR = 52;
7313    ///
7314    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE = 52001;
7315    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_DEPENDENT_TYPE = 52002;
7316    ///   * SHIPMENT_TYPE_REQUIREMENT_INVALID_REQUIREMENT_MODE = 52003;
7317    ///   * SHIPMENT_TYPE_REQUIREMENT_TOO_MANY_REQUIREMENTS = 52004;
7318    ///   * SHIPMENT_TYPE_REQUIREMENT_EMPTY_REQUIRED_TYPE = 52005;
7319    ///   * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_REQUIRED_TYPE = 52006;
7320    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE_FOUND = 52007;
7321    ///   * SHIPMENT_TYPE_REQUIREMENT_EMPTY_DEPENDENT_TYPE = 52008;
7322    ///   * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_DEPENDENT_TYPE = 52009;
7323    ///   * SHIPMENT_TYPE_REQUIREMENT_SELF_DEPENDENT_TYPE = 52010;
7324    ///   * SHIPMENT_TYPE_REQUIREMENT_GRAPH_HAS_CYCLES = 52011;
7325    /// * VEHICLE_OPERATOR_ERROR = 54;
7326    ///
7327    ///   * VEHICLE_OPERATOR_EMPTY_TYPE = 5400;
7328    ///   * VEHICLE_OPERATOR_MULTIPLE_START_TIME_WINDOWS = 5401;
7329    ///   * VEHICLE_OPERATOR_SOFT_START_TIME_WINDOW = 5402;
7330    ///   * VEHICLE_OPERATOR_MULTIPLE_END_TIME_WINDOWS = 5403;
7331    ///   * VEHICLE_OPERATOR_SOFT_END_TIME_WINDOW = 5404;
7332    /// * DURATION_SECONDS_MATRIX_ERROR = 56;
7333    ///
7334    ///   * DURATION_SECONDS_MATRIX_DURATION_NEGATIVE_OR_NAN = 5600;
7335    ///   * DURATION_SECONDS_MATRIX_DURATION_EXCEEDS_GLOBAL_DURATION = 5601;
7336    pub code: i32,
7337
7338    /// The error display name.
7339    #[serde(skip_serializing_if = "std::string::String::is_empty")]
7340    pub display_name: std::string::String,
7341
7342    /// An error context may involve 0, 1 (most of the time) or more fields. For
7343    /// example, referring to vehicle #4 and shipment #2's first pickup can be
7344    /// done as follows:
7345    ///
7346    /// ```norust
7347    /// fields { name: "vehicles" index: 4}
7348    /// fields { name: "shipments" index: 2 sub_field {name: "pickups" index: 0} }
7349    /// ```
7350    ///
7351    /// Note, however, that the cardinality of `fields` should not change for a
7352    /// given error code.
7353    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
7354    pub fields: std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>,
7355
7356    /// Human-readable string describing the error. There is a 1:1 mapping
7357    /// between `code` and `error_message` (when code != "UNSPECIFIED").
7358    ///
7359    /// *STABILITY*: Not stable: the error message associated to a given `code` may
7360    /// change (hopefully to clarify it) over time. Please rely on the
7361    /// `display_name` and `code` instead.
7362    #[serde(skip_serializing_if = "std::string::String::is_empty")]
7363    pub error_message: std::string::String,
7364
7365    /// May contain the value(s) of the field(s). This is not always available. You
7366    /// should absolutely not rely on it and use it only for manual model
7367    /// debugging.
7368    #[serde(skip_serializing_if = "std::string::String::is_empty")]
7369    pub offending_values: std::string::String,
7370
7371    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
7372    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7373}
7374
7375impl OptimizeToursValidationError {
7376    pub fn new() -> Self {
7377        std::default::Default::default()
7378    }
7379
7380    /// Sets the value of [code][crate::model::OptimizeToursValidationError::code].
7381    pub fn set_code<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
7382        self.code = v.into();
7383        self
7384    }
7385
7386    /// Sets the value of [display_name][crate::model::OptimizeToursValidationError::display_name].
7387    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7388        self.display_name = v.into();
7389        self
7390    }
7391
7392    /// Sets the value of [error_message][crate::model::OptimizeToursValidationError::error_message].
7393    pub fn set_error_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7394        self.error_message = v.into();
7395        self
7396    }
7397
7398    /// Sets the value of [offending_values][crate::model::OptimizeToursValidationError::offending_values].
7399    pub fn set_offending_values<T: std::convert::Into<std::string::String>>(
7400        mut self,
7401        v: T,
7402    ) -> Self {
7403        self.offending_values = v.into();
7404        self
7405    }
7406
7407    /// Sets the value of [fields][crate::model::OptimizeToursValidationError::fields].
7408    pub fn set_fields<T, V>(mut self, v: T) -> Self
7409    where
7410        T: std::iter::IntoIterator<Item = V>,
7411        V: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
7412    {
7413        use std::iter::Iterator;
7414        self.fields = v.into_iter().map(|i| i.into()).collect();
7415        self
7416    }
7417}
7418
7419impl wkt::message::Message for OptimizeToursValidationError {
7420    fn typename() -> &'static str {
7421        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError"
7422    }
7423}
7424
7425/// Defines additional types related to [OptimizeToursValidationError].
7426pub mod optimize_tours_validation_error {
7427    #[allow(unused_imports)]
7428    use super::*;
7429
7430    /// Specifies a context for the validation error. A `FieldReference` always
7431    /// refers to a given field in this file and follows the same hierarchical
7432    /// structure. For example, we may specify element #2 of `start_time_windows`
7433    /// of vehicle #5 using:
7434    ///
7435    /// ```norust
7436    /// name: "vehicles" index: 5 sub_field { name: "end_time_windows" index: 2 }
7437    /// ```
7438    ///
7439    /// We however omit top-level entities such as `OptimizeToursRequest` or
7440    /// `ShipmentModel` to avoid crowding the message.
7441    #[serde_with::serde_as]
7442    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
7443    #[serde(default, rename_all = "camelCase")]
7444    #[non_exhaustive]
7445    pub struct FieldReference {
7446        /// Name of the field, e.g., "vehicles".
7447        #[serde(skip_serializing_if = "std::string::String::is_empty")]
7448        pub name: std::string::String,
7449
7450        /// Recursively nested sub-field, if needed.
7451        #[serde(skip_serializing_if = "std::option::Option::is_none")]
7452        pub sub_field: std::option::Option<
7453            std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>,
7454        >,
7455
7456        #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")]
7457        pub index_or_key: std::option::Option<
7458            crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
7459        >,
7460
7461        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
7462        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7463    }
7464
7465    impl FieldReference {
7466        pub fn new() -> Self {
7467            std::default::Default::default()
7468        }
7469
7470        /// Sets the value of [name][crate::model::optimize_tours_validation_error::FieldReference::name].
7471        pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7472            self.name = v.into();
7473            self
7474        }
7475
7476        /// Sets the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
7477        pub fn set_sub_field<
7478            T: std::convert::Into<
7479                    std::option::Option<
7480                        std::boxed::Box<
7481                            crate::model::optimize_tours_validation_error::FieldReference,
7482                        >,
7483                    >,
7484                >,
7485        >(
7486            mut self,
7487            v: T,
7488        ) -> Self {
7489            self.sub_field = v.into();
7490            self
7491        }
7492
7493        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key].
7494        ///
7495        /// Note that all the setters affecting `index_or_key` are mutually
7496        /// exclusive.
7497        pub fn set_index_or_key<
7498            T: std::convert::Into<
7499                    std::option::Option<
7500                        crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
7501                    >,
7502                >,
7503        >(
7504            mut self,
7505            v: T,
7506        ) -> Self {
7507            self.index_or_key = v.into();
7508            self
7509        }
7510
7511        /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
7512        /// if it holds a `Index`, `None` if the field is not set or
7513        /// holds a different branch.
7514        pub fn index(&self) -> std::option::Option<&i32> {
7515            #[allow(unreachable_patterns)]
7516            self.index_or_key.as_ref().and_then(|v| match v {
7517                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(v) => std::option::Option::Some(v),
7518                _ => std::option::Option::None,
7519            })
7520        }
7521
7522        /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
7523        /// if it holds a `Key`, `None` if the field is not set or
7524        /// holds a different branch.
7525        pub fn key(&self) -> std::option::Option<&std::string::String> {
7526            #[allow(unreachable_patterns)]
7527            self.index_or_key.as_ref().and_then(|v| match v {
7528                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
7529                    v,
7530                ) => std::option::Option::Some(v),
7531                _ => std::option::Option::None,
7532            })
7533        }
7534
7535        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
7536        /// to hold a `Index`.
7537        ///
7538        /// Note that all the setters affecting `index_or_key` are
7539        /// mutually exclusive.
7540        pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
7541            self.index_or_key = std::option::Option::Some(
7542                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
7543                    v.into(),
7544                ),
7545            );
7546            self
7547        }
7548
7549        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
7550        /// to hold a `Key`.
7551        ///
7552        /// Note that all the setters affecting `index_or_key` are
7553        /// mutually exclusive.
7554        pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7555            self.index_or_key = std::option::Option::Some(
7556                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
7557                    v.into(),
7558                ),
7559            );
7560            self
7561        }
7562    }
7563
7564    impl wkt::message::Message for FieldReference {
7565        fn typename() -> &'static str {
7566            "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference"
7567        }
7568    }
7569
7570    /// Defines additional types related to [FieldReference].
7571    pub mod field_reference {
7572        #[allow(unused_imports)]
7573        use super::*;
7574
7575        #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
7576        #[serde(rename_all = "camelCase")]
7577        #[non_exhaustive]
7578        pub enum IndexOrKey {
7579            /// Index of the field if repeated.
7580            Index(i32),
7581            /// Key if the field is a map.
7582            Key(std::string::String),
7583        }
7584    }
7585}
7586
7587/// Data formats for input and output files.
7588#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
7589pub struct DataFormat(i32);
7590
7591impl DataFormat {
7592    /// Default value.
7593    pub const DATA_FORMAT_UNSPECIFIED: DataFormat = DataFormat::new(0);
7594
7595    /// Input data in json format.
7596    pub const JSON: DataFormat = DataFormat::new(1);
7597
7598    /// Input data in string format.
7599    pub const STRING: DataFormat = DataFormat::new(2);
7600
7601    /// Creates a new DataFormat instance.
7602    pub(crate) const fn new(value: i32) -> Self {
7603        Self(value)
7604    }
7605
7606    /// Gets the enum value.
7607    pub fn value(&self) -> i32 {
7608        self.0
7609    }
7610
7611    /// Gets the enum value as a string.
7612    pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
7613        match self.0 {
7614            0 => std::borrow::Cow::Borrowed("DATA_FORMAT_UNSPECIFIED"),
7615            1 => std::borrow::Cow::Borrowed("JSON"),
7616            2 => std::borrow::Cow::Borrowed("STRING"),
7617            _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
7618        }
7619    }
7620
7621    /// Creates an enum value from the value name.
7622    pub fn from_str_name(name: &str) -> std::option::Option<Self> {
7623        match name {
7624            "DATA_FORMAT_UNSPECIFIED" => std::option::Option::Some(Self::DATA_FORMAT_UNSPECIFIED),
7625            "JSON" => std::option::Option::Some(Self::JSON),
7626            "STRING" => std::option::Option::Some(Self::STRING),
7627            _ => std::option::Option::None,
7628        }
7629    }
7630}
7631
7632impl std::convert::From<i32> for DataFormat {
7633    fn from(value: i32) -> Self {
7634        Self::new(value)
7635    }
7636}
7637
7638impl std::default::Default for DataFormat {
7639    fn default() -> Self {
7640        Self::new(0)
7641    }
7642}