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::bare_urls)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![allow(rustdoc::invalid_html_tags)]
20#![allow(rustdoc::redundant_explicit_links)]
21#![no_implicit_prelude]
22extern crate async_trait;
23extern crate bytes;
24extern crate gaxi;
25extern crate google_cloud_gax;
26extern crate google_cloud_longrunning;
27extern crate google_cloud_lro;
28extern crate google_cloud_type;
29extern crate serde;
30extern crate serde_json;
31extern crate serde_with;
32extern crate std;
33extern crate tracing;
34extern crate wkt;
35
36mod debug;
37mod deserialize;
38mod serialize;
39
40/// The desired input location information.
41#[derive(Clone, Default, PartialEq)]
42#[non_exhaustive]
43pub struct InputConfig {
44 /// The input data format that used to store the model in Cloud Storage.
45 pub data_format: crate::model::DataFormat,
46
47 /// The location of the input model in cloud storage.
48 /// Required.
49 pub source: std::option::Option<crate::model::input_config::Source>,
50
51 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
52}
53
54impl InputConfig {
55 /// Creates a new default instance.
56 pub fn new() -> Self {
57 std::default::Default::default()
58 }
59
60 /// Sets the value of [data_format][crate::model::InputConfig::data_format].
61 ///
62 /// # Example
63 /// ```ignore,no_run
64 /// # use google_cloud_optimization_v1::model::InputConfig;
65 /// use google_cloud_optimization_v1::model::DataFormat;
66 /// let x0 = InputConfig::new().set_data_format(DataFormat::Json);
67 /// let x1 = InputConfig::new().set_data_format(DataFormat::String);
68 /// ```
69 pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
70 mut self,
71 v: T,
72 ) -> Self {
73 self.data_format = v.into();
74 self
75 }
76
77 /// Sets the value of [source][crate::model::InputConfig::source].
78 ///
79 /// Note that all the setters affecting `source` are mutually
80 /// exclusive.
81 ///
82 /// # Example
83 /// ```ignore,no_run
84 /// # use google_cloud_optimization_v1::model::InputConfig;
85 /// use google_cloud_optimization_v1::model::GcsSource;
86 /// let x = InputConfig::new().set_source(Some(
87 /// google_cloud_optimization_v1::model::input_config::Source::GcsSource(GcsSource::default().into())));
88 /// ```
89 pub fn set_source<
90 T: std::convert::Into<std::option::Option<crate::model::input_config::Source>>,
91 >(
92 mut self,
93 v: T,
94 ) -> Self {
95 self.source = v.into();
96 self
97 }
98
99 /// The value of [source][crate::model::InputConfig::source]
100 /// if it holds a `GcsSource`, `None` if the field is not set or
101 /// holds a different branch.
102 pub fn gcs_source(&self) -> std::option::Option<&std::boxed::Box<crate::model::GcsSource>> {
103 #[allow(unreachable_patterns)]
104 self.source.as_ref().and_then(|v| match v {
105 crate::model::input_config::Source::GcsSource(v) => std::option::Option::Some(v),
106 _ => std::option::Option::None,
107 })
108 }
109
110 /// Sets the value of [source][crate::model::InputConfig::source]
111 /// to hold a `GcsSource`.
112 ///
113 /// Note that all the setters affecting `source` are
114 /// mutually exclusive.
115 ///
116 /// # Example
117 /// ```ignore,no_run
118 /// # use google_cloud_optimization_v1::model::InputConfig;
119 /// use google_cloud_optimization_v1::model::GcsSource;
120 /// let x = InputConfig::new().set_gcs_source(GcsSource::default()/* use setters */);
121 /// assert!(x.gcs_source().is_some());
122 /// ```
123 pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
124 mut self,
125 v: T,
126 ) -> Self {
127 self.source =
128 std::option::Option::Some(crate::model::input_config::Source::GcsSource(v.into()));
129 self
130 }
131}
132
133impl wkt::message::Message for InputConfig {
134 fn typename() -> &'static str {
135 "type.googleapis.com/google.cloud.optimization.v1.InputConfig"
136 }
137}
138
139/// Defines additional types related to [InputConfig].
140pub mod input_config {
141 #[allow(unused_imports)]
142 use super::*;
143
144 /// The location of the input model in cloud storage.
145 /// Required.
146 #[derive(Clone, Debug, PartialEq)]
147 #[non_exhaustive]
148 pub enum Source {
149 /// The Google Cloud Storage location to read the input from. This must be a
150 /// single file.
151 GcsSource(std::boxed::Box<crate::model::GcsSource>),
152 }
153}
154
155/// The desired output location.
156#[derive(Clone, Default, PartialEq)]
157#[non_exhaustive]
158pub struct OutputConfig {
159 /// The output data format that used to store the results in Cloud Storage.
160 pub data_format: crate::model::DataFormat,
161
162 /// The location of the output result in cloud storage.
163 /// Required.
164 pub destination: std::option::Option<crate::model::output_config::Destination>,
165
166 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
167}
168
169impl OutputConfig {
170 /// Creates a new default instance.
171 pub fn new() -> Self {
172 std::default::Default::default()
173 }
174
175 /// Sets the value of [data_format][crate::model::OutputConfig::data_format].
176 ///
177 /// # Example
178 /// ```ignore,no_run
179 /// # use google_cloud_optimization_v1::model::OutputConfig;
180 /// use google_cloud_optimization_v1::model::DataFormat;
181 /// let x0 = OutputConfig::new().set_data_format(DataFormat::Json);
182 /// let x1 = OutputConfig::new().set_data_format(DataFormat::String);
183 /// ```
184 pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
185 mut self,
186 v: T,
187 ) -> Self {
188 self.data_format = v.into();
189 self
190 }
191
192 /// Sets the value of [destination][crate::model::OutputConfig::destination].
193 ///
194 /// Note that all the setters affecting `destination` are mutually
195 /// exclusive.
196 ///
197 /// # Example
198 /// ```ignore,no_run
199 /// # use google_cloud_optimization_v1::model::OutputConfig;
200 /// use google_cloud_optimization_v1::model::GcsDestination;
201 /// let x = OutputConfig::new().set_destination(Some(
202 /// google_cloud_optimization_v1::model::output_config::Destination::GcsDestination(GcsDestination::default().into())));
203 /// ```
204 pub fn set_destination<
205 T: std::convert::Into<std::option::Option<crate::model::output_config::Destination>>,
206 >(
207 mut self,
208 v: T,
209 ) -> Self {
210 self.destination = v.into();
211 self
212 }
213
214 /// The value of [destination][crate::model::OutputConfig::destination]
215 /// if it holds a `GcsDestination`, `None` if the field is not set or
216 /// holds a different branch.
217 pub fn gcs_destination(
218 &self,
219 ) -> std::option::Option<&std::boxed::Box<crate::model::GcsDestination>> {
220 #[allow(unreachable_patterns)]
221 self.destination.as_ref().and_then(|v| match v {
222 crate::model::output_config::Destination::GcsDestination(v) => {
223 std::option::Option::Some(v)
224 }
225 _ => std::option::Option::None,
226 })
227 }
228
229 /// Sets the value of [destination][crate::model::OutputConfig::destination]
230 /// to hold a `GcsDestination`.
231 ///
232 /// Note that all the setters affecting `destination` are
233 /// mutually exclusive.
234 ///
235 /// # Example
236 /// ```ignore,no_run
237 /// # use google_cloud_optimization_v1::model::OutputConfig;
238 /// use google_cloud_optimization_v1::model::GcsDestination;
239 /// let x = OutputConfig::new().set_gcs_destination(GcsDestination::default()/* use setters */);
240 /// assert!(x.gcs_destination().is_some());
241 /// ```
242 pub fn set_gcs_destination<
243 T: std::convert::Into<std::boxed::Box<crate::model::GcsDestination>>,
244 >(
245 mut self,
246 v: T,
247 ) -> Self {
248 self.destination = std::option::Option::Some(
249 crate::model::output_config::Destination::GcsDestination(v.into()),
250 );
251 self
252 }
253}
254
255impl wkt::message::Message for OutputConfig {
256 fn typename() -> &'static str {
257 "type.googleapis.com/google.cloud.optimization.v1.OutputConfig"
258 }
259}
260
261/// Defines additional types related to [OutputConfig].
262pub mod output_config {
263 #[allow(unused_imports)]
264 use super::*;
265
266 /// The location of the output result in cloud storage.
267 /// Required.
268 #[derive(Clone, Debug, PartialEq)]
269 #[non_exhaustive]
270 pub enum Destination {
271 /// The Google Cloud Storage location to write the output to.
272 GcsDestination(std::boxed::Box<crate::model::GcsDestination>),
273 }
274}
275
276/// The Google Cloud Storage location where the input file will be read from.
277#[derive(Clone, Default, PartialEq)]
278#[non_exhaustive]
279pub struct GcsSource {
280 /// Required. URI of the Google Cloud Storage location.
281 pub uri: std::string::String,
282
283 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
284}
285
286impl GcsSource {
287 /// Creates a new default instance.
288 pub fn new() -> Self {
289 std::default::Default::default()
290 }
291
292 /// Sets the value of [uri][crate::model::GcsSource::uri].
293 ///
294 /// # Example
295 /// ```ignore,no_run
296 /// # use google_cloud_optimization_v1::model::GcsSource;
297 /// let x = GcsSource::new().set_uri("example");
298 /// ```
299 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
300 self.uri = v.into();
301 self
302 }
303}
304
305impl wkt::message::Message for GcsSource {
306 fn typename() -> &'static str {
307 "type.googleapis.com/google.cloud.optimization.v1.GcsSource"
308 }
309}
310
311/// The Google Cloud Storage location where the output file will be written to.
312#[derive(Clone, Default, PartialEq)]
313#[non_exhaustive]
314pub struct GcsDestination {
315 /// Required. URI of the Google Cloud Storage location.
316 pub uri: std::string::String,
317
318 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
319}
320
321impl GcsDestination {
322 /// Creates a new default instance.
323 pub fn new() -> Self {
324 std::default::Default::default()
325 }
326
327 /// Sets the value of [uri][crate::model::GcsDestination::uri].
328 ///
329 /// # Example
330 /// ```ignore,no_run
331 /// # use google_cloud_optimization_v1::model::GcsDestination;
332 /// let x = GcsDestination::new().set_uri("example");
333 /// ```
334 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
335 self.uri = v.into();
336 self
337 }
338}
339
340impl wkt::message::Message for GcsDestination {
341 fn typename() -> &'static str {
342 "type.googleapis.com/google.cloud.optimization.v1.GcsDestination"
343 }
344}
345
346/// The long running operation metadata for async model related methods.
347#[derive(Clone, Default, PartialEq)]
348#[non_exhaustive]
349pub struct AsyncModelMetadata {
350 /// The state of the current operation.
351 pub state: crate::model::async_model_metadata::State,
352
353 /// A message providing more details about the current state of the operation.
354 /// For example, the error message if the operation is failed.
355 pub state_message: std::string::String,
356
357 /// The creation time of the operation.
358 pub create_time: std::option::Option<wkt::Timestamp>,
359
360 /// The last update time of the operation.
361 pub update_time: std::option::Option<wkt::Timestamp>,
362
363 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
364}
365
366impl AsyncModelMetadata {
367 /// Creates a new default instance.
368 pub fn new() -> Self {
369 std::default::Default::default()
370 }
371
372 /// Sets the value of [state][crate::model::AsyncModelMetadata::state].
373 ///
374 /// # Example
375 /// ```ignore,no_run
376 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
377 /// use google_cloud_optimization_v1::model::async_model_metadata::State;
378 /// let x0 = AsyncModelMetadata::new().set_state(State::Running);
379 /// let x1 = AsyncModelMetadata::new().set_state(State::Succeeded);
380 /// let x2 = AsyncModelMetadata::new().set_state(State::Cancelled);
381 /// ```
382 pub fn set_state<T: std::convert::Into<crate::model::async_model_metadata::State>>(
383 mut self,
384 v: T,
385 ) -> Self {
386 self.state = v.into();
387 self
388 }
389
390 /// Sets the value of [state_message][crate::model::AsyncModelMetadata::state_message].
391 ///
392 /// # Example
393 /// ```ignore,no_run
394 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
395 /// let x = AsyncModelMetadata::new().set_state_message("example");
396 /// ```
397 pub fn set_state_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
398 self.state_message = v.into();
399 self
400 }
401
402 /// Sets the value of [create_time][crate::model::AsyncModelMetadata::create_time].
403 ///
404 /// # Example
405 /// ```ignore,no_run
406 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
407 /// use wkt::Timestamp;
408 /// let x = AsyncModelMetadata::new().set_create_time(Timestamp::default()/* use setters */);
409 /// ```
410 pub fn set_create_time<T>(mut self, v: T) -> Self
411 where
412 T: std::convert::Into<wkt::Timestamp>,
413 {
414 self.create_time = std::option::Option::Some(v.into());
415 self
416 }
417
418 /// Sets or clears the value of [create_time][crate::model::AsyncModelMetadata::create_time].
419 ///
420 /// # Example
421 /// ```ignore,no_run
422 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
423 /// use wkt::Timestamp;
424 /// let x = AsyncModelMetadata::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
425 /// let x = AsyncModelMetadata::new().set_or_clear_create_time(None::<Timestamp>);
426 /// ```
427 pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
428 where
429 T: std::convert::Into<wkt::Timestamp>,
430 {
431 self.create_time = v.map(|x| x.into());
432 self
433 }
434
435 /// Sets the value of [update_time][crate::model::AsyncModelMetadata::update_time].
436 ///
437 /// # Example
438 /// ```ignore,no_run
439 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
440 /// use wkt::Timestamp;
441 /// let x = AsyncModelMetadata::new().set_update_time(Timestamp::default()/* use setters */);
442 /// ```
443 pub fn set_update_time<T>(mut self, v: T) -> Self
444 where
445 T: std::convert::Into<wkt::Timestamp>,
446 {
447 self.update_time = std::option::Option::Some(v.into());
448 self
449 }
450
451 /// Sets or clears the value of [update_time][crate::model::AsyncModelMetadata::update_time].
452 ///
453 /// # Example
454 /// ```ignore,no_run
455 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
456 /// use wkt::Timestamp;
457 /// let x = AsyncModelMetadata::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
458 /// let x = AsyncModelMetadata::new().set_or_clear_update_time(None::<Timestamp>);
459 /// ```
460 pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
461 where
462 T: std::convert::Into<wkt::Timestamp>,
463 {
464 self.update_time = v.map(|x| x.into());
465 self
466 }
467}
468
469impl wkt::message::Message for AsyncModelMetadata {
470 fn typename() -> &'static str {
471 "type.googleapis.com/google.cloud.optimization.v1.AsyncModelMetadata"
472 }
473}
474
475/// Defines additional types related to [AsyncModelMetadata].
476pub mod async_model_metadata {
477 #[allow(unused_imports)]
478 use super::*;
479
480 /// Possible states of the operation.
481 ///
482 /// # Working with unknown values
483 ///
484 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
485 /// additional enum variants at any time. Adding new variants is not considered
486 /// a breaking change. Applications should write their code in anticipation of:
487 ///
488 /// - New values appearing in future releases of the client library, **and**
489 /// - New values received dynamically, without application changes.
490 ///
491 /// Please consult the [Working with enums] section in the user guide for some
492 /// guidelines.
493 ///
494 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
495 #[derive(Clone, Debug, PartialEq)]
496 #[non_exhaustive]
497 pub enum State {
498 /// The default value. This value is used if the state is omitted.
499 Unspecified,
500 /// Request is being processed.
501 Running,
502 /// The operation completed successfully.
503 Succeeded,
504 /// The operation was cancelled.
505 Cancelled,
506 /// The operation has failed.
507 Failed,
508 /// If set, the enum was initialized with an unknown value.
509 ///
510 /// Applications can examine the value using [State::value] or
511 /// [State::name].
512 UnknownValue(state::UnknownValue),
513 }
514
515 #[doc(hidden)]
516 pub mod state {
517 #[allow(unused_imports)]
518 use super::*;
519 #[derive(Clone, Debug, PartialEq)]
520 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
521 }
522
523 impl State {
524 /// Gets the enum value.
525 ///
526 /// Returns `None` if the enum contains an unknown value deserialized from
527 /// the string representation of enums.
528 pub fn value(&self) -> std::option::Option<i32> {
529 match self {
530 Self::Unspecified => std::option::Option::Some(0),
531 Self::Running => std::option::Option::Some(1),
532 Self::Succeeded => std::option::Option::Some(2),
533 Self::Cancelled => std::option::Option::Some(3),
534 Self::Failed => std::option::Option::Some(4),
535 Self::UnknownValue(u) => u.0.value(),
536 }
537 }
538
539 /// Gets the enum value as a string.
540 ///
541 /// Returns `None` if the enum contains an unknown value deserialized from
542 /// the integer representation of enums.
543 pub fn name(&self) -> std::option::Option<&str> {
544 match self {
545 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
546 Self::Running => std::option::Option::Some("RUNNING"),
547 Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
548 Self::Cancelled => std::option::Option::Some("CANCELLED"),
549 Self::Failed => std::option::Option::Some("FAILED"),
550 Self::UnknownValue(u) => u.0.name(),
551 }
552 }
553 }
554
555 impl std::default::Default for State {
556 fn default() -> Self {
557 use std::convert::From;
558 Self::from(0)
559 }
560 }
561
562 impl std::fmt::Display for State {
563 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
564 wkt::internal::display_enum(f, self.name(), self.value())
565 }
566 }
567
568 impl std::convert::From<i32> for State {
569 fn from(value: i32) -> Self {
570 match value {
571 0 => Self::Unspecified,
572 1 => Self::Running,
573 2 => Self::Succeeded,
574 3 => Self::Cancelled,
575 4 => Self::Failed,
576 _ => Self::UnknownValue(state::UnknownValue(
577 wkt::internal::UnknownEnumValue::Integer(value),
578 )),
579 }
580 }
581 }
582
583 impl std::convert::From<&str> for State {
584 fn from(value: &str) -> Self {
585 use std::string::ToString;
586 match value {
587 "STATE_UNSPECIFIED" => Self::Unspecified,
588 "RUNNING" => Self::Running,
589 "SUCCEEDED" => Self::Succeeded,
590 "CANCELLED" => Self::Cancelled,
591 "FAILED" => Self::Failed,
592 _ => Self::UnknownValue(state::UnknownValue(
593 wkt::internal::UnknownEnumValue::String(value.to_string()),
594 )),
595 }
596 }
597 }
598
599 impl serde::ser::Serialize for State {
600 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
601 where
602 S: serde::Serializer,
603 {
604 match self {
605 Self::Unspecified => serializer.serialize_i32(0),
606 Self::Running => serializer.serialize_i32(1),
607 Self::Succeeded => serializer.serialize_i32(2),
608 Self::Cancelled => serializer.serialize_i32(3),
609 Self::Failed => serializer.serialize_i32(4),
610 Self::UnknownValue(u) => u.0.serialize(serializer),
611 }
612 }
613 }
614
615 impl<'de> serde::de::Deserialize<'de> for State {
616 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
617 where
618 D: serde::Deserializer<'de>,
619 {
620 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
621 ".google.cloud.optimization.v1.AsyncModelMetadata.State",
622 ))
623 }
624 }
625}
626
627/// Request to be given to a tour optimization solver which defines the
628/// shipment model to solve as well as optimization parameters.
629#[derive(Clone, Default, PartialEq)]
630#[non_exhaustive]
631pub struct OptimizeToursRequest {
632 /// Required. Target project and location to make a call.
633 ///
634 /// Format: `projects/{project-id}/locations/{location-id}`.
635 ///
636 /// If no location is specified, a region will be chosen automatically.
637 pub parent: std::string::String,
638
639 /// If this timeout is set, the server returns a response before the timeout
640 /// period has elapsed or the server deadline for synchronous requests is
641 /// reached, whichever is sooner.
642 ///
643 /// For asynchronous requests, the server will generate a solution (if
644 /// possible) before the timeout has elapsed.
645 pub timeout: std::option::Option<wkt::Duration>,
646
647 /// Shipment model to solve.
648 pub model: std::option::Option<crate::model::ShipmentModel>,
649
650 /// By default, the solving mode is `DEFAULT_SOLVE` (0).
651 pub solving_mode: crate::model::optimize_tours_request::SolvingMode,
652
653 /// Search mode used to solve the request.
654 pub search_mode: crate::model::optimize_tours_request::SearchMode,
655
656 /// Guide the optimization algorithm in finding a first solution that is
657 /// similar to a previous solution.
658 ///
659 /// The model is constrained when the first solution is built.
660 /// Any shipments not performed on a route are implicitly skipped in the first
661 /// solution, but they may be performed in successive solutions.
662 ///
663 /// The solution must satisfy some basic validity assumptions:
664 ///
665 /// * for all routes, `vehicle_index` must be in range and not be duplicated.
666 /// * for all visits, `shipment_index` and `visit_request_index` must be
667 /// in range.
668 /// * a shipment may only be referenced on one route.
669 /// * the pickup of a pickup-delivery shipment must be performed before
670 /// the delivery.
671 /// * no more than one pickup alternative or delivery alternative of
672 /// a shipment may be performed.
673 /// * for all routes, times are increasing (i.e., `vehicle_start_time
674 /// <= visits[0].start_time <= visits[1].start_time ...
675 /// <= vehicle_end_time`).
676 /// * a shipment may only be performed on a vehicle that is allowed. A
677 /// vehicle is allowed if
678 /// [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]
679 /// is empty or its `vehicle_index` is included in
680 /// [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices].
681 ///
682 /// If the injected solution is not feasible, a validation error is not
683 /// necessarily returned and an error indicating infeasibility may be returned
684 /// instead.
685 ///
686 /// [google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]: crate::model::Shipment::allowed_vehicle_indices
687 pub injected_first_solution_routes: std::vec::Vec<crate::model::ShipmentRoute>,
688
689 /// Constrain the optimization algorithm to find a final solution that is
690 /// similar to a previous solution. For example, this may be used to freeze
691 /// portions of routes which have already been completed or which are to be
692 /// completed but must not be modified.
693 ///
694 /// If the injected solution is not feasible, a validation error is not
695 /// necessarily returned and an error indicating infeasibility may be returned
696 /// instead.
697 pub injected_solution_constraint: std::option::Option<crate::model::InjectedSolutionConstraint>,
698
699 /// If non-empty, the given routes will be refreshed, without modifying their
700 /// underlying sequence of visits or travel times: only other details will be
701 /// updated. This does not solve the model.
702 ///
703 /// As of 2020/11, this only populates the polylines of non-empty routes and
704 /// requires that `populate_polylines` is true.
705 ///
706 /// The `route_polyline` fields of the passed-in routes may be inconsistent
707 /// with route `transitions`.
708 ///
709 /// This field must not be used together with `injected_first_solution_routes`
710 /// or `injected_solution_constraint`.
711 ///
712 /// `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
713 /// Polylines are still populated between all visits in all non-empty routes
714 /// regardless of whether the related shipments or vehicles are ignored.
715 pub refresh_details_routes: std::vec::Vec<crate::model::ShipmentRoute>,
716
717 /// If true:
718 ///
719 /// * uses
720 /// [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label]
721 /// instead of `vehicle_index` to
722 /// match routes in an injected solution with vehicles in the request;
723 /// reuses the mapping of original
724 /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
725 /// to new
726 /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
727 /// to update
728 /// [ConstraintRelaxation.vehicle_indices][google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]
729 /// if non-empty, but the mapping must be unambiguous (i.e., multiple
730 /// `ShipmentRoute`s must not share the same original `vehicle_index`).
731 /// * uses
732 /// [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]
733 /// instead of `shipment_index`
734 /// to match visits in an injected solution with shipments in the request;
735 /// * uses
736 /// [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
737 /// instead of
738 /// [SkippedShipment.index][google.cloud.optimization.v1.SkippedShipment.index]
739 /// to
740 /// match skipped shipments in the injected solution with request
741 /// shipments.
742 ///
743 /// This interpretation applies to the `injected_first_solution_routes`,
744 /// `injected_solution_constraint`, and `refresh_details_routes` fields.
745 /// It can be used when shipment or vehicle indices in the request have
746 /// changed since the solution was created, perhaps because shipments or
747 /// vehicles have been removed from or added to the request.
748 ///
749 /// If true, labels in the following categories must appear at most once in
750 /// their category:
751 ///
752 /// * [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] in the
753 /// request;
754 /// * [Shipment.label][google.cloud.optimization.v1.Shipment.label] in the
755 /// request;
756 /// * [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label] in the injected solution;
757 /// * [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] and [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label] in
758 /// the injected solution (except pickup/delivery visit pairs, whose
759 /// `shipment_label` must appear twice).
760 ///
761 /// If a `vehicle_label` in the injected solution does not correspond to a
762 /// request vehicle, the corresponding route is removed from the solution
763 /// along with its visits. If a `shipment_label` in the injected solution does
764 /// not correspond to a request shipment, the corresponding visit is removed
765 /// from the solution. If a
766 /// [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
767 /// in the injected solution does not correspond to a request shipment, the
768 /// `SkippedShipment` is removed from the solution.
769 ///
770 /// Removing route visits or entire routes from an injected solution may
771 /// have an effect on the implied constraints, which may lead to change in
772 /// solution, validation errors, or infeasibility.
773 ///
774 /// NOTE: The caller must ensure that each
775 /// [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] (resp.
776 /// [Shipment.label][google.cloud.optimization.v1.Shipment.label]) uniquely
777 /// identifies a vehicle (resp. shipment) entity used across the two relevant
778 /// requests: the past request that produced the `OptimizeToursResponse` used
779 /// in the injected solution and the current request that includes the injected
780 /// solution. The uniqueness checks described above are not enough to guarantee
781 /// this requirement.
782 ///
783 /// [google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]: crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices
784 /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
785 /// [google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]: crate::model::shipment_route::Visit::shipment_label
786 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
787 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_label]: crate::model::ShipmentRoute::vehicle_label
788 /// [google.cloud.optimization.v1.SkippedShipment.index]: crate::model::SkippedShipment::index
789 /// [google.cloud.optimization.v1.SkippedShipment.label]: crate::model::SkippedShipment::label
790 /// [google.cloud.optimization.v1.Vehicle.label]: crate::model::Vehicle::label
791 pub interpret_injected_solutions_using_labels: bool,
792
793 /// Consider traffic estimation in calculating `ShipmentRoute` fields
794 /// [Transition.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration],
795 /// [Visit.start_time][google.cloud.optimization.v1.ShipmentRoute.Visit.start_time],
796 /// and `vehicle_end_time`; in setting the
797 /// [ShipmentRoute.has_traffic_infeasibilities][google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]
798 /// field, and in calculating the
799 /// [OptimizeToursResponse.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.total_cost]
800 /// field.
801 ///
802 /// [google.cloud.optimization.v1.OptimizeToursResponse.total_cost]: crate::model::OptimizeToursResponse::total_cost
803 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
804 /// [google.cloud.optimization.v1.ShipmentRoute.Visit.start_time]: crate::model::shipment_route::Visit::start_time
805 /// [google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]: crate::model::ShipmentRoute::has_traffic_infeasibilities
806 pub consider_road_traffic: bool,
807
808 /// If true, polylines will be populated in response `ShipmentRoute`s.
809 pub populate_polylines: bool,
810
811 /// If true, polylines will be populated in response
812 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
813 /// Note that in this case, the polylines will also be populated in the
814 /// deprecated `travel_steps`.
815 ///
816 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
817 pub populate_transition_polylines: bool,
818
819 /// If this is set, then the request can have a deadline
820 /// (see <https://grpc.io/blog/deadlines>) of up to 60 minutes.
821 /// Otherwise, the maximum deadline is only 30 minutes.
822 /// Note that long-lived requests have a significantly larger (but still small)
823 /// risk of interruption.
824 pub allow_large_deadline_despite_interruption_risk: bool,
825
826 /// If true, travel distances will be computed using geodesic distances instead
827 /// of Google Maps distances, and travel times will be computed using geodesic
828 /// distances with a speed defined by `geodesic_meters_per_second`.
829 pub use_geodesic_distances: bool,
830
831 /// When `use_geodesic_distances` is true, this field must be set and defines
832 /// the speed applied to compute travel times. Its value must be at least 1.0
833 /// meters/seconds.
834 pub geodesic_meters_per_second: std::option::Option<f64>,
835
836 /// Truncates the number of validation errors returned. These errors are
837 /// typically attached to an INVALID_ARGUMENT error payload as a BadRequest
838 /// error detail (<https://cloud.google.com/apis/design/errors#error_details>),
839 /// unless solving_mode=VALIDATE_ONLY: see the
840 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
841 /// field.
842 /// This defaults to 100 and is capped at 10,000.
843 ///
844 /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
845 pub max_validation_errors: std::option::Option<i32>,
846
847 /// Label that may be used to identify this request, reported back in the
848 /// [OptimizeToursResponse.request_label][google.cloud.optimization.v1.OptimizeToursResponse.request_label].
849 ///
850 /// [google.cloud.optimization.v1.OptimizeToursResponse.request_label]: crate::model::OptimizeToursResponse::request_label
851 pub label: std::string::String,
852
853 /// Deprecated: Use
854 /// [OptimizeToursRequest.populate_transition_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
855 /// instead. If true, polylines will be populated in response
856 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
857 /// Note that in this case, the polylines will also be populated in the
858 /// deprecated `travel_steps`.
859 ///
860 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]: crate::model::OptimizeToursRequest::populate_transition_polylines
861 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
862 #[deprecated]
863 pub populate_travel_step_polylines: bool,
864
865 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
866}
867
868impl OptimizeToursRequest {
869 /// Creates a new default instance.
870 pub fn new() -> Self {
871 std::default::Default::default()
872 }
873
874 /// Sets the value of [parent][crate::model::OptimizeToursRequest::parent].
875 ///
876 /// # Example
877 /// ```ignore,no_run
878 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
879 /// let x = OptimizeToursRequest::new().set_parent("example");
880 /// ```
881 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
882 self.parent = v.into();
883 self
884 }
885
886 /// Sets the value of [timeout][crate::model::OptimizeToursRequest::timeout].
887 ///
888 /// # Example
889 /// ```ignore,no_run
890 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
891 /// use wkt::Duration;
892 /// let x = OptimizeToursRequest::new().set_timeout(Duration::default()/* use setters */);
893 /// ```
894 pub fn set_timeout<T>(mut self, v: T) -> Self
895 where
896 T: std::convert::Into<wkt::Duration>,
897 {
898 self.timeout = std::option::Option::Some(v.into());
899 self
900 }
901
902 /// Sets or clears the value of [timeout][crate::model::OptimizeToursRequest::timeout].
903 ///
904 /// # Example
905 /// ```ignore,no_run
906 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
907 /// use wkt::Duration;
908 /// let x = OptimizeToursRequest::new().set_or_clear_timeout(Some(Duration::default()/* use setters */));
909 /// let x = OptimizeToursRequest::new().set_or_clear_timeout(None::<Duration>);
910 /// ```
911 pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
912 where
913 T: std::convert::Into<wkt::Duration>,
914 {
915 self.timeout = v.map(|x| x.into());
916 self
917 }
918
919 /// Sets the value of [model][crate::model::OptimizeToursRequest::model].
920 ///
921 /// # Example
922 /// ```ignore,no_run
923 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
924 /// use google_cloud_optimization_v1::model::ShipmentModel;
925 /// let x = OptimizeToursRequest::new().set_model(ShipmentModel::default()/* use setters */);
926 /// ```
927 pub fn set_model<T>(mut self, v: T) -> Self
928 where
929 T: std::convert::Into<crate::model::ShipmentModel>,
930 {
931 self.model = std::option::Option::Some(v.into());
932 self
933 }
934
935 /// Sets or clears the value of [model][crate::model::OptimizeToursRequest::model].
936 ///
937 /// # Example
938 /// ```ignore,no_run
939 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
940 /// use google_cloud_optimization_v1::model::ShipmentModel;
941 /// let x = OptimizeToursRequest::new().set_or_clear_model(Some(ShipmentModel::default()/* use setters */));
942 /// let x = OptimizeToursRequest::new().set_or_clear_model(None::<ShipmentModel>);
943 /// ```
944 pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
945 where
946 T: std::convert::Into<crate::model::ShipmentModel>,
947 {
948 self.model = v.map(|x| x.into());
949 self
950 }
951
952 /// Sets the value of [solving_mode][crate::model::OptimizeToursRequest::solving_mode].
953 ///
954 /// # Example
955 /// ```ignore,no_run
956 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
957 /// use google_cloud_optimization_v1::model::optimize_tours_request::SolvingMode;
958 /// let x0 = OptimizeToursRequest::new().set_solving_mode(SolvingMode::ValidateOnly);
959 /// let x1 = OptimizeToursRequest::new().set_solving_mode(SolvingMode::DetectSomeInfeasibleShipments);
960 /// ```
961 pub fn set_solving_mode<
962 T: std::convert::Into<crate::model::optimize_tours_request::SolvingMode>,
963 >(
964 mut self,
965 v: T,
966 ) -> Self {
967 self.solving_mode = v.into();
968 self
969 }
970
971 /// Sets the value of [search_mode][crate::model::OptimizeToursRequest::search_mode].
972 ///
973 /// # Example
974 /// ```ignore,no_run
975 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
976 /// use google_cloud_optimization_v1::model::optimize_tours_request::SearchMode;
977 /// let x0 = OptimizeToursRequest::new().set_search_mode(SearchMode::ReturnFast);
978 /// let x1 = OptimizeToursRequest::new().set_search_mode(SearchMode::ConsumeAllAvailableTime);
979 /// ```
980 pub fn set_search_mode<
981 T: std::convert::Into<crate::model::optimize_tours_request::SearchMode>,
982 >(
983 mut self,
984 v: T,
985 ) -> Self {
986 self.search_mode = v.into();
987 self
988 }
989
990 /// Sets the value of [injected_first_solution_routes][crate::model::OptimizeToursRequest::injected_first_solution_routes].
991 ///
992 /// # Example
993 /// ```ignore,no_run
994 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
995 /// use google_cloud_optimization_v1::model::ShipmentRoute;
996 /// let x = OptimizeToursRequest::new()
997 /// .set_injected_first_solution_routes([
998 /// ShipmentRoute::default()/* use setters */,
999 /// ShipmentRoute::default()/* use (different) setters */,
1000 /// ]);
1001 /// ```
1002 pub fn set_injected_first_solution_routes<T, V>(mut self, v: T) -> Self
1003 where
1004 T: std::iter::IntoIterator<Item = V>,
1005 V: std::convert::Into<crate::model::ShipmentRoute>,
1006 {
1007 use std::iter::Iterator;
1008 self.injected_first_solution_routes = v.into_iter().map(|i| i.into()).collect();
1009 self
1010 }
1011
1012 /// Sets the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1013 ///
1014 /// # Example
1015 /// ```ignore,no_run
1016 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1017 /// use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
1018 /// let x = OptimizeToursRequest::new().set_injected_solution_constraint(InjectedSolutionConstraint::default()/* use setters */);
1019 /// ```
1020 pub fn set_injected_solution_constraint<T>(mut self, v: T) -> Self
1021 where
1022 T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1023 {
1024 self.injected_solution_constraint = std::option::Option::Some(v.into());
1025 self
1026 }
1027
1028 /// Sets or clears the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1029 ///
1030 /// # Example
1031 /// ```ignore,no_run
1032 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1033 /// use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
1034 /// let x = OptimizeToursRequest::new().set_or_clear_injected_solution_constraint(Some(InjectedSolutionConstraint::default()/* use setters */));
1035 /// let x = OptimizeToursRequest::new().set_or_clear_injected_solution_constraint(None::<InjectedSolutionConstraint>);
1036 /// ```
1037 pub fn set_or_clear_injected_solution_constraint<T>(mut self, v: std::option::Option<T>) -> Self
1038 where
1039 T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1040 {
1041 self.injected_solution_constraint = v.map(|x| x.into());
1042 self
1043 }
1044
1045 /// Sets the value of [refresh_details_routes][crate::model::OptimizeToursRequest::refresh_details_routes].
1046 ///
1047 /// # Example
1048 /// ```ignore,no_run
1049 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1050 /// use google_cloud_optimization_v1::model::ShipmentRoute;
1051 /// let x = OptimizeToursRequest::new()
1052 /// .set_refresh_details_routes([
1053 /// ShipmentRoute::default()/* use setters */,
1054 /// ShipmentRoute::default()/* use (different) setters */,
1055 /// ]);
1056 /// ```
1057 pub fn set_refresh_details_routes<T, V>(mut self, v: T) -> Self
1058 where
1059 T: std::iter::IntoIterator<Item = V>,
1060 V: std::convert::Into<crate::model::ShipmentRoute>,
1061 {
1062 use std::iter::Iterator;
1063 self.refresh_details_routes = v.into_iter().map(|i| i.into()).collect();
1064 self
1065 }
1066
1067 /// Sets the value of [interpret_injected_solutions_using_labels][crate::model::OptimizeToursRequest::interpret_injected_solutions_using_labels].
1068 ///
1069 /// # Example
1070 /// ```ignore,no_run
1071 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1072 /// let x = OptimizeToursRequest::new().set_interpret_injected_solutions_using_labels(true);
1073 /// ```
1074 pub fn set_interpret_injected_solutions_using_labels<T: std::convert::Into<bool>>(
1075 mut self,
1076 v: T,
1077 ) -> Self {
1078 self.interpret_injected_solutions_using_labels = v.into();
1079 self
1080 }
1081
1082 /// Sets the value of [consider_road_traffic][crate::model::OptimizeToursRequest::consider_road_traffic].
1083 ///
1084 /// # Example
1085 /// ```ignore,no_run
1086 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1087 /// let x = OptimizeToursRequest::new().set_consider_road_traffic(true);
1088 /// ```
1089 pub fn set_consider_road_traffic<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1090 self.consider_road_traffic = v.into();
1091 self
1092 }
1093
1094 /// Sets the value of [populate_polylines][crate::model::OptimizeToursRequest::populate_polylines].
1095 ///
1096 /// # Example
1097 /// ```ignore,no_run
1098 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1099 /// let x = OptimizeToursRequest::new().set_populate_polylines(true);
1100 /// ```
1101 pub fn set_populate_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1102 self.populate_polylines = v.into();
1103 self
1104 }
1105
1106 /// Sets the value of [populate_transition_polylines][crate::model::OptimizeToursRequest::populate_transition_polylines].
1107 ///
1108 /// # Example
1109 /// ```ignore,no_run
1110 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1111 /// let x = OptimizeToursRequest::new().set_populate_transition_polylines(true);
1112 /// ```
1113 pub fn set_populate_transition_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1114 self.populate_transition_polylines = v.into();
1115 self
1116 }
1117
1118 /// Sets the value of [allow_large_deadline_despite_interruption_risk][crate::model::OptimizeToursRequest::allow_large_deadline_despite_interruption_risk].
1119 ///
1120 /// # Example
1121 /// ```ignore,no_run
1122 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1123 /// let x = OptimizeToursRequest::new().set_allow_large_deadline_despite_interruption_risk(true);
1124 /// ```
1125 pub fn set_allow_large_deadline_despite_interruption_risk<T: std::convert::Into<bool>>(
1126 mut self,
1127 v: T,
1128 ) -> Self {
1129 self.allow_large_deadline_despite_interruption_risk = v.into();
1130 self
1131 }
1132
1133 /// Sets the value of [use_geodesic_distances][crate::model::OptimizeToursRequest::use_geodesic_distances].
1134 ///
1135 /// # Example
1136 /// ```ignore,no_run
1137 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1138 /// let x = OptimizeToursRequest::new().set_use_geodesic_distances(true);
1139 /// ```
1140 pub fn set_use_geodesic_distances<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1141 self.use_geodesic_distances = v.into();
1142 self
1143 }
1144
1145 /// Sets the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1146 ///
1147 /// # Example
1148 /// ```ignore,no_run
1149 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1150 /// let x = OptimizeToursRequest::new().set_geodesic_meters_per_second(42.0);
1151 /// ```
1152 pub fn set_geodesic_meters_per_second<T>(mut self, v: T) -> Self
1153 where
1154 T: std::convert::Into<f64>,
1155 {
1156 self.geodesic_meters_per_second = std::option::Option::Some(v.into());
1157 self
1158 }
1159
1160 /// Sets or clears the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1161 ///
1162 /// # Example
1163 /// ```ignore,no_run
1164 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1165 /// let x = OptimizeToursRequest::new().set_or_clear_geodesic_meters_per_second(Some(42.0));
1166 /// let x = OptimizeToursRequest::new().set_or_clear_geodesic_meters_per_second(None::<f32>);
1167 /// ```
1168 pub fn set_or_clear_geodesic_meters_per_second<T>(mut self, v: std::option::Option<T>) -> Self
1169 where
1170 T: std::convert::Into<f64>,
1171 {
1172 self.geodesic_meters_per_second = v.map(|x| x.into());
1173 self
1174 }
1175
1176 /// Sets the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1177 ///
1178 /// # Example
1179 /// ```ignore,no_run
1180 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1181 /// let x = OptimizeToursRequest::new().set_max_validation_errors(42);
1182 /// ```
1183 pub fn set_max_validation_errors<T>(mut self, v: T) -> Self
1184 where
1185 T: std::convert::Into<i32>,
1186 {
1187 self.max_validation_errors = std::option::Option::Some(v.into());
1188 self
1189 }
1190
1191 /// Sets or clears the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1192 ///
1193 /// # Example
1194 /// ```ignore,no_run
1195 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1196 /// let x = OptimizeToursRequest::new().set_or_clear_max_validation_errors(Some(42));
1197 /// let x = OptimizeToursRequest::new().set_or_clear_max_validation_errors(None::<i32>);
1198 /// ```
1199 pub fn set_or_clear_max_validation_errors<T>(mut self, v: std::option::Option<T>) -> Self
1200 where
1201 T: std::convert::Into<i32>,
1202 {
1203 self.max_validation_errors = v.map(|x| x.into());
1204 self
1205 }
1206
1207 /// Sets the value of [label][crate::model::OptimizeToursRequest::label].
1208 ///
1209 /// # Example
1210 /// ```ignore,no_run
1211 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1212 /// let x = OptimizeToursRequest::new().set_label("example");
1213 /// ```
1214 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1215 self.label = v.into();
1216 self
1217 }
1218
1219 /// Sets the value of [populate_travel_step_polylines][crate::model::OptimizeToursRequest::populate_travel_step_polylines].
1220 ///
1221 /// # Example
1222 /// ```ignore,no_run
1223 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1224 /// let x = OptimizeToursRequest::new().set_populate_travel_step_polylines(true);
1225 /// ```
1226 #[deprecated]
1227 pub fn set_populate_travel_step_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1228 self.populate_travel_step_polylines = v.into();
1229 self
1230 }
1231}
1232
1233impl wkt::message::Message for OptimizeToursRequest {
1234 fn typename() -> &'static str {
1235 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursRequest"
1236 }
1237}
1238
1239/// Defines additional types related to [OptimizeToursRequest].
1240pub mod optimize_tours_request {
1241 #[allow(unused_imports)]
1242 use super::*;
1243
1244 /// Defines how the solver should handle the request. In all modes but
1245 /// `VALIDATE_ONLY`, if the request is invalid, you will receive an
1246 /// `INVALID_REQUEST` error. See
1247 /// [max_validation_errors][google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]
1248 /// to cap the number of errors returned.
1249 ///
1250 /// [google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]: crate::model::OptimizeToursRequest::max_validation_errors
1251 ///
1252 /// # Working with unknown values
1253 ///
1254 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1255 /// additional enum variants at any time. Adding new variants is not considered
1256 /// a breaking change. Applications should write their code in anticipation of:
1257 ///
1258 /// - New values appearing in future releases of the client library, **and**
1259 /// - New values received dynamically, without application changes.
1260 ///
1261 /// Please consult the [Working with enums] section in the user guide for some
1262 /// guidelines.
1263 ///
1264 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1265 #[derive(Clone, Debug, PartialEq)]
1266 #[non_exhaustive]
1267 pub enum SolvingMode {
1268 /// Solve the model.
1269 DefaultSolve,
1270 /// Only validates the model without solving it: populates as many
1271 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1272 /// as possible.
1273 ///
1274 /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1275 ValidateOnly,
1276 /// Only populates
1277 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1278 /// or
1279 /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments],
1280 /// and doesn't actually solve the rest of the request (`status` and `routes`
1281 /// are unset in the response).
1282 /// If infeasibilities in `injected_solution_constraint` routes are detected
1283 /// they are populated in the
1284 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1285 /// field and
1286 /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]
1287 /// is left empty.
1288 ///
1289 /// *IMPORTANT*: not all infeasible shipments are returned here, but only the
1290 /// ones that are detected as infeasible during preprocessing.
1291 ///
1292 /// [google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]: crate::model::OptimizeToursResponse::skipped_shipments
1293 /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1294 DetectSomeInfeasibleShipments,
1295 /// If set, the enum was initialized with an unknown value.
1296 ///
1297 /// Applications can examine the value using [SolvingMode::value] or
1298 /// [SolvingMode::name].
1299 UnknownValue(solving_mode::UnknownValue),
1300 }
1301
1302 #[doc(hidden)]
1303 pub mod solving_mode {
1304 #[allow(unused_imports)]
1305 use super::*;
1306 #[derive(Clone, Debug, PartialEq)]
1307 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1308 }
1309
1310 impl SolvingMode {
1311 /// Gets the enum value.
1312 ///
1313 /// Returns `None` if the enum contains an unknown value deserialized from
1314 /// the string representation of enums.
1315 pub fn value(&self) -> std::option::Option<i32> {
1316 match self {
1317 Self::DefaultSolve => std::option::Option::Some(0),
1318 Self::ValidateOnly => std::option::Option::Some(1),
1319 Self::DetectSomeInfeasibleShipments => std::option::Option::Some(2),
1320 Self::UnknownValue(u) => u.0.value(),
1321 }
1322 }
1323
1324 /// Gets the enum value as a string.
1325 ///
1326 /// Returns `None` if the enum contains an unknown value deserialized from
1327 /// the integer representation of enums.
1328 pub fn name(&self) -> std::option::Option<&str> {
1329 match self {
1330 Self::DefaultSolve => std::option::Option::Some("DEFAULT_SOLVE"),
1331 Self::ValidateOnly => std::option::Option::Some("VALIDATE_ONLY"),
1332 Self::DetectSomeInfeasibleShipments => {
1333 std::option::Option::Some("DETECT_SOME_INFEASIBLE_SHIPMENTS")
1334 }
1335 Self::UnknownValue(u) => u.0.name(),
1336 }
1337 }
1338 }
1339
1340 impl std::default::Default for SolvingMode {
1341 fn default() -> Self {
1342 use std::convert::From;
1343 Self::from(0)
1344 }
1345 }
1346
1347 impl std::fmt::Display for SolvingMode {
1348 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1349 wkt::internal::display_enum(f, self.name(), self.value())
1350 }
1351 }
1352
1353 impl std::convert::From<i32> for SolvingMode {
1354 fn from(value: i32) -> Self {
1355 match value {
1356 0 => Self::DefaultSolve,
1357 1 => Self::ValidateOnly,
1358 2 => Self::DetectSomeInfeasibleShipments,
1359 _ => Self::UnknownValue(solving_mode::UnknownValue(
1360 wkt::internal::UnknownEnumValue::Integer(value),
1361 )),
1362 }
1363 }
1364 }
1365
1366 impl std::convert::From<&str> for SolvingMode {
1367 fn from(value: &str) -> Self {
1368 use std::string::ToString;
1369 match value {
1370 "DEFAULT_SOLVE" => Self::DefaultSolve,
1371 "VALIDATE_ONLY" => Self::ValidateOnly,
1372 "DETECT_SOME_INFEASIBLE_SHIPMENTS" => Self::DetectSomeInfeasibleShipments,
1373 _ => Self::UnknownValue(solving_mode::UnknownValue(
1374 wkt::internal::UnknownEnumValue::String(value.to_string()),
1375 )),
1376 }
1377 }
1378 }
1379
1380 impl serde::ser::Serialize for SolvingMode {
1381 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1382 where
1383 S: serde::Serializer,
1384 {
1385 match self {
1386 Self::DefaultSolve => serializer.serialize_i32(0),
1387 Self::ValidateOnly => serializer.serialize_i32(1),
1388 Self::DetectSomeInfeasibleShipments => serializer.serialize_i32(2),
1389 Self::UnknownValue(u) => u.0.serialize(serializer),
1390 }
1391 }
1392 }
1393
1394 impl<'de> serde::de::Deserialize<'de> for SolvingMode {
1395 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1396 where
1397 D: serde::Deserializer<'de>,
1398 {
1399 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SolvingMode>::new(
1400 ".google.cloud.optimization.v1.OptimizeToursRequest.SolvingMode",
1401 ))
1402 }
1403 }
1404
1405 /// Mode defining the behavior of the search, trading off latency versus
1406 /// solution quality. In all modes, the global request deadline is enforced.
1407 ///
1408 /// # Working with unknown values
1409 ///
1410 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1411 /// additional enum variants at any time. Adding new variants is not considered
1412 /// a breaking change. Applications should write their code in anticipation of:
1413 ///
1414 /// - New values appearing in future releases of the client library, **and**
1415 /// - New values received dynamically, without application changes.
1416 ///
1417 /// Please consult the [Working with enums] section in the user guide for some
1418 /// guidelines.
1419 ///
1420 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1421 #[derive(Clone, Debug, PartialEq)]
1422 #[non_exhaustive]
1423 pub enum SearchMode {
1424 /// Unspecified search mode, equivalent to `RETURN_FAST`.
1425 Unspecified,
1426 /// Stop the search after finding the first good solution.
1427 ReturnFast,
1428 /// Spend all the available time to search for better solutions.
1429 ConsumeAllAvailableTime,
1430 /// If set, the enum was initialized with an unknown value.
1431 ///
1432 /// Applications can examine the value using [SearchMode::value] or
1433 /// [SearchMode::name].
1434 UnknownValue(search_mode::UnknownValue),
1435 }
1436
1437 #[doc(hidden)]
1438 pub mod search_mode {
1439 #[allow(unused_imports)]
1440 use super::*;
1441 #[derive(Clone, Debug, PartialEq)]
1442 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1443 }
1444
1445 impl SearchMode {
1446 /// Gets the enum value.
1447 ///
1448 /// Returns `None` if the enum contains an unknown value deserialized from
1449 /// the string representation of enums.
1450 pub fn value(&self) -> std::option::Option<i32> {
1451 match self {
1452 Self::Unspecified => std::option::Option::Some(0),
1453 Self::ReturnFast => std::option::Option::Some(1),
1454 Self::ConsumeAllAvailableTime => std::option::Option::Some(2),
1455 Self::UnknownValue(u) => u.0.value(),
1456 }
1457 }
1458
1459 /// Gets the enum value as a string.
1460 ///
1461 /// Returns `None` if the enum contains an unknown value deserialized from
1462 /// the integer representation of enums.
1463 pub fn name(&self) -> std::option::Option<&str> {
1464 match self {
1465 Self::Unspecified => std::option::Option::Some("SEARCH_MODE_UNSPECIFIED"),
1466 Self::ReturnFast => std::option::Option::Some("RETURN_FAST"),
1467 Self::ConsumeAllAvailableTime => {
1468 std::option::Option::Some("CONSUME_ALL_AVAILABLE_TIME")
1469 }
1470 Self::UnknownValue(u) => u.0.name(),
1471 }
1472 }
1473 }
1474
1475 impl std::default::Default for SearchMode {
1476 fn default() -> Self {
1477 use std::convert::From;
1478 Self::from(0)
1479 }
1480 }
1481
1482 impl std::fmt::Display for SearchMode {
1483 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1484 wkt::internal::display_enum(f, self.name(), self.value())
1485 }
1486 }
1487
1488 impl std::convert::From<i32> for SearchMode {
1489 fn from(value: i32) -> Self {
1490 match value {
1491 0 => Self::Unspecified,
1492 1 => Self::ReturnFast,
1493 2 => Self::ConsumeAllAvailableTime,
1494 _ => Self::UnknownValue(search_mode::UnknownValue(
1495 wkt::internal::UnknownEnumValue::Integer(value),
1496 )),
1497 }
1498 }
1499 }
1500
1501 impl std::convert::From<&str> for SearchMode {
1502 fn from(value: &str) -> Self {
1503 use std::string::ToString;
1504 match value {
1505 "SEARCH_MODE_UNSPECIFIED" => Self::Unspecified,
1506 "RETURN_FAST" => Self::ReturnFast,
1507 "CONSUME_ALL_AVAILABLE_TIME" => Self::ConsumeAllAvailableTime,
1508 _ => Self::UnknownValue(search_mode::UnknownValue(
1509 wkt::internal::UnknownEnumValue::String(value.to_string()),
1510 )),
1511 }
1512 }
1513 }
1514
1515 impl serde::ser::Serialize for SearchMode {
1516 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1517 where
1518 S: serde::Serializer,
1519 {
1520 match self {
1521 Self::Unspecified => serializer.serialize_i32(0),
1522 Self::ReturnFast => serializer.serialize_i32(1),
1523 Self::ConsumeAllAvailableTime => serializer.serialize_i32(2),
1524 Self::UnknownValue(u) => u.0.serialize(serializer),
1525 }
1526 }
1527 }
1528
1529 impl<'de> serde::de::Deserialize<'de> for SearchMode {
1530 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1531 where
1532 D: serde::Deserializer<'de>,
1533 {
1534 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SearchMode>::new(
1535 ".google.cloud.optimization.v1.OptimizeToursRequest.SearchMode",
1536 ))
1537 }
1538 }
1539}
1540
1541/// Response after solving a tour optimization problem containing the routes
1542/// followed by each vehicle, the shipments which have been skipped and the
1543/// overall cost of the solution.
1544#[derive(Clone, Default, PartialEq)]
1545#[non_exhaustive]
1546pub struct OptimizeToursResponse {
1547 /// Routes computed for each vehicle; the i-th route corresponds to the i-th
1548 /// vehicle in the model.
1549 pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
1550
1551 /// Copy of the
1552 /// [OptimizeToursRequest.label][google.cloud.optimization.v1.OptimizeToursRequest.label],
1553 /// if a label was specified in the request.
1554 ///
1555 /// [google.cloud.optimization.v1.OptimizeToursRequest.label]: crate::model::OptimizeToursRequest::label
1556 pub request_label: std::string::String,
1557
1558 /// The list of all shipments skipped.
1559 pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
1560
1561 /// List of all the validation errors that we were able to detect
1562 /// independently. See the "MULTIPLE ERRORS" explanation for the
1563 /// [OptimizeToursValidationError][google.cloud.optimization.v1.OptimizeToursValidationError]
1564 /// message.
1565 ///
1566 /// [google.cloud.optimization.v1.OptimizeToursValidationError]: crate::model::OptimizeToursValidationError
1567 pub validation_errors: std::vec::Vec<crate::model::OptimizeToursValidationError>,
1568
1569 /// Duration, distance and usage metrics for this solution.
1570 pub metrics: std::option::Option<crate::model::optimize_tours_response::Metrics>,
1571
1572 /// Deprecated: Use
1573 /// [Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
1574 /// instead. Total cost of the solution. This takes into account all costs:
1575 /// costs per per hour and travel hour, fixed vehicle costs, unperformed
1576 /// shipment penalty costs, global duration cost, etc.
1577 ///
1578 /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
1579 #[deprecated]
1580 pub total_cost: f64,
1581
1582 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1583}
1584
1585impl OptimizeToursResponse {
1586 /// Creates a new default instance.
1587 pub fn new() -> Self {
1588 std::default::Default::default()
1589 }
1590
1591 /// Sets the value of [routes][crate::model::OptimizeToursResponse::routes].
1592 ///
1593 /// # Example
1594 /// ```ignore,no_run
1595 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1596 /// use google_cloud_optimization_v1::model::ShipmentRoute;
1597 /// let x = OptimizeToursResponse::new()
1598 /// .set_routes([
1599 /// ShipmentRoute::default()/* use setters */,
1600 /// ShipmentRoute::default()/* use (different) setters */,
1601 /// ]);
1602 /// ```
1603 pub fn set_routes<T, V>(mut self, v: T) -> Self
1604 where
1605 T: std::iter::IntoIterator<Item = V>,
1606 V: std::convert::Into<crate::model::ShipmentRoute>,
1607 {
1608 use std::iter::Iterator;
1609 self.routes = v.into_iter().map(|i| i.into()).collect();
1610 self
1611 }
1612
1613 /// Sets the value of [request_label][crate::model::OptimizeToursResponse::request_label].
1614 ///
1615 /// # Example
1616 /// ```ignore,no_run
1617 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1618 /// let x = OptimizeToursResponse::new().set_request_label("example");
1619 /// ```
1620 pub fn set_request_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1621 self.request_label = v.into();
1622 self
1623 }
1624
1625 /// Sets the value of [skipped_shipments][crate::model::OptimizeToursResponse::skipped_shipments].
1626 ///
1627 /// # Example
1628 /// ```ignore,no_run
1629 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1630 /// use google_cloud_optimization_v1::model::SkippedShipment;
1631 /// let x = OptimizeToursResponse::new()
1632 /// .set_skipped_shipments([
1633 /// SkippedShipment::default()/* use setters */,
1634 /// SkippedShipment::default()/* use (different) setters */,
1635 /// ]);
1636 /// ```
1637 pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
1638 where
1639 T: std::iter::IntoIterator<Item = V>,
1640 V: std::convert::Into<crate::model::SkippedShipment>,
1641 {
1642 use std::iter::Iterator;
1643 self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
1644 self
1645 }
1646
1647 /// Sets the value of [validation_errors][crate::model::OptimizeToursResponse::validation_errors].
1648 ///
1649 /// # Example
1650 /// ```ignore,no_run
1651 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1652 /// use google_cloud_optimization_v1::model::OptimizeToursValidationError;
1653 /// let x = OptimizeToursResponse::new()
1654 /// .set_validation_errors([
1655 /// OptimizeToursValidationError::default()/* use setters */,
1656 /// OptimizeToursValidationError::default()/* use (different) setters */,
1657 /// ]);
1658 /// ```
1659 pub fn set_validation_errors<T, V>(mut self, v: T) -> Self
1660 where
1661 T: std::iter::IntoIterator<Item = V>,
1662 V: std::convert::Into<crate::model::OptimizeToursValidationError>,
1663 {
1664 use std::iter::Iterator;
1665 self.validation_errors = v.into_iter().map(|i| i.into()).collect();
1666 self
1667 }
1668
1669 /// Sets the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1670 ///
1671 /// # Example
1672 /// ```ignore,no_run
1673 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1674 /// use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1675 /// let x = OptimizeToursResponse::new().set_metrics(Metrics::default()/* use setters */);
1676 /// ```
1677 pub fn set_metrics<T>(mut self, v: T) -> Self
1678 where
1679 T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1680 {
1681 self.metrics = std::option::Option::Some(v.into());
1682 self
1683 }
1684
1685 /// Sets or clears the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1686 ///
1687 /// # Example
1688 /// ```ignore,no_run
1689 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1690 /// use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1691 /// let x = OptimizeToursResponse::new().set_or_clear_metrics(Some(Metrics::default()/* use setters */));
1692 /// let x = OptimizeToursResponse::new().set_or_clear_metrics(None::<Metrics>);
1693 /// ```
1694 pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1695 where
1696 T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1697 {
1698 self.metrics = v.map(|x| x.into());
1699 self
1700 }
1701
1702 /// Sets the value of [total_cost][crate::model::OptimizeToursResponse::total_cost].
1703 ///
1704 /// # Example
1705 /// ```ignore,no_run
1706 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1707 /// let x = OptimizeToursResponse::new().set_total_cost(42.0);
1708 /// ```
1709 #[deprecated]
1710 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1711 self.total_cost = v.into();
1712 self
1713 }
1714}
1715
1716impl wkt::message::Message for OptimizeToursResponse {
1717 fn typename() -> &'static str {
1718 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse"
1719 }
1720}
1721
1722/// Defines additional types related to [OptimizeToursResponse].
1723pub mod optimize_tours_response {
1724 #[allow(unused_imports)]
1725 use super::*;
1726
1727 /// Overall metrics, aggregated over all routes.
1728 #[derive(Clone, Default, PartialEq)]
1729 #[non_exhaustive]
1730 pub struct Metrics {
1731 /// Aggregated over the routes. Each metric is the sum (or max, for loads)
1732 /// over all
1733 /// [ShipmentRoute.metrics][google.cloud.optimization.v1.ShipmentRoute.metrics]
1734 /// fields of the same name.
1735 ///
1736 /// [google.cloud.optimization.v1.ShipmentRoute.metrics]: crate::model::ShipmentRoute::metrics
1737 pub aggregated_route_metrics: std::option::Option<crate::model::AggregatedMetrics>,
1738
1739 /// Number of mandatory shipments skipped.
1740 pub skipped_mandatory_shipment_count: i32,
1741
1742 /// Number of vehicles used. Note: if a vehicle route is empty and
1743 /// [Vehicle.used_if_route_is_empty][google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]
1744 /// is true, the vehicle is considered used.
1745 ///
1746 /// [google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]: crate::model::Vehicle::used_if_route_is_empty
1747 pub used_vehicle_count: i32,
1748
1749 /// The earliest start time for a used vehicle, computed as the minimum over
1750 /// all used vehicles of
1751 /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time].
1752 ///
1753 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
1754 pub earliest_vehicle_start_time: std::option::Option<wkt::Timestamp>,
1755
1756 /// The latest end time for a used vehicle, computed as the maximum over all
1757 /// used vehicles of
1758 /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time].
1759 ///
1760 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
1761 pub latest_vehicle_end_time: std::option::Option<wkt::Timestamp>,
1762
1763 /// Cost of the solution, broken down by cost-related request fields.
1764 /// The keys are proto paths, relative to the input OptimizeToursRequest,
1765 /// e.g. "model.shipments.pickups.cost", and the values are the total cost
1766 /// generated by the corresponding cost field, aggregated over the whole
1767 /// solution. In other words, costs["model.shipments.pickups.cost"] is the
1768 /// sum of all pickup costs over the solution. All costs defined in the model
1769 /// are reported in detail here with the exception of costs related to
1770 /// TransitionAttributes that are only reported in an aggregated way as of
1771 /// 2022/01.
1772 pub costs: std::collections::HashMap<std::string::String, f64>,
1773
1774 /// Total cost of the solution. The sum of all values in the costs map.
1775 pub total_cost: f64,
1776
1777 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1778 }
1779
1780 impl Metrics {
1781 /// Creates a new default instance.
1782 pub fn new() -> Self {
1783 std::default::Default::default()
1784 }
1785
1786 /// Sets the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1787 ///
1788 /// # Example
1789 /// ```ignore,no_run
1790 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1791 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
1792 /// let x = Metrics::new().set_aggregated_route_metrics(AggregatedMetrics::default()/* use setters */);
1793 /// ```
1794 pub fn set_aggregated_route_metrics<T>(mut self, v: T) -> Self
1795 where
1796 T: std::convert::Into<crate::model::AggregatedMetrics>,
1797 {
1798 self.aggregated_route_metrics = std::option::Option::Some(v.into());
1799 self
1800 }
1801
1802 /// Sets or clears the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1803 ///
1804 /// # Example
1805 /// ```ignore,no_run
1806 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1807 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
1808 /// let x = Metrics::new().set_or_clear_aggregated_route_metrics(Some(AggregatedMetrics::default()/* use setters */));
1809 /// let x = Metrics::new().set_or_clear_aggregated_route_metrics(None::<AggregatedMetrics>);
1810 /// ```
1811 pub fn set_or_clear_aggregated_route_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1812 where
1813 T: std::convert::Into<crate::model::AggregatedMetrics>,
1814 {
1815 self.aggregated_route_metrics = v.map(|x| x.into());
1816 self
1817 }
1818
1819 /// Sets the value of [skipped_mandatory_shipment_count][crate::model::optimize_tours_response::Metrics::skipped_mandatory_shipment_count].
1820 ///
1821 /// # Example
1822 /// ```ignore,no_run
1823 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1824 /// let x = Metrics::new().set_skipped_mandatory_shipment_count(42);
1825 /// ```
1826 pub fn set_skipped_mandatory_shipment_count<T: std::convert::Into<i32>>(
1827 mut self,
1828 v: T,
1829 ) -> Self {
1830 self.skipped_mandatory_shipment_count = v.into();
1831 self
1832 }
1833
1834 /// Sets the value of [used_vehicle_count][crate::model::optimize_tours_response::Metrics::used_vehicle_count].
1835 ///
1836 /// # Example
1837 /// ```ignore,no_run
1838 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1839 /// let x = Metrics::new().set_used_vehicle_count(42);
1840 /// ```
1841 pub fn set_used_vehicle_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1842 self.used_vehicle_count = v.into();
1843 self
1844 }
1845
1846 /// Sets the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1847 ///
1848 /// # Example
1849 /// ```ignore,no_run
1850 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1851 /// use wkt::Timestamp;
1852 /// let x = Metrics::new().set_earliest_vehicle_start_time(Timestamp::default()/* use setters */);
1853 /// ```
1854 pub fn set_earliest_vehicle_start_time<T>(mut self, v: T) -> Self
1855 where
1856 T: std::convert::Into<wkt::Timestamp>,
1857 {
1858 self.earliest_vehicle_start_time = std::option::Option::Some(v.into());
1859 self
1860 }
1861
1862 /// Sets or clears the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1863 ///
1864 /// # Example
1865 /// ```ignore,no_run
1866 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1867 /// use wkt::Timestamp;
1868 /// let x = Metrics::new().set_or_clear_earliest_vehicle_start_time(Some(Timestamp::default()/* use setters */));
1869 /// let x = Metrics::new().set_or_clear_earliest_vehicle_start_time(None::<Timestamp>);
1870 /// ```
1871 pub fn set_or_clear_earliest_vehicle_start_time<T>(
1872 mut self,
1873 v: std::option::Option<T>,
1874 ) -> Self
1875 where
1876 T: std::convert::Into<wkt::Timestamp>,
1877 {
1878 self.earliest_vehicle_start_time = v.map(|x| x.into());
1879 self
1880 }
1881
1882 /// Sets the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1883 ///
1884 /// # Example
1885 /// ```ignore,no_run
1886 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1887 /// use wkt::Timestamp;
1888 /// let x = Metrics::new().set_latest_vehicle_end_time(Timestamp::default()/* use setters */);
1889 /// ```
1890 pub fn set_latest_vehicle_end_time<T>(mut self, v: T) -> Self
1891 where
1892 T: std::convert::Into<wkt::Timestamp>,
1893 {
1894 self.latest_vehicle_end_time = std::option::Option::Some(v.into());
1895 self
1896 }
1897
1898 /// Sets or clears the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1899 ///
1900 /// # Example
1901 /// ```ignore,no_run
1902 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1903 /// use wkt::Timestamp;
1904 /// let x = Metrics::new().set_or_clear_latest_vehicle_end_time(Some(Timestamp::default()/* use setters */));
1905 /// let x = Metrics::new().set_or_clear_latest_vehicle_end_time(None::<Timestamp>);
1906 /// ```
1907 pub fn set_or_clear_latest_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
1908 where
1909 T: std::convert::Into<wkt::Timestamp>,
1910 {
1911 self.latest_vehicle_end_time = v.map(|x| x.into());
1912 self
1913 }
1914
1915 /// Sets the value of [costs][crate::model::optimize_tours_response::Metrics::costs].
1916 ///
1917 /// # Example
1918 /// ```ignore,no_run
1919 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1920 /// let x = Metrics::new().set_costs([
1921 /// ("key0", 123.5),
1922 /// ("key1", 456.5),
1923 /// ]);
1924 /// ```
1925 pub fn set_costs<T, K, V>(mut self, v: T) -> Self
1926 where
1927 T: std::iter::IntoIterator<Item = (K, V)>,
1928 K: std::convert::Into<std::string::String>,
1929 V: std::convert::Into<f64>,
1930 {
1931 use std::iter::Iterator;
1932 self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1933 self
1934 }
1935
1936 /// Sets the value of [total_cost][crate::model::optimize_tours_response::Metrics::total_cost].
1937 ///
1938 /// # Example
1939 /// ```ignore,no_run
1940 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1941 /// let x = Metrics::new().set_total_cost(42.0);
1942 /// ```
1943 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1944 self.total_cost = v.into();
1945 self
1946 }
1947 }
1948
1949 impl wkt::message::Message for Metrics {
1950 fn typename() -> &'static str {
1951 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse.Metrics"
1952 }
1953 }
1954}
1955
1956/// Request to batch optimize tours as an asynchronous operation.
1957/// Each input file should contain one `OptimizeToursRequest`, and each output
1958/// file will contain one `OptimizeToursResponse`. The request contains
1959/// information to read/write and parse the files. All the input and output files
1960/// should be under the same project.
1961#[derive(Clone, Default, PartialEq)]
1962#[non_exhaustive]
1963pub struct BatchOptimizeToursRequest {
1964 /// Required. Target project and location to make a call.
1965 ///
1966 /// Format: `projects/{project-id}/locations/{location-id}`.
1967 ///
1968 /// If no location is specified, a region will be chosen automatically.
1969 pub parent: std::string::String,
1970
1971 /// Required. Input/Output information each purchase model, such as file paths
1972 /// and data formats.
1973 pub model_configs: std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
1974
1975 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1976}
1977
1978impl BatchOptimizeToursRequest {
1979 /// Creates a new default instance.
1980 pub fn new() -> Self {
1981 std::default::Default::default()
1982 }
1983
1984 /// Sets the value of [parent][crate::model::BatchOptimizeToursRequest::parent].
1985 ///
1986 /// # Example
1987 /// ```ignore,no_run
1988 /// # use google_cloud_optimization_v1::model::BatchOptimizeToursRequest;
1989 /// let x = BatchOptimizeToursRequest::new().set_parent("example");
1990 /// ```
1991 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1992 self.parent = v.into();
1993 self
1994 }
1995
1996 /// Sets the value of [model_configs][crate::model::BatchOptimizeToursRequest::model_configs].
1997 ///
1998 /// # Example
1999 /// ```ignore,no_run
2000 /// # use google_cloud_optimization_v1::model::BatchOptimizeToursRequest;
2001 /// use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2002 /// let x = BatchOptimizeToursRequest::new()
2003 /// .set_model_configs([
2004 /// AsyncModelConfig::default()/* use setters */,
2005 /// AsyncModelConfig::default()/* use (different) setters */,
2006 /// ]);
2007 /// ```
2008 pub fn set_model_configs<T, V>(mut self, v: T) -> Self
2009 where
2010 T: std::iter::IntoIterator<Item = V>,
2011 V: std::convert::Into<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
2012 {
2013 use std::iter::Iterator;
2014 self.model_configs = v.into_iter().map(|i| i.into()).collect();
2015 self
2016 }
2017}
2018
2019impl wkt::message::Message for BatchOptimizeToursRequest {
2020 fn typename() -> &'static str {
2021 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest"
2022 }
2023}
2024
2025/// Defines additional types related to [BatchOptimizeToursRequest].
2026pub mod batch_optimize_tours_request {
2027 #[allow(unused_imports)]
2028 use super::*;
2029
2030 /// Information for solving one optimization model asynchronously.
2031 #[derive(Clone, Default, PartialEq)]
2032 #[non_exhaustive]
2033 pub struct AsyncModelConfig {
2034 /// User defined model name, can be used as alias by users to keep track of
2035 /// models.
2036 pub display_name: std::string::String,
2037
2038 /// Required. Information about the input model.
2039 pub input_config: std::option::Option<crate::model::InputConfig>,
2040
2041 /// Required. The desired output location information.
2042 pub output_config: std::option::Option<crate::model::OutputConfig>,
2043
2044 /// If this is set, the model will be solved in the checkpoint mode. In this
2045 /// mode, the input model can have a deadline longer than 30 mins without the
2046 /// risk of interruption. The model will be solved in multiple short-running
2047 /// stages. Each stage generates an intermediate checkpoint
2048 /// and stores it in the user's Cloud Storage buckets. The checkpoint
2049 /// mode should be preferred over
2050 /// allow_large_deadline_despite_interruption_risk since it prevents the risk
2051 /// of interruption.
2052 pub enable_checkpoints: bool,
2053
2054 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2055 }
2056
2057 impl AsyncModelConfig {
2058 /// Creates a new default instance.
2059 pub fn new() -> Self {
2060 std::default::Default::default()
2061 }
2062
2063 /// Sets the value of [display_name][crate::model::batch_optimize_tours_request::AsyncModelConfig::display_name].
2064 ///
2065 /// # Example
2066 /// ```ignore,no_run
2067 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2068 /// let x = AsyncModelConfig::new().set_display_name("example");
2069 /// ```
2070 pub fn set_display_name<T: std::convert::Into<std::string::String>>(
2071 mut self,
2072 v: T,
2073 ) -> Self {
2074 self.display_name = v.into();
2075 self
2076 }
2077
2078 /// Sets the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
2079 ///
2080 /// # Example
2081 /// ```ignore,no_run
2082 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2083 /// use google_cloud_optimization_v1::model::InputConfig;
2084 /// let x = AsyncModelConfig::new().set_input_config(InputConfig::default()/* use setters */);
2085 /// ```
2086 pub fn set_input_config<T>(mut self, v: T) -> Self
2087 where
2088 T: std::convert::Into<crate::model::InputConfig>,
2089 {
2090 self.input_config = std::option::Option::Some(v.into());
2091 self
2092 }
2093
2094 /// Sets or clears the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
2095 ///
2096 /// # Example
2097 /// ```ignore,no_run
2098 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2099 /// use google_cloud_optimization_v1::model::InputConfig;
2100 /// let x = AsyncModelConfig::new().set_or_clear_input_config(Some(InputConfig::default()/* use setters */));
2101 /// let x = AsyncModelConfig::new().set_or_clear_input_config(None::<InputConfig>);
2102 /// ```
2103 pub fn set_or_clear_input_config<T>(mut self, v: std::option::Option<T>) -> Self
2104 where
2105 T: std::convert::Into<crate::model::InputConfig>,
2106 {
2107 self.input_config = v.map(|x| x.into());
2108 self
2109 }
2110
2111 /// Sets the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
2112 ///
2113 /// # Example
2114 /// ```ignore,no_run
2115 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2116 /// use google_cloud_optimization_v1::model::OutputConfig;
2117 /// let x = AsyncModelConfig::new().set_output_config(OutputConfig::default()/* use setters */);
2118 /// ```
2119 pub fn set_output_config<T>(mut self, v: T) -> Self
2120 where
2121 T: std::convert::Into<crate::model::OutputConfig>,
2122 {
2123 self.output_config = std::option::Option::Some(v.into());
2124 self
2125 }
2126
2127 /// Sets or clears the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
2128 ///
2129 /// # Example
2130 /// ```ignore,no_run
2131 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2132 /// use google_cloud_optimization_v1::model::OutputConfig;
2133 /// let x = AsyncModelConfig::new().set_or_clear_output_config(Some(OutputConfig::default()/* use setters */));
2134 /// let x = AsyncModelConfig::new().set_or_clear_output_config(None::<OutputConfig>);
2135 /// ```
2136 pub fn set_or_clear_output_config<T>(mut self, v: std::option::Option<T>) -> Self
2137 where
2138 T: std::convert::Into<crate::model::OutputConfig>,
2139 {
2140 self.output_config = v.map(|x| x.into());
2141 self
2142 }
2143
2144 /// Sets the value of [enable_checkpoints][crate::model::batch_optimize_tours_request::AsyncModelConfig::enable_checkpoints].
2145 ///
2146 /// # Example
2147 /// ```ignore,no_run
2148 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2149 /// let x = AsyncModelConfig::new().set_enable_checkpoints(true);
2150 /// ```
2151 pub fn set_enable_checkpoints<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2152 self.enable_checkpoints = v.into();
2153 self
2154 }
2155 }
2156
2157 impl wkt::message::Message for AsyncModelConfig {
2158 fn typename() -> &'static str {
2159 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest.AsyncModelConfig"
2160 }
2161 }
2162}
2163
2164/// Response to a `BatchOptimizeToursRequest`. This is returned in
2165/// the LRO Operation after the operation is complete.
2166#[derive(Clone, Default, PartialEq)]
2167#[non_exhaustive]
2168pub struct BatchOptimizeToursResponse {
2169 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2170}
2171
2172impl BatchOptimizeToursResponse {
2173 /// Creates a new default instance.
2174 pub fn new() -> Self {
2175 std::default::Default::default()
2176 }
2177}
2178
2179impl wkt::message::Message for BatchOptimizeToursResponse {
2180 fn typename() -> &'static str {
2181 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursResponse"
2182 }
2183}
2184
2185/// A shipment model contains a set of shipments which must be performed by a
2186/// set of vehicles, while minimizing the overall cost, which is the sum of:
2187///
2188/// * the cost of routing the vehicles (sum of cost per total time, cost per
2189/// travel time, and fixed cost over all vehicles).
2190/// * the unperformed shipment penalties.
2191/// * the cost of the global duration of the shipments
2192#[derive(Clone, Default, PartialEq)]
2193#[non_exhaustive]
2194pub struct ShipmentModel {
2195 /// Set of shipments which must be performed in the model.
2196 pub shipments: std::vec::Vec<crate::model::Shipment>,
2197
2198 /// Set of vehicles which can be used to perform visits.
2199 pub vehicles: std::vec::Vec<crate::model::Vehicle>,
2200
2201 /// Constrains the maximum number of active vehicles. A vehicle is active if
2202 /// its route performs at least one shipment. This can be used to limit the
2203 /// number of routes in the case where there are fewer drivers than
2204 /// vehicles and that the fleet of vehicles is heterogeneous. The optimization
2205 /// will then select the best subset of vehicles to use.
2206 /// Must be strictly positive.
2207 pub max_active_vehicles: std::option::Option<i32>,
2208
2209 /// Global start and end time of the model: no times outside of this range
2210 /// can be considered valid.
2211 ///
2212 /// The model's time span must be less than a year, i.e. the `global_end_time`
2213 /// and the `global_start_time` must be within 31536000 seconds of each other.
2214 ///
2215 /// When using `cost_per_*hour` fields, you might want to set this window to a
2216 /// smaller interval to increase performance (eg. if you model a single day,
2217 /// you should set the global time limits to that day).
2218 /// If unset, 00:00:00 UTC, January 1, 1970 (i.e. seconds: 0, nanos: 0) is used
2219 /// as default.
2220 pub global_start_time: std::option::Option<wkt::Timestamp>,
2221
2222 /// If unset, 00:00:00 UTC, January 1, 1971 (i.e. seconds: 31536000, nanos: 0)
2223 /// is used as default.
2224 pub global_end_time: std::option::Option<wkt::Timestamp>,
2225
2226 /// The "global duration" of the overall plan is the difference between the
2227 /// earliest effective start time and the latest effective end time of
2228 /// all vehicles. Users can assign a cost per hour to that quantity to try
2229 /// and optimize for earliest job completion, for example. This cost must be in
2230 /// the same unit as
2231 /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
2232 ///
2233 /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
2234 pub global_duration_cost_per_hour: f64,
2235
2236 /// Specifies duration and distance matrices used in the model. If this field
2237 /// is empty, Google Maps or geodesic distances will be used instead, depending
2238 /// on the value of the `use_geodesic_distances` field. If it is not empty,
2239 /// `use_geodesic_distances` cannot be true and neither
2240 /// `duration_distance_matrix_src_tags` nor `duration_distance_matrix_dst_tags`
2241 /// can be empty.
2242 ///
2243 /// Usage examples:
2244 ///
2245 /// * There are two locations: locA and locB.
2246 /// * 1 vehicle starting its route at locA and ending it at locA.
2247 /// * 1 pickup visit request at locB.
2248 ///
2249 /// ```norust
2250 /// model {
2251 /// vehicles { start_tags: "locA" end_tags: "locA" }
2252 /// shipments { pickups { tags: "locB" } }
2253 /// duration_distance_matrix_src_tags: "locA"
2254 /// duration_distance_matrix_src_tags: "locB"
2255 /// duration_distance_matrix_dst_tags: "locA"
2256 /// duration_distance_matrix_dst_tags: "locB"
2257 /// duration_distance_matrices {
2258 /// rows { # from: locA
2259 /// durations { seconds: 0 } meters: 0 # to: locA
2260 /// durations { seconds: 100 } meters: 1000 # to: locB
2261 /// }
2262 /// rows { # from: locB
2263 /// durations { seconds: 102 } meters: 990 # to: locA
2264 /// durations { seconds: 0 } meters: 0 # to: locB
2265 /// }
2266 /// }
2267 /// }
2268 /// ```
2269 ///
2270 /// * There are three locations: locA, locB and locC.
2271 /// * 1 vehicle starting its route at locA and ending it at locB, using
2272 /// matrix "fast".
2273 /// * 1 vehicle starting its route at locB and ending it at locB, using
2274 /// matrix "slow".
2275 /// * 1 vehicle starting its route at locB and ending it at locB, using
2276 /// matrix "fast".
2277 /// * 1 pickup visit request at locC.
2278 ///
2279 /// ```norust
2280 /// model {
2281 /// vehicles { start_tags: "locA" end_tags: "locB" start_tags: "fast" }
2282 /// vehicles { start_tags: "locB" end_tags: "locB" start_tags: "slow" }
2283 /// vehicles { start_tags: "locB" end_tags: "locB" start_tags: "fast" }
2284 /// shipments { pickups { tags: "locC" } }
2285 /// duration_distance_matrix_src_tags: "locA"
2286 /// duration_distance_matrix_src_tags: "locB"
2287 /// duration_distance_matrix_src_tags: "locC"
2288 /// duration_distance_matrix_dst_tags: "locB"
2289 /// duration_distance_matrix_dst_tags: "locC"
2290 /// duration_distance_matrices {
2291 /// vehicle_start_tag: "fast"
2292 /// rows { # from: locA
2293 /// durations { seconds: 1000 } meters: 2000 # to: locB
2294 /// durations { seconds: 600 } meters: 1000 # to: locC
2295 /// }
2296 /// rows { # from: locB
2297 /// durations { seconds: 0 } meters: 0 # to: locB
2298 /// durations { seconds: 700 } meters: 1200 # to: locC
2299 /// }
2300 /// rows { # from: locC
2301 /// durations { seconds: 702 } meters: 1190 # to: locB
2302 /// durations { seconds: 0 } meters: 0 # to: locC
2303 /// }
2304 /// }
2305 /// duration_distance_matrices {
2306 /// vehicle_start_tag: "slow"
2307 /// rows { # from: locA
2308 /// durations { seconds: 1800 } meters: 2001 # to: locB
2309 /// durations { seconds: 900 } meters: 1002 # to: locC
2310 /// }
2311 /// rows { # from: locB
2312 /// durations { seconds: 0 } meters: 0 # to: locB
2313 /// durations { seconds: 1000 } meters: 1202 # to: locC
2314 /// }
2315 /// rows { # from: locC
2316 /// durations { seconds: 1001 } meters: 1195 # to: locB
2317 /// durations { seconds: 0 } meters: 0 # to: locC
2318 /// }
2319 /// }
2320 /// }
2321 /// ```
2322 pub duration_distance_matrices:
2323 std::vec::Vec<crate::model::shipment_model::DurationDistanceMatrix>,
2324
2325 /// Tags defining the sources of the duration and distance matrices;
2326 /// `duration_distance_matrices(i).rows(j)` defines durations and distances
2327 /// from visits with tag `duration_distance_matrix_src_tags(j)` to other visits
2328 /// in matrix i.
2329 ///
2330 /// Tags correspond to
2331 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
2332 /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
2333 /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
2334 /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
2335 /// the same; similarly a `VisitRequest`'s source and destination tags may be
2336 /// the same. All tags must be different and cannot be empty strings. If this
2337 /// field is not empty, then `duration_distance_matrices` must not be empty.
2338 ///
2339 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
2340 /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
2341 pub duration_distance_matrix_src_tags: std::vec::Vec<std::string::String>,
2342
2343 /// Tags defining the destinations of the duration and distance matrices;
2344 /// `duration_distance_matrices(i).rows(j).durations(k)` (resp.
2345 /// `duration_distance_matrices(i).rows(j).meters(k))` defines the duration
2346 /// (resp. the distance) of the travel from visits with tag
2347 /// `duration_distance_matrix_src_tags(j)` to visits with tag
2348 /// `duration_distance_matrix_dst_tags(k)` in matrix i.
2349 ///
2350 /// Tags correspond to
2351 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
2352 /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
2353 /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
2354 /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
2355 /// the same; similarly a `VisitRequest`'s source and destination tags may be
2356 /// the same. All tags must be different and cannot be empty strings. If this
2357 /// field is not empty, then `duration_distance_matrices` must not be empty.
2358 ///
2359 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
2360 /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
2361 pub duration_distance_matrix_dst_tags: std::vec::Vec<std::string::String>,
2362
2363 /// Transition attributes added to the model.
2364 pub transition_attributes: std::vec::Vec<crate::model::TransitionAttributes>,
2365
2366 /// Sets of incompatible shipment_types (see `ShipmentTypeIncompatibility`).
2367 pub shipment_type_incompatibilities: std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
2368
2369 /// Sets of `shipment_type` requirements (see `ShipmentTypeRequirement`).
2370 pub shipment_type_requirements: std::vec::Vec<crate::model::ShipmentTypeRequirement>,
2371
2372 /// Set of precedence rules which must be enforced in the model.
2373 pub precedence_rules: std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
2374
2375 /// Deprecated: No longer used.
2376 /// Set of break rules used in the model.
2377 /// Each vehicle specifies the `BreakRule` that applies to it via the
2378 /// [Vehicle.break_rule_indices][google.cloud.optimization.v1.Vehicle.break_rule_indices]
2379 /// field (which must be a singleton).
2380 ///
2381 /// [google.cloud.optimization.v1.Vehicle.break_rule_indices]: crate::model::Vehicle::break_rule_indices
2382 #[deprecated]
2383 pub break_rules: std::vec::Vec<crate::model::shipment_model::BreakRule>,
2384
2385 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2386}
2387
2388impl ShipmentModel {
2389 /// Creates a new default instance.
2390 pub fn new() -> Self {
2391 std::default::Default::default()
2392 }
2393
2394 /// Sets the value of [shipments][crate::model::ShipmentModel::shipments].
2395 ///
2396 /// # Example
2397 /// ```ignore,no_run
2398 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2399 /// use google_cloud_optimization_v1::model::Shipment;
2400 /// let x = ShipmentModel::new()
2401 /// .set_shipments([
2402 /// Shipment::default()/* use setters */,
2403 /// Shipment::default()/* use (different) setters */,
2404 /// ]);
2405 /// ```
2406 pub fn set_shipments<T, V>(mut self, v: T) -> Self
2407 where
2408 T: std::iter::IntoIterator<Item = V>,
2409 V: std::convert::Into<crate::model::Shipment>,
2410 {
2411 use std::iter::Iterator;
2412 self.shipments = v.into_iter().map(|i| i.into()).collect();
2413 self
2414 }
2415
2416 /// Sets the value of [vehicles][crate::model::ShipmentModel::vehicles].
2417 ///
2418 /// # Example
2419 /// ```ignore,no_run
2420 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2421 /// use google_cloud_optimization_v1::model::Vehicle;
2422 /// let x = ShipmentModel::new()
2423 /// .set_vehicles([
2424 /// Vehicle::default()/* use setters */,
2425 /// Vehicle::default()/* use (different) setters */,
2426 /// ]);
2427 /// ```
2428 pub fn set_vehicles<T, V>(mut self, v: T) -> Self
2429 where
2430 T: std::iter::IntoIterator<Item = V>,
2431 V: std::convert::Into<crate::model::Vehicle>,
2432 {
2433 use std::iter::Iterator;
2434 self.vehicles = v.into_iter().map(|i| i.into()).collect();
2435 self
2436 }
2437
2438 /// Sets the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
2439 ///
2440 /// # Example
2441 /// ```ignore,no_run
2442 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2443 /// let x = ShipmentModel::new().set_max_active_vehicles(42);
2444 /// ```
2445 pub fn set_max_active_vehicles<T>(mut self, v: T) -> Self
2446 where
2447 T: std::convert::Into<i32>,
2448 {
2449 self.max_active_vehicles = std::option::Option::Some(v.into());
2450 self
2451 }
2452
2453 /// Sets or clears the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
2454 ///
2455 /// # Example
2456 /// ```ignore,no_run
2457 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2458 /// let x = ShipmentModel::new().set_or_clear_max_active_vehicles(Some(42));
2459 /// let x = ShipmentModel::new().set_or_clear_max_active_vehicles(None::<i32>);
2460 /// ```
2461 pub fn set_or_clear_max_active_vehicles<T>(mut self, v: std::option::Option<T>) -> Self
2462 where
2463 T: std::convert::Into<i32>,
2464 {
2465 self.max_active_vehicles = v.map(|x| x.into());
2466 self
2467 }
2468
2469 /// Sets the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
2470 ///
2471 /// # Example
2472 /// ```ignore,no_run
2473 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2474 /// use wkt::Timestamp;
2475 /// let x = ShipmentModel::new().set_global_start_time(Timestamp::default()/* use setters */);
2476 /// ```
2477 pub fn set_global_start_time<T>(mut self, v: T) -> Self
2478 where
2479 T: std::convert::Into<wkt::Timestamp>,
2480 {
2481 self.global_start_time = std::option::Option::Some(v.into());
2482 self
2483 }
2484
2485 /// Sets or clears the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
2486 ///
2487 /// # Example
2488 /// ```ignore,no_run
2489 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2490 /// use wkt::Timestamp;
2491 /// let x = ShipmentModel::new().set_or_clear_global_start_time(Some(Timestamp::default()/* use setters */));
2492 /// let x = ShipmentModel::new().set_or_clear_global_start_time(None::<Timestamp>);
2493 /// ```
2494 pub fn set_or_clear_global_start_time<T>(mut self, v: std::option::Option<T>) -> Self
2495 where
2496 T: std::convert::Into<wkt::Timestamp>,
2497 {
2498 self.global_start_time = v.map(|x| x.into());
2499 self
2500 }
2501
2502 /// Sets the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
2503 ///
2504 /// # Example
2505 /// ```ignore,no_run
2506 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2507 /// use wkt::Timestamp;
2508 /// let x = ShipmentModel::new().set_global_end_time(Timestamp::default()/* use setters */);
2509 /// ```
2510 pub fn set_global_end_time<T>(mut self, v: T) -> Self
2511 where
2512 T: std::convert::Into<wkt::Timestamp>,
2513 {
2514 self.global_end_time = std::option::Option::Some(v.into());
2515 self
2516 }
2517
2518 /// Sets or clears the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
2519 ///
2520 /// # Example
2521 /// ```ignore,no_run
2522 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2523 /// use wkt::Timestamp;
2524 /// let x = ShipmentModel::new().set_or_clear_global_end_time(Some(Timestamp::default()/* use setters */));
2525 /// let x = ShipmentModel::new().set_or_clear_global_end_time(None::<Timestamp>);
2526 /// ```
2527 pub fn set_or_clear_global_end_time<T>(mut self, v: std::option::Option<T>) -> Self
2528 where
2529 T: std::convert::Into<wkt::Timestamp>,
2530 {
2531 self.global_end_time = v.map(|x| x.into());
2532 self
2533 }
2534
2535 /// Sets the value of [global_duration_cost_per_hour][crate::model::ShipmentModel::global_duration_cost_per_hour].
2536 ///
2537 /// # Example
2538 /// ```ignore,no_run
2539 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2540 /// let x = ShipmentModel::new().set_global_duration_cost_per_hour(42.0);
2541 /// ```
2542 pub fn set_global_duration_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2543 self.global_duration_cost_per_hour = v.into();
2544 self
2545 }
2546
2547 /// Sets the value of [duration_distance_matrices][crate::model::ShipmentModel::duration_distance_matrices].
2548 ///
2549 /// # Example
2550 /// ```ignore,no_run
2551 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2552 /// use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2553 /// let x = ShipmentModel::new()
2554 /// .set_duration_distance_matrices([
2555 /// DurationDistanceMatrix::default()/* use setters */,
2556 /// DurationDistanceMatrix::default()/* use (different) setters */,
2557 /// ]);
2558 /// ```
2559 pub fn set_duration_distance_matrices<T, V>(mut self, v: T) -> Self
2560 where
2561 T: std::iter::IntoIterator<Item = V>,
2562 V: std::convert::Into<crate::model::shipment_model::DurationDistanceMatrix>,
2563 {
2564 use std::iter::Iterator;
2565 self.duration_distance_matrices = v.into_iter().map(|i| i.into()).collect();
2566 self
2567 }
2568
2569 /// Sets the value of [duration_distance_matrix_src_tags][crate::model::ShipmentModel::duration_distance_matrix_src_tags].
2570 ///
2571 /// # Example
2572 /// ```ignore,no_run
2573 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2574 /// let x = ShipmentModel::new().set_duration_distance_matrix_src_tags(["a", "b", "c"]);
2575 /// ```
2576 pub fn set_duration_distance_matrix_src_tags<T, V>(mut self, v: T) -> Self
2577 where
2578 T: std::iter::IntoIterator<Item = V>,
2579 V: std::convert::Into<std::string::String>,
2580 {
2581 use std::iter::Iterator;
2582 self.duration_distance_matrix_src_tags = v.into_iter().map(|i| i.into()).collect();
2583 self
2584 }
2585
2586 /// Sets the value of [duration_distance_matrix_dst_tags][crate::model::ShipmentModel::duration_distance_matrix_dst_tags].
2587 ///
2588 /// # Example
2589 /// ```ignore,no_run
2590 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2591 /// let x = ShipmentModel::new().set_duration_distance_matrix_dst_tags(["a", "b", "c"]);
2592 /// ```
2593 pub fn set_duration_distance_matrix_dst_tags<T, V>(mut self, v: T) -> Self
2594 where
2595 T: std::iter::IntoIterator<Item = V>,
2596 V: std::convert::Into<std::string::String>,
2597 {
2598 use std::iter::Iterator;
2599 self.duration_distance_matrix_dst_tags = v.into_iter().map(|i| i.into()).collect();
2600 self
2601 }
2602
2603 /// Sets the value of [transition_attributes][crate::model::ShipmentModel::transition_attributes].
2604 ///
2605 /// # Example
2606 /// ```ignore,no_run
2607 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2608 /// use google_cloud_optimization_v1::model::TransitionAttributes;
2609 /// let x = ShipmentModel::new()
2610 /// .set_transition_attributes([
2611 /// TransitionAttributes::default()/* use setters */,
2612 /// TransitionAttributes::default()/* use (different) setters */,
2613 /// ]);
2614 /// ```
2615 pub fn set_transition_attributes<T, V>(mut self, v: T) -> Self
2616 where
2617 T: std::iter::IntoIterator<Item = V>,
2618 V: std::convert::Into<crate::model::TransitionAttributes>,
2619 {
2620 use std::iter::Iterator;
2621 self.transition_attributes = v.into_iter().map(|i| i.into()).collect();
2622 self
2623 }
2624
2625 /// Sets the value of [shipment_type_incompatibilities][crate::model::ShipmentModel::shipment_type_incompatibilities].
2626 ///
2627 /// # Example
2628 /// ```ignore,no_run
2629 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2630 /// use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
2631 /// let x = ShipmentModel::new()
2632 /// .set_shipment_type_incompatibilities([
2633 /// ShipmentTypeIncompatibility::default()/* use setters */,
2634 /// ShipmentTypeIncompatibility::default()/* use (different) setters */,
2635 /// ]);
2636 /// ```
2637 pub fn set_shipment_type_incompatibilities<T, V>(mut self, v: T) -> Self
2638 where
2639 T: std::iter::IntoIterator<Item = V>,
2640 V: std::convert::Into<crate::model::ShipmentTypeIncompatibility>,
2641 {
2642 use std::iter::Iterator;
2643 self.shipment_type_incompatibilities = v.into_iter().map(|i| i.into()).collect();
2644 self
2645 }
2646
2647 /// Sets the value of [shipment_type_requirements][crate::model::ShipmentModel::shipment_type_requirements].
2648 ///
2649 /// # Example
2650 /// ```ignore,no_run
2651 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2652 /// use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
2653 /// let x = ShipmentModel::new()
2654 /// .set_shipment_type_requirements([
2655 /// ShipmentTypeRequirement::default()/* use setters */,
2656 /// ShipmentTypeRequirement::default()/* use (different) setters */,
2657 /// ]);
2658 /// ```
2659 pub fn set_shipment_type_requirements<T, V>(mut self, v: T) -> Self
2660 where
2661 T: std::iter::IntoIterator<Item = V>,
2662 V: std::convert::Into<crate::model::ShipmentTypeRequirement>,
2663 {
2664 use std::iter::Iterator;
2665 self.shipment_type_requirements = v.into_iter().map(|i| i.into()).collect();
2666 self
2667 }
2668
2669 /// Sets the value of [precedence_rules][crate::model::ShipmentModel::precedence_rules].
2670 ///
2671 /// # Example
2672 /// ```ignore,no_run
2673 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2674 /// use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2675 /// let x = ShipmentModel::new()
2676 /// .set_precedence_rules([
2677 /// PrecedenceRule::default()/* use setters */,
2678 /// PrecedenceRule::default()/* use (different) setters */,
2679 /// ]);
2680 /// ```
2681 pub fn set_precedence_rules<T, V>(mut self, v: T) -> Self
2682 where
2683 T: std::iter::IntoIterator<Item = V>,
2684 V: std::convert::Into<crate::model::shipment_model::PrecedenceRule>,
2685 {
2686 use std::iter::Iterator;
2687 self.precedence_rules = v.into_iter().map(|i| i.into()).collect();
2688 self
2689 }
2690
2691 /// Sets the value of [break_rules][crate::model::ShipmentModel::break_rules].
2692 ///
2693 /// # Example
2694 /// ```ignore,no_run
2695 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2696 /// use google_cloud_optimization_v1::model::shipment_model::BreakRule;
2697 /// let x = ShipmentModel::new()
2698 /// .set_break_rules([
2699 /// BreakRule::default()/* use setters */,
2700 /// BreakRule::default()/* use (different) setters */,
2701 /// ]);
2702 /// ```
2703 #[deprecated]
2704 pub fn set_break_rules<T, V>(mut self, v: T) -> Self
2705 where
2706 T: std::iter::IntoIterator<Item = V>,
2707 V: std::convert::Into<crate::model::shipment_model::BreakRule>,
2708 {
2709 use std::iter::Iterator;
2710 self.break_rules = v.into_iter().map(|i| i.into()).collect();
2711 self
2712 }
2713}
2714
2715impl wkt::message::Message for ShipmentModel {
2716 fn typename() -> &'static str {
2717 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel"
2718 }
2719}
2720
2721/// Defines additional types related to [ShipmentModel].
2722pub mod shipment_model {
2723 #[allow(unused_imports)]
2724 use super::*;
2725
2726 /// Specifies a duration and distance matrix from visit and vehicle start
2727 /// locations to visit and vehicle end locations.
2728 #[derive(Clone, Default, PartialEq)]
2729 #[non_exhaustive]
2730 pub struct DurationDistanceMatrix {
2731 /// Specifies the rows of the duration and distance matrix. It must have as
2732 /// many elements as
2733 /// [ShipmentModel.duration_distance_matrix_src_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags].
2734 ///
2735 /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags]: crate::model::ShipmentModel::duration_distance_matrix_src_tags
2736 pub rows: std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>,
2737
2738 /// Tag defining to which vehicles this duration and distance matrix applies.
2739 /// If empty, this applies to all vehicles, and there can only be a single
2740 /// matrix.
2741 ///
2742 /// Each vehicle start must match exactly one matrix, i.e. exactly one of
2743 /// their `start_tags` field must match the `vehicle_start_tag` of a matrix
2744 /// (and of that matrix only).
2745 ///
2746 /// All matrices must have a different `vehicle_start_tag`.
2747 pub vehicle_start_tag: std::string::String,
2748
2749 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2750 }
2751
2752 impl DurationDistanceMatrix {
2753 /// Creates a new default instance.
2754 pub fn new() -> Self {
2755 std::default::Default::default()
2756 }
2757
2758 /// Sets the value of [rows][crate::model::shipment_model::DurationDistanceMatrix::rows].
2759 ///
2760 /// # Example
2761 /// ```ignore,no_run
2762 /// # use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2763 /// use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2764 /// let x = DurationDistanceMatrix::new()
2765 /// .set_rows([
2766 /// Row::default()/* use setters */,
2767 /// Row::default()/* use (different) setters */,
2768 /// ]);
2769 /// ```
2770 pub fn set_rows<T, V>(mut self, v: T) -> Self
2771 where
2772 T: std::iter::IntoIterator<Item = V>,
2773 V: std::convert::Into<crate::model::shipment_model::duration_distance_matrix::Row>,
2774 {
2775 use std::iter::Iterator;
2776 self.rows = v.into_iter().map(|i| i.into()).collect();
2777 self
2778 }
2779
2780 /// Sets the value of [vehicle_start_tag][crate::model::shipment_model::DurationDistanceMatrix::vehicle_start_tag].
2781 ///
2782 /// # Example
2783 /// ```ignore,no_run
2784 /// # use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2785 /// let x = DurationDistanceMatrix::new().set_vehicle_start_tag("example");
2786 /// ```
2787 pub fn set_vehicle_start_tag<T: std::convert::Into<std::string::String>>(
2788 mut self,
2789 v: T,
2790 ) -> Self {
2791 self.vehicle_start_tag = v.into();
2792 self
2793 }
2794 }
2795
2796 impl wkt::message::Message for DurationDistanceMatrix {
2797 fn typename() -> &'static str {
2798 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix"
2799 }
2800 }
2801
2802 /// Defines additional types related to [DurationDistanceMatrix].
2803 pub mod duration_distance_matrix {
2804 #[allow(unused_imports)]
2805 use super::*;
2806
2807 /// Specifies a row of the duration and distance matrix.
2808 #[derive(Clone, Default, PartialEq)]
2809 #[non_exhaustive]
2810 pub struct Row {
2811 /// Duration values for a given row. It must have as many elements as
2812 /// [ShipmentModel.duration_distance_matrix_dst_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags].
2813 ///
2814 /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags]: crate::model::ShipmentModel::duration_distance_matrix_dst_tags
2815 pub durations: std::vec::Vec<wkt::Duration>,
2816
2817 /// Distance values for a given row. If no costs or constraints refer to
2818 /// distances in the model, this can be left empty; otherwise it must have
2819 /// as many elements as `durations`.
2820 pub meters: std::vec::Vec<f64>,
2821
2822 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2823 }
2824
2825 impl Row {
2826 /// Creates a new default instance.
2827 pub fn new() -> Self {
2828 std::default::Default::default()
2829 }
2830
2831 /// Sets the value of [durations][crate::model::shipment_model::duration_distance_matrix::Row::durations].
2832 ///
2833 /// # Example
2834 /// ```ignore,no_run
2835 /// # use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2836 /// use wkt::Duration;
2837 /// let x = Row::new()
2838 /// .set_durations([
2839 /// Duration::default()/* use setters */,
2840 /// Duration::default()/* use (different) setters */,
2841 /// ]);
2842 /// ```
2843 pub fn set_durations<T, V>(mut self, v: T) -> Self
2844 where
2845 T: std::iter::IntoIterator<Item = V>,
2846 V: std::convert::Into<wkt::Duration>,
2847 {
2848 use std::iter::Iterator;
2849 self.durations = v.into_iter().map(|i| i.into()).collect();
2850 self
2851 }
2852
2853 /// Sets the value of [meters][crate::model::shipment_model::duration_distance_matrix::Row::meters].
2854 ///
2855 /// # Example
2856 /// ```ignore,no_run
2857 /// # use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2858 /// let x = Row::new().set_meters([1.0, 2.0, 3.0]);
2859 /// ```
2860 pub fn set_meters<T, V>(mut self, v: T) -> Self
2861 where
2862 T: std::iter::IntoIterator<Item = V>,
2863 V: std::convert::Into<f64>,
2864 {
2865 use std::iter::Iterator;
2866 self.meters = v.into_iter().map(|i| i.into()).collect();
2867 self
2868 }
2869 }
2870
2871 impl wkt::message::Message for Row {
2872 fn typename() -> &'static str {
2873 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix.Row"
2874 }
2875 }
2876 }
2877
2878 /// A precedence rule between two events (each event is the pickup or the
2879 /// delivery of a shipment): the "second" event has to start at least
2880 /// `offset_duration` after "first" has started.
2881 ///
2882 /// Several precedences can refer to the same (or related) events, e.g.,
2883 /// "pickup of B happens after delivery of A" and "pickup of C happens after
2884 /// pickup of B".
2885 ///
2886 /// Furthermore, precedences only apply when both shipments are performed and
2887 /// are otherwise ignored.
2888 #[derive(Clone, Default, PartialEq)]
2889 #[non_exhaustive]
2890 pub struct PrecedenceRule {
2891 /// Shipment index of the "first" event. This field must be specified.
2892 pub first_index: std::option::Option<i32>,
2893
2894 /// Indicates if the "first" event is a delivery.
2895 pub first_is_delivery: bool,
2896
2897 /// Shipment index of the "second" event. This field must be specified.
2898 pub second_index: std::option::Option<i32>,
2899
2900 /// Indicates if the "second" event is a delivery.
2901 pub second_is_delivery: bool,
2902
2903 /// The offset between the "first" and "second" event. It can be negative.
2904 pub offset_duration: std::option::Option<wkt::Duration>,
2905
2906 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2907 }
2908
2909 impl PrecedenceRule {
2910 /// Creates a new default instance.
2911 pub fn new() -> Self {
2912 std::default::Default::default()
2913 }
2914
2915 /// Sets the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2916 ///
2917 /// # Example
2918 /// ```ignore,no_run
2919 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2920 /// let x = PrecedenceRule::new().set_first_index(42);
2921 /// ```
2922 pub fn set_first_index<T>(mut self, v: T) -> Self
2923 where
2924 T: std::convert::Into<i32>,
2925 {
2926 self.first_index = std::option::Option::Some(v.into());
2927 self
2928 }
2929
2930 /// Sets or clears the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2931 ///
2932 /// # Example
2933 /// ```ignore,no_run
2934 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2935 /// let x = PrecedenceRule::new().set_or_clear_first_index(Some(42));
2936 /// let x = PrecedenceRule::new().set_or_clear_first_index(None::<i32>);
2937 /// ```
2938 pub fn set_or_clear_first_index<T>(mut self, v: std::option::Option<T>) -> Self
2939 where
2940 T: std::convert::Into<i32>,
2941 {
2942 self.first_index = v.map(|x| x.into());
2943 self
2944 }
2945
2946 /// Sets the value of [first_is_delivery][crate::model::shipment_model::PrecedenceRule::first_is_delivery].
2947 ///
2948 /// # Example
2949 /// ```ignore,no_run
2950 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2951 /// let x = PrecedenceRule::new().set_first_is_delivery(true);
2952 /// ```
2953 pub fn set_first_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2954 self.first_is_delivery = v.into();
2955 self
2956 }
2957
2958 /// Sets the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2959 ///
2960 /// # Example
2961 /// ```ignore,no_run
2962 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2963 /// let x = PrecedenceRule::new().set_second_index(42);
2964 /// ```
2965 pub fn set_second_index<T>(mut self, v: T) -> Self
2966 where
2967 T: std::convert::Into<i32>,
2968 {
2969 self.second_index = std::option::Option::Some(v.into());
2970 self
2971 }
2972
2973 /// Sets or clears the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2974 ///
2975 /// # Example
2976 /// ```ignore,no_run
2977 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2978 /// let x = PrecedenceRule::new().set_or_clear_second_index(Some(42));
2979 /// let x = PrecedenceRule::new().set_or_clear_second_index(None::<i32>);
2980 /// ```
2981 pub fn set_or_clear_second_index<T>(mut self, v: std::option::Option<T>) -> Self
2982 where
2983 T: std::convert::Into<i32>,
2984 {
2985 self.second_index = v.map(|x| x.into());
2986 self
2987 }
2988
2989 /// Sets the value of [second_is_delivery][crate::model::shipment_model::PrecedenceRule::second_is_delivery].
2990 ///
2991 /// # Example
2992 /// ```ignore,no_run
2993 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2994 /// let x = PrecedenceRule::new().set_second_is_delivery(true);
2995 /// ```
2996 pub fn set_second_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2997 self.second_is_delivery = v.into();
2998 self
2999 }
3000
3001 /// Sets the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
3002 ///
3003 /// # Example
3004 /// ```ignore,no_run
3005 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
3006 /// use wkt::Duration;
3007 /// let x = PrecedenceRule::new().set_offset_duration(Duration::default()/* use setters */);
3008 /// ```
3009 pub fn set_offset_duration<T>(mut self, v: T) -> Self
3010 where
3011 T: std::convert::Into<wkt::Duration>,
3012 {
3013 self.offset_duration = std::option::Option::Some(v.into());
3014 self
3015 }
3016
3017 /// Sets or clears the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
3018 ///
3019 /// # Example
3020 /// ```ignore,no_run
3021 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
3022 /// use wkt::Duration;
3023 /// let x = PrecedenceRule::new().set_or_clear_offset_duration(Some(Duration::default()/* use setters */));
3024 /// let x = PrecedenceRule::new().set_or_clear_offset_duration(None::<Duration>);
3025 /// ```
3026 pub fn set_or_clear_offset_duration<T>(mut self, v: std::option::Option<T>) -> Self
3027 where
3028 T: std::convert::Into<wkt::Duration>,
3029 {
3030 self.offset_duration = v.map(|x| x.into());
3031 self
3032 }
3033 }
3034
3035 impl wkt::message::Message for PrecedenceRule {
3036 fn typename() -> &'static str {
3037 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.PrecedenceRule"
3038 }
3039 }
3040
3041 /// Deprecated: Use top level
3042 /// [BreakRule][google.cloud.optimization.v1.ShipmentModel.BreakRule] instead.
3043 /// Rules to generate time breaks for a vehicle (e.g. lunch
3044 /// breaks). A break is a contiguous period of time during which the vehicle
3045 /// remains idle at its current position and cannot perform any visit. A break
3046 /// may occur:
3047 ///
3048 /// * during the travel between two visits (which includes the time right
3049 /// before or right after a visit, but not in the middle of a visit), in
3050 /// which case it extends the corresponding transit time between the visits
3051 /// * before the vehicle start (the vehicle may not start in the middle of
3052 /// a break), in which case it does not affect the vehicle start time.
3053 /// * after the vehicle end (ditto, with the vehicle end time).
3054 ///
3055 /// [google.cloud.optimization.v1.ShipmentModel.BreakRule]: crate::model::shipment_model::BreakRule
3056 #[derive(Clone, Default, PartialEq)]
3057 #[non_exhaustive]
3058 #[deprecated]
3059 pub struct BreakRule {
3060 /// Sequence of breaks. See the `BreakRequest` message.
3061 pub break_requests: std::vec::Vec<crate::model::shipment_model::break_rule::BreakRequest>,
3062
3063 /// Several `FrequencyConstraint` may apply. They must all be satisfied by
3064 /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
3065 pub frequency_constraints:
3066 std::vec::Vec<crate::model::shipment_model::break_rule::FrequencyConstraint>,
3067
3068 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3069 }
3070
3071 impl BreakRule {
3072 /// Creates a new default instance.
3073 pub fn new() -> Self {
3074 std::default::Default::default()
3075 }
3076
3077 /// Sets the value of [break_requests][crate::model::shipment_model::BreakRule::break_requests].
3078 ///
3079 /// # Example
3080 /// ```ignore,no_run
3081 /// # use google_cloud_optimization_v1::model::shipment_model::BreakRule;
3082 /// use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3083 /// let x = BreakRule::new()
3084 /// .set_break_requests([
3085 /// BreakRequest::default()/* use setters */,
3086 /// BreakRequest::default()/* use (different) setters */,
3087 /// ]);
3088 /// ```
3089 pub fn set_break_requests<T, V>(mut self, v: T) -> Self
3090 where
3091 T: std::iter::IntoIterator<Item = V>,
3092 V: std::convert::Into<crate::model::shipment_model::break_rule::BreakRequest>,
3093 {
3094 use std::iter::Iterator;
3095 self.break_requests = v.into_iter().map(|i| i.into()).collect();
3096 self
3097 }
3098
3099 /// Sets the value of [frequency_constraints][crate::model::shipment_model::BreakRule::frequency_constraints].
3100 ///
3101 /// # Example
3102 /// ```ignore,no_run
3103 /// # use google_cloud_optimization_v1::model::shipment_model::BreakRule;
3104 /// use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3105 /// let x = BreakRule::new()
3106 /// .set_frequency_constraints([
3107 /// FrequencyConstraint::default()/* use setters */,
3108 /// FrequencyConstraint::default()/* use (different) setters */,
3109 /// ]);
3110 /// ```
3111 pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
3112 where
3113 T: std::iter::IntoIterator<Item = V>,
3114 V: std::convert::Into<crate::model::shipment_model::break_rule::FrequencyConstraint>,
3115 {
3116 use std::iter::Iterator;
3117 self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
3118 self
3119 }
3120 }
3121
3122 impl wkt::message::Message for BreakRule {
3123 fn typename() -> &'static str {
3124 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule"
3125 }
3126 }
3127
3128 /// Defines additional types related to [BreakRule].
3129 pub mod break_rule {
3130 #[allow(unused_imports)]
3131 use super::*;
3132
3133 /// The sequence of breaks (i.e. their number and order) that apply to each
3134 /// vehicle must be known beforehand. The repeated `BreakRequest`s define
3135 /// that sequence, in the order in which they must occur. Their time windows
3136 /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
3137 /// be compatible with the order (this is checked).
3138 #[derive(Clone, Default, PartialEq)]
3139 #[non_exhaustive]
3140 pub struct BreakRequest {
3141 /// Required. Lower bound (inclusive) on the start of the break.
3142 pub earliest_start_time: std::option::Option<wkt::Timestamp>,
3143
3144 /// Required. Upper bound (inclusive) on the start of the break.
3145 pub latest_start_time: std::option::Option<wkt::Timestamp>,
3146
3147 /// Required. Minimum duration of the break. Must be positive.
3148 pub min_duration: std::option::Option<wkt::Duration>,
3149
3150 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3151 }
3152
3153 impl BreakRequest {
3154 /// Creates a new default instance.
3155 pub fn new() -> Self {
3156 std::default::Default::default()
3157 }
3158
3159 /// Sets the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
3160 ///
3161 /// # Example
3162 /// ```ignore,no_run
3163 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3164 /// use wkt::Timestamp;
3165 /// let x = BreakRequest::new().set_earliest_start_time(Timestamp::default()/* use setters */);
3166 /// ```
3167 pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
3168 where
3169 T: std::convert::Into<wkt::Timestamp>,
3170 {
3171 self.earliest_start_time = std::option::Option::Some(v.into());
3172 self
3173 }
3174
3175 /// Sets or clears the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
3176 ///
3177 /// # Example
3178 /// ```ignore,no_run
3179 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3180 /// use wkt::Timestamp;
3181 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(Some(Timestamp::default()/* use setters */));
3182 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(None::<Timestamp>);
3183 /// ```
3184 pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3185 where
3186 T: std::convert::Into<wkt::Timestamp>,
3187 {
3188 self.earliest_start_time = v.map(|x| x.into());
3189 self
3190 }
3191
3192 /// Sets the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
3193 ///
3194 /// # Example
3195 /// ```ignore,no_run
3196 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3197 /// use wkt::Timestamp;
3198 /// let x = BreakRequest::new().set_latest_start_time(Timestamp::default()/* use setters */);
3199 /// ```
3200 pub fn set_latest_start_time<T>(mut self, v: T) -> Self
3201 where
3202 T: std::convert::Into<wkt::Timestamp>,
3203 {
3204 self.latest_start_time = std::option::Option::Some(v.into());
3205 self
3206 }
3207
3208 /// Sets or clears the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
3209 ///
3210 /// # Example
3211 /// ```ignore,no_run
3212 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3213 /// use wkt::Timestamp;
3214 /// let x = BreakRequest::new().set_or_clear_latest_start_time(Some(Timestamp::default()/* use setters */));
3215 /// let x = BreakRequest::new().set_or_clear_latest_start_time(None::<Timestamp>);
3216 /// ```
3217 pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3218 where
3219 T: std::convert::Into<wkt::Timestamp>,
3220 {
3221 self.latest_start_time = v.map(|x| x.into());
3222 self
3223 }
3224
3225 /// Sets the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
3226 ///
3227 /// # Example
3228 /// ```ignore,no_run
3229 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3230 /// use wkt::Duration;
3231 /// let x = BreakRequest::new().set_min_duration(Duration::default()/* use setters */);
3232 /// ```
3233 pub fn set_min_duration<T>(mut self, v: T) -> Self
3234 where
3235 T: std::convert::Into<wkt::Duration>,
3236 {
3237 self.min_duration = std::option::Option::Some(v.into());
3238 self
3239 }
3240
3241 /// Sets or clears the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
3242 ///
3243 /// # Example
3244 /// ```ignore,no_run
3245 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3246 /// use wkt::Duration;
3247 /// let x = BreakRequest::new().set_or_clear_min_duration(Some(Duration::default()/* use setters */));
3248 /// let x = BreakRequest::new().set_or_clear_min_duration(None::<Duration>);
3249 /// ```
3250 pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
3251 where
3252 T: std::convert::Into<wkt::Duration>,
3253 {
3254 self.min_duration = v.map(|x| x.into());
3255 self
3256 }
3257 }
3258
3259 impl wkt::message::Message for BreakRequest {
3260 fn typename() -> &'static str {
3261 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.BreakRequest"
3262 }
3263 }
3264
3265 /// One may further constrain the frequency and duration of the breaks
3266 /// specified above, by enforcing a minimum break frequency, such as
3267 /// "There must be a break of at least 1 hour every 12 hours". Assuming that
3268 /// this can be interpreted as "Within any sliding time window of 12h, there
3269 /// must be at least one break of at least one hour", that example would
3270 /// translate to the following `FrequencyConstraint`:
3271 ///
3272 /// ```norust
3273 /// {
3274 /// min_break_duration { seconds: 3600 } # 1 hour.
3275 /// max_inter_break_duration { seconds: 39600 } # 11 hours (12 - 1 = 11).
3276 /// }
3277 /// ```
3278 ///
3279 /// The timing and duration of the breaks in the solution will respect all
3280 /// such constraints, in addition to the time windows and minimum durations
3281 /// already specified in the `BreakRequest`.
3282 ///
3283 /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
3284 /// For example, the following schedule honors the "1h every 12h" example:
3285 ///
3286 /// ```norust
3287 /// 04:00 vehicle start
3288 /// .. performing travel and visits ..
3289 /// 09:00 1 hour break
3290 /// 10:00 end of the break
3291 /// .. performing travel and visits ..
3292 /// 12:00 20-min lunch break
3293 /// 12:20 end of the break
3294 /// .. performing travel and visits ..
3295 /// 21:00 1 hour break
3296 /// 22:00 end of the break
3297 /// .. performing travel and visits ..
3298 /// 23:59 vehicle end
3299 /// ```
3300 #[derive(Clone, Default, PartialEq)]
3301 #[non_exhaustive]
3302 pub struct FrequencyConstraint {
3303 /// Required. Minimum break duration for this constraint. Nonnegative.
3304 /// See description of `FrequencyConstraint`.
3305 pub min_break_duration: std::option::Option<wkt::Duration>,
3306
3307 /// Required. Maximum allowed span of any interval of time in the route
3308 /// that does not include at least partially a break of `duration >=
3309 /// min_break_duration`. Must be positive.
3310 pub max_inter_break_duration: std::option::Option<wkt::Duration>,
3311
3312 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3313 }
3314
3315 impl FrequencyConstraint {
3316 /// Creates a new default instance.
3317 pub fn new() -> Self {
3318 std::default::Default::default()
3319 }
3320
3321 /// Sets the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
3322 ///
3323 /// # Example
3324 /// ```ignore,no_run
3325 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3326 /// use wkt::Duration;
3327 /// let x = FrequencyConstraint::new().set_min_break_duration(Duration::default()/* use setters */);
3328 /// ```
3329 pub fn set_min_break_duration<T>(mut self, v: T) -> Self
3330 where
3331 T: std::convert::Into<wkt::Duration>,
3332 {
3333 self.min_break_duration = std::option::Option::Some(v.into());
3334 self
3335 }
3336
3337 /// Sets or clears the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
3338 ///
3339 /// # Example
3340 /// ```ignore,no_run
3341 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3342 /// use wkt::Duration;
3343 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(Some(Duration::default()/* use setters */));
3344 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(None::<Duration>);
3345 /// ```
3346 pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
3347 where
3348 T: std::convert::Into<wkt::Duration>,
3349 {
3350 self.min_break_duration = v.map(|x| x.into());
3351 self
3352 }
3353
3354 /// Sets the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
3355 ///
3356 /// # Example
3357 /// ```ignore,no_run
3358 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3359 /// use wkt::Duration;
3360 /// let x = FrequencyConstraint::new().set_max_inter_break_duration(Duration::default()/* use setters */);
3361 /// ```
3362 pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
3363 where
3364 T: std::convert::Into<wkt::Duration>,
3365 {
3366 self.max_inter_break_duration = std::option::Option::Some(v.into());
3367 self
3368 }
3369
3370 /// Sets or clears the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
3371 ///
3372 /// # Example
3373 /// ```ignore,no_run
3374 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3375 /// use wkt::Duration;
3376 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(Some(Duration::default()/* use setters */));
3377 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(None::<Duration>);
3378 /// ```
3379 pub fn set_or_clear_max_inter_break_duration<T>(
3380 mut self,
3381 v: std::option::Option<T>,
3382 ) -> Self
3383 where
3384 T: std::convert::Into<wkt::Duration>,
3385 {
3386 self.max_inter_break_duration = v.map(|x| x.into());
3387 self
3388 }
3389 }
3390
3391 impl wkt::message::Message for FrequencyConstraint {
3392 fn typename() -> &'static str {
3393 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.FrequencyConstraint"
3394 }
3395 }
3396 }
3397}
3398
3399/// The shipment of a single item, from one of its pickups to one of its
3400/// deliveries. For the shipment to be considered as performed, a unique vehicle
3401/// must visit one of its pickup locations (and decrease its spare capacities
3402/// accordingly), then visit one of its delivery locations later on (and
3403/// therefore re-increase its spare capacities accordingly).
3404#[derive(Clone, Default, PartialEq)]
3405#[non_exhaustive]
3406pub struct Shipment {
3407 /// Set of pickup alternatives associated to the shipment. If not specified,
3408 /// the vehicle only needs to visit a location corresponding to the deliveries.
3409 pub pickups: std::vec::Vec<crate::model::shipment::VisitRequest>,
3410
3411 /// Set of delivery alternatives associated to the shipment. If not specified,
3412 /// the vehicle only needs to visit a location corresponding to the pickups.
3413 pub deliveries: std::vec::Vec<crate::model::shipment::VisitRequest>,
3414
3415 /// Load demands of the shipment (for example weight, volume, number of
3416 /// pallets etc). The keys in the map should be identifiers describing the type
3417 /// of the corresponding load, ideally also including the units.
3418 /// For example: "weight_kg", "volume_gallons", "pallet_count", etc.
3419 /// If a given key does not appear in the map, the corresponding load is
3420 /// considered as null.
3421 pub load_demands: std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
3422
3423 /// If the shipment is not completed, this penalty is added to the overall
3424 /// cost of the routes. A shipment is considered completed if one of its pickup
3425 /// and delivery alternatives is visited. The cost may be expressed in the
3426 /// same unit used for all other cost-related fields in the model and must be
3427 /// positive.
3428 ///
3429 /// *IMPORTANT*: If this penalty is not specified, it is considered infinite,
3430 /// i.e. the shipment must be completed.
3431 pub penalty_cost: std::option::Option<f64>,
3432
3433 /// The set of vehicles that may perform this shipment. If empty, all vehicles
3434 /// may perform it. Vehicles are given by their index in the `ShipmentModel`'s
3435 /// `vehicles` list.
3436 pub allowed_vehicle_indices: std::vec::Vec<i32>,
3437
3438 /// Specifies the cost that is incurred when this shipment is delivered by each
3439 /// vehicle. If specified, it must have EITHER:
3440 ///
3441 /// * the same number of elements as `costs_per_vehicle_indices`.
3442 /// `costs_per_vehicle[i]` corresponds to vehicle
3443 /// `costs_per_vehicle_indices[i]` of the model.
3444 /// * the same number of elements as there are vehicles in the model. The
3445 /// i-th element corresponds to vehicle #i of the model.
3446 ///
3447 /// These costs must be in the same unit as `penalty_cost` and must not be
3448 /// negative. Leave this field empty, if there are no such costs.
3449 pub costs_per_vehicle: std::vec::Vec<f64>,
3450
3451 /// Indices of the vehicles to which `costs_per_vehicle` applies. If non-empty,
3452 /// it must have the same number of elements as `costs_per_vehicle`. A vehicle
3453 /// index may not be specified more than once. If a vehicle is excluded from
3454 /// `costs_per_vehicle_indices`, its cost is zero.
3455 pub costs_per_vehicle_indices: std::vec::Vec<i32>,
3456
3457 /// Specifies the maximum relative detour time compared to the shortest path
3458 /// from pickup to delivery. If specified, it must be nonnegative, and the
3459 /// shipment must contain at least a pickup and a delivery.
3460 ///
3461 /// For example, let t be the shortest time taken to go from the selected
3462 /// pickup alternative directly to the selected delivery alternative. Then
3463 /// setting `pickup_to_delivery_relative_detour_limit` enforces:
3464 ///
3465 /// ```norust
3466 /// start_time(delivery) - start_time(pickup) <=
3467 /// std::ceil(t * (1.0 + pickup_to_delivery_relative_detour_limit))
3468 /// ```
3469 ///
3470 /// If both relative and absolute limits are specified on the same shipment,
3471 /// the more constraining limit is used for each possible pickup/delivery pair.
3472 /// As of 2017/10, detours are only supported when travel durations do not
3473 /// depend on vehicles.
3474 pub pickup_to_delivery_relative_detour_limit: std::option::Option<f64>,
3475
3476 /// Specifies the maximum absolute detour time compared to the shortest path
3477 /// from pickup to delivery. If specified, it must be nonnegative, and the
3478 /// shipment must contain at least a pickup and a delivery.
3479 ///
3480 /// For example, let t be the shortest time taken to go from the selected
3481 /// pickup alternative directly to the selected delivery alternative. Then
3482 /// setting `pickup_to_delivery_absolute_detour_limit` enforces:
3483 ///
3484 /// ```norust
3485 /// start_time(delivery) - start_time(pickup) <=
3486 /// t + pickup_to_delivery_absolute_detour_limit
3487 /// ```
3488 ///
3489 /// If both relative and absolute limits are specified on the same shipment,
3490 /// the more constraining limit is used for each possible pickup/delivery pair.
3491 /// As of 2017/10, detours are only supported when travel durations do not
3492 /// depend on vehicles.
3493 pub pickup_to_delivery_absolute_detour_limit: std::option::Option<wkt::Duration>,
3494
3495 /// Specifies the maximum duration from start of pickup to start of delivery of
3496 /// a shipment. If specified, it must be nonnegative, and the shipment must
3497 /// contain at least a pickup and a delivery. This does not depend on which
3498 /// alternatives are selected for pickup and delivery, nor on vehicle speed.
3499 /// This can be specified alongside maximum detour constraints: the solution
3500 /// will respect both specifications.
3501 pub pickup_to_delivery_time_limit: std::option::Option<wkt::Duration>,
3502
3503 /// Non-empty string specifying a "type" for this shipment.
3504 /// This feature can be used to define incompatibilities or requirements
3505 /// between `shipment_types` (see `shipment_type_incompatibilities` and
3506 /// `shipment_type_requirements` in `ShipmentModel`).
3507 ///
3508 /// Differs from `visit_types` which is specified for a single visit: All
3509 /// pickup/deliveries belonging to the same shipment share the same
3510 /// `shipment_type`.
3511 pub shipment_type: std::string::String,
3512
3513 /// Specifies a label for this shipment. This label is reported in the response
3514 /// in the `shipment_label` of the corresponding
3515 /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
3516 ///
3517 /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
3518 pub label: std::string::String,
3519
3520 /// If true, skip this shipment, but don't apply a `penalty_cost`.
3521 ///
3522 /// Ignoring a shipment results in a validation error when there are any
3523 /// `shipment_type_requirements` in the model.
3524 ///
3525 /// Ignoring a shipment that is performed in `injected_first_solution_routes`
3526 /// or `injected_solution_constraint` is permitted; the solver removes the
3527 /// related pickup/delivery visits from the performing route.
3528 /// `precedence_rules` that reference ignored shipments will also be ignored.
3529 pub ignore: bool,
3530
3531 /// Deprecated: Use
3532 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
3533 /// instead.
3534 ///
3535 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3536 #[deprecated]
3537 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
3538
3539 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3540}
3541
3542impl Shipment {
3543 /// Creates a new default instance.
3544 pub fn new() -> Self {
3545 std::default::Default::default()
3546 }
3547
3548 /// Sets the value of [pickups][crate::model::Shipment::pickups].
3549 ///
3550 /// # Example
3551 /// ```ignore,no_run
3552 /// # use google_cloud_optimization_v1::model::Shipment;
3553 /// use google_cloud_optimization_v1::model::shipment::VisitRequest;
3554 /// let x = Shipment::new()
3555 /// .set_pickups([
3556 /// VisitRequest::default()/* use setters */,
3557 /// VisitRequest::default()/* use (different) setters */,
3558 /// ]);
3559 /// ```
3560 pub fn set_pickups<T, V>(mut self, v: T) -> Self
3561 where
3562 T: std::iter::IntoIterator<Item = V>,
3563 V: std::convert::Into<crate::model::shipment::VisitRequest>,
3564 {
3565 use std::iter::Iterator;
3566 self.pickups = v.into_iter().map(|i| i.into()).collect();
3567 self
3568 }
3569
3570 /// Sets the value of [deliveries][crate::model::Shipment::deliveries].
3571 ///
3572 /// # Example
3573 /// ```ignore,no_run
3574 /// # use google_cloud_optimization_v1::model::Shipment;
3575 /// use google_cloud_optimization_v1::model::shipment::VisitRequest;
3576 /// let x = Shipment::new()
3577 /// .set_deliveries([
3578 /// VisitRequest::default()/* use setters */,
3579 /// VisitRequest::default()/* use (different) setters */,
3580 /// ]);
3581 /// ```
3582 pub fn set_deliveries<T, V>(mut self, v: T) -> Self
3583 where
3584 T: std::iter::IntoIterator<Item = V>,
3585 V: std::convert::Into<crate::model::shipment::VisitRequest>,
3586 {
3587 use std::iter::Iterator;
3588 self.deliveries = v.into_iter().map(|i| i.into()).collect();
3589 self
3590 }
3591
3592 /// Sets the value of [load_demands][crate::model::Shipment::load_demands].
3593 ///
3594 /// # Example
3595 /// ```ignore,no_run
3596 /// # use google_cloud_optimization_v1::model::Shipment;
3597 /// use google_cloud_optimization_v1::model::shipment::Load;
3598 /// let x = Shipment::new().set_load_demands([
3599 /// ("key0", Load::default()/* use setters */),
3600 /// ("key1", Load::default()/* use (different) setters */),
3601 /// ]);
3602 /// ```
3603 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
3604 where
3605 T: std::iter::IntoIterator<Item = (K, V)>,
3606 K: std::convert::Into<std::string::String>,
3607 V: std::convert::Into<crate::model::shipment::Load>,
3608 {
3609 use std::iter::Iterator;
3610 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3611 self
3612 }
3613
3614 /// Sets the value of [penalty_cost][crate::model::Shipment::penalty_cost].
3615 ///
3616 /// # Example
3617 /// ```ignore,no_run
3618 /// # use google_cloud_optimization_v1::model::Shipment;
3619 /// let x = Shipment::new().set_penalty_cost(42.0);
3620 /// ```
3621 pub fn set_penalty_cost<T>(mut self, v: T) -> Self
3622 where
3623 T: std::convert::Into<f64>,
3624 {
3625 self.penalty_cost = std::option::Option::Some(v.into());
3626 self
3627 }
3628
3629 /// Sets or clears the value of [penalty_cost][crate::model::Shipment::penalty_cost].
3630 ///
3631 /// # Example
3632 /// ```ignore,no_run
3633 /// # use google_cloud_optimization_v1::model::Shipment;
3634 /// let x = Shipment::new().set_or_clear_penalty_cost(Some(42.0));
3635 /// let x = Shipment::new().set_or_clear_penalty_cost(None::<f32>);
3636 /// ```
3637 pub fn set_or_clear_penalty_cost<T>(mut self, v: std::option::Option<T>) -> Self
3638 where
3639 T: std::convert::Into<f64>,
3640 {
3641 self.penalty_cost = v.map(|x| x.into());
3642 self
3643 }
3644
3645 /// Sets the value of [allowed_vehicle_indices][crate::model::Shipment::allowed_vehicle_indices].
3646 ///
3647 /// # Example
3648 /// ```ignore,no_run
3649 /// # use google_cloud_optimization_v1::model::Shipment;
3650 /// let x = Shipment::new().set_allowed_vehicle_indices([1, 2, 3]);
3651 /// ```
3652 pub fn set_allowed_vehicle_indices<T, V>(mut self, v: T) -> Self
3653 where
3654 T: std::iter::IntoIterator<Item = V>,
3655 V: std::convert::Into<i32>,
3656 {
3657 use std::iter::Iterator;
3658 self.allowed_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
3659 self
3660 }
3661
3662 /// Sets the value of [costs_per_vehicle][crate::model::Shipment::costs_per_vehicle].
3663 ///
3664 /// # Example
3665 /// ```ignore,no_run
3666 /// # use google_cloud_optimization_v1::model::Shipment;
3667 /// let x = Shipment::new().set_costs_per_vehicle([1.0, 2.0, 3.0]);
3668 /// ```
3669 pub fn set_costs_per_vehicle<T, V>(mut self, v: T) -> Self
3670 where
3671 T: std::iter::IntoIterator<Item = V>,
3672 V: std::convert::Into<f64>,
3673 {
3674 use std::iter::Iterator;
3675 self.costs_per_vehicle = v.into_iter().map(|i| i.into()).collect();
3676 self
3677 }
3678
3679 /// Sets the value of [costs_per_vehicle_indices][crate::model::Shipment::costs_per_vehicle_indices].
3680 ///
3681 /// # Example
3682 /// ```ignore,no_run
3683 /// # use google_cloud_optimization_v1::model::Shipment;
3684 /// let x = Shipment::new().set_costs_per_vehicle_indices([1, 2, 3]);
3685 /// ```
3686 pub fn set_costs_per_vehicle_indices<T, V>(mut self, v: T) -> Self
3687 where
3688 T: std::iter::IntoIterator<Item = V>,
3689 V: std::convert::Into<i32>,
3690 {
3691 use std::iter::Iterator;
3692 self.costs_per_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
3693 self
3694 }
3695
3696 /// Sets the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
3697 ///
3698 /// # Example
3699 /// ```ignore,no_run
3700 /// # use google_cloud_optimization_v1::model::Shipment;
3701 /// let x = Shipment::new().set_pickup_to_delivery_relative_detour_limit(42.0);
3702 /// ```
3703 pub fn set_pickup_to_delivery_relative_detour_limit<T>(mut self, v: T) -> Self
3704 where
3705 T: std::convert::Into<f64>,
3706 {
3707 self.pickup_to_delivery_relative_detour_limit = std::option::Option::Some(v.into());
3708 self
3709 }
3710
3711 /// Sets or clears the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
3712 ///
3713 /// # Example
3714 /// ```ignore,no_run
3715 /// # use google_cloud_optimization_v1::model::Shipment;
3716 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_relative_detour_limit(Some(42.0));
3717 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_relative_detour_limit(None::<f32>);
3718 /// ```
3719 pub fn set_or_clear_pickup_to_delivery_relative_detour_limit<T>(
3720 mut self,
3721 v: std::option::Option<T>,
3722 ) -> Self
3723 where
3724 T: std::convert::Into<f64>,
3725 {
3726 self.pickup_to_delivery_relative_detour_limit = v.map(|x| x.into());
3727 self
3728 }
3729
3730 /// Sets the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
3731 ///
3732 /// # Example
3733 /// ```ignore,no_run
3734 /// # use google_cloud_optimization_v1::model::Shipment;
3735 /// use wkt::Duration;
3736 /// let x = Shipment::new().set_pickup_to_delivery_absolute_detour_limit(Duration::default()/* use setters */);
3737 /// ```
3738 pub fn set_pickup_to_delivery_absolute_detour_limit<T>(mut self, v: T) -> Self
3739 where
3740 T: std::convert::Into<wkt::Duration>,
3741 {
3742 self.pickup_to_delivery_absolute_detour_limit = std::option::Option::Some(v.into());
3743 self
3744 }
3745
3746 /// Sets or clears the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
3747 ///
3748 /// # Example
3749 /// ```ignore,no_run
3750 /// # use google_cloud_optimization_v1::model::Shipment;
3751 /// use wkt::Duration;
3752 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_absolute_detour_limit(Some(Duration::default()/* use setters */));
3753 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_absolute_detour_limit(None::<Duration>);
3754 /// ```
3755 pub fn set_or_clear_pickup_to_delivery_absolute_detour_limit<T>(
3756 mut self,
3757 v: std::option::Option<T>,
3758 ) -> Self
3759 where
3760 T: std::convert::Into<wkt::Duration>,
3761 {
3762 self.pickup_to_delivery_absolute_detour_limit = v.map(|x| x.into());
3763 self
3764 }
3765
3766 /// Sets the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
3767 ///
3768 /// # Example
3769 /// ```ignore,no_run
3770 /// # use google_cloud_optimization_v1::model::Shipment;
3771 /// use wkt::Duration;
3772 /// let x = Shipment::new().set_pickup_to_delivery_time_limit(Duration::default()/* use setters */);
3773 /// ```
3774 pub fn set_pickup_to_delivery_time_limit<T>(mut self, v: T) -> Self
3775 where
3776 T: std::convert::Into<wkt::Duration>,
3777 {
3778 self.pickup_to_delivery_time_limit = std::option::Option::Some(v.into());
3779 self
3780 }
3781
3782 /// Sets or clears the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
3783 ///
3784 /// # Example
3785 /// ```ignore,no_run
3786 /// # use google_cloud_optimization_v1::model::Shipment;
3787 /// use wkt::Duration;
3788 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_time_limit(Some(Duration::default()/* use setters */));
3789 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_time_limit(None::<Duration>);
3790 /// ```
3791 pub fn set_or_clear_pickup_to_delivery_time_limit<T>(
3792 mut self,
3793 v: std::option::Option<T>,
3794 ) -> Self
3795 where
3796 T: std::convert::Into<wkt::Duration>,
3797 {
3798 self.pickup_to_delivery_time_limit = v.map(|x| x.into());
3799 self
3800 }
3801
3802 /// Sets the value of [shipment_type][crate::model::Shipment::shipment_type].
3803 ///
3804 /// # Example
3805 /// ```ignore,no_run
3806 /// # use google_cloud_optimization_v1::model::Shipment;
3807 /// let x = Shipment::new().set_shipment_type("example");
3808 /// ```
3809 pub fn set_shipment_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3810 self.shipment_type = v.into();
3811 self
3812 }
3813
3814 /// Sets the value of [label][crate::model::Shipment::label].
3815 ///
3816 /// # Example
3817 /// ```ignore,no_run
3818 /// # use google_cloud_optimization_v1::model::Shipment;
3819 /// let x = Shipment::new().set_label("example");
3820 /// ```
3821 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3822 self.label = v.into();
3823 self
3824 }
3825
3826 /// Sets the value of [ignore][crate::model::Shipment::ignore].
3827 ///
3828 /// # Example
3829 /// ```ignore,no_run
3830 /// # use google_cloud_optimization_v1::model::Shipment;
3831 /// let x = Shipment::new().set_ignore(true);
3832 /// ```
3833 pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3834 self.ignore = v.into();
3835 self
3836 }
3837
3838 /// Sets the value of [demands][crate::model::Shipment::demands].
3839 ///
3840 /// # Example
3841 /// ```ignore,no_run
3842 /// # use google_cloud_optimization_v1::model::Shipment;
3843 /// use google_cloud_optimization_v1::model::CapacityQuantity;
3844 /// let x = Shipment::new()
3845 /// .set_demands([
3846 /// CapacityQuantity::default()/* use setters */,
3847 /// CapacityQuantity::default()/* use (different) setters */,
3848 /// ]);
3849 /// ```
3850 #[deprecated]
3851 pub fn set_demands<T, V>(mut self, v: T) -> Self
3852 where
3853 T: std::iter::IntoIterator<Item = V>,
3854 V: std::convert::Into<crate::model::CapacityQuantity>,
3855 {
3856 use std::iter::Iterator;
3857 self.demands = v.into_iter().map(|i| i.into()).collect();
3858 self
3859 }
3860}
3861
3862impl wkt::message::Message for Shipment {
3863 fn typename() -> &'static str {
3864 "type.googleapis.com/google.cloud.optimization.v1.Shipment"
3865 }
3866}
3867
3868/// Defines additional types related to [Shipment].
3869pub mod shipment {
3870 #[allow(unused_imports)]
3871 use super::*;
3872
3873 /// Request for a visit which can be done by a vehicle: it has a geo-location
3874 /// (or two, see below), opening and closing times represented by time windows,
3875 /// and a service duration time (time spent by the vehicle once it has arrived
3876 /// to pickup or drop off goods).
3877 #[derive(Clone, Default, PartialEq)]
3878 #[non_exhaustive]
3879 pub struct VisitRequest {
3880 /// The geo-location where the vehicle arrives when performing this
3881 /// `VisitRequest`. If the shipment model has duration distance matrices,
3882 /// `arrival_location` must not be specified.
3883 pub arrival_location: std::option::Option<google_cloud_type::model::LatLng>,
3884
3885 /// The waypoint where the vehicle arrives when performing this
3886 /// `VisitRequest`. If the shipment model has duration distance matrices,
3887 /// `arrival_waypoint` must not be specified.
3888 pub arrival_waypoint: std::option::Option<crate::model::Waypoint>,
3889
3890 /// The geo-location where the vehicle departs after completing this
3891 /// `VisitRequest`. Can be omitted if it is the same as `arrival_location`.
3892 /// If the shipment model has duration distance matrices,
3893 /// `departure_location` must not be specified.
3894 pub departure_location: std::option::Option<google_cloud_type::model::LatLng>,
3895
3896 /// The waypoint where the vehicle departs after completing this
3897 /// `VisitRequest`. Can be omitted if it is the same as `arrival_waypoint`.
3898 /// If the shipment model has duration distance matrices,
3899 /// `departure_waypoint` must not be specified.
3900 pub departure_waypoint: std::option::Option<crate::model::Waypoint>,
3901
3902 /// Specifies tags attached to the visit request.
3903 /// Empty or duplicate strings are not allowed.
3904 pub tags: std::vec::Vec<std::string::String>,
3905
3906 /// Time windows which constrain the arrival time at a visit.
3907 /// Note that a vehicle may depart outside of the arrival time window, i.e.
3908 /// arrival time + duration do not need to be inside a time window. This can
3909 /// result in waiting time if the vehicle arrives before
3910 /// [TimeWindow.start_time][google.cloud.optimization.v1.TimeWindow.start_time].
3911 ///
3912 /// The absence of `TimeWindow` means that the vehicle can perform this visit
3913 /// at any time.
3914 ///
3915 /// Time windows must be disjoint, i.e. no time window must overlap with or
3916 /// be adjacent to another, and they must be in increasing order.
3917 ///
3918 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only
3919 /// be set if there is a single time window.
3920 ///
3921 /// [google.cloud.optimization.v1.TimeWindow.start_time]: crate::model::TimeWindow::start_time
3922 pub time_windows: std::vec::Vec<crate::model::TimeWindow>,
3923
3924 /// Duration of the visit, i.e. time spent by the vehicle between arrival
3925 /// and departure (to be added to the possible waiting time; see
3926 /// `time_windows`).
3927 pub duration: std::option::Option<wkt::Duration>,
3928
3929 /// Cost to service this visit request on a vehicle route. This can be used
3930 /// to pay different costs for each alternative pickup or delivery of a
3931 /// shipment. This cost must be in the same unit as `Shipment.penalty_cost`
3932 /// and must not be negative.
3933 pub cost: f64,
3934
3935 /// Load demands of this visit request. This is just like
3936 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
3937 /// field, except that it only applies to this
3938 /// [VisitRequest][google.cloud.optimization.v1.Shipment.VisitRequest]
3939 /// instead of the whole [Shipment][google.cloud.optimization.v1.Shipment].
3940 /// The demands listed here are added to the demands listed in
3941 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands].
3942 ///
3943 /// [google.cloud.optimization.v1.Shipment]: crate::model::Shipment
3944 /// [google.cloud.optimization.v1.Shipment.VisitRequest]: crate::model::shipment::VisitRequest
3945 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3946 pub load_demands:
3947 std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
3948
3949 /// Specifies the types of the visit. This may be used to allocate additional
3950 /// time required for a vehicle to complete this visit (see
3951 /// [Vehicle.extra_visit_duration_for_visit_type][google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]).
3952 ///
3953 /// A type can only appear once.
3954 ///
3955 /// [google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]: crate::model::Vehicle::extra_visit_duration_for_visit_type
3956 pub visit_types: std::vec::Vec<std::string::String>,
3957
3958 /// Specifies a label for this `VisitRequest`. This label is reported in the
3959 /// response as `visit_label` in the corresponding
3960 /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
3961 ///
3962 /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
3963 pub label: std::string::String,
3964
3965 /// Deprecated: Use
3966 /// [VisitRequest.load_demands][google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]
3967 /// instead.
3968 ///
3969 /// [google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]: crate::model::shipment::VisitRequest::load_demands
3970 #[deprecated]
3971 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
3972
3973 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3974 }
3975
3976 impl VisitRequest {
3977 /// Creates a new default instance.
3978 pub fn new() -> Self {
3979 std::default::Default::default()
3980 }
3981
3982 /// Sets the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3983 ///
3984 /// # Example
3985 /// ```ignore,no_run
3986 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
3987 /// use google_cloud_type::model::LatLng;
3988 /// let x = VisitRequest::new().set_arrival_location(LatLng::default()/* use setters */);
3989 /// ```
3990 pub fn set_arrival_location<T>(mut self, v: T) -> Self
3991 where
3992 T: std::convert::Into<google_cloud_type::model::LatLng>,
3993 {
3994 self.arrival_location = std::option::Option::Some(v.into());
3995 self
3996 }
3997
3998 /// Sets or clears the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3999 ///
4000 /// # Example
4001 /// ```ignore,no_run
4002 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4003 /// use google_cloud_type::model::LatLng;
4004 /// let x = VisitRequest::new().set_or_clear_arrival_location(Some(LatLng::default()/* use setters */));
4005 /// let x = VisitRequest::new().set_or_clear_arrival_location(None::<LatLng>);
4006 /// ```
4007 pub fn set_or_clear_arrival_location<T>(mut self, v: std::option::Option<T>) -> Self
4008 where
4009 T: std::convert::Into<google_cloud_type::model::LatLng>,
4010 {
4011 self.arrival_location = v.map(|x| x.into());
4012 self
4013 }
4014
4015 /// Sets the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
4016 ///
4017 /// # Example
4018 /// ```ignore,no_run
4019 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4020 /// use google_cloud_optimization_v1::model::Waypoint;
4021 /// let x = VisitRequest::new().set_arrival_waypoint(Waypoint::default()/* use setters */);
4022 /// ```
4023 pub fn set_arrival_waypoint<T>(mut self, v: T) -> Self
4024 where
4025 T: std::convert::Into<crate::model::Waypoint>,
4026 {
4027 self.arrival_waypoint = std::option::Option::Some(v.into());
4028 self
4029 }
4030
4031 /// Sets or clears the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
4032 ///
4033 /// # Example
4034 /// ```ignore,no_run
4035 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4036 /// use google_cloud_optimization_v1::model::Waypoint;
4037 /// let x = VisitRequest::new().set_or_clear_arrival_waypoint(Some(Waypoint::default()/* use setters */));
4038 /// let x = VisitRequest::new().set_or_clear_arrival_waypoint(None::<Waypoint>);
4039 /// ```
4040 pub fn set_or_clear_arrival_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4041 where
4042 T: std::convert::Into<crate::model::Waypoint>,
4043 {
4044 self.arrival_waypoint = v.map(|x| x.into());
4045 self
4046 }
4047
4048 /// Sets the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
4049 ///
4050 /// # Example
4051 /// ```ignore,no_run
4052 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4053 /// use google_cloud_type::model::LatLng;
4054 /// let x = VisitRequest::new().set_departure_location(LatLng::default()/* use setters */);
4055 /// ```
4056 pub fn set_departure_location<T>(mut self, v: T) -> Self
4057 where
4058 T: std::convert::Into<google_cloud_type::model::LatLng>,
4059 {
4060 self.departure_location = std::option::Option::Some(v.into());
4061 self
4062 }
4063
4064 /// Sets or clears the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
4065 ///
4066 /// # Example
4067 /// ```ignore,no_run
4068 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4069 /// use google_cloud_type::model::LatLng;
4070 /// let x = VisitRequest::new().set_or_clear_departure_location(Some(LatLng::default()/* use setters */));
4071 /// let x = VisitRequest::new().set_or_clear_departure_location(None::<LatLng>);
4072 /// ```
4073 pub fn set_or_clear_departure_location<T>(mut self, v: std::option::Option<T>) -> Self
4074 where
4075 T: std::convert::Into<google_cloud_type::model::LatLng>,
4076 {
4077 self.departure_location = v.map(|x| x.into());
4078 self
4079 }
4080
4081 /// Sets the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
4082 ///
4083 /// # Example
4084 /// ```ignore,no_run
4085 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4086 /// use google_cloud_optimization_v1::model::Waypoint;
4087 /// let x = VisitRequest::new().set_departure_waypoint(Waypoint::default()/* use setters */);
4088 /// ```
4089 pub fn set_departure_waypoint<T>(mut self, v: T) -> Self
4090 where
4091 T: std::convert::Into<crate::model::Waypoint>,
4092 {
4093 self.departure_waypoint = std::option::Option::Some(v.into());
4094 self
4095 }
4096
4097 /// Sets or clears the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
4098 ///
4099 /// # Example
4100 /// ```ignore,no_run
4101 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4102 /// use google_cloud_optimization_v1::model::Waypoint;
4103 /// let x = VisitRequest::new().set_or_clear_departure_waypoint(Some(Waypoint::default()/* use setters */));
4104 /// let x = VisitRequest::new().set_or_clear_departure_waypoint(None::<Waypoint>);
4105 /// ```
4106 pub fn set_or_clear_departure_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4107 where
4108 T: std::convert::Into<crate::model::Waypoint>,
4109 {
4110 self.departure_waypoint = v.map(|x| x.into());
4111 self
4112 }
4113
4114 /// Sets the value of [tags][crate::model::shipment::VisitRequest::tags].
4115 ///
4116 /// # Example
4117 /// ```ignore,no_run
4118 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4119 /// let x = VisitRequest::new().set_tags(["a", "b", "c"]);
4120 /// ```
4121 pub fn set_tags<T, V>(mut self, v: T) -> Self
4122 where
4123 T: std::iter::IntoIterator<Item = V>,
4124 V: std::convert::Into<std::string::String>,
4125 {
4126 use std::iter::Iterator;
4127 self.tags = v.into_iter().map(|i| i.into()).collect();
4128 self
4129 }
4130
4131 /// Sets the value of [time_windows][crate::model::shipment::VisitRequest::time_windows].
4132 ///
4133 /// # Example
4134 /// ```ignore,no_run
4135 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4136 /// use google_cloud_optimization_v1::model::TimeWindow;
4137 /// let x = VisitRequest::new()
4138 /// .set_time_windows([
4139 /// TimeWindow::default()/* use setters */,
4140 /// TimeWindow::default()/* use (different) setters */,
4141 /// ]);
4142 /// ```
4143 pub fn set_time_windows<T, V>(mut self, v: T) -> Self
4144 where
4145 T: std::iter::IntoIterator<Item = V>,
4146 V: std::convert::Into<crate::model::TimeWindow>,
4147 {
4148 use std::iter::Iterator;
4149 self.time_windows = v.into_iter().map(|i| i.into()).collect();
4150 self
4151 }
4152
4153 /// Sets the value of [duration][crate::model::shipment::VisitRequest::duration].
4154 ///
4155 /// # Example
4156 /// ```ignore,no_run
4157 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4158 /// use wkt::Duration;
4159 /// let x = VisitRequest::new().set_duration(Duration::default()/* use setters */);
4160 /// ```
4161 pub fn set_duration<T>(mut self, v: T) -> Self
4162 where
4163 T: std::convert::Into<wkt::Duration>,
4164 {
4165 self.duration = std::option::Option::Some(v.into());
4166 self
4167 }
4168
4169 /// Sets or clears the value of [duration][crate::model::shipment::VisitRequest::duration].
4170 ///
4171 /// # Example
4172 /// ```ignore,no_run
4173 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4174 /// use wkt::Duration;
4175 /// let x = VisitRequest::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
4176 /// let x = VisitRequest::new().set_or_clear_duration(None::<Duration>);
4177 /// ```
4178 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
4179 where
4180 T: std::convert::Into<wkt::Duration>,
4181 {
4182 self.duration = v.map(|x| x.into());
4183 self
4184 }
4185
4186 /// Sets the value of [cost][crate::model::shipment::VisitRequest::cost].
4187 ///
4188 /// # Example
4189 /// ```ignore,no_run
4190 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4191 /// let x = VisitRequest::new().set_cost(42.0);
4192 /// ```
4193 pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4194 self.cost = v.into();
4195 self
4196 }
4197
4198 /// Sets the value of [load_demands][crate::model::shipment::VisitRequest::load_demands].
4199 ///
4200 /// # Example
4201 /// ```ignore,no_run
4202 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4203 /// use google_cloud_optimization_v1::model::shipment::Load;
4204 /// let x = VisitRequest::new().set_load_demands([
4205 /// ("key0", Load::default()/* use setters */),
4206 /// ("key1", Load::default()/* use (different) setters */),
4207 /// ]);
4208 /// ```
4209 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
4210 where
4211 T: std::iter::IntoIterator<Item = (K, V)>,
4212 K: std::convert::Into<std::string::String>,
4213 V: std::convert::Into<crate::model::shipment::Load>,
4214 {
4215 use std::iter::Iterator;
4216 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4217 self
4218 }
4219
4220 /// Sets the value of [visit_types][crate::model::shipment::VisitRequest::visit_types].
4221 ///
4222 /// # Example
4223 /// ```ignore,no_run
4224 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4225 /// let x = VisitRequest::new().set_visit_types(["a", "b", "c"]);
4226 /// ```
4227 pub fn set_visit_types<T, V>(mut self, v: T) -> Self
4228 where
4229 T: std::iter::IntoIterator<Item = V>,
4230 V: std::convert::Into<std::string::String>,
4231 {
4232 use std::iter::Iterator;
4233 self.visit_types = v.into_iter().map(|i| i.into()).collect();
4234 self
4235 }
4236
4237 /// Sets the value of [label][crate::model::shipment::VisitRequest::label].
4238 ///
4239 /// # Example
4240 /// ```ignore,no_run
4241 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4242 /// let x = VisitRequest::new().set_label("example");
4243 /// ```
4244 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4245 self.label = v.into();
4246 self
4247 }
4248
4249 /// Sets the value of [demands][crate::model::shipment::VisitRequest::demands].
4250 ///
4251 /// # Example
4252 /// ```ignore,no_run
4253 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4254 /// use google_cloud_optimization_v1::model::CapacityQuantity;
4255 /// let x = VisitRequest::new()
4256 /// .set_demands([
4257 /// CapacityQuantity::default()/* use setters */,
4258 /// CapacityQuantity::default()/* use (different) setters */,
4259 /// ]);
4260 /// ```
4261 #[deprecated]
4262 pub fn set_demands<T, V>(mut self, v: T) -> Self
4263 where
4264 T: std::iter::IntoIterator<Item = V>,
4265 V: std::convert::Into<crate::model::CapacityQuantity>,
4266 {
4267 use std::iter::Iterator;
4268 self.demands = v.into_iter().map(|i| i.into()).collect();
4269 self
4270 }
4271 }
4272
4273 impl wkt::message::Message for VisitRequest {
4274 fn typename() -> &'static str {
4275 "type.googleapis.com/google.cloud.optimization.v1.Shipment.VisitRequest"
4276 }
4277 }
4278
4279 /// When performing a visit, a predefined amount may be added to the vehicle
4280 /// load if it's a pickup, or subtracted if it's a delivery. This message
4281 /// defines such amount. See
4282 /// [load_demands][google.cloud.optimization.v1.Shipment.load_demands].
4283 ///
4284 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
4285 #[derive(Clone, Default, PartialEq)]
4286 #[non_exhaustive]
4287 pub struct Load {
4288 /// The amount by which the load of the vehicle performing the corresponding
4289 /// visit will vary. Since it is an integer, users are advised to choose an
4290 /// appropriate unit to avoid loss of precision. Must be ≥ 0.
4291 pub amount: i64,
4292
4293 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4294 }
4295
4296 impl Load {
4297 /// Creates a new default instance.
4298 pub fn new() -> Self {
4299 std::default::Default::default()
4300 }
4301
4302 /// Sets the value of [amount][crate::model::shipment::Load::amount].
4303 ///
4304 /// # Example
4305 /// ```ignore,no_run
4306 /// # use google_cloud_optimization_v1::model::shipment::Load;
4307 /// let x = Load::new().set_amount(42);
4308 /// ```
4309 pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
4310 self.amount = v.into();
4311 self
4312 }
4313 }
4314
4315 impl wkt::message::Message for Load {
4316 fn typename() -> &'static str {
4317 "type.googleapis.com/google.cloud.optimization.v1.Shipment.Load"
4318 }
4319 }
4320}
4321
4322/// Specifies incompatibilties between shipments depending on their
4323/// shipment_type. The appearance of incompatible shipments on the same route is
4324/// restricted based on the incompatibility mode.
4325#[derive(Clone, Default, PartialEq)]
4326#[non_exhaustive]
4327pub struct ShipmentTypeIncompatibility {
4328 /// List of incompatible types. Two shipments having different `shipment_types`
4329 /// among those listed are "incompatible".
4330 pub types: std::vec::Vec<std::string::String>,
4331
4332 /// Mode applied to the incompatibility.
4333 pub incompatibility_mode: crate::model::shipment_type_incompatibility::IncompatibilityMode,
4334
4335 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4336}
4337
4338impl ShipmentTypeIncompatibility {
4339 /// Creates a new default instance.
4340 pub fn new() -> Self {
4341 std::default::Default::default()
4342 }
4343
4344 /// Sets the value of [types][crate::model::ShipmentTypeIncompatibility::types].
4345 ///
4346 /// # Example
4347 /// ```ignore,no_run
4348 /// # use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
4349 /// let x = ShipmentTypeIncompatibility::new().set_types(["a", "b", "c"]);
4350 /// ```
4351 pub fn set_types<T, V>(mut self, v: T) -> Self
4352 where
4353 T: std::iter::IntoIterator<Item = V>,
4354 V: std::convert::Into<std::string::String>,
4355 {
4356 use std::iter::Iterator;
4357 self.types = v.into_iter().map(|i| i.into()).collect();
4358 self
4359 }
4360
4361 /// Sets the value of [incompatibility_mode][crate::model::ShipmentTypeIncompatibility::incompatibility_mode].
4362 ///
4363 /// # Example
4364 /// ```ignore,no_run
4365 /// # use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
4366 /// use google_cloud_optimization_v1::model::shipment_type_incompatibility::IncompatibilityMode;
4367 /// let x0 = ShipmentTypeIncompatibility::new().set_incompatibility_mode(IncompatibilityMode::NotPerformedBySameVehicle);
4368 /// let x1 = ShipmentTypeIncompatibility::new().set_incompatibility_mode(IncompatibilityMode::NotInSameVehicleSimultaneously);
4369 /// ```
4370 pub fn set_incompatibility_mode<
4371 T: std::convert::Into<crate::model::shipment_type_incompatibility::IncompatibilityMode>,
4372 >(
4373 mut self,
4374 v: T,
4375 ) -> Self {
4376 self.incompatibility_mode = v.into();
4377 self
4378 }
4379}
4380
4381impl wkt::message::Message for ShipmentTypeIncompatibility {
4382 fn typename() -> &'static str {
4383 "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeIncompatibility"
4384 }
4385}
4386
4387/// Defines additional types related to [ShipmentTypeIncompatibility].
4388pub mod shipment_type_incompatibility {
4389 #[allow(unused_imports)]
4390 use super::*;
4391
4392 /// Modes defining how the appearance of incompatible shipments are restricted
4393 /// on the same route.
4394 ///
4395 /// # Working with unknown values
4396 ///
4397 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4398 /// additional enum variants at any time. Adding new variants is not considered
4399 /// a breaking change. Applications should write their code in anticipation of:
4400 ///
4401 /// - New values appearing in future releases of the client library, **and**
4402 /// - New values received dynamically, without application changes.
4403 ///
4404 /// Please consult the [Working with enums] section in the user guide for some
4405 /// guidelines.
4406 ///
4407 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4408 #[derive(Clone, Debug, PartialEq)]
4409 #[non_exhaustive]
4410 pub enum IncompatibilityMode {
4411 /// Unspecified incompatibility mode. This value should never be used.
4412 Unspecified,
4413 /// In this mode, two shipments with incompatible types can never share the
4414 /// same vehicle.
4415 NotPerformedBySameVehicle,
4416 /// For two shipments with incompatible types with the
4417 /// `NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY` incompatibility mode:
4418 ///
4419 /// * If both are pickups only (no deliveries) or deliveries only (no
4420 /// pickups), they cannot share the same vehicle at all.
4421 /// * If one of the shipments has a delivery and the other a pickup, the two
4422 /// shipments can share the same vehicle iff the former shipment is
4423 /// delivered before the latter is picked up.
4424 NotInSameVehicleSimultaneously,
4425 /// If set, the enum was initialized with an unknown value.
4426 ///
4427 /// Applications can examine the value using [IncompatibilityMode::value] or
4428 /// [IncompatibilityMode::name].
4429 UnknownValue(incompatibility_mode::UnknownValue),
4430 }
4431
4432 #[doc(hidden)]
4433 pub mod incompatibility_mode {
4434 #[allow(unused_imports)]
4435 use super::*;
4436 #[derive(Clone, Debug, PartialEq)]
4437 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4438 }
4439
4440 impl IncompatibilityMode {
4441 /// Gets the enum value.
4442 ///
4443 /// Returns `None` if the enum contains an unknown value deserialized from
4444 /// the string representation of enums.
4445 pub fn value(&self) -> std::option::Option<i32> {
4446 match self {
4447 Self::Unspecified => std::option::Option::Some(0),
4448 Self::NotPerformedBySameVehicle => std::option::Option::Some(1),
4449 Self::NotInSameVehicleSimultaneously => std::option::Option::Some(2),
4450 Self::UnknownValue(u) => u.0.value(),
4451 }
4452 }
4453
4454 /// Gets the enum value as a string.
4455 ///
4456 /// Returns `None` if the enum contains an unknown value deserialized from
4457 /// the integer representation of enums.
4458 pub fn name(&self) -> std::option::Option<&str> {
4459 match self {
4460 Self::Unspecified => std::option::Option::Some("INCOMPATIBILITY_MODE_UNSPECIFIED"),
4461 Self::NotPerformedBySameVehicle => {
4462 std::option::Option::Some("NOT_PERFORMED_BY_SAME_VEHICLE")
4463 }
4464 Self::NotInSameVehicleSimultaneously => {
4465 std::option::Option::Some("NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY")
4466 }
4467 Self::UnknownValue(u) => u.0.name(),
4468 }
4469 }
4470 }
4471
4472 impl std::default::Default for IncompatibilityMode {
4473 fn default() -> Self {
4474 use std::convert::From;
4475 Self::from(0)
4476 }
4477 }
4478
4479 impl std::fmt::Display for IncompatibilityMode {
4480 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4481 wkt::internal::display_enum(f, self.name(), self.value())
4482 }
4483 }
4484
4485 impl std::convert::From<i32> for IncompatibilityMode {
4486 fn from(value: i32) -> Self {
4487 match value {
4488 0 => Self::Unspecified,
4489 1 => Self::NotPerformedBySameVehicle,
4490 2 => Self::NotInSameVehicleSimultaneously,
4491 _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
4492 wkt::internal::UnknownEnumValue::Integer(value),
4493 )),
4494 }
4495 }
4496 }
4497
4498 impl std::convert::From<&str> for IncompatibilityMode {
4499 fn from(value: &str) -> Self {
4500 use std::string::ToString;
4501 match value {
4502 "INCOMPATIBILITY_MODE_UNSPECIFIED" => Self::Unspecified,
4503 "NOT_PERFORMED_BY_SAME_VEHICLE" => Self::NotPerformedBySameVehicle,
4504 "NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY" => Self::NotInSameVehicleSimultaneously,
4505 _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
4506 wkt::internal::UnknownEnumValue::String(value.to_string()),
4507 )),
4508 }
4509 }
4510 }
4511
4512 impl serde::ser::Serialize for IncompatibilityMode {
4513 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4514 where
4515 S: serde::Serializer,
4516 {
4517 match self {
4518 Self::Unspecified => serializer.serialize_i32(0),
4519 Self::NotPerformedBySameVehicle => serializer.serialize_i32(1),
4520 Self::NotInSameVehicleSimultaneously => serializer.serialize_i32(2),
4521 Self::UnknownValue(u) => u.0.serialize(serializer),
4522 }
4523 }
4524 }
4525
4526 impl<'de> serde::de::Deserialize<'de> for IncompatibilityMode {
4527 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4528 where
4529 D: serde::Deserializer<'de>,
4530 {
4531 deserializer.deserialize_any(wkt::internal::EnumVisitor::<IncompatibilityMode>::new(
4532 ".google.cloud.optimization.v1.ShipmentTypeIncompatibility.IncompatibilityMode",
4533 ))
4534 }
4535 }
4536}
4537
4538/// Specifies requirements between shipments based on their shipment_type.
4539/// The specifics of the requirement are defined by the requirement mode.
4540#[derive(Clone, Default, PartialEq)]
4541#[non_exhaustive]
4542pub struct ShipmentTypeRequirement {
4543 /// List of alternative shipment types required by the
4544 /// `dependent_shipment_types`.
4545 pub required_shipment_type_alternatives: std::vec::Vec<std::string::String>,
4546
4547 /// All shipments with a type in the `dependent_shipment_types` field require
4548 /// at least one shipment of type `required_shipment_type_alternatives` to be
4549 /// visited on the same route.
4550 ///
4551 /// NOTE: Chains of requirements such that a `shipment_type` depends on itself
4552 /// are not allowed.
4553 pub dependent_shipment_types: std::vec::Vec<std::string::String>,
4554
4555 /// Mode applied to the requirement.
4556 pub requirement_mode: crate::model::shipment_type_requirement::RequirementMode,
4557
4558 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4559}
4560
4561impl ShipmentTypeRequirement {
4562 /// Creates a new default instance.
4563 pub fn new() -> Self {
4564 std::default::Default::default()
4565 }
4566
4567 /// Sets the value of [required_shipment_type_alternatives][crate::model::ShipmentTypeRequirement::required_shipment_type_alternatives].
4568 ///
4569 /// # Example
4570 /// ```ignore,no_run
4571 /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4572 /// let x = ShipmentTypeRequirement::new().set_required_shipment_type_alternatives(["a", "b", "c"]);
4573 /// ```
4574 pub fn set_required_shipment_type_alternatives<T, V>(mut self, v: T) -> Self
4575 where
4576 T: std::iter::IntoIterator<Item = V>,
4577 V: std::convert::Into<std::string::String>,
4578 {
4579 use std::iter::Iterator;
4580 self.required_shipment_type_alternatives = v.into_iter().map(|i| i.into()).collect();
4581 self
4582 }
4583
4584 /// Sets the value of [dependent_shipment_types][crate::model::ShipmentTypeRequirement::dependent_shipment_types].
4585 ///
4586 /// # Example
4587 /// ```ignore,no_run
4588 /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4589 /// let x = ShipmentTypeRequirement::new().set_dependent_shipment_types(["a", "b", "c"]);
4590 /// ```
4591 pub fn set_dependent_shipment_types<T, V>(mut self, v: T) -> Self
4592 where
4593 T: std::iter::IntoIterator<Item = V>,
4594 V: std::convert::Into<std::string::String>,
4595 {
4596 use std::iter::Iterator;
4597 self.dependent_shipment_types = v.into_iter().map(|i| i.into()).collect();
4598 self
4599 }
4600
4601 /// Sets the value of [requirement_mode][crate::model::ShipmentTypeRequirement::requirement_mode].
4602 ///
4603 /// # Example
4604 /// ```ignore,no_run
4605 /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4606 /// use google_cloud_optimization_v1::model::shipment_type_requirement::RequirementMode;
4607 /// let x0 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::PerformedBySameVehicle);
4608 /// let x1 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::InSameVehicleAtPickupTime);
4609 /// let x2 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::InSameVehicleAtDeliveryTime);
4610 /// ```
4611 pub fn set_requirement_mode<
4612 T: std::convert::Into<crate::model::shipment_type_requirement::RequirementMode>,
4613 >(
4614 mut self,
4615 v: T,
4616 ) -> Self {
4617 self.requirement_mode = v.into();
4618 self
4619 }
4620}
4621
4622impl wkt::message::Message for ShipmentTypeRequirement {
4623 fn typename() -> &'static str {
4624 "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeRequirement"
4625 }
4626}
4627
4628/// Defines additional types related to [ShipmentTypeRequirement].
4629pub mod shipment_type_requirement {
4630 #[allow(unused_imports)]
4631 use super::*;
4632
4633 /// Modes defining the appearance of dependent shipments on a route.
4634 ///
4635 /// # Working with unknown values
4636 ///
4637 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4638 /// additional enum variants at any time. Adding new variants is not considered
4639 /// a breaking change. Applications should write their code in anticipation of:
4640 ///
4641 /// - New values appearing in future releases of the client library, **and**
4642 /// - New values received dynamically, without application changes.
4643 ///
4644 /// Please consult the [Working with enums] section in the user guide for some
4645 /// guidelines.
4646 ///
4647 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4648 #[derive(Clone, Debug, PartialEq)]
4649 #[non_exhaustive]
4650 pub enum RequirementMode {
4651 /// Unspecified requirement mode. This value should never be used.
4652 Unspecified,
4653 /// In this mode, all "dependent" shipments must share the same vehicle as at
4654 /// least one of their "required" shipments.
4655 PerformedBySameVehicle,
4656 /// With the `IN_SAME_VEHICLE_AT_PICKUP_TIME` mode, all "dependent"
4657 /// shipments need to have at least one "required" shipment on their vehicle
4658 /// at the time of their pickup.
4659 ///
4660 /// A "dependent" shipment pickup must therefore have either:
4661 ///
4662 /// * A delivery-only "required" shipment delivered on the route after, or
4663 /// * A "required" shipment picked up on the route before it, and if the
4664 /// "required" shipment has a delivery, this delivery must be performed
4665 /// after the "dependent" shipment's pickup.
4666 InSameVehicleAtPickupTime,
4667 /// Same as before, except the "dependent" shipments need to have a
4668 /// "required" shipment on their vehicle at the time of their *delivery*.
4669 InSameVehicleAtDeliveryTime,
4670 /// If set, the enum was initialized with an unknown value.
4671 ///
4672 /// Applications can examine the value using [RequirementMode::value] or
4673 /// [RequirementMode::name].
4674 UnknownValue(requirement_mode::UnknownValue),
4675 }
4676
4677 #[doc(hidden)]
4678 pub mod requirement_mode {
4679 #[allow(unused_imports)]
4680 use super::*;
4681 #[derive(Clone, Debug, PartialEq)]
4682 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4683 }
4684
4685 impl RequirementMode {
4686 /// Gets the enum value.
4687 ///
4688 /// Returns `None` if the enum contains an unknown value deserialized from
4689 /// the string representation of enums.
4690 pub fn value(&self) -> std::option::Option<i32> {
4691 match self {
4692 Self::Unspecified => std::option::Option::Some(0),
4693 Self::PerformedBySameVehicle => std::option::Option::Some(1),
4694 Self::InSameVehicleAtPickupTime => std::option::Option::Some(2),
4695 Self::InSameVehicleAtDeliveryTime => std::option::Option::Some(3),
4696 Self::UnknownValue(u) => u.0.value(),
4697 }
4698 }
4699
4700 /// Gets the enum value as a string.
4701 ///
4702 /// Returns `None` if the enum contains an unknown value deserialized from
4703 /// the integer representation of enums.
4704 pub fn name(&self) -> std::option::Option<&str> {
4705 match self {
4706 Self::Unspecified => std::option::Option::Some("REQUIREMENT_MODE_UNSPECIFIED"),
4707 Self::PerformedBySameVehicle => {
4708 std::option::Option::Some("PERFORMED_BY_SAME_VEHICLE")
4709 }
4710 Self::InSameVehicleAtPickupTime => {
4711 std::option::Option::Some("IN_SAME_VEHICLE_AT_PICKUP_TIME")
4712 }
4713 Self::InSameVehicleAtDeliveryTime => {
4714 std::option::Option::Some("IN_SAME_VEHICLE_AT_DELIVERY_TIME")
4715 }
4716 Self::UnknownValue(u) => u.0.name(),
4717 }
4718 }
4719 }
4720
4721 impl std::default::Default for RequirementMode {
4722 fn default() -> Self {
4723 use std::convert::From;
4724 Self::from(0)
4725 }
4726 }
4727
4728 impl std::fmt::Display for RequirementMode {
4729 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4730 wkt::internal::display_enum(f, self.name(), self.value())
4731 }
4732 }
4733
4734 impl std::convert::From<i32> for RequirementMode {
4735 fn from(value: i32) -> Self {
4736 match value {
4737 0 => Self::Unspecified,
4738 1 => Self::PerformedBySameVehicle,
4739 2 => Self::InSameVehicleAtPickupTime,
4740 3 => Self::InSameVehicleAtDeliveryTime,
4741 _ => Self::UnknownValue(requirement_mode::UnknownValue(
4742 wkt::internal::UnknownEnumValue::Integer(value),
4743 )),
4744 }
4745 }
4746 }
4747
4748 impl std::convert::From<&str> for RequirementMode {
4749 fn from(value: &str) -> Self {
4750 use std::string::ToString;
4751 match value {
4752 "REQUIREMENT_MODE_UNSPECIFIED" => Self::Unspecified,
4753 "PERFORMED_BY_SAME_VEHICLE" => Self::PerformedBySameVehicle,
4754 "IN_SAME_VEHICLE_AT_PICKUP_TIME" => Self::InSameVehicleAtPickupTime,
4755 "IN_SAME_VEHICLE_AT_DELIVERY_TIME" => Self::InSameVehicleAtDeliveryTime,
4756 _ => Self::UnknownValue(requirement_mode::UnknownValue(
4757 wkt::internal::UnknownEnumValue::String(value.to_string()),
4758 )),
4759 }
4760 }
4761 }
4762
4763 impl serde::ser::Serialize for RequirementMode {
4764 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4765 where
4766 S: serde::Serializer,
4767 {
4768 match self {
4769 Self::Unspecified => serializer.serialize_i32(0),
4770 Self::PerformedBySameVehicle => serializer.serialize_i32(1),
4771 Self::InSameVehicleAtPickupTime => serializer.serialize_i32(2),
4772 Self::InSameVehicleAtDeliveryTime => serializer.serialize_i32(3),
4773 Self::UnknownValue(u) => u.0.serialize(serializer),
4774 }
4775 }
4776 }
4777
4778 impl<'de> serde::de::Deserialize<'de> for RequirementMode {
4779 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4780 where
4781 D: serde::Deserializer<'de>,
4782 {
4783 deserializer.deserialize_any(wkt::internal::EnumVisitor::<RequirementMode>::new(
4784 ".google.cloud.optimization.v1.ShipmentTypeRequirement.RequirementMode",
4785 ))
4786 }
4787 }
4788}
4789
4790/// Encapsulates a set of optional conditions to satisfy when calculating
4791/// vehicle routes. This is similar to `RouteModifiers` in the Google Maps
4792/// Platform API; see:
4793/// <https://developers.google.com/maps/documentation/routes/reference/rest/v2/RouteModifiers>.
4794#[derive(Clone, Default, PartialEq)]
4795#[non_exhaustive]
4796pub struct RouteModifiers {
4797 /// Specifies whether to avoid toll roads where reasonable. Preference will be
4798 /// given to routes not containing toll roads. Applies only to motorized travel
4799 /// modes.
4800 pub avoid_tolls: bool,
4801
4802 /// Specifies whether to avoid highways where reasonable. Preference will be
4803 /// given to routes not containing highways. Applies only to motorized travel
4804 /// modes.
4805 pub avoid_highways: bool,
4806
4807 /// Specifies whether to avoid ferries where reasonable. Preference will be
4808 /// given to routes not containing travel by ferries. Applies only to motorized
4809 /// travel modes.
4810 pub avoid_ferries: bool,
4811
4812 /// Optional. Specifies whether to avoid navigating indoors where reasonable.
4813 /// Preference will be given to routes not containing indoor navigation.
4814 /// Applies only to the `WALKING` travel mode.
4815 pub avoid_indoor: bool,
4816
4817 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4818}
4819
4820impl RouteModifiers {
4821 /// Creates a new default instance.
4822 pub fn new() -> Self {
4823 std::default::Default::default()
4824 }
4825
4826 /// Sets the value of [avoid_tolls][crate::model::RouteModifiers::avoid_tolls].
4827 ///
4828 /// # Example
4829 /// ```ignore,no_run
4830 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4831 /// let x = RouteModifiers::new().set_avoid_tolls(true);
4832 /// ```
4833 pub fn set_avoid_tolls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4834 self.avoid_tolls = v.into();
4835 self
4836 }
4837
4838 /// Sets the value of [avoid_highways][crate::model::RouteModifiers::avoid_highways].
4839 ///
4840 /// # Example
4841 /// ```ignore,no_run
4842 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4843 /// let x = RouteModifiers::new().set_avoid_highways(true);
4844 /// ```
4845 pub fn set_avoid_highways<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4846 self.avoid_highways = v.into();
4847 self
4848 }
4849
4850 /// Sets the value of [avoid_ferries][crate::model::RouteModifiers::avoid_ferries].
4851 ///
4852 /// # Example
4853 /// ```ignore,no_run
4854 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4855 /// let x = RouteModifiers::new().set_avoid_ferries(true);
4856 /// ```
4857 pub fn set_avoid_ferries<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4858 self.avoid_ferries = v.into();
4859 self
4860 }
4861
4862 /// Sets the value of [avoid_indoor][crate::model::RouteModifiers::avoid_indoor].
4863 ///
4864 /// # Example
4865 /// ```ignore,no_run
4866 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4867 /// let x = RouteModifiers::new().set_avoid_indoor(true);
4868 /// ```
4869 pub fn set_avoid_indoor<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4870 self.avoid_indoor = v.into();
4871 self
4872 }
4873}
4874
4875impl wkt::message::Message for RouteModifiers {
4876 fn typename() -> &'static str {
4877 "type.googleapis.com/google.cloud.optimization.v1.RouteModifiers"
4878 }
4879}
4880
4881/// Models a vehicle in a shipment problem. Solving a shipment problem will
4882/// build a route starting from `start_location` and ending at `end_location`
4883/// for this vehicle. A route is a sequence of visits (see `ShipmentRoute`).
4884#[derive(Clone, Default, PartialEq)]
4885#[non_exhaustive]
4886pub struct Vehicle {
4887 /// The travel mode which affects the roads usable by the vehicle and its
4888 /// speed. See also `travel_duration_multiple`.
4889 pub travel_mode: crate::model::vehicle::TravelMode,
4890
4891 /// Optional. A set of conditions to satisfy that affect the way routes are
4892 /// calculated for the given vehicle.
4893 pub route_modifiers: std::option::Option<crate::model::RouteModifiers>,
4894
4895 /// Geographic location where the vehicle starts before picking up any
4896 /// shipments. If not specified, the vehicle starts at its first pickup.
4897 /// If the shipment model has duration and distance matrices, `start_location`
4898 /// must not be specified.
4899 pub start_location: std::option::Option<google_cloud_type::model::LatLng>,
4900
4901 /// Waypoint representing a geographic location where the vehicle starts before
4902 /// picking up any shipments. If neither `start_waypoint` nor `start_location`
4903 /// is specified, the vehicle starts at its first pickup.
4904 /// If the shipment model has duration and distance matrices, `start_waypoint`
4905 /// must not be specified.
4906 pub start_waypoint: std::option::Option<crate::model::Waypoint>,
4907
4908 /// Geographic location where the vehicle ends after it has completed its last
4909 /// `VisitRequest`. If not specified the vehicle's `ShipmentRoute` ends
4910 /// immediately when it completes its last `VisitRequest`.
4911 /// If the shipment model has duration and distance matrices, `end_location`
4912 /// must not be specified.
4913 pub end_location: std::option::Option<google_cloud_type::model::LatLng>,
4914
4915 /// Waypoint representing a geographic location where the vehicle ends after
4916 /// it has completed its last `VisitRequest`. If neither `end_waypoint` nor
4917 /// `end_location` is specified, the vehicle's `ShipmentRoute` ends immediately
4918 /// when it completes its last `VisitRequest`.
4919 /// If the shipment model has duration and distance matrices, `end_waypoint`
4920 /// must not be specified.
4921 pub end_waypoint: std::option::Option<crate::model::Waypoint>,
4922
4923 /// Specifies tags attached to the start of the vehicle's route.
4924 ///
4925 /// Empty or duplicate strings are not allowed.
4926 pub start_tags: std::vec::Vec<std::string::String>,
4927
4928 /// Specifies tags attached to the end of the vehicle's route.
4929 ///
4930 /// Empty or duplicate strings are not allowed.
4931 pub end_tags: std::vec::Vec<std::string::String>,
4932
4933 /// Time windows during which the vehicle may depart its start location.
4934 /// They must be within the global time limits (see
4935 /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
4936 /// fields). If unspecified, there is no limitation besides those global time
4937 /// limits.
4938 ///
4939 /// Time windows belonging to the same repeated field must be disjoint, i.e. no
4940 /// time window can overlap with or be adjacent to another, and they must be in
4941 /// chronological order.
4942 ///
4943 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
4944 /// there is a single time window.
4945 ///
4946 /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
4947 pub start_time_windows: std::vec::Vec<crate::model::TimeWindow>,
4948
4949 /// Time windows during which the vehicle may arrive at its end location.
4950 /// They must be within the global time limits (see
4951 /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
4952 /// fields). If unspecified, there is no limitation besides those global time
4953 /// limits.
4954 ///
4955 /// Time windows belonging to the same repeated field must be disjoint, i.e. no
4956 /// time window can overlap with or be adjacent to another, and they must be in
4957 /// chronological order.
4958 ///
4959 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
4960 /// there is a single time window.
4961 ///
4962 /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
4963 pub end_time_windows: std::vec::Vec<crate::model::TimeWindow>,
4964
4965 /// Specifies a multiplicative factor that can be used to increase or decrease
4966 /// travel times of this vehicle. For example, setting this to 2.0 means
4967 /// that this vehicle is slower and has travel times that are twice what they
4968 /// are for standard vehicles. This multiple does not affect visit durations.
4969 /// It does affect cost if `cost_per_hour` or `cost_per_traveled_hour` are
4970 /// specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle
4971 /// is standard, and this multiple is considered 1.0.
4972 ///
4973 /// WARNING: Travel times will be rounded to the nearest second after this
4974 /// multiple is applied but before performing any numerical operations, thus,
4975 /// a small multiple may result in a loss of precision.
4976 ///
4977 /// See also `extra_visit_duration_for_visit_type` below.
4978 pub travel_duration_multiple: std::option::Option<f64>,
4979
4980 /// Unloading policy enforced on the vehicle.
4981 pub unloading_policy: crate::model::vehicle::UnloadingPolicy,
4982
4983 /// Capacities of the vehicle (weight, volume, # of pallets for example).
4984 /// The keys in the map are the identifiers of the type of load, consistent
4985 /// with the keys of the
4986 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
4987 /// field. If a given key is absent from this map, the corresponding capacity
4988 /// is considered to be limitless.
4989 ///
4990 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
4991 pub load_limits:
4992 std::collections::HashMap<std::string::String, crate::model::vehicle::LoadLimit>,
4993
4994 /// Vehicle costs: all costs add up and must be in the same unit as
4995 /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
4996 ///
4997 /// Cost per hour of the vehicle route. This cost is applied to the total time
4998 /// taken by the route, and includes travel time, waiting time, and visit time.
4999 /// Using `cost_per_hour` instead of just `cost_per_traveled_hour` may result
5000 /// in additional latency.
5001 ///
5002 /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
5003 pub cost_per_hour: f64,
5004
5005 /// Cost per traveled hour of the vehicle route. This cost is applied only to
5006 /// travel time taken by the route (i.e., that reported in
5007 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]),
5008 /// and excludes waiting time and visit time.
5009 ///
5010 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
5011 pub cost_per_traveled_hour: f64,
5012
5013 /// Cost per kilometer of the vehicle route. This cost is applied to the
5014 /// distance reported in the
5015 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
5016 /// and does not apply to any distance implicitly traveled from the
5017 /// `arrival_location` to the `departure_location` of a single `VisitRequest`.
5018 ///
5019 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
5020 pub cost_per_kilometer: f64,
5021
5022 /// Fixed cost applied if this vehicle is used to handle a shipment.
5023 pub fixed_cost: f64,
5024
5025 /// This field only applies to vehicles when their route does not serve any
5026 /// shipments. It indicates if the vehicle should be considered as used or not
5027 /// in this case.
5028 ///
5029 /// If true, the vehicle goes from its start to its end location even if it
5030 /// doesn't serve any shipments, and time and distance costs resulting from its
5031 /// start --> end travel are taken into account.
5032 ///
5033 /// Otherwise, it doesn't travel from its start to its end location, and no
5034 /// `break_rule` or delay (from `TransitionAttributes`) are scheduled for this
5035 /// vehicle. In this case, the vehicle's `ShipmentRoute` doesn't contain any
5036 /// information except for the vehicle index and label.
5037 pub used_if_route_is_empty: bool,
5038
5039 /// Limit applied to the total duration of the vehicle's route. In a given
5040 /// `OptimizeToursResponse`, the route duration of a vehicle is the
5041 /// difference between its `vehicle_end_time` and `vehicle_start_time`.
5042 pub route_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
5043
5044 /// Limit applied to the travel duration of the vehicle's route. In a given
5045 /// `OptimizeToursResponse`, the route travel duration is the sum of all its
5046 /// [transitions.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration].
5047 ///
5048 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
5049 pub travel_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
5050
5051 /// Limit applied to the total distance of the vehicle's route. In a given
5052 /// `OptimizeToursResponse`, the route distance is the sum of all its
5053 /// [transitions.travel_distance_meters][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters].
5054 ///
5055 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters]: crate::model::shipment_route::Transition::travel_distance_meters
5056 pub route_distance_limit: std::option::Option<crate::model::DistanceLimit>,
5057
5058 /// Specifies a map from visit_types strings to durations. The duration is time
5059 /// in addition to
5060 /// [VisitRequest.duration][google.cloud.optimization.v1.Shipment.VisitRequest.duration]
5061 /// to be taken at visits with the specified `visit_types`. This extra visit
5062 /// duration adds cost if `cost_per_hour` is specified. Keys (i.e.
5063 /// `visit_types`) cannot be empty strings.
5064 ///
5065 /// If a visit request has multiple types, a duration will be added for each
5066 /// type in the map.
5067 ///
5068 /// [google.cloud.optimization.v1.Shipment.VisitRequest.duration]: crate::model::shipment::VisitRequest::duration
5069 pub extra_visit_duration_for_visit_type:
5070 std::collections::HashMap<std::string::String, wkt::Duration>,
5071
5072 /// Describes the break schedule to be enforced on this vehicle.
5073 /// If empty, no breaks will be scheduled for this vehicle.
5074 pub break_rule: std::option::Option<crate::model::BreakRule>,
5075
5076 /// Specifies a label for this vehicle. This label is reported in the response
5077 /// as the `vehicle_label` of the corresponding
5078 /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
5079 ///
5080 /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
5081 pub label: std::string::String,
5082
5083 /// If true, `used_if_route_is_empty` must be false, and this vehicle will
5084 /// remain unused.
5085 ///
5086 /// If a shipment is performed by an ignored vehicle in
5087 /// `injected_first_solution_routes`, it is skipped in the first solution but
5088 /// is free to be performed in the response.
5089 ///
5090 /// If a shipment is performed by an ignored vehicle in
5091 /// `injected_solution_constraint` and any related pickup/delivery is
5092 /// constrained to remain on the vehicle (i.e., not relaxed to level
5093 /// `RELAX_ALL_AFTER_THRESHOLD`), it is skipped in the response.
5094 /// If a shipment has a non-empty `allowed_vehicle_indices` field and all of
5095 /// the allowed vehicles are ignored, it is skipped in the response.
5096 pub ignore: bool,
5097
5098 /// Deprecated: No longer used.
5099 /// Indices in the `break_rule` field in the source
5100 /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel]. They
5101 /// correspond to break rules enforced on the vehicle.
5102 ///
5103 /// As of 2018/03, at most one rule index per vehicle can be specified.
5104 ///
5105 /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
5106 #[deprecated]
5107 pub break_rule_indices: std::vec::Vec<i32>,
5108
5109 /// Deprecated: Use
5110 /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits]
5111 /// instead.
5112 ///
5113 /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
5114 #[deprecated]
5115 pub capacities: std::vec::Vec<crate::model::CapacityQuantity>,
5116
5117 /// Deprecated: Use
5118 /// [Vehicle.LoadLimit.start_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]
5119 /// instead.
5120 ///
5121 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]: crate::model::vehicle::LoadLimit::start_load_interval
5122 #[deprecated]
5123 pub start_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
5124
5125 /// Deprecated: Use
5126 /// [Vehicle.LoadLimit.end_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]
5127 /// instead.
5128 ///
5129 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]: crate::model::vehicle::LoadLimit::end_load_interval
5130 #[deprecated]
5131 pub end_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
5132
5133 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5134}
5135
5136impl Vehicle {
5137 /// Creates a new default instance.
5138 pub fn new() -> Self {
5139 std::default::Default::default()
5140 }
5141
5142 /// Sets the value of [travel_mode][crate::model::Vehicle::travel_mode].
5143 ///
5144 /// # Example
5145 /// ```ignore,no_run
5146 /// # use google_cloud_optimization_v1::model::Vehicle;
5147 /// use google_cloud_optimization_v1::model::vehicle::TravelMode;
5148 /// let x0 = Vehicle::new().set_travel_mode(TravelMode::Driving);
5149 /// let x1 = Vehicle::new().set_travel_mode(TravelMode::Walking);
5150 /// ```
5151 pub fn set_travel_mode<T: std::convert::Into<crate::model::vehicle::TravelMode>>(
5152 mut self,
5153 v: T,
5154 ) -> Self {
5155 self.travel_mode = v.into();
5156 self
5157 }
5158
5159 /// Sets the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
5160 ///
5161 /// # Example
5162 /// ```ignore,no_run
5163 /// # use google_cloud_optimization_v1::model::Vehicle;
5164 /// use google_cloud_optimization_v1::model::RouteModifiers;
5165 /// let x = Vehicle::new().set_route_modifiers(RouteModifiers::default()/* use setters */);
5166 /// ```
5167 pub fn set_route_modifiers<T>(mut self, v: T) -> Self
5168 where
5169 T: std::convert::Into<crate::model::RouteModifiers>,
5170 {
5171 self.route_modifiers = std::option::Option::Some(v.into());
5172 self
5173 }
5174
5175 /// Sets or clears the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
5176 ///
5177 /// # Example
5178 /// ```ignore,no_run
5179 /// # use google_cloud_optimization_v1::model::Vehicle;
5180 /// use google_cloud_optimization_v1::model::RouteModifiers;
5181 /// let x = Vehicle::new().set_or_clear_route_modifiers(Some(RouteModifiers::default()/* use setters */));
5182 /// let x = Vehicle::new().set_or_clear_route_modifiers(None::<RouteModifiers>);
5183 /// ```
5184 pub fn set_or_clear_route_modifiers<T>(mut self, v: std::option::Option<T>) -> Self
5185 where
5186 T: std::convert::Into<crate::model::RouteModifiers>,
5187 {
5188 self.route_modifiers = v.map(|x| x.into());
5189 self
5190 }
5191
5192 /// Sets the value of [start_location][crate::model::Vehicle::start_location].
5193 ///
5194 /// # Example
5195 /// ```ignore,no_run
5196 /// # use google_cloud_optimization_v1::model::Vehicle;
5197 /// use google_cloud_type::model::LatLng;
5198 /// let x = Vehicle::new().set_start_location(LatLng::default()/* use setters */);
5199 /// ```
5200 pub fn set_start_location<T>(mut self, v: T) -> Self
5201 where
5202 T: std::convert::Into<google_cloud_type::model::LatLng>,
5203 {
5204 self.start_location = std::option::Option::Some(v.into());
5205 self
5206 }
5207
5208 /// Sets or clears the value of [start_location][crate::model::Vehicle::start_location].
5209 ///
5210 /// # Example
5211 /// ```ignore,no_run
5212 /// # use google_cloud_optimization_v1::model::Vehicle;
5213 /// use google_cloud_type::model::LatLng;
5214 /// let x = Vehicle::new().set_or_clear_start_location(Some(LatLng::default()/* use setters */));
5215 /// let x = Vehicle::new().set_or_clear_start_location(None::<LatLng>);
5216 /// ```
5217 pub fn set_or_clear_start_location<T>(mut self, v: std::option::Option<T>) -> Self
5218 where
5219 T: std::convert::Into<google_cloud_type::model::LatLng>,
5220 {
5221 self.start_location = v.map(|x| x.into());
5222 self
5223 }
5224
5225 /// Sets the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
5226 ///
5227 /// # Example
5228 /// ```ignore,no_run
5229 /// # use google_cloud_optimization_v1::model::Vehicle;
5230 /// use google_cloud_optimization_v1::model::Waypoint;
5231 /// let x = Vehicle::new().set_start_waypoint(Waypoint::default()/* use setters */);
5232 /// ```
5233 pub fn set_start_waypoint<T>(mut self, v: T) -> Self
5234 where
5235 T: std::convert::Into<crate::model::Waypoint>,
5236 {
5237 self.start_waypoint = std::option::Option::Some(v.into());
5238 self
5239 }
5240
5241 /// Sets or clears the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
5242 ///
5243 /// # Example
5244 /// ```ignore,no_run
5245 /// # use google_cloud_optimization_v1::model::Vehicle;
5246 /// use google_cloud_optimization_v1::model::Waypoint;
5247 /// let x = Vehicle::new().set_or_clear_start_waypoint(Some(Waypoint::default()/* use setters */));
5248 /// let x = Vehicle::new().set_or_clear_start_waypoint(None::<Waypoint>);
5249 /// ```
5250 pub fn set_or_clear_start_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
5251 where
5252 T: std::convert::Into<crate::model::Waypoint>,
5253 {
5254 self.start_waypoint = v.map(|x| x.into());
5255 self
5256 }
5257
5258 /// Sets the value of [end_location][crate::model::Vehicle::end_location].
5259 ///
5260 /// # Example
5261 /// ```ignore,no_run
5262 /// # use google_cloud_optimization_v1::model::Vehicle;
5263 /// use google_cloud_type::model::LatLng;
5264 /// let x = Vehicle::new().set_end_location(LatLng::default()/* use setters */);
5265 /// ```
5266 pub fn set_end_location<T>(mut self, v: T) -> Self
5267 where
5268 T: std::convert::Into<google_cloud_type::model::LatLng>,
5269 {
5270 self.end_location = std::option::Option::Some(v.into());
5271 self
5272 }
5273
5274 /// Sets or clears the value of [end_location][crate::model::Vehicle::end_location].
5275 ///
5276 /// # Example
5277 /// ```ignore,no_run
5278 /// # use google_cloud_optimization_v1::model::Vehicle;
5279 /// use google_cloud_type::model::LatLng;
5280 /// let x = Vehicle::new().set_or_clear_end_location(Some(LatLng::default()/* use setters */));
5281 /// let x = Vehicle::new().set_or_clear_end_location(None::<LatLng>);
5282 /// ```
5283 pub fn set_or_clear_end_location<T>(mut self, v: std::option::Option<T>) -> Self
5284 where
5285 T: std::convert::Into<google_cloud_type::model::LatLng>,
5286 {
5287 self.end_location = v.map(|x| x.into());
5288 self
5289 }
5290
5291 /// Sets the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
5292 ///
5293 /// # Example
5294 /// ```ignore,no_run
5295 /// # use google_cloud_optimization_v1::model::Vehicle;
5296 /// use google_cloud_optimization_v1::model::Waypoint;
5297 /// let x = Vehicle::new().set_end_waypoint(Waypoint::default()/* use setters */);
5298 /// ```
5299 pub fn set_end_waypoint<T>(mut self, v: T) -> Self
5300 where
5301 T: std::convert::Into<crate::model::Waypoint>,
5302 {
5303 self.end_waypoint = std::option::Option::Some(v.into());
5304 self
5305 }
5306
5307 /// Sets or clears the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
5308 ///
5309 /// # Example
5310 /// ```ignore,no_run
5311 /// # use google_cloud_optimization_v1::model::Vehicle;
5312 /// use google_cloud_optimization_v1::model::Waypoint;
5313 /// let x = Vehicle::new().set_or_clear_end_waypoint(Some(Waypoint::default()/* use setters */));
5314 /// let x = Vehicle::new().set_or_clear_end_waypoint(None::<Waypoint>);
5315 /// ```
5316 pub fn set_or_clear_end_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
5317 where
5318 T: std::convert::Into<crate::model::Waypoint>,
5319 {
5320 self.end_waypoint = v.map(|x| x.into());
5321 self
5322 }
5323
5324 /// Sets the value of [start_tags][crate::model::Vehicle::start_tags].
5325 ///
5326 /// # Example
5327 /// ```ignore,no_run
5328 /// # use google_cloud_optimization_v1::model::Vehicle;
5329 /// let x = Vehicle::new().set_start_tags(["a", "b", "c"]);
5330 /// ```
5331 pub fn set_start_tags<T, V>(mut self, v: T) -> Self
5332 where
5333 T: std::iter::IntoIterator<Item = V>,
5334 V: std::convert::Into<std::string::String>,
5335 {
5336 use std::iter::Iterator;
5337 self.start_tags = v.into_iter().map(|i| i.into()).collect();
5338 self
5339 }
5340
5341 /// Sets the value of [end_tags][crate::model::Vehicle::end_tags].
5342 ///
5343 /// # Example
5344 /// ```ignore,no_run
5345 /// # use google_cloud_optimization_v1::model::Vehicle;
5346 /// let x = Vehicle::new().set_end_tags(["a", "b", "c"]);
5347 /// ```
5348 pub fn set_end_tags<T, V>(mut self, v: T) -> Self
5349 where
5350 T: std::iter::IntoIterator<Item = V>,
5351 V: std::convert::Into<std::string::String>,
5352 {
5353 use std::iter::Iterator;
5354 self.end_tags = v.into_iter().map(|i| i.into()).collect();
5355 self
5356 }
5357
5358 /// Sets the value of [start_time_windows][crate::model::Vehicle::start_time_windows].
5359 ///
5360 /// # Example
5361 /// ```ignore,no_run
5362 /// # use google_cloud_optimization_v1::model::Vehicle;
5363 /// use google_cloud_optimization_v1::model::TimeWindow;
5364 /// let x = Vehicle::new()
5365 /// .set_start_time_windows([
5366 /// TimeWindow::default()/* use setters */,
5367 /// TimeWindow::default()/* use (different) setters */,
5368 /// ]);
5369 /// ```
5370 pub fn set_start_time_windows<T, V>(mut self, v: T) -> Self
5371 where
5372 T: std::iter::IntoIterator<Item = V>,
5373 V: std::convert::Into<crate::model::TimeWindow>,
5374 {
5375 use std::iter::Iterator;
5376 self.start_time_windows = v.into_iter().map(|i| i.into()).collect();
5377 self
5378 }
5379
5380 /// Sets the value of [end_time_windows][crate::model::Vehicle::end_time_windows].
5381 ///
5382 /// # Example
5383 /// ```ignore,no_run
5384 /// # use google_cloud_optimization_v1::model::Vehicle;
5385 /// use google_cloud_optimization_v1::model::TimeWindow;
5386 /// let x = Vehicle::new()
5387 /// .set_end_time_windows([
5388 /// TimeWindow::default()/* use setters */,
5389 /// TimeWindow::default()/* use (different) setters */,
5390 /// ]);
5391 /// ```
5392 pub fn set_end_time_windows<T, V>(mut self, v: T) -> Self
5393 where
5394 T: std::iter::IntoIterator<Item = V>,
5395 V: std::convert::Into<crate::model::TimeWindow>,
5396 {
5397 use std::iter::Iterator;
5398 self.end_time_windows = v.into_iter().map(|i| i.into()).collect();
5399 self
5400 }
5401
5402 /// Sets the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
5403 ///
5404 /// # Example
5405 /// ```ignore,no_run
5406 /// # use google_cloud_optimization_v1::model::Vehicle;
5407 /// let x = Vehicle::new().set_travel_duration_multiple(42.0);
5408 /// ```
5409 pub fn set_travel_duration_multiple<T>(mut self, v: T) -> Self
5410 where
5411 T: std::convert::Into<f64>,
5412 {
5413 self.travel_duration_multiple = std::option::Option::Some(v.into());
5414 self
5415 }
5416
5417 /// Sets or clears the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
5418 ///
5419 /// # Example
5420 /// ```ignore,no_run
5421 /// # use google_cloud_optimization_v1::model::Vehicle;
5422 /// let x = Vehicle::new().set_or_clear_travel_duration_multiple(Some(42.0));
5423 /// let x = Vehicle::new().set_or_clear_travel_duration_multiple(None::<f32>);
5424 /// ```
5425 pub fn set_or_clear_travel_duration_multiple<T>(mut self, v: std::option::Option<T>) -> Self
5426 where
5427 T: std::convert::Into<f64>,
5428 {
5429 self.travel_duration_multiple = v.map(|x| x.into());
5430 self
5431 }
5432
5433 /// Sets the value of [unloading_policy][crate::model::Vehicle::unloading_policy].
5434 ///
5435 /// # Example
5436 /// ```ignore,no_run
5437 /// # use google_cloud_optimization_v1::model::Vehicle;
5438 /// use google_cloud_optimization_v1::model::vehicle::UnloadingPolicy;
5439 /// let x0 = Vehicle::new().set_unloading_policy(UnloadingPolicy::LastInFirstOut);
5440 /// let x1 = Vehicle::new().set_unloading_policy(UnloadingPolicy::FirstInFirstOut);
5441 /// ```
5442 pub fn set_unloading_policy<T: std::convert::Into<crate::model::vehicle::UnloadingPolicy>>(
5443 mut self,
5444 v: T,
5445 ) -> Self {
5446 self.unloading_policy = v.into();
5447 self
5448 }
5449
5450 /// Sets the value of [load_limits][crate::model::Vehicle::load_limits].
5451 ///
5452 /// # Example
5453 /// ```ignore,no_run
5454 /// # use google_cloud_optimization_v1::model::Vehicle;
5455 /// use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5456 /// let x = Vehicle::new().set_load_limits([
5457 /// ("key0", LoadLimit::default()/* use setters */),
5458 /// ("key1", LoadLimit::default()/* use (different) setters */),
5459 /// ]);
5460 /// ```
5461 pub fn set_load_limits<T, K, V>(mut self, v: T) -> Self
5462 where
5463 T: std::iter::IntoIterator<Item = (K, V)>,
5464 K: std::convert::Into<std::string::String>,
5465 V: std::convert::Into<crate::model::vehicle::LoadLimit>,
5466 {
5467 use std::iter::Iterator;
5468 self.load_limits = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5469 self
5470 }
5471
5472 /// Sets the value of [cost_per_hour][crate::model::Vehicle::cost_per_hour].
5473 ///
5474 /// # Example
5475 /// ```ignore,no_run
5476 /// # use google_cloud_optimization_v1::model::Vehicle;
5477 /// let x = Vehicle::new().set_cost_per_hour(42.0);
5478 /// ```
5479 pub fn set_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5480 self.cost_per_hour = v.into();
5481 self
5482 }
5483
5484 /// Sets the value of [cost_per_traveled_hour][crate::model::Vehicle::cost_per_traveled_hour].
5485 ///
5486 /// # Example
5487 /// ```ignore,no_run
5488 /// # use google_cloud_optimization_v1::model::Vehicle;
5489 /// let x = Vehicle::new().set_cost_per_traveled_hour(42.0);
5490 /// ```
5491 pub fn set_cost_per_traveled_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5492 self.cost_per_traveled_hour = v.into();
5493 self
5494 }
5495
5496 /// Sets the value of [cost_per_kilometer][crate::model::Vehicle::cost_per_kilometer].
5497 ///
5498 /// # Example
5499 /// ```ignore,no_run
5500 /// # use google_cloud_optimization_v1::model::Vehicle;
5501 /// let x = Vehicle::new().set_cost_per_kilometer(42.0);
5502 /// ```
5503 pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5504 self.cost_per_kilometer = v.into();
5505 self
5506 }
5507
5508 /// Sets the value of [fixed_cost][crate::model::Vehicle::fixed_cost].
5509 ///
5510 /// # Example
5511 /// ```ignore,no_run
5512 /// # use google_cloud_optimization_v1::model::Vehicle;
5513 /// let x = Vehicle::new().set_fixed_cost(42.0);
5514 /// ```
5515 pub fn set_fixed_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5516 self.fixed_cost = v.into();
5517 self
5518 }
5519
5520 /// Sets the value of [used_if_route_is_empty][crate::model::Vehicle::used_if_route_is_empty].
5521 ///
5522 /// # Example
5523 /// ```ignore,no_run
5524 /// # use google_cloud_optimization_v1::model::Vehicle;
5525 /// let x = Vehicle::new().set_used_if_route_is_empty(true);
5526 /// ```
5527 pub fn set_used_if_route_is_empty<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5528 self.used_if_route_is_empty = v.into();
5529 self
5530 }
5531
5532 /// Sets the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
5533 ///
5534 /// # Example
5535 /// ```ignore,no_run
5536 /// # use google_cloud_optimization_v1::model::Vehicle;
5537 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5538 /// let x = Vehicle::new().set_route_duration_limit(DurationLimit::default()/* use setters */);
5539 /// ```
5540 pub fn set_route_duration_limit<T>(mut self, v: T) -> Self
5541 where
5542 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5543 {
5544 self.route_duration_limit = std::option::Option::Some(v.into());
5545 self
5546 }
5547
5548 /// Sets or clears the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
5549 ///
5550 /// # Example
5551 /// ```ignore,no_run
5552 /// # use google_cloud_optimization_v1::model::Vehicle;
5553 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5554 /// let x = Vehicle::new().set_or_clear_route_duration_limit(Some(DurationLimit::default()/* use setters */));
5555 /// let x = Vehicle::new().set_or_clear_route_duration_limit(None::<DurationLimit>);
5556 /// ```
5557 pub fn set_or_clear_route_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
5558 where
5559 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5560 {
5561 self.route_duration_limit = v.map(|x| x.into());
5562 self
5563 }
5564
5565 /// Sets the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
5566 ///
5567 /// # Example
5568 /// ```ignore,no_run
5569 /// # use google_cloud_optimization_v1::model::Vehicle;
5570 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5571 /// let x = Vehicle::new().set_travel_duration_limit(DurationLimit::default()/* use setters */);
5572 /// ```
5573 pub fn set_travel_duration_limit<T>(mut self, v: T) -> Self
5574 where
5575 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5576 {
5577 self.travel_duration_limit = std::option::Option::Some(v.into());
5578 self
5579 }
5580
5581 /// Sets or clears the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
5582 ///
5583 /// # Example
5584 /// ```ignore,no_run
5585 /// # use google_cloud_optimization_v1::model::Vehicle;
5586 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5587 /// let x = Vehicle::new().set_or_clear_travel_duration_limit(Some(DurationLimit::default()/* use setters */));
5588 /// let x = Vehicle::new().set_or_clear_travel_duration_limit(None::<DurationLimit>);
5589 /// ```
5590 pub fn set_or_clear_travel_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
5591 where
5592 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5593 {
5594 self.travel_duration_limit = v.map(|x| x.into());
5595 self
5596 }
5597
5598 /// Sets the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
5599 ///
5600 /// # Example
5601 /// ```ignore,no_run
5602 /// # use google_cloud_optimization_v1::model::Vehicle;
5603 /// use google_cloud_optimization_v1::model::DistanceLimit;
5604 /// let x = Vehicle::new().set_route_distance_limit(DistanceLimit::default()/* use setters */);
5605 /// ```
5606 pub fn set_route_distance_limit<T>(mut self, v: T) -> Self
5607 where
5608 T: std::convert::Into<crate::model::DistanceLimit>,
5609 {
5610 self.route_distance_limit = std::option::Option::Some(v.into());
5611 self
5612 }
5613
5614 /// Sets or clears the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
5615 ///
5616 /// # Example
5617 /// ```ignore,no_run
5618 /// # use google_cloud_optimization_v1::model::Vehicle;
5619 /// use google_cloud_optimization_v1::model::DistanceLimit;
5620 /// let x = Vehicle::new().set_or_clear_route_distance_limit(Some(DistanceLimit::default()/* use setters */));
5621 /// let x = Vehicle::new().set_or_clear_route_distance_limit(None::<DistanceLimit>);
5622 /// ```
5623 pub fn set_or_clear_route_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
5624 where
5625 T: std::convert::Into<crate::model::DistanceLimit>,
5626 {
5627 self.route_distance_limit = v.map(|x| x.into());
5628 self
5629 }
5630
5631 /// Sets the value of [extra_visit_duration_for_visit_type][crate::model::Vehicle::extra_visit_duration_for_visit_type].
5632 ///
5633 /// # Example
5634 /// ```ignore,no_run
5635 /// # use google_cloud_optimization_v1::model::Vehicle;
5636 /// use wkt::Duration;
5637 /// let x = Vehicle::new().set_extra_visit_duration_for_visit_type([
5638 /// ("key0", Duration::default()/* use setters */),
5639 /// ("key1", Duration::default()/* use (different) setters */),
5640 /// ]);
5641 /// ```
5642 pub fn set_extra_visit_duration_for_visit_type<T, K, V>(mut self, v: T) -> Self
5643 where
5644 T: std::iter::IntoIterator<Item = (K, V)>,
5645 K: std::convert::Into<std::string::String>,
5646 V: std::convert::Into<wkt::Duration>,
5647 {
5648 use std::iter::Iterator;
5649 self.extra_visit_duration_for_visit_type =
5650 v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5651 self
5652 }
5653
5654 /// Sets the value of [break_rule][crate::model::Vehicle::break_rule].
5655 ///
5656 /// # Example
5657 /// ```ignore,no_run
5658 /// # use google_cloud_optimization_v1::model::Vehicle;
5659 /// use google_cloud_optimization_v1::model::BreakRule;
5660 /// let x = Vehicle::new().set_break_rule(BreakRule::default()/* use setters */);
5661 /// ```
5662 pub fn set_break_rule<T>(mut self, v: T) -> Self
5663 where
5664 T: std::convert::Into<crate::model::BreakRule>,
5665 {
5666 self.break_rule = std::option::Option::Some(v.into());
5667 self
5668 }
5669
5670 /// Sets or clears the value of [break_rule][crate::model::Vehicle::break_rule].
5671 ///
5672 /// # Example
5673 /// ```ignore,no_run
5674 /// # use google_cloud_optimization_v1::model::Vehicle;
5675 /// use google_cloud_optimization_v1::model::BreakRule;
5676 /// let x = Vehicle::new().set_or_clear_break_rule(Some(BreakRule::default()/* use setters */));
5677 /// let x = Vehicle::new().set_or_clear_break_rule(None::<BreakRule>);
5678 /// ```
5679 pub fn set_or_clear_break_rule<T>(mut self, v: std::option::Option<T>) -> Self
5680 where
5681 T: std::convert::Into<crate::model::BreakRule>,
5682 {
5683 self.break_rule = v.map(|x| x.into());
5684 self
5685 }
5686
5687 /// Sets the value of [label][crate::model::Vehicle::label].
5688 ///
5689 /// # Example
5690 /// ```ignore,no_run
5691 /// # use google_cloud_optimization_v1::model::Vehicle;
5692 /// let x = Vehicle::new().set_label("example");
5693 /// ```
5694 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5695 self.label = v.into();
5696 self
5697 }
5698
5699 /// Sets the value of [ignore][crate::model::Vehicle::ignore].
5700 ///
5701 /// # Example
5702 /// ```ignore,no_run
5703 /// # use google_cloud_optimization_v1::model::Vehicle;
5704 /// let x = Vehicle::new().set_ignore(true);
5705 /// ```
5706 pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5707 self.ignore = v.into();
5708 self
5709 }
5710
5711 /// Sets the value of [break_rule_indices][crate::model::Vehicle::break_rule_indices].
5712 ///
5713 /// # Example
5714 /// ```ignore,no_run
5715 /// # use google_cloud_optimization_v1::model::Vehicle;
5716 /// let x = Vehicle::new().set_break_rule_indices([1, 2, 3]);
5717 /// ```
5718 #[deprecated]
5719 pub fn set_break_rule_indices<T, V>(mut self, v: T) -> Self
5720 where
5721 T: std::iter::IntoIterator<Item = V>,
5722 V: std::convert::Into<i32>,
5723 {
5724 use std::iter::Iterator;
5725 self.break_rule_indices = v.into_iter().map(|i| i.into()).collect();
5726 self
5727 }
5728
5729 /// Sets the value of [capacities][crate::model::Vehicle::capacities].
5730 ///
5731 /// # Example
5732 /// ```ignore,no_run
5733 /// # use google_cloud_optimization_v1::model::Vehicle;
5734 /// use google_cloud_optimization_v1::model::CapacityQuantity;
5735 /// let x = Vehicle::new()
5736 /// .set_capacities([
5737 /// CapacityQuantity::default()/* use setters */,
5738 /// CapacityQuantity::default()/* use (different) setters */,
5739 /// ]);
5740 /// ```
5741 #[deprecated]
5742 pub fn set_capacities<T, V>(mut self, v: T) -> Self
5743 where
5744 T: std::iter::IntoIterator<Item = V>,
5745 V: std::convert::Into<crate::model::CapacityQuantity>,
5746 {
5747 use std::iter::Iterator;
5748 self.capacities = v.into_iter().map(|i| i.into()).collect();
5749 self
5750 }
5751
5752 /// Sets the value of [start_load_intervals][crate::model::Vehicle::start_load_intervals].
5753 ///
5754 /// # Example
5755 /// ```ignore,no_run
5756 /// # use google_cloud_optimization_v1::model::Vehicle;
5757 /// use google_cloud_optimization_v1::model::CapacityQuantityInterval;
5758 /// let x = Vehicle::new()
5759 /// .set_start_load_intervals([
5760 /// CapacityQuantityInterval::default()/* use setters */,
5761 /// CapacityQuantityInterval::default()/* use (different) setters */,
5762 /// ]);
5763 /// ```
5764 #[deprecated]
5765 pub fn set_start_load_intervals<T, V>(mut self, v: T) -> Self
5766 where
5767 T: std::iter::IntoIterator<Item = V>,
5768 V: std::convert::Into<crate::model::CapacityQuantityInterval>,
5769 {
5770 use std::iter::Iterator;
5771 self.start_load_intervals = v.into_iter().map(|i| i.into()).collect();
5772 self
5773 }
5774
5775 /// Sets the value of [end_load_intervals][crate::model::Vehicle::end_load_intervals].
5776 ///
5777 /// # Example
5778 /// ```ignore,no_run
5779 /// # use google_cloud_optimization_v1::model::Vehicle;
5780 /// use google_cloud_optimization_v1::model::CapacityQuantityInterval;
5781 /// let x = Vehicle::new()
5782 /// .set_end_load_intervals([
5783 /// CapacityQuantityInterval::default()/* use setters */,
5784 /// CapacityQuantityInterval::default()/* use (different) setters */,
5785 /// ]);
5786 /// ```
5787 #[deprecated]
5788 pub fn set_end_load_intervals<T, V>(mut self, v: T) -> Self
5789 where
5790 T: std::iter::IntoIterator<Item = V>,
5791 V: std::convert::Into<crate::model::CapacityQuantityInterval>,
5792 {
5793 use std::iter::Iterator;
5794 self.end_load_intervals = v.into_iter().map(|i| i.into()).collect();
5795 self
5796 }
5797}
5798
5799impl wkt::message::Message for Vehicle {
5800 fn typename() -> &'static str {
5801 "type.googleapis.com/google.cloud.optimization.v1.Vehicle"
5802 }
5803}
5804
5805/// Defines additional types related to [Vehicle].
5806pub mod vehicle {
5807 #[allow(unused_imports)]
5808 use super::*;
5809
5810 /// Defines a load limit applying to a vehicle, e.g. "this truck may only
5811 /// carry up to 3500 kg". See
5812 /// [load_limits][google.cloud.optimization.v1.Vehicle.load_limits].
5813 ///
5814 /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
5815 #[derive(Clone, Default, PartialEq)]
5816 #[non_exhaustive]
5817 pub struct LoadLimit {
5818 /// The maximum acceptable amount of load.
5819 pub max_load: std::option::Option<i64>,
5820
5821 /// A soft limit of the load. See
5822 /// [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max].
5823 ///
5824 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
5825 pub soft_max_load: i64,
5826
5827 /// If the load ever exceeds
5828 /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]
5829 /// along this vehicle's route, the following cost penalty applies (only once
5830 /// per vehicle): (load -
5831 /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load])
5832 ///
5833 /// * [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. All costs
5834 /// add up and must be in the same unit as
5835 /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
5836 ///
5837 /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
5838 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
5839 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]: crate::model::vehicle::LoadLimit::soft_max_load
5840 pub cost_per_unit_above_soft_max: f64,
5841
5842 /// The acceptable load interval of the vehicle at the start of the route.
5843 pub start_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
5844
5845 /// The acceptable load interval of the vehicle at the end of the route.
5846 pub end_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
5847
5848 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5849 }
5850
5851 impl LoadLimit {
5852 /// Creates a new default instance.
5853 pub fn new() -> Self {
5854 std::default::Default::default()
5855 }
5856
5857 /// Sets the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
5858 ///
5859 /// # Example
5860 /// ```ignore,no_run
5861 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5862 /// let x = LoadLimit::new().set_max_load(42);
5863 /// ```
5864 pub fn set_max_load<T>(mut self, v: T) -> Self
5865 where
5866 T: std::convert::Into<i64>,
5867 {
5868 self.max_load = std::option::Option::Some(v.into());
5869 self
5870 }
5871
5872 /// Sets or clears the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
5873 ///
5874 /// # Example
5875 /// ```ignore,no_run
5876 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5877 /// let x = LoadLimit::new().set_or_clear_max_load(Some(42));
5878 /// let x = LoadLimit::new().set_or_clear_max_load(None::<i32>);
5879 /// ```
5880 pub fn set_or_clear_max_load<T>(mut self, v: std::option::Option<T>) -> Self
5881 where
5882 T: std::convert::Into<i64>,
5883 {
5884 self.max_load = v.map(|x| x.into());
5885 self
5886 }
5887
5888 /// Sets the value of [soft_max_load][crate::model::vehicle::LoadLimit::soft_max_load].
5889 ///
5890 /// # Example
5891 /// ```ignore,no_run
5892 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5893 /// let x = LoadLimit::new().set_soft_max_load(42);
5894 /// ```
5895 pub fn set_soft_max_load<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5896 self.soft_max_load = v.into();
5897 self
5898 }
5899
5900 /// Sets the value of [cost_per_unit_above_soft_max][crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max].
5901 ///
5902 /// # Example
5903 /// ```ignore,no_run
5904 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5905 /// let x = LoadLimit::new().set_cost_per_unit_above_soft_max(42.0);
5906 /// ```
5907 pub fn set_cost_per_unit_above_soft_max<T: std::convert::Into<f64>>(
5908 mut self,
5909 v: T,
5910 ) -> Self {
5911 self.cost_per_unit_above_soft_max = v.into();
5912 self
5913 }
5914
5915 /// Sets the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
5916 ///
5917 /// # Example
5918 /// ```ignore,no_run
5919 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5920 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5921 /// let x = LoadLimit::new().set_start_load_interval(Interval::default()/* use setters */);
5922 /// ```
5923 pub fn set_start_load_interval<T>(mut self, v: T) -> Self
5924 where
5925 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5926 {
5927 self.start_load_interval = std::option::Option::Some(v.into());
5928 self
5929 }
5930
5931 /// Sets or clears the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
5932 ///
5933 /// # Example
5934 /// ```ignore,no_run
5935 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5936 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5937 /// let x = LoadLimit::new().set_or_clear_start_load_interval(Some(Interval::default()/* use setters */));
5938 /// let x = LoadLimit::new().set_or_clear_start_load_interval(None::<Interval>);
5939 /// ```
5940 pub fn set_or_clear_start_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
5941 where
5942 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5943 {
5944 self.start_load_interval = v.map(|x| x.into());
5945 self
5946 }
5947
5948 /// Sets the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
5949 ///
5950 /// # Example
5951 /// ```ignore,no_run
5952 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5953 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5954 /// let x = LoadLimit::new().set_end_load_interval(Interval::default()/* use setters */);
5955 /// ```
5956 pub fn set_end_load_interval<T>(mut self, v: T) -> Self
5957 where
5958 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5959 {
5960 self.end_load_interval = std::option::Option::Some(v.into());
5961 self
5962 }
5963
5964 /// Sets or clears the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
5965 ///
5966 /// # Example
5967 /// ```ignore,no_run
5968 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5969 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5970 /// let x = LoadLimit::new().set_or_clear_end_load_interval(Some(Interval::default()/* use setters */));
5971 /// let x = LoadLimit::new().set_or_clear_end_load_interval(None::<Interval>);
5972 /// ```
5973 pub fn set_or_clear_end_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
5974 where
5975 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5976 {
5977 self.end_load_interval = v.map(|x| x.into());
5978 self
5979 }
5980 }
5981
5982 impl wkt::message::Message for LoadLimit {
5983 fn typename() -> &'static str {
5984 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit"
5985 }
5986 }
5987
5988 /// Defines additional types related to [LoadLimit].
5989 pub mod load_limit {
5990 #[allow(unused_imports)]
5991 use super::*;
5992
5993 /// Interval of acceptable load amounts.
5994 #[derive(Clone, Default, PartialEq)]
5995 #[non_exhaustive]
5996 pub struct Interval {
5997 /// A minimum acceptable load. Must be ≥ 0.
5998 /// If they're both specified,
5999 /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
6000 /// be ≤
6001 /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
6002 ///
6003 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
6004 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
6005 pub min: i64,
6006
6007 /// A maximum acceptable load. Must be ≥ 0. If unspecified, the maximum
6008 /// load is unrestricted by this message.
6009 /// If they're both specified,
6010 /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
6011 /// be ≤
6012 /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
6013 ///
6014 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
6015 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
6016 pub max: std::option::Option<i64>,
6017
6018 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6019 }
6020
6021 impl Interval {
6022 /// Creates a new default instance.
6023 pub fn new() -> Self {
6024 std::default::Default::default()
6025 }
6026
6027 /// Sets the value of [min][crate::model::vehicle::load_limit::Interval::min].
6028 ///
6029 /// # Example
6030 /// ```ignore,no_run
6031 /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6032 /// let x = Interval::new().set_min(42);
6033 /// ```
6034 pub fn set_min<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6035 self.min = v.into();
6036 self
6037 }
6038
6039 /// Sets the value of [max][crate::model::vehicle::load_limit::Interval::max].
6040 ///
6041 /// # Example
6042 /// ```ignore,no_run
6043 /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6044 /// let x = Interval::new().set_max(42);
6045 /// ```
6046 pub fn set_max<T>(mut self, v: T) -> Self
6047 where
6048 T: std::convert::Into<i64>,
6049 {
6050 self.max = std::option::Option::Some(v.into());
6051 self
6052 }
6053
6054 /// Sets or clears the value of [max][crate::model::vehicle::load_limit::Interval::max].
6055 ///
6056 /// # Example
6057 /// ```ignore,no_run
6058 /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6059 /// let x = Interval::new().set_or_clear_max(Some(42));
6060 /// let x = Interval::new().set_or_clear_max(None::<i32>);
6061 /// ```
6062 pub fn set_or_clear_max<T>(mut self, v: std::option::Option<T>) -> Self
6063 where
6064 T: std::convert::Into<i64>,
6065 {
6066 self.max = v.map(|x| x.into());
6067 self
6068 }
6069 }
6070
6071 impl wkt::message::Message for Interval {
6072 fn typename() -> &'static str {
6073 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit.Interval"
6074 }
6075 }
6076 }
6077
6078 /// A limit defining a maximum duration of the route of a vehicle. It can be
6079 /// either hard or soft.
6080 ///
6081 /// When a soft limit field is defined, both the soft max threshold and its
6082 /// associated cost must be defined together.
6083 #[derive(Clone, Default, PartialEq)]
6084 #[non_exhaustive]
6085 pub struct DurationLimit {
6086 /// A hard limit constraining the duration to be at most max_duration.
6087 pub max_duration: std::option::Option<wkt::Duration>,
6088
6089 /// A soft limit not enforcing a maximum duration limit, but when violated
6090 /// makes the route incur a cost. This cost adds up to other costs defined in
6091 /// the model, with the same unit.
6092 ///
6093 /// If defined, `soft_max_duration` must be nonnegative. If max_duration is
6094 /// also defined, `soft_max_duration` must be less than max_duration.
6095 pub soft_max_duration: std::option::Option<wkt::Duration>,
6096
6097 /// Cost per hour incurred if the `soft_max_duration` threshold is violated.
6098 /// The additional cost is 0 if the duration is under the threshold,
6099 /// otherwise the cost depends on the duration as follows:
6100 ///
6101 /// ```norust
6102 /// cost_per_hour_after_soft_max * (duration - soft_max_duration)
6103 /// ```
6104 ///
6105 /// The cost must be nonnegative.
6106 pub cost_per_hour_after_soft_max: std::option::Option<f64>,
6107
6108 /// A soft limit not enforcing a maximum duration limit, but when violated
6109 /// makes the route incur a cost, quadratic in the duration. This cost adds
6110 /// up to other costs defined in the model, with the same unit.
6111 ///
6112 /// If defined, `quadratic_soft_max_duration` must be nonnegative. If
6113 /// `max_duration` is also defined, `quadratic_soft_max_duration` must be
6114 /// less than `max_duration`, and the difference must be no larger than one
6115 /// day:
6116 ///
6117 /// `max_duration - quadratic_soft_max_duration <= 86400 seconds`
6118 pub quadratic_soft_max_duration: std::option::Option<wkt::Duration>,
6119
6120 /// Cost per square hour incurred if the
6121 /// `quadratic_soft_max_duration` threshold is violated.
6122 ///
6123 /// The additional cost is 0 if the duration is under the threshold,
6124 /// otherwise the cost depends on the duration as follows:
6125 ///
6126 /// ```norust
6127 /// cost_per_square_hour_after_quadratic_soft_max *
6128 /// (duration - quadratic_soft_max_duration)^2
6129 /// ```
6130 ///
6131 /// The cost must be nonnegative.
6132 pub cost_per_square_hour_after_quadratic_soft_max: std::option::Option<f64>,
6133
6134 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6135 }
6136
6137 impl DurationLimit {
6138 /// Creates a new default instance.
6139 pub fn new() -> Self {
6140 std::default::Default::default()
6141 }
6142
6143 /// Sets the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
6144 ///
6145 /// # Example
6146 /// ```ignore,no_run
6147 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6148 /// use wkt::Duration;
6149 /// let x = DurationLimit::new().set_max_duration(Duration::default()/* use setters */);
6150 /// ```
6151 pub fn set_max_duration<T>(mut self, v: T) -> Self
6152 where
6153 T: std::convert::Into<wkt::Duration>,
6154 {
6155 self.max_duration = std::option::Option::Some(v.into());
6156 self
6157 }
6158
6159 /// Sets or clears the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
6160 ///
6161 /// # Example
6162 /// ```ignore,no_run
6163 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6164 /// use wkt::Duration;
6165 /// let x = DurationLimit::new().set_or_clear_max_duration(Some(Duration::default()/* use setters */));
6166 /// let x = DurationLimit::new().set_or_clear_max_duration(None::<Duration>);
6167 /// ```
6168 pub fn set_or_clear_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
6169 where
6170 T: std::convert::Into<wkt::Duration>,
6171 {
6172 self.max_duration = v.map(|x| x.into());
6173 self
6174 }
6175
6176 /// Sets the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
6177 ///
6178 /// # Example
6179 /// ```ignore,no_run
6180 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6181 /// use wkt::Duration;
6182 /// let x = DurationLimit::new().set_soft_max_duration(Duration::default()/* use setters */);
6183 /// ```
6184 pub fn set_soft_max_duration<T>(mut self, v: T) -> Self
6185 where
6186 T: std::convert::Into<wkt::Duration>,
6187 {
6188 self.soft_max_duration = std::option::Option::Some(v.into());
6189 self
6190 }
6191
6192 /// Sets or clears the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
6193 ///
6194 /// # Example
6195 /// ```ignore,no_run
6196 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6197 /// use wkt::Duration;
6198 /// let x = DurationLimit::new().set_or_clear_soft_max_duration(Some(Duration::default()/* use setters */));
6199 /// let x = DurationLimit::new().set_or_clear_soft_max_duration(None::<Duration>);
6200 /// ```
6201 pub fn set_or_clear_soft_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
6202 where
6203 T: std::convert::Into<wkt::Duration>,
6204 {
6205 self.soft_max_duration = v.map(|x| x.into());
6206 self
6207 }
6208
6209 /// Sets the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
6210 ///
6211 /// # Example
6212 /// ```ignore,no_run
6213 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6214 /// let x = DurationLimit::new().set_cost_per_hour_after_soft_max(42.0);
6215 /// ```
6216 pub fn set_cost_per_hour_after_soft_max<T>(mut self, v: T) -> Self
6217 where
6218 T: std::convert::Into<f64>,
6219 {
6220 self.cost_per_hour_after_soft_max = std::option::Option::Some(v.into());
6221 self
6222 }
6223
6224 /// Sets or clears the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
6225 ///
6226 /// # Example
6227 /// ```ignore,no_run
6228 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6229 /// let x = DurationLimit::new().set_or_clear_cost_per_hour_after_soft_max(Some(42.0));
6230 /// let x = DurationLimit::new().set_or_clear_cost_per_hour_after_soft_max(None::<f32>);
6231 /// ```
6232 pub fn set_or_clear_cost_per_hour_after_soft_max<T>(
6233 mut self,
6234 v: std::option::Option<T>,
6235 ) -> Self
6236 where
6237 T: std::convert::Into<f64>,
6238 {
6239 self.cost_per_hour_after_soft_max = v.map(|x| x.into());
6240 self
6241 }
6242
6243 /// Sets the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
6244 ///
6245 /// # Example
6246 /// ```ignore,no_run
6247 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6248 /// use wkt::Duration;
6249 /// let x = DurationLimit::new().set_quadratic_soft_max_duration(Duration::default()/* use setters */);
6250 /// ```
6251 pub fn set_quadratic_soft_max_duration<T>(mut self, v: T) -> Self
6252 where
6253 T: std::convert::Into<wkt::Duration>,
6254 {
6255 self.quadratic_soft_max_duration = std::option::Option::Some(v.into());
6256 self
6257 }
6258
6259 /// Sets or clears the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
6260 ///
6261 /// # Example
6262 /// ```ignore,no_run
6263 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6264 /// use wkt::Duration;
6265 /// let x = DurationLimit::new().set_or_clear_quadratic_soft_max_duration(Some(Duration::default()/* use setters */));
6266 /// let x = DurationLimit::new().set_or_clear_quadratic_soft_max_duration(None::<Duration>);
6267 /// ```
6268 pub fn set_or_clear_quadratic_soft_max_duration<T>(
6269 mut self,
6270 v: std::option::Option<T>,
6271 ) -> Self
6272 where
6273 T: std::convert::Into<wkt::Duration>,
6274 {
6275 self.quadratic_soft_max_duration = v.map(|x| x.into());
6276 self
6277 }
6278
6279 /// Sets the value of [cost_per_square_hour_after_quadratic_soft_max][crate::model::vehicle::DurationLimit::cost_per_square_hour_after_quadratic_soft_max].
6280 ///
6281 /// # Example
6282 /// ```ignore,no_run
6283 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6284 /// let x = DurationLimit::new().set_cost_per_square_hour_after_quadratic_soft_max(42.0);
6285 /// ```
6286 pub fn set_cost_per_square_hour_after_quadratic_soft_max<T>(mut self, v: T) -> Self
6287 where
6288 T: std::convert::Into<f64>,
6289 {
6290 self.cost_per_square_hour_after_quadratic_soft_max =
6291 std::option::Option::Some(v.into());
6292 self
6293 }
6294
6295 /// Sets or clears the value of [cost_per_square_hour_after_quadratic_soft_max][crate::model::vehicle::DurationLimit::cost_per_square_hour_after_quadratic_soft_max].
6296 ///
6297 /// # Example
6298 /// ```ignore,no_run
6299 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6300 /// let x = DurationLimit::new().set_or_clear_cost_per_square_hour_after_quadratic_soft_max(Some(42.0));
6301 /// let x = DurationLimit::new().set_or_clear_cost_per_square_hour_after_quadratic_soft_max(None::<f32>);
6302 /// ```
6303 pub fn set_or_clear_cost_per_square_hour_after_quadratic_soft_max<T>(
6304 mut self,
6305 v: std::option::Option<T>,
6306 ) -> Self
6307 where
6308 T: std::convert::Into<f64>,
6309 {
6310 self.cost_per_square_hour_after_quadratic_soft_max = v.map(|x| x.into());
6311 self
6312 }
6313 }
6314
6315 impl wkt::message::Message for DurationLimit {
6316 fn typename() -> &'static str {
6317 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.DurationLimit"
6318 }
6319 }
6320
6321 /// Travel modes which can be used by vehicles.
6322 ///
6323 /// These should be a subset of the Google Maps Platform Routes Preferred API
6324 /// travel modes, see:
6325 /// <https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelMode>.
6326 ///
6327 /// # Working with unknown values
6328 ///
6329 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6330 /// additional enum variants at any time. Adding new variants is not considered
6331 /// a breaking change. Applications should write their code in anticipation of:
6332 ///
6333 /// - New values appearing in future releases of the client library, **and**
6334 /// - New values received dynamically, without application changes.
6335 ///
6336 /// Please consult the [Working with enums] section in the user guide for some
6337 /// guidelines.
6338 ///
6339 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6340 #[derive(Clone, Debug, PartialEq)]
6341 #[non_exhaustive]
6342 pub enum TravelMode {
6343 /// Unspecified travel mode, equivalent to `DRIVING`.
6344 Unspecified,
6345 /// Travel mode corresponding to driving directions (car, ...).
6346 Driving,
6347 /// Travel mode corresponding to walking directions.
6348 Walking,
6349 /// If set, the enum was initialized with an unknown value.
6350 ///
6351 /// Applications can examine the value using [TravelMode::value] or
6352 /// [TravelMode::name].
6353 UnknownValue(travel_mode::UnknownValue),
6354 }
6355
6356 #[doc(hidden)]
6357 pub mod travel_mode {
6358 #[allow(unused_imports)]
6359 use super::*;
6360 #[derive(Clone, Debug, PartialEq)]
6361 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6362 }
6363
6364 impl TravelMode {
6365 /// Gets the enum value.
6366 ///
6367 /// Returns `None` if the enum contains an unknown value deserialized from
6368 /// the string representation of enums.
6369 pub fn value(&self) -> std::option::Option<i32> {
6370 match self {
6371 Self::Unspecified => std::option::Option::Some(0),
6372 Self::Driving => std::option::Option::Some(1),
6373 Self::Walking => std::option::Option::Some(2),
6374 Self::UnknownValue(u) => u.0.value(),
6375 }
6376 }
6377
6378 /// Gets the enum value as a string.
6379 ///
6380 /// Returns `None` if the enum contains an unknown value deserialized from
6381 /// the integer representation of enums.
6382 pub fn name(&self) -> std::option::Option<&str> {
6383 match self {
6384 Self::Unspecified => std::option::Option::Some("TRAVEL_MODE_UNSPECIFIED"),
6385 Self::Driving => std::option::Option::Some("DRIVING"),
6386 Self::Walking => std::option::Option::Some("WALKING"),
6387 Self::UnknownValue(u) => u.0.name(),
6388 }
6389 }
6390 }
6391
6392 impl std::default::Default for TravelMode {
6393 fn default() -> Self {
6394 use std::convert::From;
6395 Self::from(0)
6396 }
6397 }
6398
6399 impl std::fmt::Display for TravelMode {
6400 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6401 wkt::internal::display_enum(f, self.name(), self.value())
6402 }
6403 }
6404
6405 impl std::convert::From<i32> for TravelMode {
6406 fn from(value: i32) -> Self {
6407 match value {
6408 0 => Self::Unspecified,
6409 1 => Self::Driving,
6410 2 => Self::Walking,
6411 _ => Self::UnknownValue(travel_mode::UnknownValue(
6412 wkt::internal::UnknownEnumValue::Integer(value),
6413 )),
6414 }
6415 }
6416 }
6417
6418 impl std::convert::From<&str> for TravelMode {
6419 fn from(value: &str) -> Self {
6420 use std::string::ToString;
6421 match value {
6422 "TRAVEL_MODE_UNSPECIFIED" => Self::Unspecified,
6423 "DRIVING" => Self::Driving,
6424 "WALKING" => Self::Walking,
6425 _ => Self::UnknownValue(travel_mode::UnknownValue(
6426 wkt::internal::UnknownEnumValue::String(value.to_string()),
6427 )),
6428 }
6429 }
6430 }
6431
6432 impl serde::ser::Serialize for TravelMode {
6433 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6434 where
6435 S: serde::Serializer,
6436 {
6437 match self {
6438 Self::Unspecified => serializer.serialize_i32(0),
6439 Self::Driving => serializer.serialize_i32(1),
6440 Self::Walking => serializer.serialize_i32(2),
6441 Self::UnknownValue(u) => u.0.serialize(serializer),
6442 }
6443 }
6444 }
6445
6446 impl<'de> serde::de::Deserialize<'de> for TravelMode {
6447 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6448 where
6449 D: serde::Deserializer<'de>,
6450 {
6451 deserializer.deserialize_any(wkt::internal::EnumVisitor::<TravelMode>::new(
6452 ".google.cloud.optimization.v1.Vehicle.TravelMode",
6453 ))
6454 }
6455 }
6456
6457 /// Policy on how a vehicle can be unloaded. Applies only to shipments having
6458 /// both a pickup and a delivery.
6459 ///
6460 /// Other shipments are free to occur anywhere on the route independent of
6461 /// `unloading_policy`.
6462 ///
6463 /// # Working with unknown values
6464 ///
6465 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6466 /// additional enum variants at any time. Adding new variants is not considered
6467 /// a breaking change. Applications should write their code in anticipation of:
6468 ///
6469 /// - New values appearing in future releases of the client library, **and**
6470 /// - New values received dynamically, without application changes.
6471 ///
6472 /// Please consult the [Working with enums] section in the user guide for some
6473 /// guidelines.
6474 ///
6475 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6476 #[derive(Clone, Debug, PartialEq)]
6477 #[non_exhaustive]
6478 pub enum UnloadingPolicy {
6479 /// Unspecified unloading policy; deliveries must just occur after their
6480 /// corresponding pickups.
6481 Unspecified,
6482 /// Deliveries must occur in reverse order of pickups
6483 LastInFirstOut,
6484 /// Deliveries must occur in the same order as pickups
6485 FirstInFirstOut,
6486 /// If set, the enum was initialized with an unknown value.
6487 ///
6488 /// Applications can examine the value using [UnloadingPolicy::value] or
6489 /// [UnloadingPolicy::name].
6490 UnknownValue(unloading_policy::UnknownValue),
6491 }
6492
6493 #[doc(hidden)]
6494 pub mod unloading_policy {
6495 #[allow(unused_imports)]
6496 use super::*;
6497 #[derive(Clone, Debug, PartialEq)]
6498 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6499 }
6500
6501 impl UnloadingPolicy {
6502 /// Gets the enum value.
6503 ///
6504 /// Returns `None` if the enum contains an unknown value deserialized from
6505 /// the string representation of enums.
6506 pub fn value(&self) -> std::option::Option<i32> {
6507 match self {
6508 Self::Unspecified => std::option::Option::Some(0),
6509 Self::LastInFirstOut => std::option::Option::Some(1),
6510 Self::FirstInFirstOut => std::option::Option::Some(2),
6511 Self::UnknownValue(u) => u.0.value(),
6512 }
6513 }
6514
6515 /// Gets the enum value as a string.
6516 ///
6517 /// Returns `None` if the enum contains an unknown value deserialized from
6518 /// the integer representation of enums.
6519 pub fn name(&self) -> std::option::Option<&str> {
6520 match self {
6521 Self::Unspecified => std::option::Option::Some("UNLOADING_POLICY_UNSPECIFIED"),
6522 Self::LastInFirstOut => std::option::Option::Some("LAST_IN_FIRST_OUT"),
6523 Self::FirstInFirstOut => std::option::Option::Some("FIRST_IN_FIRST_OUT"),
6524 Self::UnknownValue(u) => u.0.name(),
6525 }
6526 }
6527 }
6528
6529 impl std::default::Default for UnloadingPolicy {
6530 fn default() -> Self {
6531 use std::convert::From;
6532 Self::from(0)
6533 }
6534 }
6535
6536 impl std::fmt::Display for UnloadingPolicy {
6537 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6538 wkt::internal::display_enum(f, self.name(), self.value())
6539 }
6540 }
6541
6542 impl std::convert::From<i32> for UnloadingPolicy {
6543 fn from(value: i32) -> Self {
6544 match value {
6545 0 => Self::Unspecified,
6546 1 => Self::LastInFirstOut,
6547 2 => Self::FirstInFirstOut,
6548 _ => Self::UnknownValue(unloading_policy::UnknownValue(
6549 wkt::internal::UnknownEnumValue::Integer(value),
6550 )),
6551 }
6552 }
6553 }
6554
6555 impl std::convert::From<&str> for UnloadingPolicy {
6556 fn from(value: &str) -> Self {
6557 use std::string::ToString;
6558 match value {
6559 "UNLOADING_POLICY_UNSPECIFIED" => Self::Unspecified,
6560 "LAST_IN_FIRST_OUT" => Self::LastInFirstOut,
6561 "FIRST_IN_FIRST_OUT" => Self::FirstInFirstOut,
6562 _ => Self::UnknownValue(unloading_policy::UnknownValue(
6563 wkt::internal::UnknownEnumValue::String(value.to_string()),
6564 )),
6565 }
6566 }
6567 }
6568
6569 impl serde::ser::Serialize for UnloadingPolicy {
6570 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6571 where
6572 S: serde::Serializer,
6573 {
6574 match self {
6575 Self::Unspecified => serializer.serialize_i32(0),
6576 Self::LastInFirstOut => serializer.serialize_i32(1),
6577 Self::FirstInFirstOut => serializer.serialize_i32(2),
6578 Self::UnknownValue(u) => u.0.serialize(serializer),
6579 }
6580 }
6581 }
6582
6583 impl<'de> serde::de::Deserialize<'de> for UnloadingPolicy {
6584 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6585 where
6586 D: serde::Deserializer<'de>,
6587 {
6588 deserializer.deserialize_any(wkt::internal::EnumVisitor::<UnloadingPolicy>::new(
6589 ".google.cloud.optimization.v1.Vehicle.UnloadingPolicy",
6590 ))
6591 }
6592 }
6593}
6594
6595/// Time windows constrain the time of an event, such as the arrival time at a
6596/// visit, or the start and end time of a vehicle.
6597///
6598/// Hard time window bounds, `start_time` and `end_time`, enforce the earliest
6599/// and latest time of the event, such that `start_time <= event_time <=
6600/// end_time`. The soft time window lower bound, `soft_start_time`, expresses a
6601/// preference for the event to happen at or after `soft_start_time` by incurring
6602/// a cost proportional to how long before soft_start_time the event occurs. The
6603/// soft time window upper bound, `soft_end_time`, expresses a preference for the
6604/// event to happen at or before `soft_end_time` by incurring a cost proportional
6605/// to how long after `soft_end_time` the event occurs. `start_time`, `end_time`,
6606/// `soft_start_time` and `soft_end_time` should be within the global time limits
6607/// (see
6608/// [ShipmentModel.global_start_time][google.cloud.optimization.v1.ShipmentModel.global_start_time]
6609/// and
6610/// [ShipmentModel.global_end_time][google.cloud.optimization.v1.ShipmentModel.global_end_time])
6611/// and should respect:
6612///
6613/// ```norust
6614/// 0 <= `start_time` <= `soft_start_time` <= `end_time` and
6615/// 0 <= `start_time` <= `soft_end_time` <= `end_time`.
6616/// ```
6617///
6618/// [google.cloud.optimization.v1.ShipmentModel.global_end_time]: crate::model::ShipmentModel::global_end_time
6619/// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
6620#[derive(Clone, Default, PartialEq)]
6621#[non_exhaustive]
6622pub struct TimeWindow {
6623 /// The hard time window start time. If unspecified it will be set to
6624 /// `ShipmentModel.global_start_time`.
6625 pub start_time: std::option::Option<wkt::Timestamp>,
6626
6627 /// The hard time window end time. If unspecified it will be set to
6628 /// `ShipmentModel.global_end_time`.
6629 pub end_time: std::option::Option<wkt::Timestamp>,
6630
6631 /// The soft start time of the time window.
6632 pub soft_start_time: std::option::Option<wkt::Timestamp>,
6633
6634 /// The soft end time of the time window.
6635 pub soft_end_time: std::option::Option<wkt::Timestamp>,
6636
6637 /// A cost per hour added to other costs in the model if the event occurs
6638 /// before soft_start_time, computed as:
6639 ///
6640 /// ```norust
6641 /// max(0, soft_start_time - t.seconds)
6642 /// * cost_per_hour_before_soft_start_time / 3600,
6643 /// t being the time of the event.
6644 /// ```
6645 ///
6646 /// This cost must be positive, and the field can only be set if
6647 /// soft_start_time has been set.
6648 pub cost_per_hour_before_soft_start_time: std::option::Option<f64>,
6649
6650 /// A cost per hour added to other costs in the model if the event occurs after
6651 /// `soft_end_time`, computed as:
6652 ///
6653 /// ```norust
6654 /// max(0, t.seconds - soft_end_time.seconds)
6655 /// * cost_per_hour_after_soft_end_time / 3600,
6656 /// t being the time of the event.
6657 /// ```
6658 ///
6659 /// This cost must be positive, and the field can only be set if
6660 /// `soft_end_time` has been set.
6661 pub cost_per_hour_after_soft_end_time: std::option::Option<f64>,
6662
6663 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6664}
6665
6666impl TimeWindow {
6667 /// Creates a new default instance.
6668 pub fn new() -> Self {
6669 std::default::Default::default()
6670 }
6671
6672 /// Sets the value of [start_time][crate::model::TimeWindow::start_time].
6673 ///
6674 /// # Example
6675 /// ```ignore,no_run
6676 /// # use google_cloud_optimization_v1::model::TimeWindow;
6677 /// use wkt::Timestamp;
6678 /// let x = TimeWindow::new().set_start_time(Timestamp::default()/* use setters */);
6679 /// ```
6680 pub fn set_start_time<T>(mut self, v: T) -> Self
6681 where
6682 T: std::convert::Into<wkt::Timestamp>,
6683 {
6684 self.start_time = std::option::Option::Some(v.into());
6685 self
6686 }
6687
6688 /// Sets or clears the value of [start_time][crate::model::TimeWindow::start_time].
6689 ///
6690 /// # Example
6691 /// ```ignore,no_run
6692 /// # use google_cloud_optimization_v1::model::TimeWindow;
6693 /// use wkt::Timestamp;
6694 /// let x = TimeWindow::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
6695 /// let x = TimeWindow::new().set_or_clear_start_time(None::<Timestamp>);
6696 /// ```
6697 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6698 where
6699 T: std::convert::Into<wkt::Timestamp>,
6700 {
6701 self.start_time = v.map(|x| x.into());
6702 self
6703 }
6704
6705 /// Sets the value of [end_time][crate::model::TimeWindow::end_time].
6706 ///
6707 /// # Example
6708 /// ```ignore,no_run
6709 /// # use google_cloud_optimization_v1::model::TimeWindow;
6710 /// use wkt::Timestamp;
6711 /// let x = TimeWindow::new().set_end_time(Timestamp::default()/* use setters */);
6712 /// ```
6713 pub fn set_end_time<T>(mut self, v: T) -> Self
6714 where
6715 T: std::convert::Into<wkt::Timestamp>,
6716 {
6717 self.end_time = std::option::Option::Some(v.into());
6718 self
6719 }
6720
6721 /// Sets or clears the value of [end_time][crate::model::TimeWindow::end_time].
6722 ///
6723 /// # Example
6724 /// ```ignore,no_run
6725 /// # use google_cloud_optimization_v1::model::TimeWindow;
6726 /// use wkt::Timestamp;
6727 /// let x = TimeWindow::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
6728 /// let x = TimeWindow::new().set_or_clear_end_time(None::<Timestamp>);
6729 /// ```
6730 pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
6731 where
6732 T: std::convert::Into<wkt::Timestamp>,
6733 {
6734 self.end_time = v.map(|x| x.into());
6735 self
6736 }
6737
6738 /// Sets the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
6739 ///
6740 /// # Example
6741 /// ```ignore,no_run
6742 /// # use google_cloud_optimization_v1::model::TimeWindow;
6743 /// use wkt::Timestamp;
6744 /// let x = TimeWindow::new().set_soft_start_time(Timestamp::default()/* use setters */);
6745 /// ```
6746 pub fn set_soft_start_time<T>(mut self, v: T) -> Self
6747 where
6748 T: std::convert::Into<wkt::Timestamp>,
6749 {
6750 self.soft_start_time = std::option::Option::Some(v.into());
6751 self
6752 }
6753
6754 /// Sets or clears the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
6755 ///
6756 /// # Example
6757 /// ```ignore,no_run
6758 /// # use google_cloud_optimization_v1::model::TimeWindow;
6759 /// use wkt::Timestamp;
6760 /// let x = TimeWindow::new().set_or_clear_soft_start_time(Some(Timestamp::default()/* use setters */));
6761 /// let x = TimeWindow::new().set_or_clear_soft_start_time(None::<Timestamp>);
6762 /// ```
6763 pub fn set_or_clear_soft_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6764 where
6765 T: std::convert::Into<wkt::Timestamp>,
6766 {
6767 self.soft_start_time = v.map(|x| x.into());
6768 self
6769 }
6770
6771 /// Sets the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
6772 ///
6773 /// # Example
6774 /// ```ignore,no_run
6775 /// # use google_cloud_optimization_v1::model::TimeWindow;
6776 /// use wkt::Timestamp;
6777 /// let x = TimeWindow::new().set_soft_end_time(Timestamp::default()/* use setters */);
6778 /// ```
6779 pub fn set_soft_end_time<T>(mut self, v: T) -> Self
6780 where
6781 T: std::convert::Into<wkt::Timestamp>,
6782 {
6783 self.soft_end_time = std::option::Option::Some(v.into());
6784 self
6785 }
6786
6787 /// Sets or clears the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
6788 ///
6789 /// # Example
6790 /// ```ignore,no_run
6791 /// # use google_cloud_optimization_v1::model::TimeWindow;
6792 /// use wkt::Timestamp;
6793 /// let x = TimeWindow::new().set_or_clear_soft_end_time(Some(Timestamp::default()/* use setters */));
6794 /// let x = TimeWindow::new().set_or_clear_soft_end_time(None::<Timestamp>);
6795 /// ```
6796 pub fn set_or_clear_soft_end_time<T>(mut self, v: std::option::Option<T>) -> Self
6797 where
6798 T: std::convert::Into<wkt::Timestamp>,
6799 {
6800 self.soft_end_time = v.map(|x| x.into());
6801 self
6802 }
6803
6804 /// Sets the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
6805 ///
6806 /// # Example
6807 /// ```ignore,no_run
6808 /// # use google_cloud_optimization_v1::model::TimeWindow;
6809 /// let x = TimeWindow::new().set_cost_per_hour_before_soft_start_time(42.0);
6810 /// ```
6811 pub fn set_cost_per_hour_before_soft_start_time<T>(mut self, v: T) -> Self
6812 where
6813 T: std::convert::Into<f64>,
6814 {
6815 self.cost_per_hour_before_soft_start_time = std::option::Option::Some(v.into());
6816 self
6817 }
6818
6819 /// Sets or clears the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
6820 ///
6821 /// # Example
6822 /// ```ignore,no_run
6823 /// # use google_cloud_optimization_v1::model::TimeWindow;
6824 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_before_soft_start_time(Some(42.0));
6825 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_before_soft_start_time(None::<f32>);
6826 /// ```
6827 pub fn set_or_clear_cost_per_hour_before_soft_start_time<T>(
6828 mut self,
6829 v: std::option::Option<T>,
6830 ) -> Self
6831 where
6832 T: std::convert::Into<f64>,
6833 {
6834 self.cost_per_hour_before_soft_start_time = v.map(|x| x.into());
6835 self
6836 }
6837
6838 /// Sets the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
6839 ///
6840 /// # Example
6841 /// ```ignore,no_run
6842 /// # use google_cloud_optimization_v1::model::TimeWindow;
6843 /// let x = TimeWindow::new().set_cost_per_hour_after_soft_end_time(42.0);
6844 /// ```
6845 pub fn set_cost_per_hour_after_soft_end_time<T>(mut self, v: T) -> Self
6846 where
6847 T: std::convert::Into<f64>,
6848 {
6849 self.cost_per_hour_after_soft_end_time = std::option::Option::Some(v.into());
6850 self
6851 }
6852
6853 /// Sets or clears the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
6854 ///
6855 /// # Example
6856 /// ```ignore,no_run
6857 /// # use google_cloud_optimization_v1::model::TimeWindow;
6858 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_after_soft_end_time(Some(42.0));
6859 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_after_soft_end_time(None::<f32>);
6860 /// ```
6861 pub fn set_or_clear_cost_per_hour_after_soft_end_time<T>(
6862 mut self,
6863 v: std::option::Option<T>,
6864 ) -> Self
6865 where
6866 T: std::convert::Into<f64>,
6867 {
6868 self.cost_per_hour_after_soft_end_time = v.map(|x| x.into());
6869 self
6870 }
6871}
6872
6873impl wkt::message::Message for TimeWindow {
6874 fn typename() -> &'static str {
6875 "type.googleapis.com/google.cloud.optimization.v1.TimeWindow"
6876 }
6877}
6878
6879/// Deprecated: Use
6880/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
6881/// instead.
6882///
6883/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
6884#[derive(Clone, Default, PartialEq)]
6885#[non_exhaustive]
6886#[deprecated]
6887pub struct CapacityQuantity {
6888 #[allow(missing_docs)]
6889 pub r#type: std::string::String,
6890
6891 #[allow(missing_docs)]
6892 pub value: i64,
6893
6894 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6895}
6896
6897impl CapacityQuantity {
6898 /// Creates a new default instance.
6899 pub fn new() -> Self {
6900 std::default::Default::default()
6901 }
6902
6903 /// Sets the value of [r#type][crate::model::CapacityQuantity::type].
6904 ///
6905 /// # Example
6906 /// ```ignore,no_run
6907 /// # use google_cloud_optimization_v1::model::CapacityQuantity;
6908 /// let x = CapacityQuantity::new().set_type("example");
6909 /// ```
6910 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6911 self.r#type = v.into();
6912 self
6913 }
6914
6915 /// Sets the value of [value][crate::model::CapacityQuantity::value].
6916 ///
6917 /// # Example
6918 /// ```ignore,no_run
6919 /// # use google_cloud_optimization_v1::model::CapacityQuantity;
6920 /// let x = CapacityQuantity::new().set_value(42);
6921 /// ```
6922 pub fn set_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6923 self.value = v.into();
6924 self
6925 }
6926}
6927
6928impl wkt::message::Message for CapacityQuantity {
6929 fn typename() -> &'static str {
6930 "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantity"
6931 }
6932}
6933
6934/// Deprecated: Use
6935/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
6936/// instead.
6937///
6938/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
6939#[derive(Clone, Default, PartialEq)]
6940#[non_exhaustive]
6941#[deprecated]
6942pub struct CapacityQuantityInterval {
6943 #[allow(missing_docs)]
6944 pub r#type: std::string::String,
6945
6946 #[allow(missing_docs)]
6947 pub min_value: std::option::Option<i64>,
6948
6949 #[allow(missing_docs)]
6950 pub max_value: std::option::Option<i64>,
6951
6952 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6953}
6954
6955impl CapacityQuantityInterval {
6956 /// Creates a new default instance.
6957 pub fn new() -> Self {
6958 std::default::Default::default()
6959 }
6960
6961 /// Sets the value of [r#type][crate::model::CapacityQuantityInterval::type].
6962 ///
6963 /// # Example
6964 /// ```ignore,no_run
6965 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6966 /// let x = CapacityQuantityInterval::new().set_type("example");
6967 /// ```
6968 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6969 self.r#type = v.into();
6970 self
6971 }
6972
6973 /// Sets the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
6974 ///
6975 /// # Example
6976 /// ```ignore,no_run
6977 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6978 /// let x = CapacityQuantityInterval::new().set_min_value(42);
6979 /// ```
6980 pub fn set_min_value<T>(mut self, v: T) -> Self
6981 where
6982 T: std::convert::Into<i64>,
6983 {
6984 self.min_value = std::option::Option::Some(v.into());
6985 self
6986 }
6987
6988 /// Sets or clears the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
6989 ///
6990 /// # Example
6991 /// ```ignore,no_run
6992 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6993 /// let x = CapacityQuantityInterval::new().set_or_clear_min_value(Some(42));
6994 /// let x = CapacityQuantityInterval::new().set_or_clear_min_value(None::<i32>);
6995 /// ```
6996 pub fn set_or_clear_min_value<T>(mut self, v: std::option::Option<T>) -> Self
6997 where
6998 T: std::convert::Into<i64>,
6999 {
7000 self.min_value = v.map(|x| x.into());
7001 self
7002 }
7003
7004 /// Sets the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
7005 ///
7006 /// # Example
7007 /// ```ignore,no_run
7008 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
7009 /// let x = CapacityQuantityInterval::new().set_max_value(42);
7010 /// ```
7011 pub fn set_max_value<T>(mut self, v: T) -> Self
7012 where
7013 T: std::convert::Into<i64>,
7014 {
7015 self.max_value = std::option::Option::Some(v.into());
7016 self
7017 }
7018
7019 /// Sets or clears the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
7020 ///
7021 /// # Example
7022 /// ```ignore,no_run
7023 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
7024 /// let x = CapacityQuantityInterval::new().set_or_clear_max_value(Some(42));
7025 /// let x = CapacityQuantityInterval::new().set_or_clear_max_value(None::<i32>);
7026 /// ```
7027 pub fn set_or_clear_max_value<T>(mut self, v: std::option::Option<T>) -> Self
7028 where
7029 T: std::convert::Into<i64>,
7030 {
7031 self.max_value = v.map(|x| x.into());
7032 self
7033 }
7034}
7035
7036impl wkt::message::Message for CapacityQuantityInterval {
7037 fn typename() -> &'static str {
7038 "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantityInterval"
7039 }
7040}
7041
7042/// A limit defining a maximum distance which can be traveled. It can be either
7043/// hard or soft.
7044///
7045/// If a soft limit is defined, both `soft_max_meters` and
7046/// `cost_per_kilometer_above_soft_max` must be defined and be nonnegative.
7047#[derive(Clone, Default, PartialEq)]
7048#[non_exhaustive]
7049pub struct DistanceLimit {
7050 /// A hard limit constraining the distance to be at most max_meters. The limit
7051 /// must be nonnegative.
7052 pub max_meters: std::option::Option<i64>,
7053
7054 /// A soft limit not enforcing a maximum distance limit, but when violated
7055 /// results in a cost which adds up to other costs defined in the model,
7056 /// with the same unit.
7057 ///
7058 /// If defined soft_max_meters must be less than max_meters and must be
7059 /// nonnegative.
7060 pub soft_max_meters: std::option::Option<i64>,
7061
7062 /// Cost per kilometer incurred, increasing up to `soft_max_meters`, with
7063 /// formula:
7064 ///
7065 /// ```norust
7066 /// min(distance_meters, soft_max_meters) / 1000.0 *
7067 /// cost_per_kilometer_below_soft_max.
7068 /// ```
7069 ///
7070 /// This cost is not supported in `route_distance_limit`.
7071 pub cost_per_kilometer_below_soft_max: std::option::Option<f64>,
7072
7073 /// Cost per kilometer incurred if distance is above `soft_max_meters` limit.
7074 /// The additional cost is 0 if the distance is under the limit, otherwise the
7075 /// formula used to compute the cost is the following:
7076 ///
7077 /// ```norust
7078 /// (distance_meters - soft_max_meters) / 1000.0 *
7079 /// cost_per_kilometer_above_soft_max.
7080 /// ```
7081 ///
7082 /// The cost must be nonnegative.
7083 pub cost_per_kilometer_above_soft_max: std::option::Option<f64>,
7084
7085 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7086}
7087
7088impl DistanceLimit {
7089 /// Creates a new default instance.
7090 pub fn new() -> Self {
7091 std::default::Default::default()
7092 }
7093
7094 /// Sets the value of [max_meters][crate::model::DistanceLimit::max_meters].
7095 ///
7096 /// # Example
7097 /// ```ignore,no_run
7098 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7099 /// let x = DistanceLimit::new().set_max_meters(42);
7100 /// ```
7101 pub fn set_max_meters<T>(mut self, v: T) -> Self
7102 where
7103 T: std::convert::Into<i64>,
7104 {
7105 self.max_meters = std::option::Option::Some(v.into());
7106 self
7107 }
7108
7109 /// Sets or clears the value of [max_meters][crate::model::DistanceLimit::max_meters].
7110 ///
7111 /// # Example
7112 /// ```ignore,no_run
7113 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7114 /// let x = DistanceLimit::new().set_or_clear_max_meters(Some(42));
7115 /// let x = DistanceLimit::new().set_or_clear_max_meters(None::<i32>);
7116 /// ```
7117 pub fn set_or_clear_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
7118 where
7119 T: std::convert::Into<i64>,
7120 {
7121 self.max_meters = v.map(|x| x.into());
7122 self
7123 }
7124
7125 /// Sets the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
7126 ///
7127 /// # Example
7128 /// ```ignore,no_run
7129 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7130 /// let x = DistanceLimit::new().set_soft_max_meters(42);
7131 /// ```
7132 pub fn set_soft_max_meters<T>(mut self, v: T) -> Self
7133 where
7134 T: std::convert::Into<i64>,
7135 {
7136 self.soft_max_meters = std::option::Option::Some(v.into());
7137 self
7138 }
7139
7140 /// Sets or clears the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
7141 ///
7142 /// # Example
7143 /// ```ignore,no_run
7144 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7145 /// let x = DistanceLimit::new().set_or_clear_soft_max_meters(Some(42));
7146 /// let x = DistanceLimit::new().set_or_clear_soft_max_meters(None::<i32>);
7147 /// ```
7148 pub fn set_or_clear_soft_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
7149 where
7150 T: std::convert::Into<i64>,
7151 {
7152 self.soft_max_meters = v.map(|x| x.into());
7153 self
7154 }
7155
7156 /// Sets the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
7157 ///
7158 /// # Example
7159 /// ```ignore,no_run
7160 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7161 /// let x = DistanceLimit::new().set_cost_per_kilometer_below_soft_max(42.0);
7162 /// ```
7163 pub fn set_cost_per_kilometer_below_soft_max<T>(mut self, v: T) -> Self
7164 where
7165 T: std::convert::Into<f64>,
7166 {
7167 self.cost_per_kilometer_below_soft_max = std::option::Option::Some(v.into());
7168 self
7169 }
7170
7171 /// Sets or clears the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
7172 ///
7173 /// # Example
7174 /// ```ignore,no_run
7175 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7176 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_below_soft_max(Some(42.0));
7177 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_below_soft_max(None::<f32>);
7178 /// ```
7179 pub fn set_or_clear_cost_per_kilometer_below_soft_max<T>(
7180 mut self,
7181 v: std::option::Option<T>,
7182 ) -> Self
7183 where
7184 T: std::convert::Into<f64>,
7185 {
7186 self.cost_per_kilometer_below_soft_max = v.map(|x| x.into());
7187 self
7188 }
7189
7190 /// Sets the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
7191 ///
7192 /// # Example
7193 /// ```ignore,no_run
7194 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7195 /// let x = DistanceLimit::new().set_cost_per_kilometer_above_soft_max(42.0);
7196 /// ```
7197 pub fn set_cost_per_kilometer_above_soft_max<T>(mut self, v: T) -> Self
7198 where
7199 T: std::convert::Into<f64>,
7200 {
7201 self.cost_per_kilometer_above_soft_max = std::option::Option::Some(v.into());
7202 self
7203 }
7204
7205 /// Sets or clears the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
7206 ///
7207 /// # Example
7208 /// ```ignore,no_run
7209 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7210 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_above_soft_max(Some(42.0));
7211 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_above_soft_max(None::<f32>);
7212 /// ```
7213 pub fn set_or_clear_cost_per_kilometer_above_soft_max<T>(
7214 mut self,
7215 v: std::option::Option<T>,
7216 ) -> Self
7217 where
7218 T: std::convert::Into<f64>,
7219 {
7220 self.cost_per_kilometer_above_soft_max = v.map(|x| x.into());
7221 self
7222 }
7223}
7224
7225impl wkt::message::Message for DistanceLimit {
7226 fn typename() -> &'static str {
7227 "type.googleapis.com/google.cloud.optimization.v1.DistanceLimit"
7228 }
7229}
7230
7231/// Specifies attributes of transitions between two consecutive visits on a
7232/// route. Several `TransitionAttributes` may apply to the same transition: in
7233/// that case, all extra costs add up and the strictest constraint or limit
7234/// applies (following natural "AND" semantics).
7235#[derive(Clone, Default, PartialEq)]
7236#[non_exhaustive]
7237pub struct TransitionAttributes {
7238 /// Tags defining the set of (src->dst) transitions these attributes apply to.
7239 ///
7240 /// A source visit or vehicle start matches iff its
7241 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
7242 /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags]
7243 /// either contains `src_tag` or does not contain `excluded_src_tag` (depending
7244 /// on which of these two fields is non-empty).
7245 ///
7246 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
7247 /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
7248 pub src_tag: std::string::String,
7249
7250 /// See `src_tag`. Exactly one of `src_tag` and `excluded_src_tag` must be
7251 /// non-empty.
7252 pub excluded_src_tag: std::string::String,
7253
7254 /// A destination visit or vehicle end matches iff its
7255 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
7256 /// or [Vehicle.end_tags][google.cloud.optimization.v1.Vehicle.end_tags] either
7257 /// contains `dst_tag` or does not contain `excluded_dst_tag` (depending on
7258 /// which of these two fields is non-empty).
7259 ///
7260 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
7261 /// [google.cloud.optimization.v1.Vehicle.end_tags]: crate::model::Vehicle::end_tags
7262 pub dst_tag: std::string::String,
7263
7264 /// See `dst_tag`. Exactly one of `dst_tag` and `excluded_dst_tag` must be
7265 /// non-empty.
7266 pub excluded_dst_tag: std::string::String,
7267
7268 /// Specifies a cost for performing this transition. This is in the same unit
7269 /// as all other costs in the model and must not be negative. It is applied on
7270 /// top of all other existing costs.
7271 pub cost: f64,
7272
7273 /// Specifies a cost per kilometer applied to the distance traveled while
7274 /// performing this transition. It adds up to any
7275 /// [Vehicle.cost_per_kilometer][google.cloud.optimization.v1.Vehicle.cost_per_kilometer]
7276 /// specified on vehicles.
7277 ///
7278 /// [google.cloud.optimization.v1.Vehicle.cost_per_kilometer]: crate::model::Vehicle::cost_per_kilometer
7279 pub cost_per_kilometer: f64,
7280
7281 /// Specifies a limit on the distance traveled while performing this
7282 /// transition.
7283 ///
7284 /// As of 2021/06, only soft limits are supported.
7285 pub distance_limit: std::option::Option<crate::model::DistanceLimit>,
7286
7287 /// Specifies a delay incurred when performing this transition.
7288 ///
7289 /// This delay always occurs *after* finishing the source visit and *before*
7290 /// starting the destination visit.
7291 pub delay: std::option::Option<wkt::Duration>,
7292
7293 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7294}
7295
7296impl TransitionAttributes {
7297 /// Creates a new default instance.
7298 pub fn new() -> Self {
7299 std::default::Default::default()
7300 }
7301
7302 /// Sets the value of [src_tag][crate::model::TransitionAttributes::src_tag].
7303 ///
7304 /// # Example
7305 /// ```ignore,no_run
7306 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7307 /// let x = TransitionAttributes::new().set_src_tag("example");
7308 /// ```
7309 pub fn set_src_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7310 self.src_tag = v.into();
7311 self
7312 }
7313
7314 /// Sets the value of [excluded_src_tag][crate::model::TransitionAttributes::excluded_src_tag].
7315 ///
7316 /// # Example
7317 /// ```ignore,no_run
7318 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7319 /// let x = TransitionAttributes::new().set_excluded_src_tag("example");
7320 /// ```
7321 pub fn set_excluded_src_tag<T: std::convert::Into<std::string::String>>(
7322 mut self,
7323 v: T,
7324 ) -> Self {
7325 self.excluded_src_tag = v.into();
7326 self
7327 }
7328
7329 /// Sets the value of [dst_tag][crate::model::TransitionAttributes::dst_tag].
7330 ///
7331 /// # Example
7332 /// ```ignore,no_run
7333 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7334 /// let x = TransitionAttributes::new().set_dst_tag("example");
7335 /// ```
7336 pub fn set_dst_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7337 self.dst_tag = v.into();
7338 self
7339 }
7340
7341 /// Sets the value of [excluded_dst_tag][crate::model::TransitionAttributes::excluded_dst_tag].
7342 ///
7343 /// # Example
7344 /// ```ignore,no_run
7345 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7346 /// let x = TransitionAttributes::new().set_excluded_dst_tag("example");
7347 /// ```
7348 pub fn set_excluded_dst_tag<T: std::convert::Into<std::string::String>>(
7349 mut self,
7350 v: T,
7351 ) -> Self {
7352 self.excluded_dst_tag = v.into();
7353 self
7354 }
7355
7356 /// Sets the value of [cost][crate::model::TransitionAttributes::cost].
7357 ///
7358 /// # Example
7359 /// ```ignore,no_run
7360 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7361 /// let x = TransitionAttributes::new().set_cost(42.0);
7362 /// ```
7363 pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7364 self.cost = v.into();
7365 self
7366 }
7367
7368 /// Sets the value of [cost_per_kilometer][crate::model::TransitionAttributes::cost_per_kilometer].
7369 ///
7370 /// # Example
7371 /// ```ignore,no_run
7372 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7373 /// let x = TransitionAttributes::new().set_cost_per_kilometer(42.0);
7374 /// ```
7375 pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7376 self.cost_per_kilometer = v.into();
7377 self
7378 }
7379
7380 /// Sets the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
7381 ///
7382 /// # Example
7383 /// ```ignore,no_run
7384 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7385 /// use google_cloud_optimization_v1::model::DistanceLimit;
7386 /// let x = TransitionAttributes::new().set_distance_limit(DistanceLimit::default()/* use setters */);
7387 /// ```
7388 pub fn set_distance_limit<T>(mut self, v: T) -> Self
7389 where
7390 T: std::convert::Into<crate::model::DistanceLimit>,
7391 {
7392 self.distance_limit = std::option::Option::Some(v.into());
7393 self
7394 }
7395
7396 /// Sets or clears the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
7397 ///
7398 /// # Example
7399 /// ```ignore,no_run
7400 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7401 /// use google_cloud_optimization_v1::model::DistanceLimit;
7402 /// let x = TransitionAttributes::new().set_or_clear_distance_limit(Some(DistanceLimit::default()/* use setters */));
7403 /// let x = TransitionAttributes::new().set_or_clear_distance_limit(None::<DistanceLimit>);
7404 /// ```
7405 pub fn set_or_clear_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
7406 where
7407 T: std::convert::Into<crate::model::DistanceLimit>,
7408 {
7409 self.distance_limit = v.map(|x| x.into());
7410 self
7411 }
7412
7413 /// Sets the value of [delay][crate::model::TransitionAttributes::delay].
7414 ///
7415 /// # Example
7416 /// ```ignore,no_run
7417 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7418 /// use wkt::Duration;
7419 /// let x = TransitionAttributes::new().set_delay(Duration::default()/* use setters */);
7420 /// ```
7421 pub fn set_delay<T>(mut self, v: T) -> Self
7422 where
7423 T: std::convert::Into<wkt::Duration>,
7424 {
7425 self.delay = std::option::Option::Some(v.into());
7426 self
7427 }
7428
7429 /// Sets or clears the value of [delay][crate::model::TransitionAttributes::delay].
7430 ///
7431 /// # Example
7432 /// ```ignore,no_run
7433 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7434 /// use wkt::Duration;
7435 /// let x = TransitionAttributes::new().set_or_clear_delay(Some(Duration::default()/* use setters */));
7436 /// let x = TransitionAttributes::new().set_or_clear_delay(None::<Duration>);
7437 /// ```
7438 pub fn set_or_clear_delay<T>(mut self, v: std::option::Option<T>) -> Self
7439 where
7440 T: std::convert::Into<wkt::Duration>,
7441 {
7442 self.delay = v.map(|x| x.into());
7443 self
7444 }
7445}
7446
7447impl wkt::message::Message for TransitionAttributes {
7448 fn typename() -> &'static str {
7449 "type.googleapis.com/google.cloud.optimization.v1.TransitionAttributes"
7450 }
7451}
7452
7453/// Encapsulates a waypoint. Waypoints mark arrival and departure locations of
7454/// VisitRequests, and start and end locations of Vehicles.
7455#[derive(Clone, Default, PartialEq)]
7456#[non_exhaustive]
7457pub struct Waypoint {
7458 /// Indicates that the location of this waypoint is meant to have a preference
7459 /// for the vehicle to stop at a particular side of road. When you set this
7460 /// value, the route will pass through the location so that the vehicle can
7461 /// stop at the side of road that the location is biased towards from the
7462 /// center of the road. This option works only for the 'DRIVING' travel mode,
7463 /// and when the 'location_type' is set to 'location'.
7464 pub side_of_road: bool,
7465
7466 /// Different ways to represent a location.
7467 pub location_type: std::option::Option<crate::model::waypoint::LocationType>,
7468
7469 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7470}
7471
7472impl Waypoint {
7473 /// Creates a new default instance.
7474 pub fn new() -> Self {
7475 std::default::Default::default()
7476 }
7477
7478 /// Sets the value of [side_of_road][crate::model::Waypoint::side_of_road].
7479 ///
7480 /// # Example
7481 /// ```ignore,no_run
7482 /// # use google_cloud_optimization_v1::model::Waypoint;
7483 /// let x = Waypoint::new().set_side_of_road(true);
7484 /// ```
7485 pub fn set_side_of_road<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7486 self.side_of_road = v.into();
7487 self
7488 }
7489
7490 /// Sets the value of [location_type][crate::model::Waypoint::location_type].
7491 ///
7492 /// Note that all the setters affecting `location_type` are mutually
7493 /// exclusive.
7494 ///
7495 /// # Example
7496 /// ```ignore,no_run
7497 /// # use google_cloud_optimization_v1::model::Waypoint;
7498 /// use google_cloud_optimization_v1::model::waypoint::LocationType;
7499 /// let x = Waypoint::new().set_location_type(Some(LocationType::PlaceId("example".to_string())));
7500 /// ```
7501 pub fn set_location_type<
7502 T: std::convert::Into<std::option::Option<crate::model::waypoint::LocationType>>,
7503 >(
7504 mut self,
7505 v: T,
7506 ) -> Self {
7507 self.location_type = v.into();
7508 self
7509 }
7510
7511 /// The value of [location_type][crate::model::Waypoint::location_type]
7512 /// if it holds a `Location`, `None` if the field is not set or
7513 /// holds a different branch.
7514 pub fn location(&self) -> std::option::Option<&std::boxed::Box<crate::model::Location>> {
7515 #[allow(unreachable_patterns)]
7516 self.location_type.as_ref().and_then(|v| match v {
7517 crate::model::waypoint::LocationType::Location(v) => std::option::Option::Some(v),
7518 _ => std::option::Option::None,
7519 })
7520 }
7521
7522 /// Sets the value of [location_type][crate::model::Waypoint::location_type]
7523 /// to hold a `Location`.
7524 ///
7525 /// Note that all the setters affecting `location_type` are
7526 /// mutually exclusive.
7527 ///
7528 /// # Example
7529 /// ```ignore,no_run
7530 /// # use google_cloud_optimization_v1::model::Waypoint;
7531 /// use google_cloud_optimization_v1::model::Location;
7532 /// let x = Waypoint::new().set_location(Location::default()/* use setters */);
7533 /// assert!(x.location().is_some());
7534 /// assert!(x.place_id().is_none());
7535 /// ```
7536 pub fn set_location<T: std::convert::Into<std::boxed::Box<crate::model::Location>>>(
7537 mut self,
7538 v: T,
7539 ) -> Self {
7540 self.location_type =
7541 std::option::Option::Some(crate::model::waypoint::LocationType::Location(v.into()));
7542 self
7543 }
7544
7545 /// The value of [location_type][crate::model::Waypoint::location_type]
7546 /// if it holds a `PlaceId`, `None` if the field is not set or
7547 /// holds a different branch.
7548 pub fn place_id(&self) -> std::option::Option<&std::string::String> {
7549 #[allow(unreachable_patterns)]
7550 self.location_type.as_ref().and_then(|v| match v {
7551 crate::model::waypoint::LocationType::PlaceId(v) => std::option::Option::Some(v),
7552 _ => std::option::Option::None,
7553 })
7554 }
7555
7556 /// Sets the value of [location_type][crate::model::Waypoint::location_type]
7557 /// to hold a `PlaceId`.
7558 ///
7559 /// Note that all the setters affecting `location_type` are
7560 /// mutually exclusive.
7561 ///
7562 /// # Example
7563 /// ```ignore,no_run
7564 /// # use google_cloud_optimization_v1::model::Waypoint;
7565 /// let x = Waypoint::new().set_place_id("example");
7566 /// assert!(x.place_id().is_some());
7567 /// assert!(x.location().is_none());
7568 /// ```
7569 pub fn set_place_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7570 self.location_type =
7571 std::option::Option::Some(crate::model::waypoint::LocationType::PlaceId(v.into()));
7572 self
7573 }
7574}
7575
7576impl wkt::message::Message for Waypoint {
7577 fn typename() -> &'static str {
7578 "type.googleapis.com/google.cloud.optimization.v1.Waypoint"
7579 }
7580}
7581
7582/// Defines additional types related to [Waypoint].
7583pub mod waypoint {
7584 #[allow(unused_imports)]
7585 use super::*;
7586
7587 /// Different ways to represent a location.
7588 #[derive(Clone, Debug, PartialEq)]
7589 #[non_exhaustive]
7590 pub enum LocationType {
7591 /// A point specified using geographic coordinates, including an optional
7592 /// heading.
7593 Location(std::boxed::Box<crate::model::Location>),
7594 /// The POI Place ID associated with the waypoint.
7595 PlaceId(std::string::String),
7596 }
7597}
7598
7599/// Encapsulates a location (a geographic point, and an optional heading).
7600#[derive(Clone, Default, PartialEq)]
7601#[non_exhaustive]
7602pub struct Location {
7603 /// The waypoint's geographic coordinates.
7604 pub lat_lng: std::option::Option<google_cloud_type::model::LatLng>,
7605
7606 /// The compass heading associated with the direction of the flow of traffic.
7607 /// This value is used to specify the side of the road to use for pickup and
7608 /// drop-off. Heading values can be from 0 to 360, where 0 specifies a heading
7609 /// of due North, 90 specifies a heading of due East, etc.
7610 pub heading: std::option::Option<i32>,
7611
7612 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7613}
7614
7615impl Location {
7616 /// Creates a new default instance.
7617 pub fn new() -> Self {
7618 std::default::Default::default()
7619 }
7620
7621 /// Sets the value of [lat_lng][crate::model::Location::lat_lng].
7622 ///
7623 /// # Example
7624 /// ```ignore,no_run
7625 /// # use google_cloud_optimization_v1::model::Location;
7626 /// use google_cloud_type::model::LatLng;
7627 /// let x = Location::new().set_lat_lng(LatLng::default()/* use setters */);
7628 /// ```
7629 pub fn set_lat_lng<T>(mut self, v: T) -> Self
7630 where
7631 T: std::convert::Into<google_cloud_type::model::LatLng>,
7632 {
7633 self.lat_lng = std::option::Option::Some(v.into());
7634 self
7635 }
7636
7637 /// Sets or clears the value of [lat_lng][crate::model::Location::lat_lng].
7638 ///
7639 /// # Example
7640 /// ```ignore,no_run
7641 /// # use google_cloud_optimization_v1::model::Location;
7642 /// use google_cloud_type::model::LatLng;
7643 /// let x = Location::new().set_or_clear_lat_lng(Some(LatLng::default()/* use setters */));
7644 /// let x = Location::new().set_or_clear_lat_lng(None::<LatLng>);
7645 /// ```
7646 pub fn set_or_clear_lat_lng<T>(mut self, v: std::option::Option<T>) -> Self
7647 where
7648 T: std::convert::Into<google_cloud_type::model::LatLng>,
7649 {
7650 self.lat_lng = v.map(|x| x.into());
7651 self
7652 }
7653
7654 /// Sets the value of [heading][crate::model::Location::heading].
7655 ///
7656 /// # Example
7657 /// ```ignore,no_run
7658 /// # use google_cloud_optimization_v1::model::Location;
7659 /// let x = Location::new().set_heading(42);
7660 /// ```
7661 pub fn set_heading<T>(mut self, v: T) -> Self
7662 where
7663 T: std::convert::Into<i32>,
7664 {
7665 self.heading = std::option::Option::Some(v.into());
7666 self
7667 }
7668
7669 /// Sets or clears the value of [heading][crate::model::Location::heading].
7670 ///
7671 /// # Example
7672 /// ```ignore,no_run
7673 /// # use google_cloud_optimization_v1::model::Location;
7674 /// let x = Location::new().set_or_clear_heading(Some(42));
7675 /// let x = Location::new().set_or_clear_heading(None::<i32>);
7676 /// ```
7677 pub fn set_or_clear_heading<T>(mut self, v: std::option::Option<T>) -> Self
7678 where
7679 T: std::convert::Into<i32>,
7680 {
7681 self.heading = v.map(|x| x.into());
7682 self
7683 }
7684}
7685
7686impl wkt::message::Message for Location {
7687 fn typename() -> &'static str {
7688 "type.googleapis.com/google.cloud.optimization.v1.Location"
7689 }
7690}
7691
7692/// Rules to generate time breaks for a vehicle (e.g. lunch breaks). A break
7693/// is a contiguous period of time during which the vehicle remains idle at its
7694/// current position and cannot perform any visit. A break may occur:
7695///
7696/// * during the travel between two visits (which includes the time right
7697/// before or right after a visit, but not in the middle of a visit), in
7698/// which case it extends the corresponding transit time between the visits,
7699/// * or before the vehicle start (the vehicle may not start in the middle of
7700/// a break), in which case it does not affect the vehicle start time.
7701/// * or after the vehicle end (ditto, with the vehicle end time).
7702#[derive(Clone, Default, PartialEq)]
7703#[non_exhaustive]
7704pub struct BreakRule {
7705 /// Sequence of breaks. See the `BreakRequest` message.
7706 pub break_requests: std::vec::Vec<crate::model::break_rule::BreakRequest>,
7707
7708 /// Several `FrequencyConstraint` may apply. They must all be satisfied by
7709 /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
7710 pub frequency_constraints: std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
7711
7712 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7713}
7714
7715impl BreakRule {
7716 /// Creates a new default instance.
7717 pub fn new() -> Self {
7718 std::default::Default::default()
7719 }
7720
7721 /// Sets the value of [break_requests][crate::model::BreakRule::break_requests].
7722 ///
7723 /// # Example
7724 /// ```ignore,no_run
7725 /// # use google_cloud_optimization_v1::model::BreakRule;
7726 /// use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7727 /// let x = BreakRule::new()
7728 /// .set_break_requests([
7729 /// BreakRequest::default()/* use setters */,
7730 /// BreakRequest::default()/* use (different) setters */,
7731 /// ]);
7732 /// ```
7733 pub fn set_break_requests<T, V>(mut self, v: T) -> Self
7734 where
7735 T: std::iter::IntoIterator<Item = V>,
7736 V: std::convert::Into<crate::model::break_rule::BreakRequest>,
7737 {
7738 use std::iter::Iterator;
7739 self.break_requests = v.into_iter().map(|i| i.into()).collect();
7740 self
7741 }
7742
7743 /// Sets the value of [frequency_constraints][crate::model::BreakRule::frequency_constraints].
7744 ///
7745 /// # Example
7746 /// ```ignore,no_run
7747 /// # use google_cloud_optimization_v1::model::BreakRule;
7748 /// use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7749 /// let x = BreakRule::new()
7750 /// .set_frequency_constraints([
7751 /// FrequencyConstraint::default()/* use setters */,
7752 /// FrequencyConstraint::default()/* use (different) setters */,
7753 /// ]);
7754 /// ```
7755 pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
7756 where
7757 T: std::iter::IntoIterator<Item = V>,
7758 V: std::convert::Into<crate::model::break_rule::FrequencyConstraint>,
7759 {
7760 use std::iter::Iterator;
7761 self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
7762 self
7763 }
7764}
7765
7766impl wkt::message::Message for BreakRule {
7767 fn typename() -> &'static str {
7768 "type.googleapis.com/google.cloud.optimization.v1.BreakRule"
7769 }
7770}
7771
7772/// Defines additional types related to [BreakRule].
7773pub mod break_rule {
7774 #[allow(unused_imports)]
7775 use super::*;
7776
7777 /// The sequence of breaks (i.e. their number and order) that apply to each
7778 /// vehicle must be known beforehand. The repeated `BreakRequest`s define
7779 /// that sequence, in the order in which they must occur. Their time windows
7780 /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
7781 /// be compatible with the order (this is checked).
7782 #[derive(Clone, Default, PartialEq)]
7783 #[non_exhaustive]
7784 pub struct BreakRequest {
7785 /// Required. Lower bound (inclusive) on the start of the break.
7786 pub earliest_start_time: std::option::Option<wkt::Timestamp>,
7787
7788 /// Required. Upper bound (inclusive) on the start of the break.
7789 pub latest_start_time: std::option::Option<wkt::Timestamp>,
7790
7791 /// Required. Minimum duration of the break. Must be positive.
7792 pub min_duration: std::option::Option<wkt::Duration>,
7793
7794 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7795 }
7796
7797 impl BreakRequest {
7798 /// Creates a new default instance.
7799 pub fn new() -> Self {
7800 std::default::Default::default()
7801 }
7802
7803 /// Sets the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
7804 ///
7805 /// # Example
7806 /// ```ignore,no_run
7807 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7808 /// use wkt::Timestamp;
7809 /// let x = BreakRequest::new().set_earliest_start_time(Timestamp::default()/* use setters */);
7810 /// ```
7811 pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
7812 where
7813 T: std::convert::Into<wkt::Timestamp>,
7814 {
7815 self.earliest_start_time = std::option::Option::Some(v.into());
7816 self
7817 }
7818
7819 /// Sets or clears the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
7820 ///
7821 /// # Example
7822 /// ```ignore,no_run
7823 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7824 /// use wkt::Timestamp;
7825 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(Some(Timestamp::default()/* use setters */));
7826 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(None::<Timestamp>);
7827 /// ```
7828 pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7829 where
7830 T: std::convert::Into<wkt::Timestamp>,
7831 {
7832 self.earliest_start_time = v.map(|x| x.into());
7833 self
7834 }
7835
7836 /// Sets the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
7837 ///
7838 /// # Example
7839 /// ```ignore,no_run
7840 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7841 /// use wkt::Timestamp;
7842 /// let x = BreakRequest::new().set_latest_start_time(Timestamp::default()/* use setters */);
7843 /// ```
7844 pub fn set_latest_start_time<T>(mut self, v: T) -> Self
7845 where
7846 T: std::convert::Into<wkt::Timestamp>,
7847 {
7848 self.latest_start_time = std::option::Option::Some(v.into());
7849 self
7850 }
7851
7852 /// Sets or clears the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
7853 ///
7854 /// # Example
7855 /// ```ignore,no_run
7856 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7857 /// use wkt::Timestamp;
7858 /// let x = BreakRequest::new().set_or_clear_latest_start_time(Some(Timestamp::default()/* use setters */));
7859 /// let x = BreakRequest::new().set_or_clear_latest_start_time(None::<Timestamp>);
7860 /// ```
7861 pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7862 where
7863 T: std::convert::Into<wkt::Timestamp>,
7864 {
7865 self.latest_start_time = v.map(|x| x.into());
7866 self
7867 }
7868
7869 /// Sets the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
7870 ///
7871 /// # Example
7872 /// ```ignore,no_run
7873 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7874 /// use wkt::Duration;
7875 /// let x = BreakRequest::new().set_min_duration(Duration::default()/* use setters */);
7876 /// ```
7877 pub fn set_min_duration<T>(mut self, v: T) -> Self
7878 where
7879 T: std::convert::Into<wkt::Duration>,
7880 {
7881 self.min_duration = std::option::Option::Some(v.into());
7882 self
7883 }
7884
7885 /// Sets or clears the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
7886 ///
7887 /// # Example
7888 /// ```ignore,no_run
7889 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7890 /// use wkt::Duration;
7891 /// let x = BreakRequest::new().set_or_clear_min_duration(Some(Duration::default()/* use setters */));
7892 /// let x = BreakRequest::new().set_or_clear_min_duration(None::<Duration>);
7893 /// ```
7894 pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
7895 where
7896 T: std::convert::Into<wkt::Duration>,
7897 {
7898 self.min_duration = v.map(|x| x.into());
7899 self
7900 }
7901 }
7902
7903 impl wkt::message::Message for BreakRequest {
7904 fn typename() -> &'static str {
7905 "type.googleapis.com/google.cloud.optimization.v1.BreakRule.BreakRequest"
7906 }
7907 }
7908
7909 /// One may further constrain the frequency and duration of the breaks
7910 /// specified above, by enforcing a minimum break frequency, such as
7911 /// "There must be a break of at least 1 hour every 12 hours". Assuming that
7912 /// this can be interpreted as "Within any sliding time window of 12h, there
7913 /// must be at least one break of at least one hour", that example would
7914 /// translate to the following `FrequencyConstraint`:
7915 ///
7916 /// ```norust
7917 /// {
7918 /// min_break_duration { seconds: 3600 } # 1 hour.
7919 /// max_inter_break_duration { seconds: 39600 } # 11 hours (12 - 1 = 11).
7920 /// }
7921 /// ```
7922 ///
7923 /// The timing and duration of the breaks in the solution will respect all
7924 /// such constraints, in addition to the time windows and minimum durations
7925 /// already specified in the `BreakRequest`.
7926 ///
7927 /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
7928 /// For example, the following schedule honors the "1h every 12h" example:
7929 ///
7930 /// ```norust
7931 /// 04:00 vehicle start
7932 /// .. performing travel and visits ..
7933 /// 09:00 1 hour break
7934 /// 10:00 end of the break
7935 /// .. performing travel and visits ..
7936 /// 12:00 20-min lunch break
7937 /// 12:20 end of the break
7938 /// .. performing travel and visits ..
7939 /// 21:00 1 hour break
7940 /// 22:00 end of the break
7941 /// .. performing travel and visits ..
7942 /// 23:59 vehicle end
7943 /// ```
7944 #[derive(Clone, Default, PartialEq)]
7945 #[non_exhaustive]
7946 pub struct FrequencyConstraint {
7947 /// Required. Minimum break duration for this constraint. Nonnegative.
7948 /// See description of `FrequencyConstraint`.
7949 pub min_break_duration: std::option::Option<wkt::Duration>,
7950
7951 /// Required. Maximum allowed span of any interval of time in the route that
7952 /// does not include at least partially a break of `duration >=
7953 /// min_break_duration`. Must be positive.
7954 pub max_inter_break_duration: std::option::Option<wkt::Duration>,
7955
7956 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7957 }
7958
7959 impl FrequencyConstraint {
7960 /// Creates a new default instance.
7961 pub fn new() -> Self {
7962 std::default::Default::default()
7963 }
7964
7965 /// Sets the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
7966 ///
7967 /// # Example
7968 /// ```ignore,no_run
7969 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7970 /// use wkt::Duration;
7971 /// let x = FrequencyConstraint::new().set_min_break_duration(Duration::default()/* use setters */);
7972 /// ```
7973 pub fn set_min_break_duration<T>(mut self, v: T) -> Self
7974 where
7975 T: std::convert::Into<wkt::Duration>,
7976 {
7977 self.min_break_duration = std::option::Option::Some(v.into());
7978 self
7979 }
7980
7981 /// Sets or clears the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
7982 ///
7983 /// # Example
7984 /// ```ignore,no_run
7985 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7986 /// use wkt::Duration;
7987 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(Some(Duration::default()/* use setters */));
7988 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(None::<Duration>);
7989 /// ```
7990 pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
7991 where
7992 T: std::convert::Into<wkt::Duration>,
7993 {
7994 self.min_break_duration = v.map(|x| x.into());
7995 self
7996 }
7997
7998 /// Sets the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
7999 ///
8000 /// # Example
8001 /// ```ignore,no_run
8002 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
8003 /// use wkt::Duration;
8004 /// let x = FrequencyConstraint::new().set_max_inter_break_duration(Duration::default()/* use setters */);
8005 /// ```
8006 pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
8007 where
8008 T: std::convert::Into<wkt::Duration>,
8009 {
8010 self.max_inter_break_duration = std::option::Option::Some(v.into());
8011 self
8012 }
8013
8014 /// Sets or clears the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
8015 ///
8016 /// # Example
8017 /// ```ignore,no_run
8018 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
8019 /// use wkt::Duration;
8020 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(Some(Duration::default()/* use setters */));
8021 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(None::<Duration>);
8022 /// ```
8023 pub fn set_or_clear_max_inter_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
8024 where
8025 T: std::convert::Into<wkt::Duration>,
8026 {
8027 self.max_inter_break_duration = v.map(|x| x.into());
8028 self
8029 }
8030 }
8031
8032 impl wkt::message::Message for FrequencyConstraint {
8033 fn typename() -> &'static str {
8034 "type.googleapis.com/google.cloud.optimization.v1.BreakRule.FrequencyConstraint"
8035 }
8036 }
8037}
8038
8039/// A vehicle's route can be decomposed, along the time axis, like this (we
8040/// assume there are n visits):
8041///
8042/// ```norust
8043/// | | | | | T[2], | | |
8044/// | Transition | Visit #0 | | | V[2], | | |
8045/// | #0 | aka | T[1] | V[1] | ... | V[n-1] | T[n] |
8046/// | aka T[0] | V[0] | | | V[n-2],| | |
8047/// | | | | | T[n-1] | | |
8048/// ^ ^ ^ ^ ^ ^ ^ ^
8049/// vehicle V[0].start V[0].end V[1]. V[1]. V[n]. V[n]. vehicle
8050/// start (arrival) (departure) start end start end end
8051/// ```
8052///
8053/// Note that we make a difference between:
8054///
8055/// * "punctual events", such as the vehicle start and end and each visit's start
8056/// and end (aka arrival and departure). They happen at a given second.
8057/// * "time intervals", such as the visits themselves, and the transition between
8058/// visits. Though time intervals can sometimes have zero duration, i.e. start
8059/// and end at the same second, they often have a positive duration.
8060///
8061/// Invariants:
8062///
8063/// * If there are n visits, there are n+1 transitions.
8064/// * A visit is always surrounded by a transition before it (same index) and a
8065/// transition after it (index + 1).
8066/// * The vehicle start is always followed by transition #0.
8067/// * The vehicle end is always preceded by transition #n.
8068///
8069/// Zooming in, here is what happens during a `Transition` and a `Visit`:
8070///
8071/// ```norust
8072/// ---+-------------------------------------+-----------------------------+-->
8073/// | TRANSITION[i] | VISIT[i] |
8074/// | | |
8075/// | * TRAVEL: the vehicle moves from | PERFORM the visit: |
8076/// | VISIT[i-1].departure_location to | |
8077/// | VISIT[i].arrival_location, which | * Spend some time: |
8078/// | takes a given travel duration | the "visit duration". |
8079/// | and distance | |
8080/// | | * Load or unload |
8081/// | * BREAKS: the driver may have | some quantities from the |
8082/// | breaks (e.g. lunch break). | vehicle: the "demand". |
8083/// | | |
8084/// | * WAIT: the driver/vehicle does | |
8085/// | nothing. This can happen for | |
8086/// | many reasons, for example when | |
8087/// | the vehicle reaches the next | |
8088/// | event's destination before the | |
8089/// | start of its time window | |
8090/// | | |
8091/// | * DELAY: *right before* the next | |
8092/// | arrival. E.g. the vehicle and/or | |
8093/// | driver spends time unloading. | |
8094/// | | |
8095/// ---+-------------------------------------+-----------------------------+-->
8096/// ^ ^ ^
8097/// V[i-1].end V[i].start V[i].end
8098/// ```
8099///
8100/// Lastly, here is how the TRAVEL, BREAKS, DELAY and WAIT can be arranged
8101/// during a transition.
8102///
8103/// * They don't overlap.
8104/// * The DELAY is unique and *must* be a contiguous period of time right
8105/// before the next visit (or vehicle end). Thus, it suffice to know the
8106/// delay duration to know its start and end time.
8107/// * The BREAKS are contiguous, non-overlapping periods of time. The
8108/// response specifies the start time and duration of each break.
8109/// * TRAVEL and WAIT are "preemptable": they can be interrupted several times
8110/// during this transition. Clients can assume that travel happens "as soon as
8111/// possible" and that "wait" fills the remaining time.
8112///
8113/// A (complex) example:
8114///
8115/// ```norust
8116/// TRANSITION[i]
8117/// --++-----+-----------------------------------------------------------++-->
8118/// || | | | | | | ||
8119/// || T | B | T | | B | | D ||
8120/// || r | r | r | W | r | W | e ||
8121/// || a | e | a | a | e | a | l ||
8122/// || v | a | v | i | a | i | a ||
8123/// || e | k | e | t | k | t | y ||
8124/// || l | | l | | | | ||
8125/// || | | | | | | ||
8126/// --++-----------------------------------------------------------------++-->
8127/// ```
8128#[derive(Clone, Default, PartialEq)]
8129#[non_exhaustive]
8130pub struct ShipmentRoute {
8131 /// Vehicle performing the route, identified by its index in the source
8132 /// `ShipmentModel`.
8133 pub vehicle_index: i32,
8134
8135 /// Label of the vehicle performing this route, equal to
8136 /// `ShipmentModel.vehicles(vehicle_index).label`, if specified.
8137 pub vehicle_label: std::string::String,
8138
8139 /// Time at which the vehicle starts its route.
8140 pub vehicle_start_time: std::option::Option<wkt::Timestamp>,
8141
8142 /// Time at which the vehicle finishes its route.
8143 pub vehicle_end_time: std::option::Option<wkt::Timestamp>,
8144
8145 /// Ordered sequence of visits representing a route.
8146 /// visits[i] is the i-th visit in the route.
8147 /// If this field is empty, the vehicle is considered as unused.
8148 pub visits: std::vec::Vec<crate::model::shipment_route::Visit>,
8149
8150 /// Ordered list of transitions for the route.
8151 pub transitions: std::vec::Vec<crate::model::shipment_route::Transition>,
8152
8153 /// When
8154 /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
8155 /// is set to true, this field indicates that inconsistencies in route timings
8156 /// are predicted using traffic-based travel duration estimates. There may be
8157 /// insufficient time to complete traffic-adjusted travel, delays, and breaks
8158 /// between visits, before the first visit, or after the last visit, while
8159 /// still satisfying the visit and vehicle time windows. For example,
8160 ///
8161 /// ```norust
8162 /// start_time(previous_visit) + duration(previous_visit) +
8163 /// travel_duration(previous_visit, next_visit) > start_time(next_visit)
8164 /// ```
8165 ///
8166 /// Arrival at next_visit will likely happen later than its current
8167 /// time window due the increased estimate of travel time
8168 /// `travel_duration(previous_visit, next_visit)` due to traffic. Also, a break
8169 /// may be forced to overlap with a visit due to an increase in travel time
8170 /// estimates and visit or break time window restrictions.
8171 ///
8172 /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
8173 pub has_traffic_infeasibilities: bool,
8174
8175 /// The encoded polyline representation of the route.
8176 /// This field is only populated if
8177 /// [OptimizeToursRequest.populate_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]
8178 /// is set to true.
8179 ///
8180 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]: crate::model::OptimizeToursRequest::populate_polylines
8181 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
8182
8183 /// Breaks scheduled for the vehicle performing this route.
8184 /// The `breaks` sequence represents time intervals, each starting at the
8185 /// corresponding `start_time` and lasting `duration` seconds.
8186 pub breaks: std::vec::Vec<crate::model::shipment_route::Break>,
8187
8188 /// Duration, distance and load metrics for this route. The fields of
8189 /// [AggregatedMetrics][google.cloud.optimization.v1.AggregatedMetrics] are
8190 /// summed over all
8191 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
8192 /// or
8193 /// [ShipmentRoute.visits][google.cloud.optimization.v1.ShipmentRoute.visits],
8194 /// depending on the context.
8195 ///
8196 /// [google.cloud.optimization.v1.AggregatedMetrics]: crate::model::AggregatedMetrics
8197 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8198 /// [google.cloud.optimization.v1.ShipmentRoute.visits]: crate::model::ShipmentRoute::visits
8199 pub metrics: std::option::Option<crate::model::AggregatedMetrics>,
8200
8201 /// Cost of the route, broken down by cost-related request fields.
8202 /// The keys are proto paths, relative to the input OptimizeToursRequest, e.g.
8203 /// "model.shipments.pickups.cost", and the values are the total cost
8204 /// generated by the corresponding cost field, aggregated over the whole route.
8205 /// In other words, costs["model.shipments.pickups.cost"] is the sum of all
8206 /// pickup costs over the route. All costs defined in the model are reported in
8207 /// detail here with the exception of costs related to TransitionAttributes
8208 /// that are only reported in an aggregated way as of 2022/01.
8209 pub route_costs: std::collections::HashMap<std::string::String, f64>,
8210
8211 /// Total cost of the route. The sum of all costs in the cost map.
8212 pub route_total_cost: f64,
8213
8214 /// Deprecated: Use
8215 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
8216 /// instead. Vehicle loads upon arrival at its end location, for each type
8217 /// specified in
8218 /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
8219 /// `start_load_intervals`, `end_load_intervals` or demands. Exception: we omit
8220 /// loads for quantity types unconstrained by intervals and that don't have any
8221 /// non-zero demand on the route.
8222 ///
8223 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
8224 /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
8225 #[deprecated]
8226 pub end_loads: std::vec::Vec<crate::model::CapacityQuantity>,
8227
8228 /// Deprecated: Use
8229 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
8230 /// instead. Ordered list of travel steps for the route.
8231 ///
8232 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8233 #[deprecated]
8234 pub travel_steps: std::vec::Vec<crate::model::shipment_route::TravelStep>,
8235
8236 /// Deprecated: No longer used.
8237 /// This field will only be populated at the
8238 /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit]
8239 /// level.
8240 ///
8241 /// This field is the extra detour time due to the shipments visited on the
8242 /// route.
8243 ///
8244 /// It is equal to `vehicle_end_time` - `vehicle_start_time` - travel duration
8245 /// from the vehicle's start_location to its `end_location`.
8246 ///
8247 /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
8248 #[deprecated]
8249 pub vehicle_detour: std::option::Option<wkt::Duration>,
8250
8251 /// Deprecated: Delay occurring before the vehicle end. See
8252 /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
8253 ///
8254 /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
8255 #[deprecated]
8256 pub delay_before_vehicle_end: std::option::Option<crate::model::shipment_route::Delay>,
8257
8258 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8259}
8260
8261impl ShipmentRoute {
8262 /// Creates a new default instance.
8263 pub fn new() -> Self {
8264 std::default::Default::default()
8265 }
8266
8267 /// Sets the value of [vehicle_index][crate::model::ShipmentRoute::vehicle_index].
8268 ///
8269 /// # Example
8270 /// ```ignore,no_run
8271 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8272 /// let x = ShipmentRoute::new().set_vehicle_index(42);
8273 /// ```
8274 pub fn set_vehicle_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8275 self.vehicle_index = v.into();
8276 self
8277 }
8278
8279 /// Sets the value of [vehicle_label][crate::model::ShipmentRoute::vehicle_label].
8280 ///
8281 /// # Example
8282 /// ```ignore,no_run
8283 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8284 /// let x = ShipmentRoute::new().set_vehicle_label("example");
8285 /// ```
8286 pub fn set_vehicle_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8287 self.vehicle_label = v.into();
8288 self
8289 }
8290
8291 /// Sets the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
8292 ///
8293 /// # Example
8294 /// ```ignore,no_run
8295 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8296 /// use wkt::Timestamp;
8297 /// let x = ShipmentRoute::new().set_vehicle_start_time(Timestamp::default()/* use setters */);
8298 /// ```
8299 pub fn set_vehicle_start_time<T>(mut self, v: T) -> Self
8300 where
8301 T: std::convert::Into<wkt::Timestamp>,
8302 {
8303 self.vehicle_start_time = std::option::Option::Some(v.into());
8304 self
8305 }
8306
8307 /// Sets or clears the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
8308 ///
8309 /// # Example
8310 /// ```ignore,no_run
8311 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8312 /// use wkt::Timestamp;
8313 /// let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(Some(Timestamp::default()/* use setters */));
8314 /// let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(None::<Timestamp>);
8315 /// ```
8316 pub fn set_or_clear_vehicle_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8317 where
8318 T: std::convert::Into<wkt::Timestamp>,
8319 {
8320 self.vehicle_start_time = v.map(|x| x.into());
8321 self
8322 }
8323
8324 /// Sets the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
8325 ///
8326 /// # Example
8327 /// ```ignore,no_run
8328 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8329 /// use wkt::Timestamp;
8330 /// let x = ShipmentRoute::new().set_vehicle_end_time(Timestamp::default()/* use setters */);
8331 /// ```
8332 pub fn set_vehicle_end_time<T>(mut self, v: T) -> Self
8333 where
8334 T: std::convert::Into<wkt::Timestamp>,
8335 {
8336 self.vehicle_end_time = std::option::Option::Some(v.into());
8337 self
8338 }
8339
8340 /// Sets or clears the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
8341 ///
8342 /// # Example
8343 /// ```ignore,no_run
8344 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8345 /// use wkt::Timestamp;
8346 /// let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(Some(Timestamp::default()/* use setters */));
8347 /// let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(None::<Timestamp>);
8348 /// ```
8349 pub fn set_or_clear_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
8350 where
8351 T: std::convert::Into<wkt::Timestamp>,
8352 {
8353 self.vehicle_end_time = v.map(|x| x.into());
8354 self
8355 }
8356
8357 /// Sets the value of [visits][crate::model::ShipmentRoute::visits].
8358 ///
8359 /// # Example
8360 /// ```ignore,no_run
8361 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8362 /// use google_cloud_optimization_v1::model::shipment_route::Visit;
8363 /// let x = ShipmentRoute::new()
8364 /// .set_visits([
8365 /// Visit::default()/* use setters */,
8366 /// Visit::default()/* use (different) setters */,
8367 /// ]);
8368 /// ```
8369 pub fn set_visits<T, V>(mut self, v: T) -> Self
8370 where
8371 T: std::iter::IntoIterator<Item = V>,
8372 V: std::convert::Into<crate::model::shipment_route::Visit>,
8373 {
8374 use std::iter::Iterator;
8375 self.visits = v.into_iter().map(|i| i.into()).collect();
8376 self
8377 }
8378
8379 /// Sets the value of [transitions][crate::model::ShipmentRoute::transitions].
8380 ///
8381 /// # Example
8382 /// ```ignore,no_run
8383 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8384 /// use google_cloud_optimization_v1::model::shipment_route::Transition;
8385 /// let x = ShipmentRoute::new()
8386 /// .set_transitions([
8387 /// Transition::default()/* use setters */,
8388 /// Transition::default()/* use (different) setters */,
8389 /// ]);
8390 /// ```
8391 pub fn set_transitions<T, V>(mut self, v: T) -> Self
8392 where
8393 T: std::iter::IntoIterator<Item = V>,
8394 V: std::convert::Into<crate::model::shipment_route::Transition>,
8395 {
8396 use std::iter::Iterator;
8397 self.transitions = v.into_iter().map(|i| i.into()).collect();
8398 self
8399 }
8400
8401 /// Sets the value of [has_traffic_infeasibilities][crate::model::ShipmentRoute::has_traffic_infeasibilities].
8402 ///
8403 /// # Example
8404 /// ```ignore,no_run
8405 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8406 /// let x = ShipmentRoute::new().set_has_traffic_infeasibilities(true);
8407 /// ```
8408 pub fn set_has_traffic_infeasibilities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8409 self.has_traffic_infeasibilities = v.into();
8410 self
8411 }
8412
8413 /// Sets the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
8414 ///
8415 /// # Example
8416 /// ```ignore,no_run
8417 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8418 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
8419 /// let x = ShipmentRoute::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
8420 /// ```
8421 pub fn set_route_polyline<T>(mut self, v: T) -> Self
8422 where
8423 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8424 {
8425 self.route_polyline = std::option::Option::Some(v.into());
8426 self
8427 }
8428
8429 /// Sets or clears the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
8430 ///
8431 /// # Example
8432 /// ```ignore,no_run
8433 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8434 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
8435 /// let x = ShipmentRoute::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
8436 /// let x = ShipmentRoute::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
8437 /// ```
8438 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
8439 where
8440 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8441 {
8442 self.route_polyline = v.map(|x| x.into());
8443 self
8444 }
8445
8446 /// Sets the value of [breaks][crate::model::ShipmentRoute::breaks].
8447 ///
8448 /// # Example
8449 /// ```ignore,no_run
8450 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8451 /// use google_cloud_optimization_v1::model::shipment_route::Break;
8452 /// let x = ShipmentRoute::new()
8453 /// .set_breaks([
8454 /// Break::default()/* use setters */,
8455 /// Break::default()/* use (different) setters */,
8456 /// ]);
8457 /// ```
8458 pub fn set_breaks<T, V>(mut self, v: T) -> Self
8459 where
8460 T: std::iter::IntoIterator<Item = V>,
8461 V: std::convert::Into<crate::model::shipment_route::Break>,
8462 {
8463 use std::iter::Iterator;
8464 self.breaks = v.into_iter().map(|i| i.into()).collect();
8465 self
8466 }
8467
8468 /// Sets the value of [metrics][crate::model::ShipmentRoute::metrics].
8469 ///
8470 /// # Example
8471 /// ```ignore,no_run
8472 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8473 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
8474 /// let x = ShipmentRoute::new().set_metrics(AggregatedMetrics::default()/* use setters */);
8475 /// ```
8476 pub fn set_metrics<T>(mut self, v: T) -> Self
8477 where
8478 T: std::convert::Into<crate::model::AggregatedMetrics>,
8479 {
8480 self.metrics = std::option::Option::Some(v.into());
8481 self
8482 }
8483
8484 /// Sets or clears the value of [metrics][crate::model::ShipmentRoute::metrics].
8485 ///
8486 /// # Example
8487 /// ```ignore,no_run
8488 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8489 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
8490 /// let x = ShipmentRoute::new().set_or_clear_metrics(Some(AggregatedMetrics::default()/* use setters */));
8491 /// let x = ShipmentRoute::new().set_or_clear_metrics(None::<AggregatedMetrics>);
8492 /// ```
8493 pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
8494 where
8495 T: std::convert::Into<crate::model::AggregatedMetrics>,
8496 {
8497 self.metrics = v.map(|x| x.into());
8498 self
8499 }
8500
8501 /// Sets the value of [route_costs][crate::model::ShipmentRoute::route_costs].
8502 ///
8503 /// # Example
8504 /// ```ignore,no_run
8505 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8506 /// let x = ShipmentRoute::new().set_route_costs([
8507 /// ("key0", 123.5),
8508 /// ("key1", 456.5),
8509 /// ]);
8510 /// ```
8511 pub fn set_route_costs<T, K, V>(mut self, v: T) -> Self
8512 where
8513 T: std::iter::IntoIterator<Item = (K, V)>,
8514 K: std::convert::Into<std::string::String>,
8515 V: std::convert::Into<f64>,
8516 {
8517 use std::iter::Iterator;
8518 self.route_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8519 self
8520 }
8521
8522 /// Sets the value of [route_total_cost][crate::model::ShipmentRoute::route_total_cost].
8523 ///
8524 /// # Example
8525 /// ```ignore,no_run
8526 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8527 /// let x = ShipmentRoute::new().set_route_total_cost(42.0);
8528 /// ```
8529 pub fn set_route_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8530 self.route_total_cost = v.into();
8531 self
8532 }
8533
8534 /// Sets the value of [end_loads][crate::model::ShipmentRoute::end_loads].
8535 ///
8536 /// # Example
8537 /// ```ignore,no_run
8538 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8539 /// use google_cloud_optimization_v1::model::CapacityQuantity;
8540 /// let x = ShipmentRoute::new()
8541 /// .set_end_loads([
8542 /// CapacityQuantity::default()/* use setters */,
8543 /// CapacityQuantity::default()/* use (different) setters */,
8544 /// ]);
8545 /// ```
8546 #[deprecated]
8547 pub fn set_end_loads<T, V>(mut self, v: T) -> Self
8548 where
8549 T: std::iter::IntoIterator<Item = V>,
8550 V: std::convert::Into<crate::model::CapacityQuantity>,
8551 {
8552 use std::iter::Iterator;
8553 self.end_loads = v.into_iter().map(|i| i.into()).collect();
8554 self
8555 }
8556
8557 /// Sets the value of [travel_steps][crate::model::ShipmentRoute::travel_steps].
8558 ///
8559 /// # Example
8560 /// ```ignore,no_run
8561 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8562 /// use google_cloud_optimization_v1::model::shipment_route::TravelStep;
8563 /// let x = ShipmentRoute::new()
8564 /// .set_travel_steps([
8565 /// TravelStep::default()/* use setters */,
8566 /// TravelStep::default()/* use (different) setters */,
8567 /// ]);
8568 /// ```
8569 #[deprecated]
8570 pub fn set_travel_steps<T, V>(mut self, v: T) -> Self
8571 where
8572 T: std::iter::IntoIterator<Item = V>,
8573 V: std::convert::Into<crate::model::shipment_route::TravelStep>,
8574 {
8575 use std::iter::Iterator;
8576 self.travel_steps = v.into_iter().map(|i| i.into()).collect();
8577 self
8578 }
8579
8580 /// Sets the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
8581 ///
8582 /// # Example
8583 /// ```ignore,no_run
8584 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8585 /// use wkt::Duration;
8586 /// let x = ShipmentRoute::new().set_vehicle_detour(Duration::default()/* use setters */);
8587 /// ```
8588 #[deprecated]
8589 pub fn set_vehicle_detour<T>(mut self, v: T) -> Self
8590 where
8591 T: std::convert::Into<wkt::Duration>,
8592 {
8593 self.vehicle_detour = std::option::Option::Some(v.into());
8594 self
8595 }
8596
8597 /// Sets or clears the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
8598 ///
8599 /// # Example
8600 /// ```ignore,no_run
8601 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8602 /// use wkt::Duration;
8603 /// let x = ShipmentRoute::new().set_or_clear_vehicle_detour(Some(Duration::default()/* use setters */));
8604 /// let x = ShipmentRoute::new().set_or_clear_vehicle_detour(None::<Duration>);
8605 /// ```
8606 #[deprecated]
8607 pub fn set_or_clear_vehicle_detour<T>(mut self, v: std::option::Option<T>) -> Self
8608 where
8609 T: std::convert::Into<wkt::Duration>,
8610 {
8611 self.vehicle_detour = v.map(|x| x.into());
8612 self
8613 }
8614
8615 /// Sets the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
8616 ///
8617 /// # Example
8618 /// ```ignore,no_run
8619 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8620 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
8621 /// let x = ShipmentRoute::new().set_delay_before_vehicle_end(Delay::default()/* use setters */);
8622 /// ```
8623 #[deprecated]
8624 pub fn set_delay_before_vehicle_end<T>(mut self, v: T) -> Self
8625 where
8626 T: std::convert::Into<crate::model::shipment_route::Delay>,
8627 {
8628 self.delay_before_vehicle_end = std::option::Option::Some(v.into());
8629 self
8630 }
8631
8632 /// Sets or clears the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
8633 ///
8634 /// # Example
8635 /// ```ignore,no_run
8636 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8637 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
8638 /// let x = ShipmentRoute::new().set_or_clear_delay_before_vehicle_end(Some(Delay::default()/* use setters */));
8639 /// let x = ShipmentRoute::new().set_or_clear_delay_before_vehicle_end(None::<Delay>);
8640 /// ```
8641 #[deprecated]
8642 pub fn set_or_clear_delay_before_vehicle_end<T>(mut self, v: std::option::Option<T>) -> Self
8643 where
8644 T: std::convert::Into<crate::model::shipment_route::Delay>,
8645 {
8646 self.delay_before_vehicle_end = v.map(|x| x.into());
8647 self
8648 }
8649}
8650
8651impl wkt::message::Message for ShipmentRoute {
8652 fn typename() -> &'static str {
8653 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute"
8654 }
8655}
8656
8657/// Defines additional types related to [ShipmentRoute].
8658pub mod shipment_route {
8659 #[allow(unused_imports)]
8660 use super::*;
8661
8662 /// Deprecated: Use
8663 /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
8664 /// instead. Time interval spent on the route resulting from a
8665 /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
8666 ///
8667 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
8668 /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
8669 #[derive(Clone, Default, PartialEq)]
8670 #[non_exhaustive]
8671 #[deprecated]
8672 pub struct Delay {
8673 /// Start of the delay.
8674 pub start_time: std::option::Option<wkt::Timestamp>,
8675
8676 /// Duration of the delay.
8677 pub duration: std::option::Option<wkt::Duration>,
8678
8679 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8680 }
8681
8682 impl Delay {
8683 /// Creates a new default instance.
8684 pub fn new() -> Self {
8685 std::default::Default::default()
8686 }
8687
8688 /// Sets the value of [start_time][crate::model::shipment_route::Delay::start_time].
8689 ///
8690 /// # Example
8691 /// ```ignore,no_run
8692 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8693 /// use wkt::Timestamp;
8694 /// let x = Delay::new().set_start_time(Timestamp::default()/* use setters */);
8695 /// ```
8696 pub fn set_start_time<T>(mut self, v: T) -> Self
8697 where
8698 T: std::convert::Into<wkt::Timestamp>,
8699 {
8700 self.start_time = std::option::Option::Some(v.into());
8701 self
8702 }
8703
8704 /// Sets or clears the value of [start_time][crate::model::shipment_route::Delay::start_time].
8705 ///
8706 /// # Example
8707 /// ```ignore,no_run
8708 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8709 /// use wkt::Timestamp;
8710 /// let x = Delay::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
8711 /// let x = Delay::new().set_or_clear_start_time(None::<Timestamp>);
8712 /// ```
8713 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8714 where
8715 T: std::convert::Into<wkt::Timestamp>,
8716 {
8717 self.start_time = v.map(|x| x.into());
8718 self
8719 }
8720
8721 /// Sets the value of [duration][crate::model::shipment_route::Delay::duration].
8722 ///
8723 /// # Example
8724 /// ```ignore,no_run
8725 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8726 /// use wkt::Duration;
8727 /// let x = Delay::new().set_duration(Duration::default()/* use setters */);
8728 /// ```
8729 pub fn set_duration<T>(mut self, v: T) -> Self
8730 where
8731 T: std::convert::Into<wkt::Duration>,
8732 {
8733 self.duration = std::option::Option::Some(v.into());
8734 self
8735 }
8736
8737 /// Sets or clears the value of [duration][crate::model::shipment_route::Delay::duration].
8738 ///
8739 /// # Example
8740 /// ```ignore,no_run
8741 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8742 /// use wkt::Duration;
8743 /// let x = Delay::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
8744 /// let x = Delay::new().set_or_clear_duration(None::<Duration>);
8745 /// ```
8746 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
8747 where
8748 T: std::convert::Into<wkt::Duration>,
8749 {
8750 self.duration = v.map(|x| x.into());
8751 self
8752 }
8753 }
8754
8755 impl wkt::message::Message for Delay {
8756 fn typename() -> &'static str {
8757 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Delay"
8758 }
8759 }
8760
8761 /// A visit performed during a route. This visit corresponds to a pickup or a
8762 /// delivery of a `Shipment`.
8763 #[derive(Clone, Default, PartialEq)]
8764 #[non_exhaustive]
8765 pub struct Visit {
8766 /// Index of the `shipments` field in the source
8767 /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel].
8768 ///
8769 /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
8770 pub shipment_index: i32,
8771
8772 /// If true the visit corresponds to a pickup of a `Shipment`. Otherwise, it
8773 /// corresponds to a delivery.
8774 pub is_pickup: bool,
8775
8776 /// Index of `VisitRequest` in either the pickup or delivery field of the
8777 /// `Shipment` (see `is_pickup`).
8778 pub visit_request_index: i32,
8779
8780 /// Time at which the visit starts. Note that the vehicle may arrive earlier
8781 /// than this at the visit location. Times are consistent with the
8782 /// `ShipmentModel`.
8783 pub start_time: std::option::Option<wkt::Timestamp>,
8784
8785 /// Total visit load demand as the sum of the shipment and the visit request
8786 /// `load_demands`. The values are negative if the visit is a delivery.
8787 /// Demands are reported for the same types as the
8788 /// [Transition.loads][google.cloud.optimization.v1.ShipmentRoute.Transition]
8789 /// (see this field).
8790 ///
8791 /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
8792 pub load_demands:
8793 std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
8794
8795 /// Extra detour time due to the shipments visited on the route before the
8796 /// visit and to the potential waiting time induced by time windows.
8797 /// If the visit is a delivery, the detour is computed from the corresponding
8798 /// pickup visit and is equal to:
8799 ///
8800 /// ```norust
8801 /// start_time(delivery) - start_time(pickup)
8802 /// - (duration(pickup) + travel duration from the pickup location
8803 /// to the delivery location).
8804 /// ```
8805 ///
8806 /// Otherwise, it is computed from the vehicle `start_location` and is equal
8807 /// to:
8808 ///
8809 /// ```norust
8810 /// start_time - vehicle_start_time - travel duration from
8811 /// the vehicle's `start_location` to the visit.
8812 /// ```
8813 pub detour: std::option::Option<wkt::Duration>,
8814
8815 /// Copy of the corresponding `Shipment.label`, if specified in the
8816 /// `Shipment`.
8817 pub shipment_label: std::string::String,
8818
8819 /// Copy of the corresponding
8820 /// [VisitRequest.label][google.cloud.optimization.v1.Shipment.VisitRequest.label],
8821 /// if specified in the `VisitRequest`.
8822 ///
8823 /// [google.cloud.optimization.v1.Shipment.VisitRequest.label]: crate::model::shipment::VisitRequest::label
8824 pub visit_label: std::string::String,
8825
8826 /// Deprecated: Use
8827 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
8828 /// instead. Vehicle loads upon arrival at the visit location, for each type
8829 /// specified in
8830 /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
8831 /// `start_load_intervals`, `end_load_intervals` or `demands`.
8832 ///
8833 /// Exception: we omit loads for quantity types unconstrained by intervals
8834 /// and that don't have any non-zero demand on the route.
8835 ///
8836 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
8837 /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
8838 #[deprecated]
8839 pub arrival_loads: std::vec::Vec<crate::model::CapacityQuantity>,
8840
8841 /// Deprecated: Use
8842 /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
8843 /// instead. Delay occurring before the visit starts.
8844 ///
8845 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
8846 #[deprecated]
8847 pub delay_before_start: std::option::Option<crate::model::shipment_route::Delay>,
8848
8849 /// Deprecated: Use
8850 /// [Visit.load_demands][google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]
8851 /// instead.
8852 ///
8853 /// [google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]: crate::model::shipment_route::Visit::load_demands
8854 #[deprecated]
8855 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
8856
8857 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8858 }
8859
8860 impl Visit {
8861 /// Creates a new default instance.
8862 pub fn new() -> Self {
8863 std::default::Default::default()
8864 }
8865
8866 /// Sets the value of [shipment_index][crate::model::shipment_route::Visit::shipment_index].
8867 ///
8868 /// # Example
8869 /// ```ignore,no_run
8870 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8871 /// let x = Visit::new().set_shipment_index(42);
8872 /// ```
8873 pub fn set_shipment_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8874 self.shipment_index = v.into();
8875 self
8876 }
8877
8878 /// Sets the value of [is_pickup][crate::model::shipment_route::Visit::is_pickup].
8879 ///
8880 /// # Example
8881 /// ```ignore,no_run
8882 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8883 /// let x = Visit::new().set_is_pickup(true);
8884 /// ```
8885 pub fn set_is_pickup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8886 self.is_pickup = v.into();
8887 self
8888 }
8889
8890 /// Sets the value of [visit_request_index][crate::model::shipment_route::Visit::visit_request_index].
8891 ///
8892 /// # Example
8893 /// ```ignore,no_run
8894 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8895 /// let x = Visit::new().set_visit_request_index(42);
8896 /// ```
8897 pub fn set_visit_request_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8898 self.visit_request_index = v.into();
8899 self
8900 }
8901
8902 /// Sets the value of [start_time][crate::model::shipment_route::Visit::start_time].
8903 ///
8904 /// # Example
8905 /// ```ignore,no_run
8906 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8907 /// use wkt::Timestamp;
8908 /// let x = Visit::new().set_start_time(Timestamp::default()/* use setters */);
8909 /// ```
8910 pub fn set_start_time<T>(mut self, v: T) -> Self
8911 where
8912 T: std::convert::Into<wkt::Timestamp>,
8913 {
8914 self.start_time = std::option::Option::Some(v.into());
8915 self
8916 }
8917
8918 /// Sets or clears the value of [start_time][crate::model::shipment_route::Visit::start_time].
8919 ///
8920 /// # Example
8921 /// ```ignore,no_run
8922 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8923 /// use wkt::Timestamp;
8924 /// let x = Visit::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
8925 /// let x = Visit::new().set_or_clear_start_time(None::<Timestamp>);
8926 /// ```
8927 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8928 where
8929 T: std::convert::Into<wkt::Timestamp>,
8930 {
8931 self.start_time = v.map(|x| x.into());
8932 self
8933 }
8934
8935 /// Sets the value of [load_demands][crate::model::shipment_route::Visit::load_demands].
8936 ///
8937 /// # Example
8938 /// ```ignore,no_run
8939 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8940 /// use google_cloud_optimization_v1::model::shipment::Load;
8941 /// let x = Visit::new().set_load_demands([
8942 /// ("key0", Load::default()/* use setters */),
8943 /// ("key1", Load::default()/* use (different) setters */),
8944 /// ]);
8945 /// ```
8946 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
8947 where
8948 T: std::iter::IntoIterator<Item = (K, V)>,
8949 K: std::convert::Into<std::string::String>,
8950 V: std::convert::Into<crate::model::shipment::Load>,
8951 {
8952 use std::iter::Iterator;
8953 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8954 self
8955 }
8956
8957 /// Sets the value of [detour][crate::model::shipment_route::Visit::detour].
8958 ///
8959 /// # Example
8960 /// ```ignore,no_run
8961 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8962 /// use wkt::Duration;
8963 /// let x = Visit::new().set_detour(Duration::default()/* use setters */);
8964 /// ```
8965 pub fn set_detour<T>(mut self, v: T) -> Self
8966 where
8967 T: std::convert::Into<wkt::Duration>,
8968 {
8969 self.detour = std::option::Option::Some(v.into());
8970 self
8971 }
8972
8973 /// Sets or clears the value of [detour][crate::model::shipment_route::Visit::detour].
8974 ///
8975 /// # Example
8976 /// ```ignore,no_run
8977 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8978 /// use wkt::Duration;
8979 /// let x = Visit::new().set_or_clear_detour(Some(Duration::default()/* use setters */));
8980 /// let x = Visit::new().set_or_clear_detour(None::<Duration>);
8981 /// ```
8982 pub fn set_or_clear_detour<T>(mut self, v: std::option::Option<T>) -> Self
8983 where
8984 T: std::convert::Into<wkt::Duration>,
8985 {
8986 self.detour = v.map(|x| x.into());
8987 self
8988 }
8989
8990 /// Sets the value of [shipment_label][crate::model::shipment_route::Visit::shipment_label].
8991 ///
8992 /// # Example
8993 /// ```ignore,no_run
8994 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8995 /// let x = Visit::new().set_shipment_label("example");
8996 /// ```
8997 pub fn set_shipment_label<T: std::convert::Into<std::string::String>>(
8998 mut self,
8999 v: T,
9000 ) -> Self {
9001 self.shipment_label = v.into();
9002 self
9003 }
9004
9005 /// Sets the value of [visit_label][crate::model::shipment_route::Visit::visit_label].
9006 ///
9007 /// # Example
9008 /// ```ignore,no_run
9009 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9010 /// let x = Visit::new().set_visit_label("example");
9011 /// ```
9012 pub fn set_visit_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9013 self.visit_label = v.into();
9014 self
9015 }
9016
9017 /// Sets the value of [arrival_loads][crate::model::shipment_route::Visit::arrival_loads].
9018 ///
9019 /// # Example
9020 /// ```ignore,no_run
9021 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9022 /// use google_cloud_optimization_v1::model::CapacityQuantity;
9023 /// let x = Visit::new()
9024 /// .set_arrival_loads([
9025 /// CapacityQuantity::default()/* use setters */,
9026 /// CapacityQuantity::default()/* use (different) setters */,
9027 /// ]);
9028 /// ```
9029 #[deprecated]
9030 pub fn set_arrival_loads<T, V>(mut self, v: T) -> Self
9031 where
9032 T: std::iter::IntoIterator<Item = V>,
9033 V: std::convert::Into<crate::model::CapacityQuantity>,
9034 {
9035 use std::iter::Iterator;
9036 self.arrival_loads = v.into_iter().map(|i| i.into()).collect();
9037 self
9038 }
9039
9040 /// Sets the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
9041 ///
9042 /// # Example
9043 /// ```ignore,no_run
9044 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9045 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
9046 /// let x = Visit::new().set_delay_before_start(Delay::default()/* use setters */);
9047 /// ```
9048 #[deprecated]
9049 pub fn set_delay_before_start<T>(mut self, v: T) -> Self
9050 where
9051 T: std::convert::Into<crate::model::shipment_route::Delay>,
9052 {
9053 self.delay_before_start = std::option::Option::Some(v.into());
9054 self
9055 }
9056
9057 /// Sets or clears the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
9058 ///
9059 /// # Example
9060 /// ```ignore,no_run
9061 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9062 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
9063 /// let x = Visit::new().set_or_clear_delay_before_start(Some(Delay::default()/* use setters */));
9064 /// let x = Visit::new().set_or_clear_delay_before_start(None::<Delay>);
9065 /// ```
9066 #[deprecated]
9067 pub fn set_or_clear_delay_before_start<T>(mut self, v: std::option::Option<T>) -> Self
9068 where
9069 T: std::convert::Into<crate::model::shipment_route::Delay>,
9070 {
9071 self.delay_before_start = v.map(|x| x.into());
9072 self
9073 }
9074
9075 /// Sets the value of [demands][crate::model::shipment_route::Visit::demands].
9076 ///
9077 /// # Example
9078 /// ```ignore,no_run
9079 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9080 /// use google_cloud_optimization_v1::model::CapacityQuantity;
9081 /// let x = Visit::new()
9082 /// .set_demands([
9083 /// CapacityQuantity::default()/* use setters */,
9084 /// CapacityQuantity::default()/* use (different) setters */,
9085 /// ]);
9086 /// ```
9087 #[deprecated]
9088 pub fn set_demands<T, V>(mut self, v: T) -> Self
9089 where
9090 T: std::iter::IntoIterator<Item = V>,
9091 V: std::convert::Into<crate::model::CapacityQuantity>,
9092 {
9093 use std::iter::Iterator;
9094 self.demands = v.into_iter().map(|i| i.into()).collect();
9095 self
9096 }
9097 }
9098
9099 impl wkt::message::Message for Visit {
9100 fn typename() -> &'static str {
9101 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Visit"
9102 }
9103 }
9104
9105 /// Transition between two events on the route. See the description of
9106 /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
9107 ///
9108 /// If the vehicle does not have a `start_location` and/or `end_location`, the
9109 /// corresponding travel metrics are 0.
9110 ///
9111 /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
9112 #[derive(Clone, Default, PartialEq)]
9113 #[non_exhaustive]
9114 pub struct Transition {
9115 /// Travel duration during this transition.
9116 pub travel_duration: std::option::Option<wkt::Duration>,
9117
9118 /// Distance traveled during the transition.
9119 pub travel_distance_meters: f64,
9120
9121 /// When traffic is requested via
9122 /// [OptimizeToursRequest.consider_road_traffic]
9123 /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
9124 /// and the traffic info couldn't be retrieved for a `Transition`, this
9125 /// boolean is set to true. This may be temporary (rare hiccup in the
9126 /// realtime traffic servers) or permanent (no data for this location).
9127 pub traffic_info_unavailable: bool,
9128
9129 /// Sum of the delay durations applied to this transition. If any, the delay
9130 /// starts exactly `delay_duration` seconds before the next event (visit or
9131 /// vehicle end). See
9132 /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
9133 ///
9134 /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
9135 pub delay_duration: std::option::Option<wkt::Duration>,
9136
9137 /// Sum of the duration of the breaks occurring during this transition, if
9138 /// any. Details about each break's start time and duration are stored in
9139 /// [ShipmentRoute.breaks][google.cloud.optimization.v1.ShipmentRoute.breaks].
9140 ///
9141 /// [google.cloud.optimization.v1.ShipmentRoute.breaks]: crate::model::ShipmentRoute::breaks
9142 pub break_duration: std::option::Option<wkt::Duration>,
9143
9144 /// Time spent waiting during this transition. Wait duration corresponds to
9145 /// idle time and does not include break time. Also note that this wait time
9146 /// may be split into several non-contiguous intervals.
9147 pub wait_duration: std::option::Option<wkt::Duration>,
9148
9149 /// Total duration of the transition, provided for convenience. It is equal
9150 /// to:
9151 ///
9152 /// * next visit `start_time` (or `vehicle_end_time` if this is the last
9153 /// transition) - this transition's `start_time`;
9154 /// * if `ShipmentRoute.has_traffic_infeasibilities` is false, the following
9155 /// additionally holds: `total_duration = travel_duration + delay_duration
9156 ///
9157 /// + break_duration + wait_duration`.
9158 pub total_duration: std::option::Option<wkt::Duration>,
9159
9160 /// Start time of this transition.
9161 pub start_time: std::option::Option<wkt::Timestamp>,
9162
9163 /// The encoded polyline representation of the route followed during the
9164 /// transition.
9165 /// This field is only populated if [populate_transition_polylines]
9166 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
9167 /// is set to true.
9168 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
9169
9170 /// Vehicle loads during this transition, for each type that either appears
9171 /// in this vehicle's
9172 /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits],
9173 /// or that have non-zero
9174 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
9175 /// on some shipment performed on this route.
9176 ///
9177 /// The loads during the first transition are the starting loads of the
9178 /// vehicle route. Then, after each visit, the visit's `load_demands` are
9179 /// either added or subtracted to get the next transition's loads, depending
9180 /// on whether the visit was a pickup or a delivery.
9181 ///
9182 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
9183 /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
9184 pub vehicle_loads: std::collections::HashMap<
9185 std::string::String,
9186 crate::model::shipment_route::VehicleLoad,
9187 >,
9188
9189 /// Deprecated: Use
9190 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
9191 /// instead.
9192 ///
9193 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9194 #[deprecated]
9195 pub loads: std::vec::Vec<crate::model::CapacityQuantity>,
9196
9197 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9198 }
9199
9200 impl Transition {
9201 /// Creates a new default instance.
9202 pub fn new() -> Self {
9203 std::default::Default::default()
9204 }
9205
9206 /// Sets the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
9207 ///
9208 /// # Example
9209 /// ```ignore,no_run
9210 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9211 /// use wkt::Duration;
9212 /// let x = Transition::new().set_travel_duration(Duration::default()/* use setters */);
9213 /// ```
9214 pub fn set_travel_duration<T>(mut self, v: T) -> Self
9215 where
9216 T: std::convert::Into<wkt::Duration>,
9217 {
9218 self.travel_duration = std::option::Option::Some(v.into());
9219 self
9220 }
9221
9222 /// Sets or clears the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
9223 ///
9224 /// # Example
9225 /// ```ignore,no_run
9226 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9227 /// use wkt::Duration;
9228 /// let x = Transition::new().set_or_clear_travel_duration(Some(Duration::default()/* use setters */));
9229 /// let x = Transition::new().set_or_clear_travel_duration(None::<Duration>);
9230 /// ```
9231 pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
9232 where
9233 T: std::convert::Into<wkt::Duration>,
9234 {
9235 self.travel_duration = v.map(|x| x.into());
9236 self
9237 }
9238
9239 /// Sets the value of [travel_distance_meters][crate::model::shipment_route::Transition::travel_distance_meters].
9240 ///
9241 /// # Example
9242 /// ```ignore,no_run
9243 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9244 /// let x = Transition::new().set_travel_distance_meters(42.0);
9245 /// ```
9246 pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9247 self.travel_distance_meters = v.into();
9248 self
9249 }
9250
9251 /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::Transition::traffic_info_unavailable].
9252 ///
9253 /// # Example
9254 /// ```ignore,no_run
9255 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9256 /// let x = Transition::new().set_traffic_info_unavailable(true);
9257 /// ```
9258 pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9259 self.traffic_info_unavailable = v.into();
9260 self
9261 }
9262
9263 /// Sets the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
9264 ///
9265 /// # Example
9266 /// ```ignore,no_run
9267 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9268 /// use wkt::Duration;
9269 /// let x = Transition::new().set_delay_duration(Duration::default()/* use setters */);
9270 /// ```
9271 pub fn set_delay_duration<T>(mut self, v: T) -> Self
9272 where
9273 T: std::convert::Into<wkt::Duration>,
9274 {
9275 self.delay_duration = std::option::Option::Some(v.into());
9276 self
9277 }
9278
9279 /// Sets or clears the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
9280 ///
9281 /// # Example
9282 /// ```ignore,no_run
9283 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9284 /// use wkt::Duration;
9285 /// let x = Transition::new().set_or_clear_delay_duration(Some(Duration::default()/* use setters */));
9286 /// let x = Transition::new().set_or_clear_delay_duration(None::<Duration>);
9287 /// ```
9288 pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
9289 where
9290 T: std::convert::Into<wkt::Duration>,
9291 {
9292 self.delay_duration = v.map(|x| x.into());
9293 self
9294 }
9295
9296 /// Sets the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
9297 ///
9298 /// # Example
9299 /// ```ignore,no_run
9300 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9301 /// use wkt::Duration;
9302 /// let x = Transition::new().set_break_duration(Duration::default()/* use setters */);
9303 /// ```
9304 pub fn set_break_duration<T>(mut self, v: T) -> Self
9305 where
9306 T: std::convert::Into<wkt::Duration>,
9307 {
9308 self.break_duration = std::option::Option::Some(v.into());
9309 self
9310 }
9311
9312 /// Sets or clears the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
9313 ///
9314 /// # Example
9315 /// ```ignore,no_run
9316 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9317 /// use wkt::Duration;
9318 /// let x = Transition::new().set_or_clear_break_duration(Some(Duration::default()/* use setters */));
9319 /// let x = Transition::new().set_or_clear_break_duration(None::<Duration>);
9320 /// ```
9321 pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
9322 where
9323 T: std::convert::Into<wkt::Duration>,
9324 {
9325 self.break_duration = v.map(|x| x.into());
9326 self
9327 }
9328
9329 /// Sets the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
9330 ///
9331 /// # Example
9332 /// ```ignore,no_run
9333 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9334 /// use wkt::Duration;
9335 /// let x = Transition::new().set_wait_duration(Duration::default()/* use setters */);
9336 /// ```
9337 pub fn set_wait_duration<T>(mut self, v: T) -> Self
9338 where
9339 T: std::convert::Into<wkt::Duration>,
9340 {
9341 self.wait_duration = std::option::Option::Some(v.into());
9342 self
9343 }
9344
9345 /// Sets or clears the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
9346 ///
9347 /// # Example
9348 /// ```ignore,no_run
9349 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9350 /// use wkt::Duration;
9351 /// let x = Transition::new().set_or_clear_wait_duration(Some(Duration::default()/* use setters */));
9352 /// let x = Transition::new().set_or_clear_wait_duration(None::<Duration>);
9353 /// ```
9354 pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
9355 where
9356 T: std::convert::Into<wkt::Duration>,
9357 {
9358 self.wait_duration = v.map(|x| x.into());
9359 self
9360 }
9361
9362 /// Sets the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
9363 ///
9364 /// # Example
9365 /// ```ignore,no_run
9366 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9367 /// use wkt::Duration;
9368 /// let x = Transition::new().set_total_duration(Duration::default()/* use setters */);
9369 /// ```
9370 pub fn set_total_duration<T>(mut self, v: T) -> Self
9371 where
9372 T: std::convert::Into<wkt::Duration>,
9373 {
9374 self.total_duration = std::option::Option::Some(v.into());
9375 self
9376 }
9377
9378 /// Sets or clears the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
9379 ///
9380 /// # Example
9381 /// ```ignore,no_run
9382 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9383 /// use wkt::Duration;
9384 /// let x = Transition::new().set_or_clear_total_duration(Some(Duration::default()/* use setters */));
9385 /// let x = Transition::new().set_or_clear_total_duration(None::<Duration>);
9386 /// ```
9387 pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
9388 where
9389 T: std::convert::Into<wkt::Duration>,
9390 {
9391 self.total_duration = v.map(|x| x.into());
9392 self
9393 }
9394
9395 /// Sets the value of [start_time][crate::model::shipment_route::Transition::start_time].
9396 ///
9397 /// # Example
9398 /// ```ignore,no_run
9399 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9400 /// use wkt::Timestamp;
9401 /// let x = Transition::new().set_start_time(Timestamp::default()/* use setters */);
9402 /// ```
9403 pub fn set_start_time<T>(mut self, v: T) -> Self
9404 where
9405 T: std::convert::Into<wkt::Timestamp>,
9406 {
9407 self.start_time = std::option::Option::Some(v.into());
9408 self
9409 }
9410
9411 /// Sets or clears the value of [start_time][crate::model::shipment_route::Transition::start_time].
9412 ///
9413 /// # Example
9414 /// ```ignore,no_run
9415 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9416 /// use wkt::Timestamp;
9417 /// let x = Transition::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
9418 /// let x = Transition::new().set_or_clear_start_time(None::<Timestamp>);
9419 /// ```
9420 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
9421 where
9422 T: std::convert::Into<wkt::Timestamp>,
9423 {
9424 self.start_time = v.map(|x| x.into());
9425 self
9426 }
9427
9428 /// Sets the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
9429 ///
9430 /// # Example
9431 /// ```ignore,no_run
9432 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9433 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9434 /// let x = Transition::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
9435 /// ```
9436 pub fn set_route_polyline<T>(mut self, v: T) -> Self
9437 where
9438 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9439 {
9440 self.route_polyline = std::option::Option::Some(v.into());
9441 self
9442 }
9443
9444 /// Sets or clears the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
9445 ///
9446 /// # Example
9447 /// ```ignore,no_run
9448 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9449 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9450 /// let x = Transition::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
9451 /// let x = Transition::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
9452 /// ```
9453 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
9454 where
9455 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9456 {
9457 self.route_polyline = v.map(|x| x.into());
9458 self
9459 }
9460
9461 /// Sets the value of [vehicle_loads][crate::model::shipment_route::Transition::vehicle_loads].
9462 ///
9463 /// # Example
9464 /// ```ignore,no_run
9465 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9466 /// use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
9467 /// let x = Transition::new().set_vehicle_loads([
9468 /// ("key0", VehicleLoad::default()/* use setters */),
9469 /// ("key1", VehicleLoad::default()/* use (different) setters */),
9470 /// ]);
9471 /// ```
9472 pub fn set_vehicle_loads<T, K, V>(mut self, v: T) -> Self
9473 where
9474 T: std::iter::IntoIterator<Item = (K, V)>,
9475 K: std::convert::Into<std::string::String>,
9476 V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
9477 {
9478 use std::iter::Iterator;
9479 self.vehicle_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
9480 self
9481 }
9482
9483 /// Sets the value of [loads][crate::model::shipment_route::Transition::loads].
9484 ///
9485 /// # Example
9486 /// ```ignore,no_run
9487 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9488 /// use google_cloud_optimization_v1::model::CapacityQuantity;
9489 /// let x = Transition::new()
9490 /// .set_loads([
9491 /// CapacityQuantity::default()/* use setters */,
9492 /// CapacityQuantity::default()/* use (different) setters */,
9493 /// ]);
9494 /// ```
9495 #[deprecated]
9496 pub fn set_loads<T, V>(mut self, v: T) -> Self
9497 where
9498 T: std::iter::IntoIterator<Item = V>,
9499 V: std::convert::Into<crate::model::CapacityQuantity>,
9500 {
9501 use std::iter::Iterator;
9502 self.loads = v.into_iter().map(|i| i.into()).collect();
9503 self
9504 }
9505 }
9506
9507 impl wkt::message::Message for Transition {
9508 fn typename() -> &'static str {
9509 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Transition"
9510 }
9511 }
9512
9513 /// Reports the actual load of the vehicle at some point along the route,
9514 /// for a given type (see
9515 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]).
9516 ///
9517 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9518 #[derive(Clone, Default, PartialEq)]
9519 #[non_exhaustive]
9520 pub struct VehicleLoad {
9521 /// The amount of load on the vehicle, for the given type. The unit of load
9522 /// is usually indicated by the type. See
9523 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads].
9524 ///
9525 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9526 pub amount: i64,
9527
9528 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9529 }
9530
9531 impl VehicleLoad {
9532 /// Creates a new default instance.
9533 pub fn new() -> Self {
9534 std::default::Default::default()
9535 }
9536
9537 /// Sets the value of [amount][crate::model::shipment_route::VehicleLoad::amount].
9538 ///
9539 /// # Example
9540 /// ```ignore,no_run
9541 /// # use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
9542 /// let x = VehicleLoad::new().set_amount(42);
9543 /// ```
9544 pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
9545 self.amount = v.into();
9546 self
9547 }
9548 }
9549
9550 impl wkt::message::Message for VehicleLoad {
9551 fn typename() -> &'static str {
9552 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.VehicleLoad"
9553 }
9554 }
9555
9556 /// The encoded representation of a polyline. More information on polyline
9557 /// encoding can be found here:
9558 /// <https://developers.google.com/maps/documentation/utilities/polylinealgorithm>
9559 /// <https://developers.google.com/maps/documentation/javascript/reference/geometry#encoding>.
9560 #[derive(Clone, Default, PartialEq)]
9561 #[non_exhaustive]
9562 pub struct EncodedPolyline {
9563 /// String representing encoded points of the polyline.
9564 pub points: std::string::String,
9565
9566 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9567 }
9568
9569 impl EncodedPolyline {
9570 /// Creates a new default instance.
9571 pub fn new() -> Self {
9572 std::default::Default::default()
9573 }
9574
9575 /// Sets the value of [points][crate::model::shipment_route::EncodedPolyline::points].
9576 ///
9577 /// # Example
9578 /// ```ignore,no_run
9579 /// # use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9580 /// let x = EncodedPolyline::new().set_points("example");
9581 /// ```
9582 pub fn set_points<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9583 self.points = v.into();
9584 self
9585 }
9586 }
9587
9588 impl wkt::message::Message for EncodedPolyline {
9589 fn typename() -> &'static str {
9590 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.EncodedPolyline"
9591 }
9592 }
9593
9594 /// Data representing the execution of a break.
9595 #[derive(Clone, Default, PartialEq)]
9596 #[non_exhaustive]
9597 pub struct Break {
9598 /// Start time of a break.
9599 pub start_time: std::option::Option<wkt::Timestamp>,
9600
9601 /// Duration of a break.
9602 pub duration: std::option::Option<wkt::Duration>,
9603
9604 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9605 }
9606
9607 impl Break {
9608 /// Creates a new default instance.
9609 pub fn new() -> Self {
9610 std::default::Default::default()
9611 }
9612
9613 /// Sets the value of [start_time][crate::model::shipment_route::Break::start_time].
9614 ///
9615 /// # Example
9616 /// ```ignore,no_run
9617 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9618 /// use wkt::Timestamp;
9619 /// let x = Break::new().set_start_time(Timestamp::default()/* use setters */);
9620 /// ```
9621 pub fn set_start_time<T>(mut self, v: T) -> Self
9622 where
9623 T: std::convert::Into<wkt::Timestamp>,
9624 {
9625 self.start_time = std::option::Option::Some(v.into());
9626 self
9627 }
9628
9629 /// Sets or clears the value of [start_time][crate::model::shipment_route::Break::start_time].
9630 ///
9631 /// # Example
9632 /// ```ignore,no_run
9633 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9634 /// use wkt::Timestamp;
9635 /// let x = Break::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
9636 /// let x = Break::new().set_or_clear_start_time(None::<Timestamp>);
9637 /// ```
9638 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
9639 where
9640 T: std::convert::Into<wkt::Timestamp>,
9641 {
9642 self.start_time = v.map(|x| x.into());
9643 self
9644 }
9645
9646 /// Sets the value of [duration][crate::model::shipment_route::Break::duration].
9647 ///
9648 /// # Example
9649 /// ```ignore,no_run
9650 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9651 /// use wkt::Duration;
9652 /// let x = Break::new().set_duration(Duration::default()/* use setters */);
9653 /// ```
9654 pub fn set_duration<T>(mut self, v: T) -> Self
9655 where
9656 T: std::convert::Into<wkt::Duration>,
9657 {
9658 self.duration = std::option::Option::Some(v.into());
9659 self
9660 }
9661
9662 /// Sets or clears the value of [duration][crate::model::shipment_route::Break::duration].
9663 ///
9664 /// # Example
9665 /// ```ignore,no_run
9666 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9667 /// use wkt::Duration;
9668 /// let x = Break::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
9669 /// let x = Break::new().set_or_clear_duration(None::<Duration>);
9670 /// ```
9671 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
9672 where
9673 T: std::convert::Into<wkt::Duration>,
9674 {
9675 self.duration = v.map(|x| x.into());
9676 self
9677 }
9678 }
9679
9680 impl wkt::message::Message for Break {
9681 fn typename() -> &'static str {
9682 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Break"
9683 }
9684 }
9685
9686 /// Deprecated: Use
9687 /// [ShipmentRoute.Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
9688 /// instead. Travel between each visit along the route: from the vehicle's
9689 /// `start_location` to the first visit's `arrival_location`, then from the
9690 /// first visit's `departure_location` to the second visit's
9691 /// `arrival_location`, and so on until the vehicle's `end_location`. This
9692 /// accounts only for the actual travel between visits, not counting the
9693 /// waiting time, the time spent performing a visit, nor the distance covered
9694 /// during a visit.
9695 ///
9696 /// Invariant: `travel_steps_size() == visits_size() + 1`.
9697 ///
9698 /// If the vehicle does not have a start_ and/or end_location, the
9699 /// corresponding travel metrics are 0 and/or empty.
9700 ///
9701 /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
9702 #[derive(Clone, Default, PartialEq)]
9703 #[non_exhaustive]
9704 #[deprecated]
9705 pub struct TravelStep {
9706 /// Duration of the travel step.
9707 pub duration: std::option::Option<wkt::Duration>,
9708
9709 /// Distance traveled during the step.
9710 pub distance_meters: f64,
9711
9712 /// When traffic is requested via
9713 /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
9714 /// and the traffic info couldn't be retrieved for a TravelStep, this boolean
9715 /// is set to true. This may be temporary (rare hiccup in the realtime
9716 /// traffic servers) or permanent (no data for this location).
9717 ///
9718 /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
9719 pub traffic_info_unavailable: bool,
9720
9721 /// The encoded polyline representation of the route followed during the
9722 /// step.
9723 ///
9724 /// This field is only populated if
9725 /// [OptimizeToursRequest.populate_travel_step_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]
9726 /// is set to true.
9727 ///
9728 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]: crate::model::OptimizeToursRequest::populate_travel_step_polylines
9729 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
9730
9731 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9732 }
9733
9734 impl TravelStep {
9735 /// Creates a new default instance.
9736 pub fn new() -> Self {
9737 std::default::Default::default()
9738 }
9739
9740 /// Sets the value of [duration][crate::model::shipment_route::TravelStep::duration].
9741 ///
9742 /// # Example
9743 /// ```ignore,no_run
9744 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9745 /// use wkt::Duration;
9746 /// let x = TravelStep::new().set_duration(Duration::default()/* use setters */);
9747 /// ```
9748 pub fn set_duration<T>(mut self, v: T) -> Self
9749 where
9750 T: std::convert::Into<wkt::Duration>,
9751 {
9752 self.duration = std::option::Option::Some(v.into());
9753 self
9754 }
9755
9756 /// Sets or clears the value of [duration][crate::model::shipment_route::TravelStep::duration].
9757 ///
9758 /// # Example
9759 /// ```ignore,no_run
9760 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9761 /// use wkt::Duration;
9762 /// let x = TravelStep::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
9763 /// let x = TravelStep::new().set_or_clear_duration(None::<Duration>);
9764 /// ```
9765 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
9766 where
9767 T: std::convert::Into<wkt::Duration>,
9768 {
9769 self.duration = v.map(|x| x.into());
9770 self
9771 }
9772
9773 /// Sets the value of [distance_meters][crate::model::shipment_route::TravelStep::distance_meters].
9774 ///
9775 /// # Example
9776 /// ```ignore,no_run
9777 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9778 /// let x = TravelStep::new().set_distance_meters(42.0);
9779 /// ```
9780 pub fn set_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9781 self.distance_meters = v.into();
9782 self
9783 }
9784
9785 /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::TravelStep::traffic_info_unavailable].
9786 ///
9787 /// # Example
9788 /// ```ignore,no_run
9789 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9790 /// let x = TravelStep::new().set_traffic_info_unavailable(true);
9791 /// ```
9792 pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9793 self.traffic_info_unavailable = v.into();
9794 self
9795 }
9796
9797 /// Sets the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
9798 ///
9799 /// # Example
9800 /// ```ignore,no_run
9801 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9802 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9803 /// let x = TravelStep::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
9804 /// ```
9805 pub fn set_route_polyline<T>(mut self, v: T) -> Self
9806 where
9807 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9808 {
9809 self.route_polyline = std::option::Option::Some(v.into());
9810 self
9811 }
9812
9813 /// Sets or clears the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
9814 ///
9815 /// # Example
9816 /// ```ignore,no_run
9817 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9818 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9819 /// let x = TravelStep::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
9820 /// let x = TravelStep::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
9821 /// ```
9822 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
9823 where
9824 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9825 {
9826 self.route_polyline = v.map(|x| x.into());
9827 self
9828 }
9829 }
9830
9831 impl wkt::message::Message for TravelStep {
9832 fn typename() -> &'static str {
9833 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.TravelStep"
9834 }
9835 }
9836}
9837
9838/// Specifies details of unperformed shipments in a solution. For trivial cases
9839/// and/or if we are able to identify the cause for skipping, we report the
9840/// reason here.
9841#[derive(Clone, Default, PartialEq)]
9842#[non_exhaustive]
9843pub struct SkippedShipment {
9844 /// The index corresponds to the index of the shipment in the source
9845 /// `ShipmentModel`.
9846 pub index: i32,
9847
9848 /// Copy of the corresponding
9849 /// [Shipment.label][google.cloud.optimization.v1.Shipment.label], if specified
9850 /// in the `Shipment`.
9851 ///
9852 /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
9853 pub label: std::string::String,
9854
9855 /// A list of reasons that explain why the shipment was skipped. See comment
9856 /// above `Reason`.
9857 pub reasons: std::vec::Vec<crate::model::skipped_shipment::Reason>,
9858
9859 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9860}
9861
9862impl SkippedShipment {
9863 /// Creates a new default instance.
9864 pub fn new() -> Self {
9865 std::default::Default::default()
9866 }
9867
9868 /// Sets the value of [index][crate::model::SkippedShipment::index].
9869 ///
9870 /// # Example
9871 /// ```ignore,no_run
9872 /// # use google_cloud_optimization_v1::model::SkippedShipment;
9873 /// let x = SkippedShipment::new().set_index(42);
9874 /// ```
9875 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9876 self.index = v.into();
9877 self
9878 }
9879
9880 /// Sets the value of [label][crate::model::SkippedShipment::label].
9881 ///
9882 /// # Example
9883 /// ```ignore,no_run
9884 /// # use google_cloud_optimization_v1::model::SkippedShipment;
9885 /// let x = SkippedShipment::new().set_label("example");
9886 /// ```
9887 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9888 self.label = v.into();
9889 self
9890 }
9891
9892 /// Sets the value of [reasons][crate::model::SkippedShipment::reasons].
9893 ///
9894 /// # Example
9895 /// ```ignore,no_run
9896 /// # use google_cloud_optimization_v1::model::SkippedShipment;
9897 /// use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9898 /// let x = SkippedShipment::new()
9899 /// .set_reasons([
9900 /// Reason::default()/* use setters */,
9901 /// Reason::default()/* use (different) setters */,
9902 /// ]);
9903 /// ```
9904 pub fn set_reasons<T, V>(mut self, v: T) -> Self
9905 where
9906 T: std::iter::IntoIterator<Item = V>,
9907 V: std::convert::Into<crate::model::skipped_shipment::Reason>,
9908 {
9909 use std::iter::Iterator;
9910 self.reasons = v.into_iter().map(|i| i.into()).collect();
9911 self
9912 }
9913}
9914
9915impl wkt::message::Message for SkippedShipment {
9916 fn typename() -> &'static str {
9917 "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment"
9918 }
9919}
9920
9921/// Defines additional types related to [SkippedShipment].
9922pub mod skipped_shipment {
9923 #[allow(unused_imports)]
9924 use super::*;
9925
9926 /// If we can explain why the shipment was skipped, reasons will be listed
9927 /// here. If the reason is not the same for all vehicles, `reason` will have
9928 /// more than 1 element. A skipped shipment cannot have duplicate reasons,
9929 /// i.e. where all fields are the same except for `example_vehicle_index`.
9930 /// Example:
9931 ///
9932 /// ```norust
9933 /// reasons {
9934 /// code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
9935 /// example_vehicle_index: 1
9936 /// example_exceeded_capacity_type: "Apples"
9937 /// }
9938 /// reasons {
9939 /// code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
9940 /// example_vehicle_index: 3
9941 /// example_exceeded_capacity_type: "Pears"
9942 /// }
9943 /// reasons {
9944 /// code: CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT
9945 /// example_vehicle_index: 1
9946 /// }
9947 /// ```
9948 ///
9949 /// The skipped shipment is incompatible with all vehicles. The reasons may
9950 /// be different for all vehicles but at least one vehicle's "Apples"
9951 /// capacity would be exceeded (including vehicle 1), at least one vehicle's
9952 /// "Pears" capacity would be exceeded (including vehicle 3) and at least one
9953 /// vehicle's distance limit would be exceeded (including vehicle 1).
9954 #[derive(Clone, Default, PartialEq)]
9955 #[non_exhaustive]
9956 pub struct Reason {
9957 /// Refer to the comments of Code.
9958 pub code: crate::model::skipped_shipment::reason::Code,
9959
9960 /// If the reason is related to a shipment-vehicle incompatibility, this
9961 /// field provides the index of one relevant vehicle.
9962 pub example_vehicle_index: std::option::Option<i32>,
9963
9964 /// If the reason code is `DEMAND_EXCEEDS_VEHICLE_CAPACITY`, documents one
9965 /// capacity type that is exceeded.
9966 pub example_exceeded_capacity_type: std::string::String,
9967
9968 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9969 }
9970
9971 impl Reason {
9972 /// Creates a new default instance.
9973 pub fn new() -> Self {
9974 std::default::Default::default()
9975 }
9976
9977 /// Sets the value of [code][crate::model::skipped_shipment::Reason::code].
9978 ///
9979 /// # Example
9980 /// ```ignore,no_run
9981 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9982 /// use google_cloud_optimization_v1::model::skipped_shipment::reason::Code;
9983 /// let x0 = Reason::new().set_code(Code::NoVehicle);
9984 /// let x1 = Reason::new().set_code(Code::DemandExceedsVehicleCapacity);
9985 /// let x2 = Reason::new().set_code(Code::CannotBePerformedWithinVehicleDistanceLimit);
9986 /// ```
9987 pub fn set_code<T: std::convert::Into<crate::model::skipped_shipment::reason::Code>>(
9988 mut self,
9989 v: T,
9990 ) -> Self {
9991 self.code = v.into();
9992 self
9993 }
9994
9995 /// Sets the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
9996 ///
9997 /// # Example
9998 /// ```ignore,no_run
9999 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
10000 /// let x = Reason::new().set_example_vehicle_index(42);
10001 /// ```
10002 pub fn set_example_vehicle_index<T>(mut self, v: T) -> Self
10003 where
10004 T: std::convert::Into<i32>,
10005 {
10006 self.example_vehicle_index = std::option::Option::Some(v.into());
10007 self
10008 }
10009
10010 /// Sets or clears the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
10011 ///
10012 /// # Example
10013 /// ```ignore,no_run
10014 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
10015 /// let x = Reason::new().set_or_clear_example_vehicle_index(Some(42));
10016 /// let x = Reason::new().set_or_clear_example_vehicle_index(None::<i32>);
10017 /// ```
10018 pub fn set_or_clear_example_vehicle_index<T>(mut self, v: std::option::Option<T>) -> Self
10019 where
10020 T: std::convert::Into<i32>,
10021 {
10022 self.example_vehicle_index = v.map(|x| x.into());
10023 self
10024 }
10025
10026 /// Sets the value of [example_exceeded_capacity_type][crate::model::skipped_shipment::Reason::example_exceeded_capacity_type].
10027 ///
10028 /// # Example
10029 /// ```ignore,no_run
10030 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
10031 /// let x = Reason::new().set_example_exceeded_capacity_type("example");
10032 /// ```
10033 pub fn set_example_exceeded_capacity_type<T: std::convert::Into<std::string::String>>(
10034 mut self,
10035 v: T,
10036 ) -> Self {
10037 self.example_exceeded_capacity_type = v.into();
10038 self
10039 }
10040 }
10041
10042 impl wkt::message::Message for Reason {
10043 fn typename() -> &'static str {
10044 "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment.Reason"
10045 }
10046 }
10047
10048 /// Defines additional types related to [Reason].
10049 pub mod reason {
10050 #[allow(unused_imports)]
10051 use super::*;
10052
10053 /// Code identifying the reason type. The order here is meaningless. In
10054 /// particular, it gives no indication of whether a given reason will
10055 /// appear before another in the solution, if both apply.
10056 ///
10057 /// # Working with unknown values
10058 ///
10059 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10060 /// additional enum variants at any time. Adding new variants is not considered
10061 /// a breaking change. Applications should write their code in anticipation of:
10062 ///
10063 /// - New values appearing in future releases of the client library, **and**
10064 /// - New values received dynamically, without application changes.
10065 ///
10066 /// Please consult the [Working with enums] section in the user guide for some
10067 /// guidelines.
10068 ///
10069 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
10070 #[derive(Clone, Debug, PartialEq)]
10071 #[non_exhaustive]
10072 pub enum Code {
10073 /// This should never be used. If we are unable to understand why a
10074 /// shipment was skipped, we simply return an empty set of reasons.
10075 Unspecified,
10076 /// There is no vehicle in the model making all shipments infeasible.
10077 NoVehicle,
10078 /// The demand of the shipment exceeds a vehicle's capacity for some
10079 /// capacity types, one of which is `example_exceeded_capacity_type`.
10080 DemandExceedsVehicleCapacity,
10081 /// The minimum distance necessary to perform this shipment, i.e. from
10082 /// the vehicle's `start_location` to the shipment's pickup and/or delivery
10083 /// locations and to the vehicle's end location exceeds the vehicle's
10084 /// `route_distance_limit`.
10085 ///
10086 /// Note that for this computation we use the geodesic distances.
10087 CannotBePerformedWithinVehicleDistanceLimit,
10088 /// The minimum time necessary to perform this shipment, including travel
10089 /// time, wait time and service time exceeds the vehicle's
10090 /// `route_duration_limit`.
10091 ///
10092 /// Note: travel time is computed in the best-case scenario, namely as
10093 /// geodesic distance x 36 m/s (roughly 130 km/hour).
10094 CannotBePerformedWithinVehicleDurationLimit,
10095 /// Same as above but we only compare minimum travel time and the
10096 /// vehicle's `travel_duration_limit`.
10097 CannotBePerformedWithinVehicleTravelDurationLimit,
10098 /// The vehicle cannot perform this shipment in the best-case scenario
10099 /// (see `CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT` for time
10100 /// computation) if it starts at its earliest start time: the total time
10101 /// would make the vehicle end after its latest end time.
10102 CannotBePerformedWithinVehicleTimeWindows,
10103 /// The `allowed_vehicle_indices` field of the shipment is not empty and
10104 /// this vehicle does not belong to it.
10105 VehicleNotAllowed,
10106 /// If set, the enum was initialized with an unknown value.
10107 ///
10108 /// Applications can examine the value using [Code::value] or
10109 /// [Code::name].
10110 UnknownValue(code::UnknownValue),
10111 }
10112
10113 #[doc(hidden)]
10114 pub mod code {
10115 #[allow(unused_imports)]
10116 use super::*;
10117 #[derive(Clone, Debug, PartialEq)]
10118 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10119 }
10120
10121 impl Code {
10122 /// Gets the enum value.
10123 ///
10124 /// Returns `None` if the enum contains an unknown value deserialized from
10125 /// the string representation of enums.
10126 pub fn value(&self) -> std::option::Option<i32> {
10127 match self {
10128 Self::Unspecified => std::option::Option::Some(0),
10129 Self::NoVehicle => std::option::Option::Some(1),
10130 Self::DemandExceedsVehicleCapacity => std::option::Option::Some(2),
10131 Self::CannotBePerformedWithinVehicleDistanceLimit => {
10132 std::option::Option::Some(3)
10133 }
10134 Self::CannotBePerformedWithinVehicleDurationLimit => {
10135 std::option::Option::Some(4)
10136 }
10137 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10138 std::option::Option::Some(5)
10139 }
10140 Self::CannotBePerformedWithinVehicleTimeWindows => std::option::Option::Some(6),
10141 Self::VehicleNotAllowed => std::option::Option::Some(7),
10142 Self::UnknownValue(u) => u.0.value(),
10143 }
10144 }
10145
10146 /// Gets the enum value as a string.
10147 ///
10148 /// Returns `None` if the enum contains an unknown value deserialized from
10149 /// the integer representation of enums.
10150 pub fn name(&self) -> std::option::Option<&str> {
10151 match self {
10152 Self::Unspecified => std::option::Option::Some("CODE_UNSPECIFIED"),
10153 Self::NoVehicle => std::option::Option::Some("NO_VEHICLE"),
10154 Self::DemandExceedsVehicleCapacity => {
10155 std::option::Option::Some("DEMAND_EXCEEDS_VEHICLE_CAPACITY")
10156 }
10157 Self::CannotBePerformedWithinVehicleDistanceLimit => std::option::Option::Some(
10158 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT",
10159 ),
10160 Self::CannotBePerformedWithinVehicleDurationLimit => std::option::Option::Some(
10161 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT",
10162 ),
10163 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10164 std::option::Option::Some(
10165 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT",
10166 )
10167 }
10168 Self::CannotBePerformedWithinVehicleTimeWindows => {
10169 std::option::Option::Some("CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS")
10170 }
10171 Self::VehicleNotAllowed => std::option::Option::Some("VEHICLE_NOT_ALLOWED"),
10172 Self::UnknownValue(u) => u.0.name(),
10173 }
10174 }
10175 }
10176
10177 impl std::default::Default for Code {
10178 fn default() -> Self {
10179 use std::convert::From;
10180 Self::from(0)
10181 }
10182 }
10183
10184 impl std::fmt::Display for Code {
10185 fn fmt(
10186 &self,
10187 f: &mut std::fmt::Formatter<'_>,
10188 ) -> std::result::Result<(), std::fmt::Error> {
10189 wkt::internal::display_enum(f, self.name(), self.value())
10190 }
10191 }
10192
10193 impl std::convert::From<i32> for Code {
10194 fn from(value: i32) -> Self {
10195 match value {
10196 0 => Self::Unspecified,
10197 1 => Self::NoVehicle,
10198 2 => Self::DemandExceedsVehicleCapacity,
10199 3 => Self::CannotBePerformedWithinVehicleDistanceLimit,
10200 4 => Self::CannotBePerformedWithinVehicleDurationLimit,
10201 5 => Self::CannotBePerformedWithinVehicleTravelDurationLimit,
10202 6 => Self::CannotBePerformedWithinVehicleTimeWindows,
10203 7 => Self::VehicleNotAllowed,
10204 _ => Self::UnknownValue(code::UnknownValue(
10205 wkt::internal::UnknownEnumValue::Integer(value),
10206 )),
10207 }
10208 }
10209 }
10210
10211 impl std::convert::From<&str> for Code {
10212 fn from(value: &str) -> Self {
10213 use std::string::ToString;
10214 match value {
10215 "CODE_UNSPECIFIED" => Self::Unspecified,
10216 "NO_VEHICLE" => Self::NoVehicle,
10217 "DEMAND_EXCEEDS_VEHICLE_CAPACITY" => Self::DemandExceedsVehicleCapacity,
10218 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT" => {
10219 Self::CannotBePerformedWithinVehicleDistanceLimit
10220 }
10221 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT" => {
10222 Self::CannotBePerformedWithinVehicleDurationLimit
10223 }
10224 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT" => {
10225 Self::CannotBePerformedWithinVehicleTravelDurationLimit
10226 }
10227 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS" => {
10228 Self::CannotBePerformedWithinVehicleTimeWindows
10229 }
10230 "VEHICLE_NOT_ALLOWED" => Self::VehicleNotAllowed,
10231 _ => Self::UnknownValue(code::UnknownValue(
10232 wkt::internal::UnknownEnumValue::String(value.to_string()),
10233 )),
10234 }
10235 }
10236 }
10237
10238 impl serde::ser::Serialize for Code {
10239 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10240 where
10241 S: serde::Serializer,
10242 {
10243 match self {
10244 Self::Unspecified => serializer.serialize_i32(0),
10245 Self::NoVehicle => serializer.serialize_i32(1),
10246 Self::DemandExceedsVehicleCapacity => serializer.serialize_i32(2),
10247 Self::CannotBePerformedWithinVehicleDistanceLimit => {
10248 serializer.serialize_i32(3)
10249 }
10250 Self::CannotBePerformedWithinVehicleDurationLimit => {
10251 serializer.serialize_i32(4)
10252 }
10253 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10254 serializer.serialize_i32(5)
10255 }
10256 Self::CannotBePerformedWithinVehicleTimeWindows => serializer.serialize_i32(6),
10257 Self::VehicleNotAllowed => serializer.serialize_i32(7),
10258 Self::UnknownValue(u) => u.0.serialize(serializer),
10259 }
10260 }
10261 }
10262
10263 impl<'de> serde::de::Deserialize<'de> for Code {
10264 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10265 where
10266 D: serde::Deserializer<'de>,
10267 {
10268 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
10269 ".google.cloud.optimization.v1.SkippedShipment.Reason.Code",
10270 ))
10271 }
10272 }
10273 }
10274}
10275
10276/// Aggregated metrics for
10277/// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute] (resp. for
10278/// [OptimizeToursResponse][google.cloud.optimization.v1.OptimizeToursResponse]
10279/// over all [Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
10280/// and/or [Visit][google.cloud.optimization.v1.ShipmentRoute.Visit] (resp. over
10281/// all [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]) elements.
10282///
10283/// [google.cloud.optimization.v1.OptimizeToursResponse]: crate::model::OptimizeToursResponse
10284/// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
10285/// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
10286/// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
10287#[derive(Clone, Default, PartialEq)]
10288#[non_exhaustive]
10289pub struct AggregatedMetrics {
10290 /// Number of shipments performed. Note that a pickup and delivery pair only
10291 /// counts once.
10292 pub performed_shipment_count: i32,
10293
10294 /// Total travel duration for a route or a solution.
10295 pub travel_duration: std::option::Option<wkt::Duration>,
10296
10297 /// Total wait duration for a route or a solution.
10298 pub wait_duration: std::option::Option<wkt::Duration>,
10299
10300 /// Total delay duration for a route or a solution.
10301 pub delay_duration: std::option::Option<wkt::Duration>,
10302
10303 /// Total break duration for a route or a solution.
10304 pub break_duration: std::option::Option<wkt::Duration>,
10305
10306 /// Total visit duration for a route or a solution.
10307 pub visit_duration: std::option::Option<wkt::Duration>,
10308
10309 /// The total duration should be equal to the sum of all durations above.
10310 /// For routes, it also corresponds to:
10311 /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]
10312 /// `-`
10313 /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]
10314 ///
10315 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
10316 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
10317 pub total_duration: std::option::Option<wkt::Duration>,
10318
10319 /// Total travel distance for a route or a solution.
10320 pub travel_distance_meters: f64,
10321
10322 /// Maximum load achieved over the entire route (resp. solution), for each of
10323 /// the quantities on this route (resp. solution), computed as the maximum over
10324 /// all
10325 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
10326 /// (resp.
10327 /// [ShipmentRoute.metrics.max_loads][google.cloud.optimization.v1.AggregatedMetrics.max_loads].
10328 ///
10329 /// [google.cloud.optimization.v1.AggregatedMetrics.max_loads]: crate::model::AggregatedMetrics::max_loads
10330 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
10331 pub max_loads:
10332 std::collections::HashMap<std::string::String, crate::model::shipment_route::VehicleLoad>,
10333
10334 /// Deprecated: Use
10335 /// [ShipmentRoute.route_costs][google.cloud.optimization.v1.ShipmentRoute.route_costs]
10336 /// and
10337 /// [OptimizeToursResponse.Metrics.costs][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]
10338 /// instead.
10339 ///
10340 /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]: crate::model::optimize_tours_response::Metrics::costs
10341 /// [google.cloud.optimization.v1.ShipmentRoute.route_costs]: crate::model::ShipmentRoute::route_costs
10342 #[deprecated]
10343 pub costs: std::collections::HashMap<std::string::String, f64>,
10344
10345 /// Deprecated: Use
10346 /// [ShipmentRoute.route_total_cost][google.cloud.optimization.v1.ShipmentRoute.route_total_cost]
10347 /// and
10348 /// [OptimizeToursResponse.Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
10349 /// instead.
10350 ///
10351 /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
10352 /// [google.cloud.optimization.v1.ShipmentRoute.route_total_cost]: crate::model::ShipmentRoute::route_total_cost
10353 #[deprecated]
10354 pub total_cost: f64,
10355
10356 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10357}
10358
10359impl AggregatedMetrics {
10360 /// Creates a new default instance.
10361 pub fn new() -> Self {
10362 std::default::Default::default()
10363 }
10364
10365 /// Sets the value of [performed_shipment_count][crate::model::AggregatedMetrics::performed_shipment_count].
10366 ///
10367 /// # Example
10368 /// ```ignore,no_run
10369 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10370 /// let x = AggregatedMetrics::new().set_performed_shipment_count(42);
10371 /// ```
10372 pub fn set_performed_shipment_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10373 self.performed_shipment_count = v.into();
10374 self
10375 }
10376
10377 /// Sets the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
10378 ///
10379 /// # Example
10380 /// ```ignore,no_run
10381 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10382 /// use wkt::Duration;
10383 /// let x = AggregatedMetrics::new().set_travel_duration(Duration::default()/* use setters */);
10384 /// ```
10385 pub fn set_travel_duration<T>(mut self, v: T) -> Self
10386 where
10387 T: std::convert::Into<wkt::Duration>,
10388 {
10389 self.travel_duration = std::option::Option::Some(v.into());
10390 self
10391 }
10392
10393 /// Sets or clears the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
10394 ///
10395 /// # Example
10396 /// ```ignore,no_run
10397 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10398 /// use wkt::Duration;
10399 /// let x = AggregatedMetrics::new().set_or_clear_travel_duration(Some(Duration::default()/* use setters */));
10400 /// let x = AggregatedMetrics::new().set_or_clear_travel_duration(None::<Duration>);
10401 /// ```
10402 pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
10403 where
10404 T: std::convert::Into<wkt::Duration>,
10405 {
10406 self.travel_duration = v.map(|x| x.into());
10407 self
10408 }
10409
10410 /// Sets the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
10411 ///
10412 /// # Example
10413 /// ```ignore,no_run
10414 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10415 /// use wkt::Duration;
10416 /// let x = AggregatedMetrics::new().set_wait_duration(Duration::default()/* use setters */);
10417 /// ```
10418 pub fn set_wait_duration<T>(mut self, v: T) -> Self
10419 where
10420 T: std::convert::Into<wkt::Duration>,
10421 {
10422 self.wait_duration = std::option::Option::Some(v.into());
10423 self
10424 }
10425
10426 /// Sets or clears the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
10427 ///
10428 /// # Example
10429 /// ```ignore,no_run
10430 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10431 /// use wkt::Duration;
10432 /// let x = AggregatedMetrics::new().set_or_clear_wait_duration(Some(Duration::default()/* use setters */));
10433 /// let x = AggregatedMetrics::new().set_or_clear_wait_duration(None::<Duration>);
10434 /// ```
10435 pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
10436 where
10437 T: std::convert::Into<wkt::Duration>,
10438 {
10439 self.wait_duration = v.map(|x| x.into());
10440 self
10441 }
10442
10443 /// Sets the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
10444 ///
10445 /// # Example
10446 /// ```ignore,no_run
10447 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10448 /// use wkt::Duration;
10449 /// let x = AggregatedMetrics::new().set_delay_duration(Duration::default()/* use setters */);
10450 /// ```
10451 pub fn set_delay_duration<T>(mut self, v: T) -> Self
10452 where
10453 T: std::convert::Into<wkt::Duration>,
10454 {
10455 self.delay_duration = std::option::Option::Some(v.into());
10456 self
10457 }
10458
10459 /// Sets or clears the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
10460 ///
10461 /// # Example
10462 /// ```ignore,no_run
10463 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10464 /// use wkt::Duration;
10465 /// let x = AggregatedMetrics::new().set_or_clear_delay_duration(Some(Duration::default()/* use setters */));
10466 /// let x = AggregatedMetrics::new().set_or_clear_delay_duration(None::<Duration>);
10467 /// ```
10468 pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
10469 where
10470 T: std::convert::Into<wkt::Duration>,
10471 {
10472 self.delay_duration = v.map(|x| x.into());
10473 self
10474 }
10475
10476 /// Sets the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
10477 ///
10478 /// # Example
10479 /// ```ignore,no_run
10480 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10481 /// use wkt::Duration;
10482 /// let x = AggregatedMetrics::new().set_break_duration(Duration::default()/* use setters */);
10483 /// ```
10484 pub fn set_break_duration<T>(mut self, v: T) -> Self
10485 where
10486 T: std::convert::Into<wkt::Duration>,
10487 {
10488 self.break_duration = std::option::Option::Some(v.into());
10489 self
10490 }
10491
10492 /// Sets or clears the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
10493 ///
10494 /// # Example
10495 /// ```ignore,no_run
10496 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10497 /// use wkt::Duration;
10498 /// let x = AggregatedMetrics::new().set_or_clear_break_duration(Some(Duration::default()/* use setters */));
10499 /// let x = AggregatedMetrics::new().set_or_clear_break_duration(None::<Duration>);
10500 /// ```
10501 pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
10502 where
10503 T: std::convert::Into<wkt::Duration>,
10504 {
10505 self.break_duration = v.map(|x| x.into());
10506 self
10507 }
10508
10509 /// Sets the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
10510 ///
10511 /// # Example
10512 /// ```ignore,no_run
10513 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10514 /// use wkt::Duration;
10515 /// let x = AggregatedMetrics::new().set_visit_duration(Duration::default()/* use setters */);
10516 /// ```
10517 pub fn set_visit_duration<T>(mut self, v: T) -> Self
10518 where
10519 T: std::convert::Into<wkt::Duration>,
10520 {
10521 self.visit_duration = std::option::Option::Some(v.into());
10522 self
10523 }
10524
10525 /// Sets or clears the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
10526 ///
10527 /// # Example
10528 /// ```ignore,no_run
10529 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10530 /// use wkt::Duration;
10531 /// let x = AggregatedMetrics::new().set_or_clear_visit_duration(Some(Duration::default()/* use setters */));
10532 /// let x = AggregatedMetrics::new().set_or_clear_visit_duration(None::<Duration>);
10533 /// ```
10534 pub fn set_or_clear_visit_duration<T>(mut self, v: std::option::Option<T>) -> Self
10535 where
10536 T: std::convert::Into<wkt::Duration>,
10537 {
10538 self.visit_duration = v.map(|x| x.into());
10539 self
10540 }
10541
10542 /// Sets the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
10543 ///
10544 /// # Example
10545 /// ```ignore,no_run
10546 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10547 /// use wkt::Duration;
10548 /// let x = AggregatedMetrics::new().set_total_duration(Duration::default()/* use setters */);
10549 /// ```
10550 pub fn set_total_duration<T>(mut self, v: T) -> Self
10551 where
10552 T: std::convert::Into<wkt::Duration>,
10553 {
10554 self.total_duration = std::option::Option::Some(v.into());
10555 self
10556 }
10557
10558 /// Sets or clears the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
10559 ///
10560 /// # Example
10561 /// ```ignore,no_run
10562 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10563 /// use wkt::Duration;
10564 /// let x = AggregatedMetrics::new().set_or_clear_total_duration(Some(Duration::default()/* use setters */));
10565 /// let x = AggregatedMetrics::new().set_or_clear_total_duration(None::<Duration>);
10566 /// ```
10567 pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
10568 where
10569 T: std::convert::Into<wkt::Duration>,
10570 {
10571 self.total_duration = v.map(|x| x.into());
10572 self
10573 }
10574
10575 /// Sets the value of [travel_distance_meters][crate::model::AggregatedMetrics::travel_distance_meters].
10576 ///
10577 /// # Example
10578 /// ```ignore,no_run
10579 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10580 /// let x = AggregatedMetrics::new().set_travel_distance_meters(42.0);
10581 /// ```
10582 pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
10583 self.travel_distance_meters = v.into();
10584 self
10585 }
10586
10587 /// Sets the value of [max_loads][crate::model::AggregatedMetrics::max_loads].
10588 ///
10589 /// # Example
10590 /// ```ignore,no_run
10591 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10592 /// use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
10593 /// let x = AggregatedMetrics::new().set_max_loads([
10594 /// ("key0", VehicleLoad::default()/* use setters */),
10595 /// ("key1", VehicleLoad::default()/* use (different) setters */),
10596 /// ]);
10597 /// ```
10598 pub fn set_max_loads<T, K, V>(mut self, v: T) -> Self
10599 where
10600 T: std::iter::IntoIterator<Item = (K, V)>,
10601 K: std::convert::Into<std::string::String>,
10602 V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
10603 {
10604 use std::iter::Iterator;
10605 self.max_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
10606 self
10607 }
10608
10609 /// Sets the value of [costs][crate::model::AggregatedMetrics::costs].
10610 ///
10611 /// # Example
10612 /// ```ignore,no_run
10613 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10614 /// let x = AggregatedMetrics::new().set_costs([
10615 /// ("key0", 123.5),
10616 /// ("key1", 456.5),
10617 /// ]);
10618 /// ```
10619 #[deprecated]
10620 pub fn set_costs<T, K, V>(mut self, v: T) -> Self
10621 where
10622 T: std::iter::IntoIterator<Item = (K, V)>,
10623 K: std::convert::Into<std::string::String>,
10624 V: std::convert::Into<f64>,
10625 {
10626 use std::iter::Iterator;
10627 self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
10628 self
10629 }
10630
10631 /// Sets the value of [total_cost][crate::model::AggregatedMetrics::total_cost].
10632 ///
10633 /// # Example
10634 /// ```ignore,no_run
10635 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10636 /// let x = AggregatedMetrics::new().set_total_cost(42.0);
10637 /// ```
10638 #[deprecated]
10639 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
10640 self.total_cost = v.into();
10641 self
10642 }
10643}
10644
10645impl wkt::message::Message for AggregatedMetrics {
10646 fn typename() -> &'static str {
10647 "type.googleapis.com/google.cloud.optimization.v1.AggregatedMetrics"
10648 }
10649}
10650
10651/// Solution injected in the request including information about which visits
10652/// must be constrained and how they must be constrained.
10653#[derive(Clone, Default, PartialEq)]
10654#[non_exhaustive]
10655pub struct InjectedSolutionConstraint {
10656 /// Routes of the solution to inject. Some routes may be omitted from the
10657 /// original solution. The routes and skipped shipments must satisfy the basic
10658 /// validity assumptions listed for `injected_first_solution_routes`.
10659 pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
10660
10661 /// Skipped shipments of the solution to inject. Some may be omitted from the
10662 /// original solution. See the `routes` field.
10663 pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
10664
10665 /// For zero or more groups of vehicles, specifies when and how much to relax
10666 /// constraints. If this field is empty, all non-empty vehicle routes are
10667 /// fully constrained.
10668 pub constraint_relaxations:
10669 std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>,
10670
10671 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10672}
10673
10674impl InjectedSolutionConstraint {
10675 /// Creates a new default instance.
10676 pub fn new() -> Self {
10677 std::default::Default::default()
10678 }
10679
10680 /// Sets the value of [routes][crate::model::InjectedSolutionConstraint::routes].
10681 ///
10682 /// # Example
10683 /// ```ignore,no_run
10684 /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10685 /// use google_cloud_optimization_v1::model::ShipmentRoute;
10686 /// let x = InjectedSolutionConstraint::new()
10687 /// .set_routes([
10688 /// ShipmentRoute::default()/* use setters */,
10689 /// ShipmentRoute::default()/* use (different) setters */,
10690 /// ]);
10691 /// ```
10692 pub fn set_routes<T, V>(mut self, v: T) -> Self
10693 where
10694 T: std::iter::IntoIterator<Item = V>,
10695 V: std::convert::Into<crate::model::ShipmentRoute>,
10696 {
10697 use std::iter::Iterator;
10698 self.routes = v.into_iter().map(|i| i.into()).collect();
10699 self
10700 }
10701
10702 /// Sets the value of [skipped_shipments][crate::model::InjectedSolutionConstraint::skipped_shipments].
10703 ///
10704 /// # Example
10705 /// ```ignore,no_run
10706 /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10707 /// use google_cloud_optimization_v1::model::SkippedShipment;
10708 /// let x = InjectedSolutionConstraint::new()
10709 /// .set_skipped_shipments([
10710 /// SkippedShipment::default()/* use setters */,
10711 /// SkippedShipment::default()/* use (different) setters */,
10712 /// ]);
10713 /// ```
10714 pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
10715 where
10716 T: std::iter::IntoIterator<Item = V>,
10717 V: std::convert::Into<crate::model::SkippedShipment>,
10718 {
10719 use std::iter::Iterator;
10720 self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
10721 self
10722 }
10723
10724 /// Sets the value of [constraint_relaxations][crate::model::InjectedSolutionConstraint::constraint_relaxations].
10725 ///
10726 /// # Example
10727 /// ```ignore,no_run
10728 /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10729 /// use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10730 /// let x = InjectedSolutionConstraint::new()
10731 /// .set_constraint_relaxations([
10732 /// ConstraintRelaxation::default()/* use setters */,
10733 /// ConstraintRelaxation::default()/* use (different) setters */,
10734 /// ]);
10735 /// ```
10736 pub fn set_constraint_relaxations<T, V>(mut self, v: T) -> Self
10737 where
10738 T: std::iter::IntoIterator<Item = V>,
10739 V: std::convert::Into<crate::model::injected_solution_constraint::ConstraintRelaxation>,
10740 {
10741 use std::iter::Iterator;
10742 self.constraint_relaxations = v.into_iter().map(|i| i.into()).collect();
10743 self
10744 }
10745}
10746
10747impl wkt::message::Message for InjectedSolutionConstraint {
10748 fn typename() -> &'static str {
10749 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint"
10750 }
10751}
10752
10753/// Defines additional types related to [InjectedSolutionConstraint].
10754pub mod injected_solution_constraint {
10755 #[allow(unused_imports)]
10756 use super::*;
10757
10758 /// For a group of vehicles, specifies at what threshold(s) constraints on
10759 /// visits will be relaxed and to which level. Shipments listed in
10760 /// the `skipped_shipment` field are constrained to be skipped; i.e., they
10761 /// cannot be performed.
10762 #[derive(Clone, Default, PartialEq)]
10763 #[non_exhaustive]
10764 pub struct ConstraintRelaxation {
10765 /// All the visit constraint relaxations that will apply to visits on
10766 /// routes with vehicles in `vehicle_indices`.
10767 pub relaxations: std::vec::Vec<
10768 crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
10769 >,
10770
10771 /// Specifies the vehicle indices to which the visit constraint
10772 /// `relaxations` apply. If empty, this is considered the default and the
10773 /// `relaxations` apply to all vehicles that are not specified in other
10774 /// `constraint_relaxations`. There can be at most one default, i.e., at
10775 /// most one constraint relaxation field is allowed empty
10776 /// `vehicle_indices`. A vehicle index can only be listed once, even within
10777 /// several `constraint_relaxations`.
10778 ///
10779 /// A vehicle index is mapped the same as
10780 /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index],
10781 /// if `interpret_injected_solutions_using_labels` is true (see `fields`
10782 /// comment).
10783 ///
10784 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
10785 pub vehicle_indices: std::vec::Vec<i32>,
10786
10787 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10788 }
10789
10790 impl ConstraintRelaxation {
10791 /// Creates a new default instance.
10792 pub fn new() -> Self {
10793 std::default::Default::default()
10794 }
10795
10796 /// Sets the value of [relaxations][crate::model::injected_solution_constraint::ConstraintRelaxation::relaxations].
10797 ///
10798 /// # Example
10799 /// ```ignore,no_run
10800 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10801 /// use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10802 /// let x = ConstraintRelaxation::new()
10803 /// .set_relaxations([
10804 /// Relaxation::default()/* use setters */,
10805 /// Relaxation::default()/* use (different) setters */,
10806 /// ]);
10807 /// ```
10808 pub fn set_relaxations<T, V>(mut self, v: T) -> Self
10809 where
10810 T: std::iter::IntoIterator<Item = V>,
10811 V: std::convert::Into<
10812 crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
10813 >,
10814 {
10815 use std::iter::Iterator;
10816 self.relaxations = v.into_iter().map(|i| i.into()).collect();
10817 self
10818 }
10819
10820 /// Sets the value of [vehicle_indices][crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices].
10821 ///
10822 /// # Example
10823 /// ```ignore,no_run
10824 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10825 /// let x = ConstraintRelaxation::new().set_vehicle_indices([1, 2, 3]);
10826 /// ```
10827 pub fn set_vehicle_indices<T, V>(mut self, v: T) -> Self
10828 where
10829 T: std::iter::IntoIterator<Item = V>,
10830 V: std::convert::Into<i32>,
10831 {
10832 use std::iter::Iterator;
10833 self.vehicle_indices = v.into_iter().map(|i| i.into()).collect();
10834 self
10835 }
10836 }
10837
10838 impl wkt::message::Message for ConstraintRelaxation {
10839 fn typename() -> &'static str {
10840 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation"
10841 }
10842 }
10843
10844 /// Defines additional types related to [ConstraintRelaxation].
10845 pub mod constraint_relaxation {
10846 #[allow(unused_imports)]
10847 use super::*;
10848
10849 /// If `relaxations` is empty, the start time and sequence of all visits
10850 /// on `routes` are fully constrained and no new visits may be inserted or
10851 /// added to those routes. Also, a vehicle's start and end time in
10852 /// `routes` is fully constrained, unless the vehicle is empty (i.e., has no
10853 /// visits and has `used_if_route_is_empty` set to false in the model).
10854 ///
10855 /// `relaxations(i).level` specifies the constraint relaxation level applied
10856 /// to a visit #j that satisfies:
10857 ///
10858 /// * `route.visits(j).start_time >= relaxations(i).threshold_time` AND
10859 /// * `j + 1 >= relaxations(i).threshold_visit_count`
10860 ///
10861 /// Similarly, the vehicle start is relaxed to `relaxations(i).level` if it
10862 /// satisfies:
10863 ///
10864 /// * `vehicle_start_time >= relaxations(i).threshold_time` AND
10865 /// * `relaxations(i).threshold_visit_count == 0`
10866 /// and the vehicle end is relaxed to `relaxations(i).level` if it satisfies:
10867 /// * `vehicle_end_time >= relaxations(i).threshold_time` AND
10868 /// * `route.visits_size() + 1 >= relaxations(i).threshold_visit_count`
10869 ///
10870 /// To apply a relaxation level if a visit meets the `threshold_visit_count`
10871 /// OR the `threshold_time` add two `relaxations` with the same `level`:
10872 /// one with only `threshold_visit_count` set and the other with only
10873 /// `threshold_time` set. If a visit satisfies the conditions of multiple
10874 /// `relaxations`, the most relaxed level applies. As a result, from the
10875 /// vehicle start through the route visits in order to the vehicle end, the
10876 /// relaxation level becomes more relaxed: i.e., the relaxation level is
10877 /// non-decreasing as the route progresses.
10878 ///
10879 /// The timing and sequence of route visits that do not satisfy the
10880 /// threshold conditions of any `relaxations` are fully constrained
10881 /// and no visits may be inserted into these sequences. Also, if a
10882 /// vehicle start or end does not satisfy the conditions of any
10883 /// relaxation the time is fixed, unless the vehicle is empty.
10884 #[derive(Clone, Default, PartialEq)]
10885 #[non_exhaustive]
10886 pub struct Relaxation {
10887
10888 /// The constraint relaxation level that applies when the conditions
10889 /// at or after `threshold_time` AND at least `threshold_visit_count` are
10890 /// satisfied.
10891 pub level: crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level,
10892
10893 /// The time at or after which the relaxation `level` may be applied.
10894 pub threshold_time: std::option::Option<wkt::Timestamp>,
10895
10896 /// The number of visits at or after which the relaxation `level` may be
10897 /// applied. If `threshold_visit_count` is 0 (or unset), the `level` may be
10898 /// applied directly at the vehicle start.
10899 ///
10900 /// If it is `route.visits_size() + 1`, the `level` may only be applied to
10901 /// the vehicle end. If it is more than `route.visits_size() + 1`,
10902 /// `level` is not applied at all for that route.
10903 pub threshold_visit_count: i32,
10904
10905 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10906 }
10907
10908 impl Relaxation {
10909 /// Creates a new default instance.
10910 pub fn new() -> Self {
10911 std::default::Default::default()
10912 }
10913
10914 /// Sets the value of [level][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::level].
10915 ///
10916 /// # Example
10917 /// ```ignore,no_run
10918 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10919 /// use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::relaxation::Level;
10920 /// let x0 = Relaxation::new().set_level(Level::RelaxVisitTimesAfterThreshold);
10921 /// let x1 = Relaxation::new().set_level(Level::RelaxVisitTimesAndSequenceAfterThreshold);
10922 /// let x2 = Relaxation::new().set_level(Level::RelaxAllAfterThreshold);
10923 /// ```
10924 pub fn set_level<T: std::convert::Into<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>(mut self, v: T) -> Self{
10925 self.level = v.into();
10926 self
10927 }
10928
10929 /// Sets the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
10930 ///
10931 /// # Example
10932 /// ```ignore,no_run
10933 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10934 /// use wkt::Timestamp;
10935 /// let x = Relaxation::new().set_threshold_time(Timestamp::default()/* use setters */);
10936 /// ```
10937 pub fn set_threshold_time<T>(mut self, v: T) -> Self
10938 where
10939 T: std::convert::Into<wkt::Timestamp>,
10940 {
10941 self.threshold_time = std::option::Option::Some(v.into());
10942 self
10943 }
10944
10945 /// Sets or clears the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
10946 ///
10947 /// # Example
10948 /// ```ignore,no_run
10949 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10950 /// use wkt::Timestamp;
10951 /// let x = Relaxation::new().set_or_clear_threshold_time(Some(Timestamp::default()/* use setters */));
10952 /// let x = Relaxation::new().set_or_clear_threshold_time(None::<Timestamp>);
10953 /// ```
10954 pub fn set_or_clear_threshold_time<T>(mut self, v: std::option::Option<T>) -> Self
10955 where
10956 T: std::convert::Into<wkt::Timestamp>,
10957 {
10958 self.threshold_time = v.map(|x| x.into());
10959 self
10960 }
10961
10962 /// Sets the value of [threshold_visit_count][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_visit_count].
10963 ///
10964 /// # Example
10965 /// ```ignore,no_run
10966 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10967 /// let x = Relaxation::new().set_threshold_visit_count(42);
10968 /// ```
10969 pub fn set_threshold_visit_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10970 self.threshold_visit_count = v.into();
10971 self
10972 }
10973 }
10974
10975 impl wkt::message::Message for Relaxation {
10976 fn typename() -> &'static str {
10977 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation"
10978 }
10979 }
10980
10981 /// Defines additional types related to [Relaxation].
10982 pub mod relaxation {
10983 #[allow(unused_imports)]
10984 use super::*;
10985
10986 /// Expresses the different constraint relaxation levels, which are
10987 /// applied for a visit and those that follow when it satisfies the
10988 /// threshold conditions.
10989 ///
10990 /// The enumeration below is in order of increasing relaxation.
10991 ///
10992 /// # Working with unknown values
10993 ///
10994 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10995 /// additional enum variants at any time. Adding new variants is not considered
10996 /// a breaking change. Applications should write their code in anticipation of:
10997 ///
10998 /// - New values appearing in future releases of the client library, **and**
10999 /// - New values received dynamically, without application changes.
11000 ///
11001 /// Please consult the [Working with enums] section in the user guide for some
11002 /// guidelines.
11003 ///
11004 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
11005 #[derive(Clone, Debug, PartialEq)]
11006 #[non_exhaustive]
11007 pub enum Level {
11008 /// Implicit default relaxation level: no constraints are relaxed,
11009 /// i.e., all visits are fully constrained.
11010 ///
11011 /// This value must not be explicitly used in `level`.
11012 Unspecified,
11013 /// Visit start times and vehicle start/end times will be relaxed, but
11014 /// each visit remains bound to the same vehicle and the visit sequence
11015 /// must be observed: no visit can be inserted between them or before
11016 /// them.
11017 RelaxVisitTimesAfterThreshold,
11018 /// Same as `RELAX_VISIT_TIMES_AFTER_THRESHOLD`, but the visit sequence
11019 /// is also relaxed: visits can only be performed by this vehicle, but
11020 /// can potentially become unperformed.
11021 RelaxVisitTimesAndSequenceAfterThreshold,
11022 /// Same as `RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD`, but the
11023 /// vehicle is also relaxed: visits are completely free at or after the
11024 /// threshold time and can potentially become unperformed.
11025 RelaxAllAfterThreshold,
11026 /// If set, the enum was initialized with an unknown value.
11027 ///
11028 /// Applications can examine the value using [Level::value] or
11029 /// [Level::name].
11030 UnknownValue(level::UnknownValue),
11031 }
11032
11033 #[doc(hidden)]
11034 pub mod level {
11035 #[allow(unused_imports)]
11036 use super::*;
11037 #[derive(Clone, Debug, PartialEq)]
11038 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11039 }
11040
11041 impl Level {
11042 /// Gets the enum value.
11043 ///
11044 /// Returns `None` if the enum contains an unknown value deserialized from
11045 /// the string representation of enums.
11046 pub fn value(&self) -> std::option::Option<i32> {
11047 match self {
11048 Self::Unspecified => std::option::Option::Some(0),
11049 Self::RelaxVisitTimesAfterThreshold => std::option::Option::Some(1),
11050 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
11051 std::option::Option::Some(2)
11052 }
11053 Self::RelaxAllAfterThreshold => std::option::Option::Some(3),
11054 Self::UnknownValue(u) => u.0.value(),
11055 }
11056 }
11057
11058 /// Gets the enum value as a string.
11059 ///
11060 /// Returns `None` if the enum contains an unknown value deserialized from
11061 /// the integer representation of enums.
11062 pub fn name(&self) -> std::option::Option<&str> {
11063 match self {
11064 Self::Unspecified => std::option::Option::Some("LEVEL_UNSPECIFIED"),
11065 Self::RelaxVisitTimesAfterThreshold => {
11066 std::option::Option::Some("RELAX_VISIT_TIMES_AFTER_THRESHOLD")
11067 }
11068 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
11069 std::option::Option::Some(
11070 "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD",
11071 )
11072 }
11073 Self::RelaxAllAfterThreshold => {
11074 std::option::Option::Some("RELAX_ALL_AFTER_THRESHOLD")
11075 }
11076 Self::UnknownValue(u) => u.0.name(),
11077 }
11078 }
11079 }
11080
11081 impl std::default::Default for Level {
11082 fn default() -> Self {
11083 use std::convert::From;
11084 Self::from(0)
11085 }
11086 }
11087
11088 impl std::fmt::Display for Level {
11089 fn fmt(
11090 &self,
11091 f: &mut std::fmt::Formatter<'_>,
11092 ) -> std::result::Result<(), std::fmt::Error> {
11093 wkt::internal::display_enum(f, self.name(), self.value())
11094 }
11095 }
11096
11097 impl std::convert::From<i32> for Level {
11098 fn from(value: i32) -> Self {
11099 match value {
11100 0 => Self::Unspecified,
11101 1 => Self::RelaxVisitTimesAfterThreshold,
11102 2 => Self::RelaxVisitTimesAndSequenceAfterThreshold,
11103 3 => Self::RelaxAllAfterThreshold,
11104 _ => Self::UnknownValue(level::UnknownValue(
11105 wkt::internal::UnknownEnumValue::Integer(value),
11106 )),
11107 }
11108 }
11109 }
11110
11111 impl std::convert::From<&str> for Level {
11112 fn from(value: &str) -> Self {
11113 use std::string::ToString;
11114 match value {
11115 "LEVEL_UNSPECIFIED" => Self::Unspecified,
11116 "RELAX_VISIT_TIMES_AFTER_THRESHOLD" => Self::RelaxVisitTimesAfterThreshold,
11117 "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD" => {
11118 Self::RelaxVisitTimesAndSequenceAfterThreshold
11119 }
11120 "RELAX_ALL_AFTER_THRESHOLD" => Self::RelaxAllAfterThreshold,
11121 _ => Self::UnknownValue(level::UnknownValue(
11122 wkt::internal::UnknownEnumValue::String(value.to_string()),
11123 )),
11124 }
11125 }
11126 }
11127
11128 impl serde::ser::Serialize for Level {
11129 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11130 where
11131 S: serde::Serializer,
11132 {
11133 match self {
11134 Self::Unspecified => serializer.serialize_i32(0),
11135 Self::RelaxVisitTimesAfterThreshold => serializer.serialize_i32(1),
11136 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
11137 serializer.serialize_i32(2)
11138 }
11139 Self::RelaxAllAfterThreshold => serializer.serialize_i32(3),
11140 Self::UnknownValue(u) => u.0.serialize(serializer),
11141 }
11142 }
11143 }
11144
11145 impl<'de> serde::de::Deserialize<'de> for Level {
11146 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11147 where
11148 D: serde::Deserializer<'de>,
11149 {
11150 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Level>::new(
11151 ".google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation.Level"))
11152 }
11153 }
11154 }
11155 }
11156}
11157
11158/// Describes an error encountered when validating an `OptimizeToursRequest`.
11159#[derive(Clone, Default, PartialEq)]
11160#[non_exhaustive]
11161pub struct OptimizeToursValidationError {
11162 /// A validation error is defined by the pair (`code`, `display_name`) which
11163 /// are always present.
11164 ///
11165 /// Other fields (below) provide more context about the error.
11166 ///
11167 /// *MULTIPLE ERRORS*:
11168 /// When there are multiple errors, the validation process tries to output
11169 /// several of them. Much like a compiler, this is an imperfect process. Some
11170 /// validation errors will be "fatal", meaning that they stop the entire
11171 /// validation process. This is the case for `display_name="UNSPECIFIED"`
11172 /// errors, among others. Some may cause the validation process to skip other
11173 /// errors.
11174 ///
11175 /// *STABILITY*:
11176 /// `code` and `display_name` should be very stable. But new codes and
11177 /// display names may appear over time, which may cause a given (invalid)
11178 /// request to yield a different (`code`, `display_name`) pair because the new
11179 /// error hid the old one (see "MULTIPLE ERRORS").
11180 ///
11181 /// *REFERENCE*: A list of all (code, name) pairs:
11182 ///
11183 /// * UNSPECIFIED = 0;
11184 ///
11185 /// * VALIDATION_TIMEOUT_ERROR = 10; Validation couldn't be completed within
11186 /// the deadline.
11187 ///
11188 /// * REQUEST_OPTIONS_ERROR = 12;
11189 ///
11190 /// * REQUEST_OPTIONS_INVALID_SOLVING_MODE = 1201;
11191 /// * REQUEST_OPTIONS_INVALID_MAX_VALIDATION_ERRORS = 1203;
11192 /// * REQUEST_OPTIONS_INVALID_GEODESIC_METERS_PER_SECOND = 1204;
11193 /// * REQUEST_OPTIONS_GEODESIC_METERS_PER_SECOND_TOO_SMALL = 1205;
11194 /// * REQUEST_OPTIONS_MISSING_GEODESIC_METERS_PER_SECOND = 1206;
11195 /// * REQUEST_OPTIONS_POPULATE_PATHFINDER_TRIPS_AND_GEODESIC_DISTANCE
11196 /// = 1207;
11197 /// * REQUEST_OPTIONS_COST_MODEL_OPTIONS_AND_GEODESIC_DISTANCE = 1208;
11198 /// * REQUEST_OPTIONS_TRAVEL_MODE_INCOMPATIBLE_WITH_TRAFFIC = 1211;
11199 /// * REQUEST_OPTIONS_MULTIPLE_TRAFFIC_FLAVORS = 1212;
11200 /// * REQUEST_OPTIONS_INVALID_TRAFFIC_FLAVOR = 1213;
11201 /// * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITHOUT_GLOBAL_START_TIME = 1214;
11202 /// * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITH_PRECEDENCES = 1215;
11203 /// * REQUEST_OPTIONS_TRAFFIC_PREFILL_MODE_INVALID = 1216;
11204 /// * REQUEST_OPTIONS_TRAFFIC_PREFILL_ENABLED_WITHOUT_TRAFFIC = 1217;
11205 /// * INJECTED_SOLUTION_ERROR = 20;
11206 ///
11207 /// * INJECTED_SOLUTION_MISSING_LABEL = 2000;
11208 /// * INJECTED_SOLUTION_DUPLICATE_LABEL = 2001;
11209 /// * INJECTED_SOLUTION_AMBIGUOUS_INDEX = 2002;
11210 /// * INJECTED_SOLUTION_INFEASIBLE_AFTER_GETTING_TRAVEL_TIMES = 2003;
11211 /// * INJECTED_SOLUTION_TRANSITION_INCONSISTENT_WITH_ACTUAL_TRAVEL = 2004;
11212 /// * INJECTED_SOLUTION_CONCURRENT_SOLUTION_TYPES = 2005;
11213 /// * INJECTED_SOLUTION_MORE_THAN_ONE_PER_TYPE = 2006;
11214 /// * INJECTED_SOLUTION_REFRESH_WITHOUT_POPULATE = 2008;
11215 /// * INJECTED_SOLUTION_CONSTRAINED_ROUTE_PORTION_INFEASIBLE = 2010;
11216 /// * SHIPMENT_MODEL_ERROR = 22;
11217 ///
11218 /// * SHIPMENT_MODEL_TOO_LARGE = 2200;
11219 /// * SHIPMENT_MODEL_TOO_MANY_CAPACITY_TYPES = 2201;
11220 /// * SHIPMENT_MODEL_GLOBAL_START_TIME_NEGATIVE_OR_NAN = 2202;
11221 /// * SHIPMENT_MODEL_GLOBAL_END_TIME_TOO_LARGE_OR_NAN = 2203;
11222 /// * SHIPMENT_MODEL_GLOBAL_START_TIME_AFTER_GLOBAL_END_TIME = 2204;
11223 /// * SHIPMENT_MODEL_GLOBAL_DURATION_TOO_LONG = 2205;
11224 /// * SHIPMENT_MODEL_MAX_ACTIVE_VEHICLES_NOT_POSITIVE = 2206;
11225 /// * SHIPMENT_MODEL_DURATION_MATRIX_TOO_LARGE = 2207;
11226 /// * INDEX_ERROR = 24;
11227 ///
11228 /// * TAG_ERROR = 26;
11229 ///
11230 /// * TIME_WINDOW_ERROR = 28;
11231 ///
11232 /// * TIME_WINDOW_INVALID_START_TIME = 2800;
11233 /// * TIME_WINDOW_INVALID_END_TIME = 2801;
11234 /// * TIME_WINDOW_INVALID_SOFT_START_TIME = 2802;
11235 /// * TIME_WINDOW_INVALID_SOFT_END_TIME = 2803;
11236 /// * TIME_WINDOW_OUTSIDE_GLOBAL_TIME_WINDOW = 2804;
11237 /// * TIME_WINDOW_START_TIME_AFTER_END_TIME = 2805;
11238 /// * TIME_WINDOW_INVALID_COST_PER_HOUR_BEFORE_SOFT_START_TIME = 2806;
11239 /// * TIME_WINDOW_INVALID_COST_PER_HOUR_AFTER_SOFT_END_TIME = 2807;
11240 /// * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_WITHOUT_SOFT_START_TIME
11241 /// = 2808;
11242 /// * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_WITHOUT_SOFT_END_TIME = 2809;
11243 /// * TIME_WINDOW_SOFT_START_TIME_WITHOUT_COST_BEFORE_SOFT_START_TIME
11244 /// = 2810;
11245 /// * TIME_WINDOW_SOFT_END_TIME_WITHOUT_COST_AFTER_SOFT_END_TIME = 2811;
11246 /// * TIME_WINDOW_OVERLAPPING_ADJACENT_OR_EARLIER_THAN_PREVIOUS = 2812;
11247 /// * TIME_WINDOW_START_TIME_AFTER_SOFT_START_TIME = 2813;
11248 /// * TIME_WINDOW_SOFT_START_TIME_AFTER_END_TIME = 2814;
11249 /// * TIME_WINDOW_START_TIME_AFTER_SOFT_END_TIME = 2815;
11250 /// * TIME_WINDOW_SOFT_END_TIME_AFTER_END_TIME = 2816;
11251 /// * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_SET_AND_MULTIPLE_WINDOWS
11252 /// = 2817;
11253 /// * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_SET_AND_MULTIPLE_WINDOWS = 2818;
11254 /// * TRANSITION_ATTRIBUTES_ERROR = 30;
11255 /// * TRANSITION_ATTRIBUTES_INVALID_COST = 3000;
11256 /// * TRANSITION_ATTRIBUTES_INVALID_COST_PER_KILOMETER = 3001;
11257 /// * TRANSITION_ATTRIBUTES_DUPLICATE_TAG_PAIR = 3002;
11258 /// * TRANSITION_ATTRIBUTES_DISTANCE_LIMIT_MAX_METERS_UNSUPPORTED = 3003;
11259 /// * TRANSITION_ATTRIBUTES_UNSPECIFIED_SOURCE_TAGS = 3004;
11260 /// * TRANSITION_ATTRIBUTES_CONFLICTING_SOURCE_TAGS_FIELDS = 3005;
11261 /// * TRANSITION_ATTRIBUTES_UNSPECIFIED_DESTINATION_TAGS = 3006;
11262 /// * TRANSITION_ATTRIBUTES_CONFLICTING_DESTINATION_TAGS_FIELDS = 3007;
11263 /// * TRANSITION_ATTRIBUTES_DELAY_DURATION_NEGATIVE_OR_NAN = 3008;
11264 /// * TRANSITION_ATTRIBUTES_DELAY_DURATION_EXCEEDS_GLOBAL_DURATION = 3009;
11265 /// * AMOUNT_ERROR = 31;
11266 ///
11267 /// * AMOUNT_NEGATIVE_VALUE = 3100;
11268 /// * LOAD_LIMIT_ERROR = 33;
11269 ///
11270 /// * LOAD_LIMIT_INVALID_COST_ABOVE_SOFT_MAX = 3303;
11271 /// * LOAD_LIMIT_SOFT_MAX_WITHOUT_COST_ABOVE_SOFT_MAX = 3304;
11272 /// * LOAD_LIMIT_COST_ABOVE_SOFT_MAX_WITHOUT_SOFT_MAX = 3305;
11273 /// * LOAD_LIMIT_NEGATIVE_SOFT_MAX = 3306;
11274 /// * LOAD_LIMIT_MIXED_DEMAND_TYPE = 3307;
11275 /// * LOAD_LIMIT_MAX_LOAD_NEGATIVE_VALUE = 3308;
11276 /// * LOAD_LIMIT_SOFT_MAX_ABOVE_MAX = 3309;
11277 /// * INTERVAL_ERROR = 34;
11278 ///
11279 /// * INTERVAL_MIN_EXCEEDS_MAX = 3401;
11280 /// * INTERVAL_NEGATIVE_MIN = 3402;
11281 /// * INTERVAL_NEGATIVE_MAX = 3403;
11282 /// * INTERVAL_MIN_EXCEEDS_CAPACITY = 3404;
11283 /// * INTERVAL_MAX_EXCEEDS_CAPACITY = 3405;
11284 /// * DISTANCE_LIMIT_ERROR = 36;
11285 ///
11286 /// * DISTANCE_LIMIT_INVALID_COST_AFTER_SOFT_MAX = 3601;
11287 /// * DISTANCE_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3602;
11288 /// * DISTANCE_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3603;
11289 /// * DISTANCE_LIMIT_NEGATIVE_MAX = 3604;
11290 /// * DISTANCE_LIMIT_NEGATIVE_SOFT_MAX = 3605;
11291 /// * DISTANCE_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3606;
11292 /// * DURATION_LIMIT_ERROR = 38;
11293 ///
11294 /// * DURATION_LIMIT_MAX_DURATION_NEGATIVE_OR_NAN = 3800;
11295 /// * DURATION_LIMIT_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3801;
11296 /// * DURATION_LIMIT_INVALID_COST_PER_HOUR_AFTER_SOFT_MAX = 3802;
11297 /// * DURATION_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3803;
11298 /// * DURATION_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3804;
11299 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3805;
11300 /// * DURATION_LIMIT_INVALID_COST_AFTER_QUADRATIC_SOFT_MAX = 3806;
11301 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_COST_PER_SQUARE_HOUR
11302 /// = 3807;
11303 /// * DURATION_LIMIT_COST_PER_SQUARE_HOUR_WITHOUT_QUADRATIC_SOFT_MAX
11304 /// = 3808;
11305 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_MAX = 3809;
11306 /// * DURATION_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3810;
11307 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_LARGER_THAN_MAX = 3811;
11308 /// * DURATION_LIMIT_DIFF_BETWEEN_MAX_AND_QUADRATIC_SOFT_MAX_TOO_LARGE
11309 /// = 3812;
11310 /// * DURATION_LIMIT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3813;
11311 /// * DURATION_LIMIT_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3814;
11312 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION
11313 /// = 3815;
11314 /// * SHIPMENT_ERROR = 40;
11315 ///
11316 /// * SHIPMENT_PD_LIMIT_WITHOUT_PICKUP_AND_DELIVERY = 4014;
11317 /// * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_NEGATIVE_OR_NAN = 4000;
11318 /// * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION
11319 /// = 4001;
11320 /// * SHIPMENT_PD_RELATIVE_DETOUR_LIMIT_INVALID = 4015;
11321 /// * SHIPMENT_PD_DETOUR_LIMIT_AND_EXTRA_VISIT_DURATION = 4016;
11322 /// * SHIPMENT_PD_TIME_LIMIT_DURATION_NEGATIVE_OR_NAN = 4002;
11323 /// * SHIPMENT_PD_TIME_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4003;
11324 /// * SHIPMENT_EMPTY_SHIPMENT_TYPE = 4004;
11325 /// * SHIPMENT_NO_PICKUP_NO_DELIVERY = 4005;
11326 /// * SHIPMENT_INVALID_PENALTY_COST = 4006;
11327 /// * SHIPMENT_ALLOWED_VEHICLE_INDEX_OUT_OF_BOUNDS = 4007;
11328 /// * SHIPMENT_DUPLICATE_ALLOWED_VEHICLE_INDEX = 4008;
11329 /// * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITHOUT_INDEX = 4009;
11330 /// * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITH_INDEX = 4010;
11331 /// * SHIPMENT_INVALID_COST_FOR_VEHICLE = 4011;
11332 /// * SHIPMENT_COST_FOR_VEHICLE_INDEX_OUT_OF_BOUNDS = 4012;
11333 /// * SHIPMENT_DUPLICATE_COST_FOR_VEHICLE_INDEX = 4013;
11334 /// * VEHICLE_ERROR = 42;
11335 ///
11336 /// * VEHICLE_EMPTY_REQUIRED_OPERATOR_TYPE = 4200;
11337 /// * VEHICLE_DUPLICATE_REQUIRED_OPERATOR_TYPE = 4201;
11338 /// * VEHICLE_NO_OPERATOR_WITH_REQUIRED_OPERATOR_TYPE = 4202;
11339 /// * VEHICLE_EMPTY_START_TAG = 4203;
11340 /// * VEHICLE_DUPLICATE_START_TAG = 4204;
11341 /// * VEHICLE_EMPTY_END_TAG = 4205;
11342 /// * VEHICLE_DUPLICATE_END_TAG = 4206;
11343 /// * VEHICLE_EXTRA_VISIT_DURATION_NEGATIVE_OR_NAN = 4207;
11344 /// * VEHICLE_EXTRA_VISIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4208;
11345 /// * VEHICLE_EXTRA_VISIT_DURATION_EMPTY_KEY = 4209;
11346 /// * VEHICLE_FIRST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4210;
11347 /// * VEHICLE_FIRST_SHIPMENT_IGNORED = 4211;
11348 /// * VEHICLE_FIRST_SHIPMENT_NOT_BOUND = 4212;
11349 /// * VEHICLE_LAST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4213;
11350 /// * VEHICLE_LAST_SHIPMENT_IGNORED = 4214;
11351 /// * VEHICLE_LAST_SHIPMENT_NOT_BOUND = 4215;
11352 /// * VEHICLE_IGNORED_WITH_USED_IF_ROUTE_IS_EMPTY = 4216;
11353 /// * VEHICLE_INVALID_COST_PER_KILOMETER = 4217;
11354 /// * VEHICLE_INVALID_COST_PER_HOUR = 4218;
11355 /// * VEHICLE_INVALID_COST_PER_TRAVELED_HOUR = 4219;
11356 /// * VEHICLE_INVALID_FIXED_COST = 4220;
11357 /// * VEHICLE_INVALID_TRAVEL_DURATION_MULTIPLE = 4221;
11358 /// * VEHICLE_TRAVEL_DURATION_MULTIPLE_WITH_SHIPMENT_PD_DETOUR_LIMITS
11359 /// = 4223;
11360 /// * VEHICLE_MATRIX_INDEX_WITH_SHIPMENT_PD_DETOUR_LIMITS = 4224;
11361 /// * VEHICLE_MINIMUM_DURATION_LONGER_THAN_DURATION_LIMIT = 4222;
11362 /// * VISIT_REQUEST_ERROR = 44;
11363 ///
11364 /// * VISIT_REQUEST_EMPTY_TAG = 4400;
11365 /// * VISIT_REQUEST_DUPLICATE_TAG = 4401;
11366 /// * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404;
11367 /// * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405;
11368 /// * PRECEDENCE_ERROR = 46;
11369 ///
11370 /// * PRECEDENCE_RULE_MISSING_FIRST_INDEX = 4600;
11371 /// * PRECEDENCE_RULE_MISSING_SECOND_INDEX = 4601;
11372 /// * PRECEDENCE_RULE_FIRST_INDEX_OUT_OF_BOUNDS = 4602;
11373 /// * PRECEDENCE_RULE_SECOND_INDEX_OUT_OF_BOUNDS = 4603;
11374 /// * PRECEDENCE_RULE_DUPLICATE_INDEX = 4604;
11375 /// * PRECEDENCE_RULE_INEXISTENT_FIRST_VISIT_REQUEST = 4605;
11376 /// * PRECEDENCE_RULE_INEXISTENT_SECOND_VISIT_REQUEST = 4606;
11377 /// * BREAK_ERROR = 48;
11378 ///
11379 /// * BREAK_RULE_EMPTY = 4800;
11380 /// * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801;
11381 /// * BREAK_REQUEST_UNSPECIFIED_EARLIEST_START_TIME = 4802;
11382 /// * BREAK_REQUEST_UNSPECIFIED_LATEST_START_TIME = 4803;
11383 /// * BREAK_REQUEST_DURATION_NEGATIVE_OR_NAN = 4804; = 4804;
11384 /// * BREAK_REQUEST_LATEST_START_TIME_BEFORE_EARLIEST_START_TIME = 4805;
11385 /// * BREAK_REQUEST_EARLIEST_START_TIME_BEFORE_GLOBAL_START_TIME = 4806;
11386 /// * BREAK_REQUEST_LATEST_END_TIME_AFTER_GLOBAL_END_TIME = 4807;
11387 /// * BREAK_REQUEST_NON_SCHEDULABLE = 4808;
11388 /// * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_NEGATIVE_OR_NAN = 4809;
11389 /// * BREAK_FREQUENCY_MIN_BREAK_DURATION_NEGATIVE_OR_NAN = 4810;
11390 /// * BREAK_FREQUENCY_MIN_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION = 4811;
11391 /// * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION
11392 /// = 4812;
11393 /// * BREAK_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4813;
11394 /// * BREAK_FREQUENCY_MISSING_MAX_INTER_BREAK_DURATION = 4814;
11395 /// * BREAK_FREQUENCY_MISSING_MIN_BREAK_DURATION = 4815;
11396 /// * SHIPMENT_TYPE_INCOMPATIBILITY_ERROR = 50;
11397 ///
11398 /// * SHIPMENT_TYPE_INCOMPATIBILITY_EMPTY_TYPE = 5001;
11399 /// * SHIPMENT_TYPE_INCOMPATIBILITY_LESS_THAN_TWO_TYPES = 5002;
11400 /// * SHIPMENT_TYPE_INCOMPATIBILITY_DUPLICATE_TYPE = 5003;
11401 /// * SHIPMENT_TYPE_INCOMPATIBILITY_INVALID_INCOMPATIBILITY_MODE = 5004;
11402 /// * SHIPMENT_TYPE_INCOMPATIBILITY_TOO_MANY_INCOMPATIBILITIES = 5005;
11403 /// * SHIPMENT_TYPE_REQUIREMENT_ERROR = 52;
11404 ///
11405 /// * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE = 52001;
11406 /// * SHIPMENT_TYPE_REQUIREMENT_NO_DEPENDENT_TYPE = 52002;
11407 /// * SHIPMENT_TYPE_REQUIREMENT_INVALID_REQUIREMENT_MODE = 52003;
11408 /// * SHIPMENT_TYPE_REQUIREMENT_TOO_MANY_REQUIREMENTS = 52004;
11409 /// * SHIPMENT_TYPE_REQUIREMENT_EMPTY_REQUIRED_TYPE = 52005;
11410 /// * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_REQUIRED_TYPE = 52006;
11411 /// * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE_FOUND = 52007;
11412 /// * SHIPMENT_TYPE_REQUIREMENT_EMPTY_DEPENDENT_TYPE = 52008;
11413 /// * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_DEPENDENT_TYPE = 52009;
11414 /// * SHIPMENT_TYPE_REQUIREMENT_SELF_DEPENDENT_TYPE = 52010;
11415 /// * SHIPMENT_TYPE_REQUIREMENT_GRAPH_HAS_CYCLES = 52011;
11416 /// * VEHICLE_OPERATOR_ERROR = 54;
11417 ///
11418 /// * VEHICLE_OPERATOR_EMPTY_TYPE = 5400;
11419 /// * VEHICLE_OPERATOR_MULTIPLE_START_TIME_WINDOWS = 5401;
11420 /// * VEHICLE_OPERATOR_SOFT_START_TIME_WINDOW = 5402;
11421 /// * VEHICLE_OPERATOR_MULTIPLE_END_TIME_WINDOWS = 5403;
11422 /// * VEHICLE_OPERATOR_SOFT_END_TIME_WINDOW = 5404;
11423 /// * DURATION_SECONDS_MATRIX_ERROR = 56;
11424 ///
11425 /// * DURATION_SECONDS_MATRIX_DURATION_NEGATIVE_OR_NAN = 5600;
11426 /// * DURATION_SECONDS_MATRIX_DURATION_EXCEEDS_GLOBAL_DURATION = 5601;
11427 pub code: i32,
11428
11429 /// The error display name.
11430 pub display_name: std::string::String,
11431
11432 /// An error context may involve 0, 1 (most of the time) or more fields. For
11433 /// example, referring to vehicle #4 and shipment #2's first pickup can be
11434 /// done as follows:
11435 ///
11436 /// ```norust
11437 /// fields { name: "vehicles" index: 4}
11438 /// fields { name: "shipments" index: 2 sub_field {name: "pickups" index: 0} }
11439 /// ```
11440 ///
11441 /// Note, however, that the cardinality of `fields` should not change for a
11442 /// given error code.
11443 pub fields: std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>,
11444
11445 /// Human-readable string describing the error. There is a 1:1 mapping
11446 /// between `code` and `error_message` (when code != "UNSPECIFIED").
11447 ///
11448 /// *STABILITY*: Not stable: the error message associated to a given `code` may
11449 /// change (hopefully to clarify it) over time. Please rely on the
11450 /// `display_name` and `code` instead.
11451 pub error_message: std::string::String,
11452
11453 /// May contain the value(s) of the field(s). This is not always available. You
11454 /// should absolutely not rely on it and use it only for manual model
11455 /// debugging.
11456 pub offending_values: std::string::String,
11457
11458 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11459}
11460
11461impl OptimizeToursValidationError {
11462 /// Creates a new default instance.
11463 pub fn new() -> Self {
11464 std::default::Default::default()
11465 }
11466
11467 /// Sets the value of [code][crate::model::OptimizeToursValidationError::code].
11468 ///
11469 /// # Example
11470 /// ```ignore,no_run
11471 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11472 /// let x = OptimizeToursValidationError::new().set_code(42);
11473 /// ```
11474 pub fn set_code<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
11475 self.code = v.into();
11476 self
11477 }
11478
11479 /// Sets the value of [display_name][crate::model::OptimizeToursValidationError::display_name].
11480 ///
11481 /// # Example
11482 /// ```ignore,no_run
11483 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11484 /// let x = OptimizeToursValidationError::new().set_display_name("example");
11485 /// ```
11486 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11487 self.display_name = v.into();
11488 self
11489 }
11490
11491 /// Sets the value of [fields][crate::model::OptimizeToursValidationError::fields].
11492 ///
11493 /// # Example
11494 /// ```ignore,no_run
11495 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11496 /// use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11497 /// let x = OptimizeToursValidationError::new()
11498 /// .set_fields([
11499 /// FieldReference::default()/* use setters */,
11500 /// FieldReference::default()/* use (different) setters */,
11501 /// ]);
11502 /// ```
11503 pub fn set_fields<T, V>(mut self, v: T) -> Self
11504 where
11505 T: std::iter::IntoIterator<Item = V>,
11506 V: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11507 {
11508 use std::iter::Iterator;
11509 self.fields = v.into_iter().map(|i| i.into()).collect();
11510 self
11511 }
11512
11513 /// Sets the value of [error_message][crate::model::OptimizeToursValidationError::error_message].
11514 ///
11515 /// # Example
11516 /// ```ignore,no_run
11517 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11518 /// let x = OptimizeToursValidationError::new().set_error_message("example");
11519 /// ```
11520 pub fn set_error_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11521 self.error_message = v.into();
11522 self
11523 }
11524
11525 /// Sets the value of [offending_values][crate::model::OptimizeToursValidationError::offending_values].
11526 ///
11527 /// # Example
11528 /// ```ignore,no_run
11529 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11530 /// let x = OptimizeToursValidationError::new().set_offending_values("example");
11531 /// ```
11532 pub fn set_offending_values<T: std::convert::Into<std::string::String>>(
11533 mut self,
11534 v: T,
11535 ) -> Self {
11536 self.offending_values = v.into();
11537 self
11538 }
11539}
11540
11541impl wkt::message::Message for OptimizeToursValidationError {
11542 fn typename() -> &'static str {
11543 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError"
11544 }
11545}
11546
11547/// Defines additional types related to [OptimizeToursValidationError].
11548pub mod optimize_tours_validation_error {
11549 #[allow(unused_imports)]
11550 use super::*;
11551
11552 /// Specifies a context for the validation error. A `FieldReference` always
11553 /// refers to a given field in this file and follows the same hierarchical
11554 /// structure. For example, we may specify element #2 of `start_time_windows`
11555 /// of vehicle #5 using:
11556 ///
11557 /// ```norust
11558 /// name: "vehicles" index: 5 sub_field { name: "end_time_windows" index: 2 }
11559 /// ```
11560 ///
11561 /// We however omit top-level entities such as `OptimizeToursRequest` or
11562 /// `ShipmentModel` to avoid crowding the message.
11563 #[derive(Clone, Default, PartialEq)]
11564 #[non_exhaustive]
11565 pub struct FieldReference {
11566 /// Name of the field, e.g., "vehicles".
11567 pub name: std::string::String,
11568
11569 /// Recursively nested sub-field, if needed.
11570 pub sub_field: std::option::Option<
11571 std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>,
11572 >,
11573
11574 #[allow(missing_docs)]
11575 pub index_or_key: std::option::Option<
11576 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
11577 >,
11578
11579 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11580 }
11581
11582 impl FieldReference {
11583 /// Creates a new default instance.
11584 pub fn new() -> Self {
11585 std::default::Default::default()
11586 }
11587
11588 /// Sets the value of [name][crate::model::optimize_tours_validation_error::FieldReference::name].
11589 ///
11590 /// # Example
11591 /// ```ignore,no_run
11592 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11593 /// let x = FieldReference::new().set_name("example");
11594 /// ```
11595 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11596 self.name = v.into();
11597 self
11598 }
11599
11600 /// Sets the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
11601 ///
11602 /// # Example
11603 /// ```ignore,no_run
11604 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11605 /// let x = FieldReference::new().set_sub_field(FieldReference::default()/* use setters */);
11606 /// ```
11607 pub fn set_sub_field<T>(mut self, v: T) -> Self
11608 where
11609 T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11610 {
11611 self.sub_field = std::option::Option::Some(std::boxed::Box::new(v.into()));
11612 self
11613 }
11614
11615 /// Sets or clears the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
11616 ///
11617 /// # Example
11618 /// ```ignore,no_run
11619 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11620 /// let x = FieldReference::new().set_or_clear_sub_field(Some(FieldReference::default()/* use setters */));
11621 /// let x = FieldReference::new().set_or_clear_sub_field(None::<FieldReference>);
11622 /// ```
11623 pub fn set_or_clear_sub_field<T>(mut self, v: std::option::Option<T>) -> Self
11624 where
11625 T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11626 {
11627 self.sub_field = v.map(|x| std::boxed::Box::new(x.into()));
11628 self
11629 }
11630
11631 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key].
11632 ///
11633 /// Note that all the setters affecting `index_or_key` are mutually
11634 /// exclusive.
11635 ///
11636 /// # Example
11637 /// ```ignore,no_run
11638 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11639 /// use google_cloud_optimization_v1::model::optimize_tours_validation_error::field_reference::IndexOrKey;
11640 /// let x = FieldReference::new().set_index_or_key(Some(IndexOrKey::Index(42)));
11641 /// ```
11642 pub fn set_index_or_key<
11643 T: std::convert::Into<
11644 std::option::Option<
11645 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
11646 >,
11647 >,
11648 >(
11649 mut self,
11650 v: T,
11651 ) -> Self {
11652 self.index_or_key = v.into();
11653 self
11654 }
11655
11656 /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11657 /// if it holds a `Index`, `None` if the field is not set or
11658 /// holds a different branch.
11659 pub fn index(&self) -> std::option::Option<&i32> {
11660 #[allow(unreachable_patterns)]
11661 self.index_or_key.as_ref().and_then(|v| match v {
11662 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(v) => std::option::Option::Some(v),
11663 _ => std::option::Option::None,
11664 })
11665 }
11666
11667 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11668 /// to hold a `Index`.
11669 ///
11670 /// Note that all the setters affecting `index_or_key` are
11671 /// mutually exclusive.
11672 ///
11673 /// # Example
11674 /// ```ignore,no_run
11675 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11676 /// let x = FieldReference::new().set_index(42);
11677 /// assert!(x.index().is_some());
11678 /// assert!(x.key().is_none());
11679 /// ```
11680 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
11681 self.index_or_key = std::option::Option::Some(
11682 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
11683 v.into(),
11684 ),
11685 );
11686 self
11687 }
11688
11689 /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11690 /// if it holds a `Key`, `None` if the field is not set or
11691 /// holds a different branch.
11692 pub fn key(&self) -> std::option::Option<&std::string::String> {
11693 #[allow(unreachable_patterns)]
11694 self.index_or_key.as_ref().and_then(|v| match v {
11695 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
11696 v,
11697 ) => std::option::Option::Some(v),
11698 _ => std::option::Option::None,
11699 })
11700 }
11701
11702 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11703 /// to hold a `Key`.
11704 ///
11705 /// Note that all the setters affecting `index_or_key` are
11706 /// mutually exclusive.
11707 ///
11708 /// # Example
11709 /// ```ignore,no_run
11710 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11711 /// let x = FieldReference::new().set_key("example");
11712 /// assert!(x.key().is_some());
11713 /// assert!(x.index().is_none());
11714 /// ```
11715 pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11716 self.index_or_key = std::option::Option::Some(
11717 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
11718 v.into(),
11719 ),
11720 );
11721 self
11722 }
11723 }
11724
11725 impl wkt::message::Message for FieldReference {
11726 fn typename() -> &'static str {
11727 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference"
11728 }
11729 }
11730
11731 /// Defines additional types related to [FieldReference].
11732 pub mod field_reference {
11733 #[allow(unused_imports)]
11734 use super::*;
11735
11736 #[allow(missing_docs)]
11737 #[derive(Clone, Debug, PartialEq)]
11738 #[non_exhaustive]
11739 pub enum IndexOrKey {
11740 /// Index of the field if repeated.
11741 Index(i32),
11742 /// Key if the field is a map.
11743 Key(std::string::String),
11744 }
11745 }
11746}
11747
11748/// Data formats for input and output files.
11749///
11750/// # Working with unknown values
11751///
11752/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
11753/// additional enum variants at any time. Adding new variants is not considered
11754/// a breaking change. Applications should write their code in anticipation of:
11755///
11756/// - New values appearing in future releases of the client library, **and**
11757/// - New values received dynamically, without application changes.
11758///
11759/// Please consult the [Working with enums] section in the user guide for some
11760/// guidelines.
11761///
11762/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
11763#[derive(Clone, Debug, PartialEq)]
11764#[non_exhaustive]
11765pub enum DataFormat {
11766 /// Default value.
11767 Unspecified,
11768 /// Input data in json format.
11769 Json,
11770 /// Input data in string format.
11771 String,
11772 /// If set, the enum was initialized with an unknown value.
11773 ///
11774 /// Applications can examine the value using [DataFormat::value] or
11775 /// [DataFormat::name].
11776 UnknownValue(data_format::UnknownValue),
11777}
11778
11779#[doc(hidden)]
11780pub mod data_format {
11781 #[allow(unused_imports)]
11782 use super::*;
11783 #[derive(Clone, Debug, PartialEq)]
11784 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11785}
11786
11787impl DataFormat {
11788 /// Gets the enum value.
11789 ///
11790 /// Returns `None` if the enum contains an unknown value deserialized from
11791 /// the string representation of enums.
11792 pub fn value(&self) -> std::option::Option<i32> {
11793 match self {
11794 Self::Unspecified => std::option::Option::Some(0),
11795 Self::Json => std::option::Option::Some(1),
11796 Self::String => std::option::Option::Some(2),
11797 Self::UnknownValue(u) => u.0.value(),
11798 }
11799 }
11800
11801 /// Gets the enum value as a string.
11802 ///
11803 /// Returns `None` if the enum contains an unknown value deserialized from
11804 /// the integer representation of enums.
11805 pub fn name(&self) -> std::option::Option<&str> {
11806 match self {
11807 Self::Unspecified => std::option::Option::Some("DATA_FORMAT_UNSPECIFIED"),
11808 Self::Json => std::option::Option::Some("JSON"),
11809 Self::String => std::option::Option::Some("STRING"),
11810 Self::UnknownValue(u) => u.0.name(),
11811 }
11812 }
11813}
11814
11815impl std::default::Default for DataFormat {
11816 fn default() -> Self {
11817 use std::convert::From;
11818 Self::from(0)
11819 }
11820}
11821
11822impl std::fmt::Display for DataFormat {
11823 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11824 wkt::internal::display_enum(f, self.name(), self.value())
11825 }
11826}
11827
11828impl std::convert::From<i32> for DataFormat {
11829 fn from(value: i32) -> Self {
11830 match value {
11831 0 => Self::Unspecified,
11832 1 => Self::Json,
11833 2 => Self::String,
11834 _ => Self::UnknownValue(data_format::UnknownValue(
11835 wkt::internal::UnknownEnumValue::Integer(value),
11836 )),
11837 }
11838 }
11839}
11840
11841impl std::convert::From<&str> for DataFormat {
11842 fn from(value: &str) -> Self {
11843 use std::string::ToString;
11844 match value {
11845 "DATA_FORMAT_UNSPECIFIED" => Self::Unspecified,
11846 "JSON" => Self::Json,
11847 "STRING" => Self::String,
11848 _ => Self::UnknownValue(data_format::UnknownValue(
11849 wkt::internal::UnknownEnumValue::String(value.to_string()),
11850 )),
11851 }
11852 }
11853}
11854
11855impl serde::ser::Serialize for DataFormat {
11856 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11857 where
11858 S: serde::Serializer,
11859 {
11860 match self {
11861 Self::Unspecified => serializer.serialize_i32(0),
11862 Self::Json => serializer.serialize_i32(1),
11863 Self::String => serializer.serialize_i32(2),
11864 Self::UnknownValue(u) => u.0.serialize(serializer),
11865 }
11866 }
11867}
11868
11869impl<'de> serde::de::Deserialize<'de> for DataFormat {
11870 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11871 where
11872 D: serde::Deserializer<'de>,
11873 {
11874 deserializer.deserialize_any(wkt::internal::EnumVisitor::<DataFormat>::new(
11875 ".google.cloud.optimization.v1.DataFormat",
11876 ))
11877 }
11878}