google_cloud_optimization_v1/model.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gaxi;
23extern crate google_cloud_gax;
24extern crate google_cloud_longrunning;
25extern crate google_cloud_lro;
26extern crate google_cloud_type;
27extern crate serde;
28extern crate serde_json;
29extern crate serde_with;
30extern crate std;
31extern crate tracing;
32extern crate wkt;
33
34mod debug;
35mod deserialize;
36mod serialize;
37
38/// The desired input location information.
39#[derive(Clone, Default, PartialEq)]
40#[non_exhaustive]
41pub struct InputConfig {
42 /// The input data format that used to store the model in Cloud Storage.
43 pub data_format: crate::model::DataFormat,
44
45 /// The location of the input model in cloud storage.
46 /// Required.
47 pub source: std::option::Option<crate::model::input_config::Source>,
48
49 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
50}
51
52impl InputConfig {
53 /// Creates a new default instance.
54 pub fn new() -> Self {
55 std::default::Default::default()
56 }
57
58 /// Sets the value of [data_format][crate::model::InputConfig::data_format].
59 ///
60 /// # Example
61 /// ```ignore,no_run
62 /// # use google_cloud_optimization_v1::model::InputConfig;
63 /// use google_cloud_optimization_v1::model::DataFormat;
64 /// let x0 = InputConfig::new().set_data_format(DataFormat::Json);
65 /// let x1 = InputConfig::new().set_data_format(DataFormat::String);
66 /// ```
67 pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
68 mut self,
69 v: T,
70 ) -> Self {
71 self.data_format = v.into();
72 self
73 }
74
75 /// Sets the value of [source][crate::model::InputConfig::source].
76 ///
77 /// Note that all the setters affecting `source` are mutually
78 /// exclusive.
79 ///
80 /// # Example
81 /// ```ignore,no_run
82 /// # use google_cloud_optimization_v1::model::InputConfig;
83 /// use google_cloud_optimization_v1::model::GcsSource;
84 /// let x = InputConfig::new().set_source(Some(
85 /// google_cloud_optimization_v1::model::input_config::Source::GcsSource(GcsSource::default().into())));
86 /// ```
87 pub fn set_source<
88 T: std::convert::Into<std::option::Option<crate::model::input_config::Source>>,
89 >(
90 mut self,
91 v: T,
92 ) -> Self {
93 self.source = v.into();
94 self
95 }
96
97 /// The value of [source][crate::model::InputConfig::source]
98 /// if it holds a `GcsSource`, `None` if the field is not set or
99 /// holds a different branch.
100 pub fn gcs_source(&self) -> std::option::Option<&std::boxed::Box<crate::model::GcsSource>> {
101 #[allow(unreachable_patterns)]
102 self.source.as_ref().and_then(|v| match v {
103 crate::model::input_config::Source::GcsSource(v) => std::option::Option::Some(v),
104 _ => std::option::Option::None,
105 })
106 }
107
108 /// Sets the value of [source][crate::model::InputConfig::source]
109 /// to hold a `GcsSource`.
110 ///
111 /// Note that all the setters affecting `source` are
112 /// mutually exclusive.
113 ///
114 /// # Example
115 /// ```ignore,no_run
116 /// # use google_cloud_optimization_v1::model::InputConfig;
117 /// use google_cloud_optimization_v1::model::GcsSource;
118 /// let x = InputConfig::new().set_gcs_source(GcsSource::default()/* use setters */);
119 /// assert!(x.gcs_source().is_some());
120 /// ```
121 pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
122 mut self,
123 v: T,
124 ) -> Self {
125 self.source =
126 std::option::Option::Some(crate::model::input_config::Source::GcsSource(v.into()));
127 self
128 }
129}
130
131impl wkt::message::Message for InputConfig {
132 fn typename() -> &'static str {
133 "type.googleapis.com/google.cloud.optimization.v1.InputConfig"
134 }
135}
136
137/// Defines additional types related to [InputConfig].
138pub mod input_config {
139 #[allow(unused_imports)]
140 use super::*;
141
142 /// The location of the input model in cloud storage.
143 /// Required.
144 #[derive(Clone, Debug, PartialEq)]
145 #[non_exhaustive]
146 pub enum Source {
147 /// The Google Cloud Storage location to read the input from. This must be a
148 /// single file.
149 GcsSource(std::boxed::Box<crate::model::GcsSource>),
150 }
151}
152
153/// The desired output location.
154#[derive(Clone, Default, PartialEq)]
155#[non_exhaustive]
156pub struct OutputConfig {
157 /// The output data format that used to store the results in Cloud Storage.
158 pub data_format: crate::model::DataFormat,
159
160 /// The location of the output result in cloud storage.
161 /// Required.
162 pub destination: std::option::Option<crate::model::output_config::Destination>,
163
164 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
165}
166
167impl OutputConfig {
168 /// Creates a new default instance.
169 pub fn new() -> Self {
170 std::default::Default::default()
171 }
172
173 /// Sets the value of [data_format][crate::model::OutputConfig::data_format].
174 ///
175 /// # Example
176 /// ```ignore,no_run
177 /// # use google_cloud_optimization_v1::model::OutputConfig;
178 /// use google_cloud_optimization_v1::model::DataFormat;
179 /// let x0 = OutputConfig::new().set_data_format(DataFormat::Json);
180 /// let x1 = OutputConfig::new().set_data_format(DataFormat::String);
181 /// ```
182 pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
183 mut self,
184 v: T,
185 ) -> Self {
186 self.data_format = v.into();
187 self
188 }
189
190 /// Sets the value of [destination][crate::model::OutputConfig::destination].
191 ///
192 /// Note that all the setters affecting `destination` are mutually
193 /// exclusive.
194 ///
195 /// # Example
196 /// ```ignore,no_run
197 /// # use google_cloud_optimization_v1::model::OutputConfig;
198 /// use google_cloud_optimization_v1::model::GcsDestination;
199 /// let x = OutputConfig::new().set_destination(Some(
200 /// google_cloud_optimization_v1::model::output_config::Destination::GcsDestination(GcsDestination::default().into())));
201 /// ```
202 pub fn set_destination<
203 T: std::convert::Into<std::option::Option<crate::model::output_config::Destination>>,
204 >(
205 mut self,
206 v: T,
207 ) -> Self {
208 self.destination = v.into();
209 self
210 }
211
212 /// The value of [destination][crate::model::OutputConfig::destination]
213 /// if it holds a `GcsDestination`, `None` if the field is not set or
214 /// holds a different branch.
215 pub fn gcs_destination(
216 &self,
217 ) -> std::option::Option<&std::boxed::Box<crate::model::GcsDestination>> {
218 #[allow(unreachable_patterns)]
219 self.destination.as_ref().and_then(|v| match v {
220 crate::model::output_config::Destination::GcsDestination(v) => {
221 std::option::Option::Some(v)
222 }
223 _ => std::option::Option::None,
224 })
225 }
226
227 /// Sets the value of [destination][crate::model::OutputConfig::destination]
228 /// to hold a `GcsDestination`.
229 ///
230 /// Note that all the setters affecting `destination` are
231 /// mutually exclusive.
232 ///
233 /// # Example
234 /// ```ignore,no_run
235 /// # use google_cloud_optimization_v1::model::OutputConfig;
236 /// use google_cloud_optimization_v1::model::GcsDestination;
237 /// let x = OutputConfig::new().set_gcs_destination(GcsDestination::default()/* use setters */);
238 /// assert!(x.gcs_destination().is_some());
239 /// ```
240 pub fn set_gcs_destination<
241 T: std::convert::Into<std::boxed::Box<crate::model::GcsDestination>>,
242 >(
243 mut self,
244 v: T,
245 ) -> Self {
246 self.destination = std::option::Option::Some(
247 crate::model::output_config::Destination::GcsDestination(v.into()),
248 );
249 self
250 }
251}
252
253impl wkt::message::Message for OutputConfig {
254 fn typename() -> &'static str {
255 "type.googleapis.com/google.cloud.optimization.v1.OutputConfig"
256 }
257}
258
259/// Defines additional types related to [OutputConfig].
260pub mod output_config {
261 #[allow(unused_imports)]
262 use super::*;
263
264 /// The location of the output result in cloud storage.
265 /// Required.
266 #[derive(Clone, Debug, PartialEq)]
267 #[non_exhaustive]
268 pub enum Destination {
269 /// The Google Cloud Storage location to write the output to.
270 GcsDestination(std::boxed::Box<crate::model::GcsDestination>),
271 }
272}
273
274/// The Google Cloud Storage location where the input file will be read from.
275#[derive(Clone, Default, PartialEq)]
276#[non_exhaustive]
277pub struct GcsSource {
278 /// Required. URI of the Google Cloud Storage location.
279 pub uri: std::string::String,
280
281 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
282}
283
284impl GcsSource {
285 /// Creates a new default instance.
286 pub fn new() -> Self {
287 std::default::Default::default()
288 }
289
290 /// Sets the value of [uri][crate::model::GcsSource::uri].
291 ///
292 /// # Example
293 /// ```ignore,no_run
294 /// # use google_cloud_optimization_v1::model::GcsSource;
295 /// let x = GcsSource::new().set_uri("example");
296 /// ```
297 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
298 self.uri = v.into();
299 self
300 }
301}
302
303impl wkt::message::Message for GcsSource {
304 fn typename() -> &'static str {
305 "type.googleapis.com/google.cloud.optimization.v1.GcsSource"
306 }
307}
308
309/// The Google Cloud Storage location where the output file will be written to.
310#[derive(Clone, Default, PartialEq)]
311#[non_exhaustive]
312pub struct GcsDestination {
313 /// Required. URI of the Google Cloud Storage location.
314 pub uri: std::string::String,
315
316 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
317}
318
319impl GcsDestination {
320 /// Creates a new default instance.
321 pub fn new() -> Self {
322 std::default::Default::default()
323 }
324
325 /// Sets the value of [uri][crate::model::GcsDestination::uri].
326 ///
327 /// # Example
328 /// ```ignore,no_run
329 /// # use google_cloud_optimization_v1::model::GcsDestination;
330 /// let x = GcsDestination::new().set_uri("example");
331 /// ```
332 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
333 self.uri = v.into();
334 self
335 }
336}
337
338impl wkt::message::Message for GcsDestination {
339 fn typename() -> &'static str {
340 "type.googleapis.com/google.cloud.optimization.v1.GcsDestination"
341 }
342}
343
344/// The long running operation metadata for async model related methods.
345#[derive(Clone, Default, PartialEq)]
346#[non_exhaustive]
347pub struct AsyncModelMetadata {
348 /// The state of the current operation.
349 pub state: crate::model::async_model_metadata::State,
350
351 /// A message providing more details about the current state of the operation.
352 /// For example, the error message if the operation is failed.
353 pub state_message: std::string::String,
354
355 /// The creation time of the operation.
356 pub create_time: std::option::Option<wkt::Timestamp>,
357
358 /// The last update time of the operation.
359 pub update_time: std::option::Option<wkt::Timestamp>,
360
361 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
362}
363
364impl AsyncModelMetadata {
365 /// Creates a new default instance.
366 pub fn new() -> Self {
367 std::default::Default::default()
368 }
369
370 /// Sets the value of [state][crate::model::AsyncModelMetadata::state].
371 ///
372 /// # Example
373 /// ```ignore,no_run
374 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
375 /// use google_cloud_optimization_v1::model::async_model_metadata::State;
376 /// let x0 = AsyncModelMetadata::new().set_state(State::Running);
377 /// let x1 = AsyncModelMetadata::new().set_state(State::Succeeded);
378 /// let x2 = AsyncModelMetadata::new().set_state(State::Cancelled);
379 /// ```
380 pub fn set_state<T: std::convert::Into<crate::model::async_model_metadata::State>>(
381 mut self,
382 v: T,
383 ) -> Self {
384 self.state = v.into();
385 self
386 }
387
388 /// Sets the value of [state_message][crate::model::AsyncModelMetadata::state_message].
389 ///
390 /// # Example
391 /// ```ignore,no_run
392 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
393 /// let x = AsyncModelMetadata::new().set_state_message("example");
394 /// ```
395 pub fn set_state_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
396 self.state_message = v.into();
397 self
398 }
399
400 /// Sets the value of [create_time][crate::model::AsyncModelMetadata::create_time].
401 ///
402 /// # Example
403 /// ```ignore,no_run
404 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
405 /// use wkt::Timestamp;
406 /// let x = AsyncModelMetadata::new().set_create_time(Timestamp::default()/* use setters */);
407 /// ```
408 pub fn set_create_time<T>(mut self, v: T) -> Self
409 where
410 T: std::convert::Into<wkt::Timestamp>,
411 {
412 self.create_time = std::option::Option::Some(v.into());
413 self
414 }
415
416 /// Sets or clears the value of [create_time][crate::model::AsyncModelMetadata::create_time].
417 ///
418 /// # Example
419 /// ```ignore,no_run
420 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
421 /// use wkt::Timestamp;
422 /// let x = AsyncModelMetadata::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
423 /// let x = AsyncModelMetadata::new().set_or_clear_create_time(None::<Timestamp>);
424 /// ```
425 pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
426 where
427 T: std::convert::Into<wkt::Timestamp>,
428 {
429 self.create_time = v.map(|x| x.into());
430 self
431 }
432
433 /// Sets the value of [update_time][crate::model::AsyncModelMetadata::update_time].
434 ///
435 /// # Example
436 /// ```ignore,no_run
437 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
438 /// use wkt::Timestamp;
439 /// let x = AsyncModelMetadata::new().set_update_time(Timestamp::default()/* use setters */);
440 /// ```
441 pub fn set_update_time<T>(mut self, v: T) -> Self
442 where
443 T: std::convert::Into<wkt::Timestamp>,
444 {
445 self.update_time = std::option::Option::Some(v.into());
446 self
447 }
448
449 /// Sets or clears the value of [update_time][crate::model::AsyncModelMetadata::update_time].
450 ///
451 /// # Example
452 /// ```ignore,no_run
453 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
454 /// use wkt::Timestamp;
455 /// let x = AsyncModelMetadata::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
456 /// let x = AsyncModelMetadata::new().set_or_clear_update_time(None::<Timestamp>);
457 /// ```
458 pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
459 where
460 T: std::convert::Into<wkt::Timestamp>,
461 {
462 self.update_time = v.map(|x| x.into());
463 self
464 }
465}
466
467impl wkt::message::Message for AsyncModelMetadata {
468 fn typename() -> &'static str {
469 "type.googleapis.com/google.cloud.optimization.v1.AsyncModelMetadata"
470 }
471}
472
473/// Defines additional types related to [AsyncModelMetadata].
474pub mod async_model_metadata {
475 #[allow(unused_imports)]
476 use super::*;
477
478 /// Possible states of the operation.
479 ///
480 /// # Working with unknown values
481 ///
482 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
483 /// additional enum variants at any time. Adding new variants is not considered
484 /// a breaking change. Applications should write their code in anticipation of:
485 ///
486 /// - New values appearing in future releases of the client library, **and**
487 /// - New values received dynamically, without application changes.
488 ///
489 /// Please consult the [Working with enums] section in the user guide for some
490 /// guidelines.
491 ///
492 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
493 #[derive(Clone, Debug, PartialEq)]
494 #[non_exhaustive]
495 pub enum State {
496 /// The default value. This value is used if the state is omitted.
497 Unspecified,
498 /// Request is being processed.
499 Running,
500 /// The operation completed successfully.
501 Succeeded,
502 /// The operation was cancelled.
503 Cancelled,
504 /// The operation has failed.
505 Failed,
506 /// If set, the enum was initialized with an unknown value.
507 ///
508 /// Applications can examine the value using [State::value] or
509 /// [State::name].
510 UnknownValue(state::UnknownValue),
511 }
512
513 #[doc(hidden)]
514 pub mod state {
515 #[allow(unused_imports)]
516 use super::*;
517 #[derive(Clone, Debug, PartialEq)]
518 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
519 }
520
521 impl State {
522 /// Gets the enum value.
523 ///
524 /// Returns `None` if the enum contains an unknown value deserialized from
525 /// the string representation of enums.
526 pub fn value(&self) -> std::option::Option<i32> {
527 match self {
528 Self::Unspecified => std::option::Option::Some(0),
529 Self::Running => std::option::Option::Some(1),
530 Self::Succeeded => std::option::Option::Some(2),
531 Self::Cancelled => std::option::Option::Some(3),
532 Self::Failed => std::option::Option::Some(4),
533 Self::UnknownValue(u) => u.0.value(),
534 }
535 }
536
537 /// Gets the enum value as a string.
538 ///
539 /// Returns `None` if the enum contains an unknown value deserialized from
540 /// the integer representation of enums.
541 pub fn name(&self) -> std::option::Option<&str> {
542 match self {
543 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
544 Self::Running => std::option::Option::Some("RUNNING"),
545 Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
546 Self::Cancelled => std::option::Option::Some("CANCELLED"),
547 Self::Failed => std::option::Option::Some("FAILED"),
548 Self::UnknownValue(u) => u.0.name(),
549 }
550 }
551 }
552
553 impl std::default::Default for State {
554 fn default() -> Self {
555 use std::convert::From;
556 Self::from(0)
557 }
558 }
559
560 impl std::fmt::Display for State {
561 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
562 wkt::internal::display_enum(f, self.name(), self.value())
563 }
564 }
565
566 impl std::convert::From<i32> for State {
567 fn from(value: i32) -> Self {
568 match value {
569 0 => Self::Unspecified,
570 1 => Self::Running,
571 2 => Self::Succeeded,
572 3 => Self::Cancelled,
573 4 => Self::Failed,
574 _ => Self::UnknownValue(state::UnknownValue(
575 wkt::internal::UnknownEnumValue::Integer(value),
576 )),
577 }
578 }
579 }
580
581 impl std::convert::From<&str> for State {
582 fn from(value: &str) -> Self {
583 use std::string::ToString;
584 match value {
585 "STATE_UNSPECIFIED" => Self::Unspecified,
586 "RUNNING" => Self::Running,
587 "SUCCEEDED" => Self::Succeeded,
588 "CANCELLED" => Self::Cancelled,
589 "FAILED" => Self::Failed,
590 _ => Self::UnknownValue(state::UnknownValue(
591 wkt::internal::UnknownEnumValue::String(value.to_string()),
592 )),
593 }
594 }
595 }
596
597 impl serde::ser::Serialize for State {
598 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
599 where
600 S: serde::Serializer,
601 {
602 match self {
603 Self::Unspecified => serializer.serialize_i32(0),
604 Self::Running => serializer.serialize_i32(1),
605 Self::Succeeded => serializer.serialize_i32(2),
606 Self::Cancelled => serializer.serialize_i32(3),
607 Self::Failed => serializer.serialize_i32(4),
608 Self::UnknownValue(u) => u.0.serialize(serializer),
609 }
610 }
611 }
612
613 impl<'de> serde::de::Deserialize<'de> for State {
614 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
615 where
616 D: serde::Deserializer<'de>,
617 {
618 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
619 ".google.cloud.optimization.v1.AsyncModelMetadata.State",
620 ))
621 }
622 }
623}
624
625/// Request to be given to a tour optimization solver which defines the
626/// shipment model to solve as well as optimization parameters.
627#[derive(Clone, Default, PartialEq)]
628#[non_exhaustive]
629pub struct OptimizeToursRequest {
630 /// Required. Target project and location to make a call.
631 ///
632 /// Format: `projects/{project-id}/locations/{location-id}`.
633 ///
634 /// If no location is specified, a region will be chosen automatically.
635 pub parent: std::string::String,
636
637 /// If this timeout is set, the server returns a response before the timeout
638 /// period has elapsed or the server deadline for synchronous requests is
639 /// reached, whichever is sooner.
640 ///
641 /// For asynchronous requests, the server will generate a solution (if
642 /// possible) before the timeout has elapsed.
643 pub timeout: std::option::Option<wkt::Duration>,
644
645 /// Shipment model to solve.
646 pub model: std::option::Option<crate::model::ShipmentModel>,
647
648 /// By default, the solving mode is `DEFAULT_SOLVE` (0).
649 pub solving_mode: crate::model::optimize_tours_request::SolvingMode,
650
651 /// Search mode used to solve the request.
652 pub search_mode: crate::model::optimize_tours_request::SearchMode,
653
654 /// Guide the optimization algorithm in finding a first solution that is
655 /// similar to a previous solution.
656 ///
657 /// The model is constrained when the first solution is built.
658 /// Any shipments not performed on a route are implicitly skipped in the first
659 /// solution, but they may be performed in successive solutions.
660 ///
661 /// The solution must satisfy some basic validity assumptions:
662 ///
663 /// * for all routes, `vehicle_index` must be in range and not be duplicated.
664 /// * for all visits, `shipment_index` and `visit_request_index` must be
665 /// in range.
666 /// * a shipment may only be referenced on one route.
667 /// * the pickup of a pickup-delivery shipment must be performed before
668 /// the delivery.
669 /// * no more than one pickup alternative or delivery alternative of
670 /// a shipment may be performed.
671 /// * for all routes, times are increasing (i.e., `vehicle_start_time
672 /// <= visits[0].start_time <= visits[1].start_time ...
673 /// <= vehicle_end_time`).
674 /// * a shipment may only be performed on a vehicle that is allowed. A
675 /// vehicle is allowed if
676 /// [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]
677 /// is empty or its `vehicle_index` is included in
678 /// [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices].
679 ///
680 /// If the injected solution is not feasible, a validation error is not
681 /// necessarily returned and an error indicating infeasibility may be returned
682 /// instead.
683 ///
684 /// [google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]: crate::model::Shipment::allowed_vehicle_indices
685 pub injected_first_solution_routes: std::vec::Vec<crate::model::ShipmentRoute>,
686
687 /// Constrain the optimization algorithm to find a final solution that is
688 /// similar to a previous solution. For example, this may be used to freeze
689 /// portions of routes which have already been completed or which are to be
690 /// completed but must not be modified.
691 ///
692 /// If the injected solution is not feasible, a validation error is not
693 /// necessarily returned and an error indicating infeasibility may be returned
694 /// instead.
695 pub injected_solution_constraint: std::option::Option<crate::model::InjectedSolutionConstraint>,
696
697 /// If non-empty, the given routes will be refreshed, without modifying their
698 /// underlying sequence of visits or travel times: only other details will be
699 /// updated. This does not solve the model.
700 ///
701 /// As of 2020/11, this only populates the polylines of non-empty routes and
702 /// requires that `populate_polylines` is true.
703 ///
704 /// The `route_polyline` fields of the passed-in routes may be inconsistent
705 /// with route `transitions`.
706 ///
707 /// This field must not be used together with `injected_first_solution_routes`
708 /// or `injected_solution_constraint`.
709 ///
710 /// `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
711 /// Polylines are still populated between all visits in all non-empty routes
712 /// regardless of whether the related shipments or vehicles are ignored.
713 pub refresh_details_routes: std::vec::Vec<crate::model::ShipmentRoute>,
714
715 /// If true:
716 ///
717 /// * uses
718 /// [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label]
719 /// instead of `vehicle_index` to
720 /// match routes in an injected solution with vehicles in the request;
721 /// reuses the mapping of original
722 /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
723 /// to new
724 /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
725 /// to update
726 /// [ConstraintRelaxation.vehicle_indices][google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]
727 /// if non-empty, but the mapping must be unambiguous (i.e., multiple
728 /// `ShipmentRoute`s must not share the same original `vehicle_index`).
729 /// * uses
730 /// [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]
731 /// instead of `shipment_index`
732 /// to match visits in an injected solution with shipments in the request;
733 /// * uses
734 /// [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
735 /// instead of
736 /// [SkippedShipment.index][google.cloud.optimization.v1.SkippedShipment.index]
737 /// to
738 /// match skipped shipments in the injected solution with request
739 /// shipments.
740 ///
741 /// This interpretation applies to the `injected_first_solution_routes`,
742 /// `injected_solution_constraint`, and `refresh_details_routes` fields.
743 /// It can be used when shipment or vehicle indices in the request have
744 /// changed since the solution was created, perhaps because shipments or
745 /// vehicles have been removed from or added to the request.
746 ///
747 /// If true, labels in the following categories must appear at most once in
748 /// their category:
749 ///
750 /// * [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] in the
751 /// request;
752 /// * [Shipment.label][google.cloud.optimization.v1.Shipment.label] in the
753 /// request;
754 /// * [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label] in the injected solution;
755 /// * [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] and [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label] in
756 /// the injected solution (except pickup/delivery visit pairs, whose
757 /// `shipment_label` must appear twice).
758 ///
759 /// If a `vehicle_label` in the injected solution does not correspond to a
760 /// request vehicle, the corresponding route is removed from the solution
761 /// along with its visits. If a `shipment_label` in the injected solution does
762 /// not correspond to a request shipment, the corresponding visit is removed
763 /// from the solution. If a
764 /// [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
765 /// in the injected solution does not correspond to a request shipment, the
766 /// `SkippedShipment` is removed from the solution.
767 ///
768 /// Removing route visits or entire routes from an injected solution may
769 /// have an effect on the implied constraints, which may lead to change in
770 /// solution, validation errors, or infeasibility.
771 ///
772 /// NOTE: The caller must ensure that each
773 /// [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] (resp.
774 /// [Shipment.label][google.cloud.optimization.v1.Shipment.label]) uniquely
775 /// identifies a vehicle (resp. shipment) entity used across the two relevant
776 /// requests: the past request that produced the `OptimizeToursResponse` used
777 /// in the injected solution and the current request that includes the injected
778 /// solution. The uniqueness checks described above are not enough to guarantee
779 /// this requirement.
780 ///
781 /// [google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]: crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices
782 /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
783 /// [google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]: crate::model::shipment_route::Visit::shipment_label
784 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
785 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_label]: crate::model::ShipmentRoute::vehicle_label
786 /// [google.cloud.optimization.v1.SkippedShipment.index]: crate::model::SkippedShipment::index
787 /// [google.cloud.optimization.v1.SkippedShipment.label]: crate::model::SkippedShipment::label
788 /// [google.cloud.optimization.v1.Vehicle.label]: crate::model::Vehicle::label
789 pub interpret_injected_solutions_using_labels: bool,
790
791 /// Consider traffic estimation in calculating `ShipmentRoute` fields
792 /// [Transition.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration],
793 /// [Visit.start_time][google.cloud.optimization.v1.ShipmentRoute.Visit.start_time],
794 /// and `vehicle_end_time`; in setting the
795 /// [ShipmentRoute.has_traffic_infeasibilities][google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]
796 /// field, and in calculating the
797 /// [OptimizeToursResponse.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.total_cost]
798 /// field.
799 ///
800 /// [google.cloud.optimization.v1.OptimizeToursResponse.total_cost]: crate::model::OptimizeToursResponse::total_cost
801 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
802 /// [google.cloud.optimization.v1.ShipmentRoute.Visit.start_time]: crate::model::shipment_route::Visit::start_time
803 /// [google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]: crate::model::ShipmentRoute::has_traffic_infeasibilities
804 pub consider_road_traffic: bool,
805
806 /// If true, polylines will be populated in response `ShipmentRoute`s.
807 pub populate_polylines: bool,
808
809 /// If true, polylines will be populated in response
810 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
811 /// Note that in this case, the polylines will also be populated in the
812 /// deprecated `travel_steps`.
813 ///
814 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
815 pub populate_transition_polylines: bool,
816
817 /// If this is set, then the request can have a deadline
818 /// (see <https://grpc.io/blog/deadlines>) of up to 60 minutes.
819 /// Otherwise, the maximum deadline is only 30 minutes.
820 /// Note that long-lived requests have a significantly larger (but still small)
821 /// risk of interruption.
822 pub allow_large_deadline_despite_interruption_risk: bool,
823
824 /// If true, travel distances will be computed using geodesic distances instead
825 /// of Google Maps distances, and travel times will be computed using geodesic
826 /// distances with a speed defined by `geodesic_meters_per_second`.
827 pub use_geodesic_distances: bool,
828
829 /// When `use_geodesic_distances` is true, this field must be set and defines
830 /// the speed applied to compute travel times. Its value must be at least 1.0
831 /// meters/seconds.
832 pub geodesic_meters_per_second: std::option::Option<f64>,
833
834 /// Truncates the number of validation errors returned. These errors are
835 /// typically attached to an INVALID_ARGUMENT error payload as a BadRequest
836 /// error detail (<https://cloud.google.com/apis/design/errors#error_details>),
837 /// unless solving_mode=VALIDATE_ONLY: see the
838 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
839 /// field.
840 /// This defaults to 100 and is capped at 10,000.
841 ///
842 /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
843 pub max_validation_errors: std::option::Option<i32>,
844
845 /// Label that may be used to identify this request, reported back in the
846 /// [OptimizeToursResponse.request_label][google.cloud.optimization.v1.OptimizeToursResponse.request_label].
847 ///
848 /// [google.cloud.optimization.v1.OptimizeToursResponse.request_label]: crate::model::OptimizeToursResponse::request_label
849 pub label: std::string::String,
850
851 /// Deprecated: Use
852 /// [OptimizeToursRequest.populate_transition_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
853 /// instead. If true, polylines will be populated in response
854 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
855 /// Note that in this case, the polylines will also be populated in the
856 /// deprecated `travel_steps`.
857 ///
858 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]: crate::model::OptimizeToursRequest::populate_transition_polylines
859 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
860 #[deprecated]
861 pub populate_travel_step_polylines: bool,
862
863 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
864}
865
866impl OptimizeToursRequest {
867 /// Creates a new default instance.
868 pub fn new() -> Self {
869 std::default::Default::default()
870 }
871
872 /// Sets the value of [parent][crate::model::OptimizeToursRequest::parent].
873 ///
874 /// # Example
875 /// ```ignore,no_run
876 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
877 /// let x = OptimizeToursRequest::new().set_parent("example");
878 /// ```
879 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
880 self.parent = v.into();
881 self
882 }
883
884 /// Sets the value of [timeout][crate::model::OptimizeToursRequest::timeout].
885 ///
886 /// # Example
887 /// ```ignore,no_run
888 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
889 /// use wkt::Duration;
890 /// let x = OptimizeToursRequest::new().set_timeout(Duration::default()/* use setters */);
891 /// ```
892 pub fn set_timeout<T>(mut self, v: T) -> Self
893 where
894 T: std::convert::Into<wkt::Duration>,
895 {
896 self.timeout = std::option::Option::Some(v.into());
897 self
898 }
899
900 /// Sets or clears the value of [timeout][crate::model::OptimizeToursRequest::timeout].
901 ///
902 /// # Example
903 /// ```ignore,no_run
904 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
905 /// use wkt::Duration;
906 /// let x = OptimizeToursRequest::new().set_or_clear_timeout(Some(Duration::default()/* use setters */));
907 /// let x = OptimizeToursRequest::new().set_or_clear_timeout(None::<Duration>);
908 /// ```
909 pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
910 where
911 T: std::convert::Into<wkt::Duration>,
912 {
913 self.timeout = v.map(|x| x.into());
914 self
915 }
916
917 /// Sets the value of [model][crate::model::OptimizeToursRequest::model].
918 ///
919 /// # Example
920 /// ```ignore,no_run
921 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
922 /// use google_cloud_optimization_v1::model::ShipmentModel;
923 /// let x = OptimizeToursRequest::new().set_model(ShipmentModel::default()/* use setters */);
924 /// ```
925 pub fn set_model<T>(mut self, v: T) -> Self
926 where
927 T: std::convert::Into<crate::model::ShipmentModel>,
928 {
929 self.model = std::option::Option::Some(v.into());
930 self
931 }
932
933 /// Sets or clears the value of [model][crate::model::OptimizeToursRequest::model].
934 ///
935 /// # Example
936 /// ```ignore,no_run
937 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
938 /// use google_cloud_optimization_v1::model::ShipmentModel;
939 /// let x = OptimizeToursRequest::new().set_or_clear_model(Some(ShipmentModel::default()/* use setters */));
940 /// let x = OptimizeToursRequest::new().set_or_clear_model(None::<ShipmentModel>);
941 /// ```
942 pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
943 where
944 T: std::convert::Into<crate::model::ShipmentModel>,
945 {
946 self.model = v.map(|x| x.into());
947 self
948 }
949
950 /// Sets the value of [solving_mode][crate::model::OptimizeToursRequest::solving_mode].
951 ///
952 /// # Example
953 /// ```ignore,no_run
954 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
955 /// use google_cloud_optimization_v1::model::optimize_tours_request::SolvingMode;
956 /// let x0 = OptimizeToursRequest::new().set_solving_mode(SolvingMode::ValidateOnly);
957 /// let x1 = OptimizeToursRequest::new().set_solving_mode(SolvingMode::DetectSomeInfeasibleShipments);
958 /// ```
959 pub fn set_solving_mode<
960 T: std::convert::Into<crate::model::optimize_tours_request::SolvingMode>,
961 >(
962 mut self,
963 v: T,
964 ) -> Self {
965 self.solving_mode = v.into();
966 self
967 }
968
969 /// Sets the value of [search_mode][crate::model::OptimizeToursRequest::search_mode].
970 ///
971 /// # Example
972 /// ```ignore,no_run
973 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
974 /// use google_cloud_optimization_v1::model::optimize_tours_request::SearchMode;
975 /// let x0 = OptimizeToursRequest::new().set_search_mode(SearchMode::ReturnFast);
976 /// let x1 = OptimizeToursRequest::new().set_search_mode(SearchMode::ConsumeAllAvailableTime);
977 /// ```
978 pub fn set_search_mode<
979 T: std::convert::Into<crate::model::optimize_tours_request::SearchMode>,
980 >(
981 mut self,
982 v: T,
983 ) -> Self {
984 self.search_mode = v.into();
985 self
986 }
987
988 /// Sets the value of [injected_first_solution_routes][crate::model::OptimizeToursRequest::injected_first_solution_routes].
989 ///
990 /// # Example
991 /// ```ignore,no_run
992 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
993 /// use google_cloud_optimization_v1::model::ShipmentRoute;
994 /// let x = OptimizeToursRequest::new()
995 /// .set_injected_first_solution_routes([
996 /// ShipmentRoute::default()/* use setters */,
997 /// ShipmentRoute::default()/* use (different) setters */,
998 /// ]);
999 /// ```
1000 pub fn set_injected_first_solution_routes<T, V>(mut self, v: T) -> Self
1001 where
1002 T: std::iter::IntoIterator<Item = V>,
1003 V: std::convert::Into<crate::model::ShipmentRoute>,
1004 {
1005 use std::iter::Iterator;
1006 self.injected_first_solution_routes = v.into_iter().map(|i| i.into()).collect();
1007 self
1008 }
1009
1010 /// Sets the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1011 ///
1012 /// # Example
1013 /// ```ignore,no_run
1014 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1015 /// use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
1016 /// let x = OptimizeToursRequest::new().set_injected_solution_constraint(InjectedSolutionConstraint::default()/* use setters */);
1017 /// ```
1018 pub fn set_injected_solution_constraint<T>(mut self, v: T) -> Self
1019 where
1020 T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1021 {
1022 self.injected_solution_constraint = std::option::Option::Some(v.into());
1023 self
1024 }
1025
1026 /// Sets or clears the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1027 ///
1028 /// # Example
1029 /// ```ignore,no_run
1030 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1031 /// use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
1032 /// let x = OptimizeToursRequest::new().set_or_clear_injected_solution_constraint(Some(InjectedSolutionConstraint::default()/* use setters */));
1033 /// let x = OptimizeToursRequest::new().set_or_clear_injected_solution_constraint(None::<InjectedSolutionConstraint>);
1034 /// ```
1035 pub fn set_or_clear_injected_solution_constraint<T>(mut self, v: std::option::Option<T>) -> Self
1036 where
1037 T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1038 {
1039 self.injected_solution_constraint = v.map(|x| x.into());
1040 self
1041 }
1042
1043 /// Sets the value of [refresh_details_routes][crate::model::OptimizeToursRequest::refresh_details_routes].
1044 ///
1045 /// # Example
1046 /// ```ignore,no_run
1047 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1048 /// use google_cloud_optimization_v1::model::ShipmentRoute;
1049 /// let x = OptimizeToursRequest::new()
1050 /// .set_refresh_details_routes([
1051 /// ShipmentRoute::default()/* use setters */,
1052 /// ShipmentRoute::default()/* use (different) setters */,
1053 /// ]);
1054 /// ```
1055 pub fn set_refresh_details_routes<T, V>(mut self, v: T) -> Self
1056 where
1057 T: std::iter::IntoIterator<Item = V>,
1058 V: std::convert::Into<crate::model::ShipmentRoute>,
1059 {
1060 use std::iter::Iterator;
1061 self.refresh_details_routes = v.into_iter().map(|i| i.into()).collect();
1062 self
1063 }
1064
1065 /// Sets the value of [interpret_injected_solutions_using_labels][crate::model::OptimizeToursRequest::interpret_injected_solutions_using_labels].
1066 ///
1067 /// # Example
1068 /// ```ignore,no_run
1069 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1070 /// let x = OptimizeToursRequest::new().set_interpret_injected_solutions_using_labels(true);
1071 /// ```
1072 pub fn set_interpret_injected_solutions_using_labels<T: std::convert::Into<bool>>(
1073 mut self,
1074 v: T,
1075 ) -> Self {
1076 self.interpret_injected_solutions_using_labels = v.into();
1077 self
1078 }
1079
1080 /// Sets the value of [consider_road_traffic][crate::model::OptimizeToursRequest::consider_road_traffic].
1081 ///
1082 /// # Example
1083 /// ```ignore,no_run
1084 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1085 /// let x = OptimizeToursRequest::new().set_consider_road_traffic(true);
1086 /// ```
1087 pub fn set_consider_road_traffic<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1088 self.consider_road_traffic = v.into();
1089 self
1090 }
1091
1092 /// Sets the value of [populate_polylines][crate::model::OptimizeToursRequest::populate_polylines].
1093 ///
1094 /// # Example
1095 /// ```ignore,no_run
1096 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1097 /// let x = OptimizeToursRequest::new().set_populate_polylines(true);
1098 /// ```
1099 pub fn set_populate_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1100 self.populate_polylines = v.into();
1101 self
1102 }
1103
1104 /// Sets the value of [populate_transition_polylines][crate::model::OptimizeToursRequest::populate_transition_polylines].
1105 ///
1106 /// # Example
1107 /// ```ignore,no_run
1108 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1109 /// let x = OptimizeToursRequest::new().set_populate_transition_polylines(true);
1110 /// ```
1111 pub fn set_populate_transition_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1112 self.populate_transition_polylines = v.into();
1113 self
1114 }
1115
1116 /// Sets the value of [allow_large_deadline_despite_interruption_risk][crate::model::OptimizeToursRequest::allow_large_deadline_despite_interruption_risk].
1117 ///
1118 /// # Example
1119 /// ```ignore,no_run
1120 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1121 /// let x = OptimizeToursRequest::new().set_allow_large_deadline_despite_interruption_risk(true);
1122 /// ```
1123 pub fn set_allow_large_deadline_despite_interruption_risk<T: std::convert::Into<bool>>(
1124 mut self,
1125 v: T,
1126 ) -> Self {
1127 self.allow_large_deadline_despite_interruption_risk = v.into();
1128 self
1129 }
1130
1131 /// Sets the value of [use_geodesic_distances][crate::model::OptimizeToursRequest::use_geodesic_distances].
1132 ///
1133 /// # Example
1134 /// ```ignore,no_run
1135 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1136 /// let x = OptimizeToursRequest::new().set_use_geodesic_distances(true);
1137 /// ```
1138 pub fn set_use_geodesic_distances<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1139 self.use_geodesic_distances = v.into();
1140 self
1141 }
1142
1143 /// Sets the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1144 ///
1145 /// # Example
1146 /// ```ignore,no_run
1147 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1148 /// let x = OptimizeToursRequest::new().set_geodesic_meters_per_second(42.0);
1149 /// ```
1150 pub fn set_geodesic_meters_per_second<T>(mut self, v: T) -> Self
1151 where
1152 T: std::convert::Into<f64>,
1153 {
1154 self.geodesic_meters_per_second = std::option::Option::Some(v.into());
1155 self
1156 }
1157
1158 /// Sets or clears the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1159 ///
1160 /// # Example
1161 /// ```ignore,no_run
1162 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1163 /// let x = OptimizeToursRequest::new().set_or_clear_geodesic_meters_per_second(Some(42.0));
1164 /// let x = OptimizeToursRequest::new().set_or_clear_geodesic_meters_per_second(None::<f32>);
1165 /// ```
1166 pub fn set_or_clear_geodesic_meters_per_second<T>(mut self, v: std::option::Option<T>) -> Self
1167 where
1168 T: std::convert::Into<f64>,
1169 {
1170 self.geodesic_meters_per_second = v.map(|x| x.into());
1171 self
1172 }
1173
1174 /// Sets the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1175 ///
1176 /// # Example
1177 /// ```ignore,no_run
1178 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1179 /// let x = OptimizeToursRequest::new().set_max_validation_errors(42);
1180 /// ```
1181 pub fn set_max_validation_errors<T>(mut self, v: T) -> Self
1182 where
1183 T: std::convert::Into<i32>,
1184 {
1185 self.max_validation_errors = std::option::Option::Some(v.into());
1186 self
1187 }
1188
1189 /// Sets or clears the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1190 ///
1191 /// # Example
1192 /// ```ignore,no_run
1193 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1194 /// let x = OptimizeToursRequest::new().set_or_clear_max_validation_errors(Some(42));
1195 /// let x = OptimizeToursRequest::new().set_or_clear_max_validation_errors(None::<i32>);
1196 /// ```
1197 pub fn set_or_clear_max_validation_errors<T>(mut self, v: std::option::Option<T>) -> Self
1198 where
1199 T: std::convert::Into<i32>,
1200 {
1201 self.max_validation_errors = v.map(|x| x.into());
1202 self
1203 }
1204
1205 /// Sets the value of [label][crate::model::OptimizeToursRequest::label].
1206 ///
1207 /// # Example
1208 /// ```ignore,no_run
1209 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1210 /// let x = OptimizeToursRequest::new().set_label("example");
1211 /// ```
1212 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1213 self.label = v.into();
1214 self
1215 }
1216
1217 /// Sets the value of [populate_travel_step_polylines][crate::model::OptimizeToursRequest::populate_travel_step_polylines].
1218 ///
1219 /// # Example
1220 /// ```ignore,no_run
1221 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1222 /// let x = OptimizeToursRequest::new().set_populate_travel_step_polylines(true);
1223 /// ```
1224 #[deprecated]
1225 pub fn set_populate_travel_step_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1226 self.populate_travel_step_polylines = v.into();
1227 self
1228 }
1229}
1230
1231impl wkt::message::Message for OptimizeToursRequest {
1232 fn typename() -> &'static str {
1233 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursRequest"
1234 }
1235}
1236
1237/// Defines additional types related to [OptimizeToursRequest].
1238pub mod optimize_tours_request {
1239 #[allow(unused_imports)]
1240 use super::*;
1241
1242 /// Defines how the solver should handle the request. In all modes but
1243 /// `VALIDATE_ONLY`, if the request is invalid, you will receive an
1244 /// `INVALID_REQUEST` error. See
1245 /// [max_validation_errors][google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]
1246 /// to cap the number of errors returned.
1247 ///
1248 /// [google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]: crate::model::OptimizeToursRequest::max_validation_errors
1249 ///
1250 /// # Working with unknown values
1251 ///
1252 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1253 /// additional enum variants at any time. Adding new variants is not considered
1254 /// a breaking change. Applications should write their code in anticipation of:
1255 ///
1256 /// - New values appearing in future releases of the client library, **and**
1257 /// - New values received dynamically, without application changes.
1258 ///
1259 /// Please consult the [Working with enums] section in the user guide for some
1260 /// guidelines.
1261 ///
1262 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1263 #[derive(Clone, Debug, PartialEq)]
1264 #[non_exhaustive]
1265 pub enum SolvingMode {
1266 /// Solve the model.
1267 DefaultSolve,
1268 /// Only validates the model without solving it: populates as many
1269 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1270 /// as possible.
1271 ///
1272 /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1273 ValidateOnly,
1274 /// Only populates
1275 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1276 /// or
1277 /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments],
1278 /// and doesn't actually solve the rest of the request (`status` and `routes`
1279 /// are unset in the response).
1280 /// If infeasibilities in `injected_solution_constraint` routes are detected
1281 /// they are populated in the
1282 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1283 /// field and
1284 /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]
1285 /// is left empty.
1286 ///
1287 /// *IMPORTANT*: not all infeasible shipments are returned here, but only the
1288 /// ones that are detected as infeasible during preprocessing.
1289 ///
1290 /// [google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]: crate::model::OptimizeToursResponse::skipped_shipments
1291 /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1292 DetectSomeInfeasibleShipments,
1293 /// If set, the enum was initialized with an unknown value.
1294 ///
1295 /// Applications can examine the value using [SolvingMode::value] or
1296 /// [SolvingMode::name].
1297 UnknownValue(solving_mode::UnknownValue),
1298 }
1299
1300 #[doc(hidden)]
1301 pub mod solving_mode {
1302 #[allow(unused_imports)]
1303 use super::*;
1304 #[derive(Clone, Debug, PartialEq)]
1305 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1306 }
1307
1308 impl SolvingMode {
1309 /// Gets the enum value.
1310 ///
1311 /// Returns `None` if the enum contains an unknown value deserialized from
1312 /// the string representation of enums.
1313 pub fn value(&self) -> std::option::Option<i32> {
1314 match self {
1315 Self::DefaultSolve => std::option::Option::Some(0),
1316 Self::ValidateOnly => std::option::Option::Some(1),
1317 Self::DetectSomeInfeasibleShipments => std::option::Option::Some(2),
1318 Self::UnknownValue(u) => u.0.value(),
1319 }
1320 }
1321
1322 /// Gets the enum value as a string.
1323 ///
1324 /// Returns `None` if the enum contains an unknown value deserialized from
1325 /// the integer representation of enums.
1326 pub fn name(&self) -> std::option::Option<&str> {
1327 match self {
1328 Self::DefaultSolve => std::option::Option::Some("DEFAULT_SOLVE"),
1329 Self::ValidateOnly => std::option::Option::Some("VALIDATE_ONLY"),
1330 Self::DetectSomeInfeasibleShipments => {
1331 std::option::Option::Some("DETECT_SOME_INFEASIBLE_SHIPMENTS")
1332 }
1333 Self::UnknownValue(u) => u.0.name(),
1334 }
1335 }
1336 }
1337
1338 impl std::default::Default for SolvingMode {
1339 fn default() -> Self {
1340 use std::convert::From;
1341 Self::from(0)
1342 }
1343 }
1344
1345 impl std::fmt::Display for SolvingMode {
1346 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1347 wkt::internal::display_enum(f, self.name(), self.value())
1348 }
1349 }
1350
1351 impl std::convert::From<i32> for SolvingMode {
1352 fn from(value: i32) -> Self {
1353 match value {
1354 0 => Self::DefaultSolve,
1355 1 => Self::ValidateOnly,
1356 2 => Self::DetectSomeInfeasibleShipments,
1357 _ => Self::UnknownValue(solving_mode::UnknownValue(
1358 wkt::internal::UnknownEnumValue::Integer(value),
1359 )),
1360 }
1361 }
1362 }
1363
1364 impl std::convert::From<&str> for SolvingMode {
1365 fn from(value: &str) -> Self {
1366 use std::string::ToString;
1367 match value {
1368 "DEFAULT_SOLVE" => Self::DefaultSolve,
1369 "VALIDATE_ONLY" => Self::ValidateOnly,
1370 "DETECT_SOME_INFEASIBLE_SHIPMENTS" => Self::DetectSomeInfeasibleShipments,
1371 _ => Self::UnknownValue(solving_mode::UnknownValue(
1372 wkt::internal::UnknownEnumValue::String(value.to_string()),
1373 )),
1374 }
1375 }
1376 }
1377
1378 impl serde::ser::Serialize for SolvingMode {
1379 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1380 where
1381 S: serde::Serializer,
1382 {
1383 match self {
1384 Self::DefaultSolve => serializer.serialize_i32(0),
1385 Self::ValidateOnly => serializer.serialize_i32(1),
1386 Self::DetectSomeInfeasibleShipments => serializer.serialize_i32(2),
1387 Self::UnknownValue(u) => u.0.serialize(serializer),
1388 }
1389 }
1390 }
1391
1392 impl<'de> serde::de::Deserialize<'de> for SolvingMode {
1393 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1394 where
1395 D: serde::Deserializer<'de>,
1396 {
1397 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SolvingMode>::new(
1398 ".google.cloud.optimization.v1.OptimizeToursRequest.SolvingMode",
1399 ))
1400 }
1401 }
1402
1403 /// Mode defining the behavior of the search, trading off latency versus
1404 /// solution quality. In all modes, the global request deadline is enforced.
1405 ///
1406 /// # Working with unknown values
1407 ///
1408 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1409 /// additional enum variants at any time. Adding new variants is not considered
1410 /// a breaking change. Applications should write their code in anticipation of:
1411 ///
1412 /// - New values appearing in future releases of the client library, **and**
1413 /// - New values received dynamically, without application changes.
1414 ///
1415 /// Please consult the [Working with enums] section in the user guide for some
1416 /// guidelines.
1417 ///
1418 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1419 #[derive(Clone, Debug, PartialEq)]
1420 #[non_exhaustive]
1421 pub enum SearchMode {
1422 /// Unspecified search mode, equivalent to `RETURN_FAST`.
1423 Unspecified,
1424 /// Stop the search after finding the first good solution.
1425 ReturnFast,
1426 /// Spend all the available time to search for better solutions.
1427 ConsumeAllAvailableTime,
1428 /// If set, the enum was initialized with an unknown value.
1429 ///
1430 /// Applications can examine the value using [SearchMode::value] or
1431 /// [SearchMode::name].
1432 UnknownValue(search_mode::UnknownValue),
1433 }
1434
1435 #[doc(hidden)]
1436 pub mod search_mode {
1437 #[allow(unused_imports)]
1438 use super::*;
1439 #[derive(Clone, Debug, PartialEq)]
1440 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1441 }
1442
1443 impl SearchMode {
1444 /// Gets the enum value.
1445 ///
1446 /// Returns `None` if the enum contains an unknown value deserialized from
1447 /// the string representation of enums.
1448 pub fn value(&self) -> std::option::Option<i32> {
1449 match self {
1450 Self::Unspecified => std::option::Option::Some(0),
1451 Self::ReturnFast => std::option::Option::Some(1),
1452 Self::ConsumeAllAvailableTime => std::option::Option::Some(2),
1453 Self::UnknownValue(u) => u.0.value(),
1454 }
1455 }
1456
1457 /// Gets the enum value as a string.
1458 ///
1459 /// Returns `None` if the enum contains an unknown value deserialized from
1460 /// the integer representation of enums.
1461 pub fn name(&self) -> std::option::Option<&str> {
1462 match self {
1463 Self::Unspecified => std::option::Option::Some("SEARCH_MODE_UNSPECIFIED"),
1464 Self::ReturnFast => std::option::Option::Some("RETURN_FAST"),
1465 Self::ConsumeAllAvailableTime => {
1466 std::option::Option::Some("CONSUME_ALL_AVAILABLE_TIME")
1467 }
1468 Self::UnknownValue(u) => u.0.name(),
1469 }
1470 }
1471 }
1472
1473 impl std::default::Default for SearchMode {
1474 fn default() -> Self {
1475 use std::convert::From;
1476 Self::from(0)
1477 }
1478 }
1479
1480 impl std::fmt::Display for SearchMode {
1481 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1482 wkt::internal::display_enum(f, self.name(), self.value())
1483 }
1484 }
1485
1486 impl std::convert::From<i32> for SearchMode {
1487 fn from(value: i32) -> Self {
1488 match value {
1489 0 => Self::Unspecified,
1490 1 => Self::ReturnFast,
1491 2 => Self::ConsumeAllAvailableTime,
1492 _ => Self::UnknownValue(search_mode::UnknownValue(
1493 wkt::internal::UnknownEnumValue::Integer(value),
1494 )),
1495 }
1496 }
1497 }
1498
1499 impl std::convert::From<&str> for SearchMode {
1500 fn from(value: &str) -> Self {
1501 use std::string::ToString;
1502 match value {
1503 "SEARCH_MODE_UNSPECIFIED" => Self::Unspecified,
1504 "RETURN_FAST" => Self::ReturnFast,
1505 "CONSUME_ALL_AVAILABLE_TIME" => Self::ConsumeAllAvailableTime,
1506 _ => Self::UnknownValue(search_mode::UnknownValue(
1507 wkt::internal::UnknownEnumValue::String(value.to_string()),
1508 )),
1509 }
1510 }
1511 }
1512
1513 impl serde::ser::Serialize for SearchMode {
1514 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1515 where
1516 S: serde::Serializer,
1517 {
1518 match self {
1519 Self::Unspecified => serializer.serialize_i32(0),
1520 Self::ReturnFast => serializer.serialize_i32(1),
1521 Self::ConsumeAllAvailableTime => serializer.serialize_i32(2),
1522 Self::UnknownValue(u) => u.0.serialize(serializer),
1523 }
1524 }
1525 }
1526
1527 impl<'de> serde::de::Deserialize<'de> for SearchMode {
1528 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1529 where
1530 D: serde::Deserializer<'de>,
1531 {
1532 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SearchMode>::new(
1533 ".google.cloud.optimization.v1.OptimizeToursRequest.SearchMode",
1534 ))
1535 }
1536 }
1537}
1538
1539/// Response after solving a tour optimization problem containing the routes
1540/// followed by each vehicle, the shipments which have been skipped and the
1541/// overall cost of the solution.
1542#[derive(Clone, Default, PartialEq)]
1543#[non_exhaustive]
1544pub struct OptimizeToursResponse {
1545 /// Routes computed for each vehicle; the i-th route corresponds to the i-th
1546 /// vehicle in the model.
1547 pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
1548
1549 /// Copy of the
1550 /// [OptimizeToursRequest.label][google.cloud.optimization.v1.OptimizeToursRequest.label],
1551 /// if a label was specified in the request.
1552 ///
1553 /// [google.cloud.optimization.v1.OptimizeToursRequest.label]: crate::model::OptimizeToursRequest::label
1554 pub request_label: std::string::String,
1555
1556 /// The list of all shipments skipped.
1557 pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
1558
1559 /// List of all the validation errors that we were able to detect
1560 /// independently. See the "MULTIPLE ERRORS" explanation for the
1561 /// [OptimizeToursValidationError][google.cloud.optimization.v1.OptimizeToursValidationError]
1562 /// message.
1563 ///
1564 /// [google.cloud.optimization.v1.OptimizeToursValidationError]: crate::model::OptimizeToursValidationError
1565 pub validation_errors: std::vec::Vec<crate::model::OptimizeToursValidationError>,
1566
1567 /// Duration, distance and usage metrics for this solution.
1568 pub metrics: std::option::Option<crate::model::optimize_tours_response::Metrics>,
1569
1570 /// Deprecated: Use
1571 /// [Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
1572 /// instead. Total cost of the solution. This takes into account all costs:
1573 /// costs per per hour and travel hour, fixed vehicle costs, unperformed
1574 /// shipment penalty costs, global duration cost, etc.
1575 ///
1576 /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
1577 #[deprecated]
1578 pub total_cost: f64,
1579
1580 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1581}
1582
1583impl OptimizeToursResponse {
1584 /// Creates a new default instance.
1585 pub fn new() -> Self {
1586 std::default::Default::default()
1587 }
1588
1589 /// Sets the value of [routes][crate::model::OptimizeToursResponse::routes].
1590 ///
1591 /// # Example
1592 /// ```ignore,no_run
1593 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1594 /// use google_cloud_optimization_v1::model::ShipmentRoute;
1595 /// let x = OptimizeToursResponse::new()
1596 /// .set_routes([
1597 /// ShipmentRoute::default()/* use setters */,
1598 /// ShipmentRoute::default()/* use (different) setters */,
1599 /// ]);
1600 /// ```
1601 pub fn set_routes<T, V>(mut self, v: T) -> Self
1602 where
1603 T: std::iter::IntoIterator<Item = V>,
1604 V: std::convert::Into<crate::model::ShipmentRoute>,
1605 {
1606 use std::iter::Iterator;
1607 self.routes = v.into_iter().map(|i| i.into()).collect();
1608 self
1609 }
1610
1611 /// Sets the value of [request_label][crate::model::OptimizeToursResponse::request_label].
1612 ///
1613 /// # Example
1614 /// ```ignore,no_run
1615 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1616 /// let x = OptimizeToursResponse::new().set_request_label("example");
1617 /// ```
1618 pub fn set_request_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1619 self.request_label = v.into();
1620 self
1621 }
1622
1623 /// Sets the value of [skipped_shipments][crate::model::OptimizeToursResponse::skipped_shipments].
1624 ///
1625 /// # Example
1626 /// ```ignore,no_run
1627 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1628 /// use google_cloud_optimization_v1::model::SkippedShipment;
1629 /// let x = OptimizeToursResponse::new()
1630 /// .set_skipped_shipments([
1631 /// SkippedShipment::default()/* use setters */,
1632 /// SkippedShipment::default()/* use (different) setters */,
1633 /// ]);
1634 /// ```
1635 pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
1636 where
1637 T: std::iter::IntoIterator<Item = V>,
1638 V: std::convert::Into<crate::model::SkippedShipment>,
1639 {
1640 use std::iter::Iterator;
1641 self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
1642 self
1643 }
1644
1645 /// Sets the value of [validation_errors][crate::model::OptimizeToursResponse::validation_errors].
1646 ///
1647 /// # Example
1648 /// ```ignore,no_run
1649 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1650 /// use google_cloud_optimization_v1::model::OptimizeToursValidationError;
1651 /// let x = OptimizeToursResponse::new()
1652 /// .set_validation_errors([
1653 /// OptimizeToursValidationError::default()/* use setters */,
1654 /// OptimizeToursValidationError::default()/* use (different) setters */,
1655 /// ]);
1656 /// ```
1657 pub fn set_validation_errors<T, V>(mut self, v: T) -> Self
1658 where
1659 T: std::iter::IntoIterator<Item = V>,
1660 V: std::convert::Into<crate::model::OptimizeToursValidationError>,
1661 {
1662 use std::iter::Iterator;
1663 self.validation_errors = v.into_iter().map(|i| i.into()).collect();
1664 self
1665 }
1666
1667 /// Sets the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1668 ///
1669 /// # Example
1670 /// ```ignore,no_run
1671 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1672 /// use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1673 /// let x = OptimizeToursResponse::new().set_metrics(Metrics::default()/* use setters */);
1674 /// ```
1675 pub fn set_metrics<T>(mut self, v: T) -> Self
1676 where
1677 T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1678 {
1679 self.metrics = std::option::Option::Some(v.into());
1680 self
1681 }
1682
1683 /// Sets or clears the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1684 ///
1685 /// # Example
1686 /// ```ignore,no_run
1687 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1688 /// use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1689 /// let x = OptimizeToursResponse::new().set_or_clear_metrics(Some(Metrics::default()/* use setters */));
1690 /// let x = OptimizeToursResponse::new().set_or_clear_metrics(None::<Metrics>);
1691 /// ```
1692 pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1693 where
1694 T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1695 {
1696 self.metrics = v.map(|x| x.into());
1697 self
1698 }
1699
1700 /// Sets the value of [total_cost][crate::model::OptimizeToursResponse::total_cost].
1701 ///
1702 /// # Example
1703 /// ```ignore,no_run
1704 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1705 /// let x = OptimizeToursResponse::new().set_total_cost(42.0);
1706 /// ```
1707 #[deprecated]
1708 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1709 self.total_cost = v.into();
1710 self
1711 }
1712}
1713
1714impl wkt::message::Message for OptimizeToursResponse {
1715 fn typename() -> &'static str {
1716 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse"
1717 }
1718}
1719
1720/// Defines additional types related to [OptimizeToursResponse].
1721pub mod optimize_tours_response {
1722 #[allow(unused_imports)]
1723 use super::*;
1724
1725 /// Overall metrics, aggregated over all routes.
1726 #[derive(Clone, Default, PartialEq)]
1727 #[non_exhaustive]
1728 pub struct Metrics {
1729 /// Aggregated over the routes. Each metric is the sum (or max, for loads)
1730 /// over all
1731 /// [ShipmentRoute.metrics][google.cloud.optimization.v1.ShipmentRoute.metrics]
1732 /// fields of the same name.
1733 ///
1734 /// [google.cloud.optimization.v1.ShipmentRoute.metrics]: crate::model::ShipmentRoute::metrics
1735 pub aggregated_route_metrics: std::option::Option<crate::model::AggregatedMetrics>,
1736
1737 /// Number of mandatory shipments skipped.
1738 pub skipped_mandatory_shipment_count: i32,
1739
1740 /// Number of vehicles used. Note: if a vehicle route is empty and
1741 /// [Vehicle.used_if_route_is_empty][google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]
1742 /// is true, the vehicle is considered used.
1743 ///
1744 /// [google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]: crate::model::Vehicle::used_if_route_is_empty
1745 pub used_vehicle_count: i32,
1746
1747 /// The earliest start time for a used vehicle, computed as the minimum over
1748 /// all used vehicles of
1749 /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time].
1750 ///
1751 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
1752 pub earliest_vehicle_start_time: std::option::Option<wkt::Timestamp>,
1753
1754 /// The latest end time for a used vehicle, computed as the maximum over all
1755 /// used vehicles of
1756 /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time].
1757 ///
1758 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
1759 pub latest_vehicle_end_time: std::option::Option<wkt::Timestamp>,
1760
1761 /// Cost of the solution, broken down by cost-related request fields.
1762 /// The keys are proto paths, relative to the input OptimizeToursRequest,
1763 /// e.g. "model.shipments.pickups.cost", and the values are the total cost
1764 /// generated by the corresponding cost field, aggregated over the whole
1765 /// solution. In other words, costs["model.shipments.pickups.cost"] is the
1766 /// sum of all pickup costs over the solution. All costs defined in the model
1767 /// are reported in detail here with the exception of costs related to
1768 /// TransitionAttributes that are only reported in an aggregated way as of
1769 /// 2022/01.
1770 pub costs: std::collections::HashMap<std::string::String, f64>,
1771
1772 /// Total cost of the solution. The sum of all values in the costs map.
1773 pub total_cost: f64,
1774
1775 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1776 }
1777
1778 impl Metrics {
1779 /// Creates a new default instance.
1780 pub fn new() -> Self {
1781 std::default::Default::default()
1782 }
1783
1784 /// Sets the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1785 ///
1786 /// # Example
1787 /// ```ignore,no_run
1788 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1789 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
1790 /// let x = Metrics::new().set_aggregated_route_metrics(AggregatedMetrics::default()/* use setters */);
1791 /// ```
1792 pub fn set_aggregated_route_metrics<T>(mut self, v: T) -> Self
1793 where
1794 T: std::convert::Into<crate::model::AggregatedMetrics>,
1795 {
1796 self.aggregated_route_metrics = std::option::Option::Some(v.into());
1797 self
1798 }
1799
1800 /// Sets or clears the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1801 ///
1802 /// # Example
1803 /// ```ignore,no_run
1804 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1805 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
1806 /// let x = Metrics::new().set_or_clear_aggregated_route_metrics(Some(AggregatedMetrics::default()/* use setters */));
1807 /// let x = Metrics::new().set_or_clear_aggregated_route_metrics(None::<AggregatedMetrics>);
1808 /// ```
1809 pub fn set_or_clear_aggregated_route_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1810 where
1811 T: std::convert::Into<crate::model::AggregatedMetrics>,
1812 {
1813 self.aggregated_route_metrics = v.map(|x| x.into());
1814 self
1815 }
1816
1817 /// Sets the value of [skipped_mandatory_shipment_count][crate::model::optimize_tours_response::Metrics::skipped_mandatory_shipment_count].
1818 ///
1819 /// # Example
1820 /// ```ignore,no_run
1821 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1822 /// let x = Metrics::new().set_skipped_mandatory_shipment_count(42);
1823 /// ```
1824 pub fn set_skipped_mandatory_shipment_count<T: std::convert::Into<i32>>(
1825 mut self,
1826 v: T,
1827 ) -> Self {
1828 self.skipped_mandatory_shipment_count = v.into();
1829 self
1830 }
1831
1832 /// Sets the value of [used_vehicle_count][crate::model::optimize_tours_response::Metrics::used_vehicle_count].
1833 ///
1834 /// # Example
1835 /// ```ignore,no_run
1836 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1837 /// let x = Metrics::new().set_used_vehicle_count(42);
1838 /// ```
1839 pub fn set_used_vehicle_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1840 self.used_vehicle_count = v.into();
1841 self
1842 }
1843
1844 /// Sets the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1845 ///
1846 /// # Example
1847 /// ```ignore,no_run
1848 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1849 /// use wkt::Timestamp;
1850 /// let x = Metrics::new().set_earliest_vehicle_start_time(Timestamp::default()/* use setters */);
1851 /// ```
1852 pub fn set_earliest_vehicle_start_time<T>(mut self, v: T) -> Self
1853 where
1854 T: std::convert::Into<wkt::Timestamp>,
1855 {
1856 self.earliest_vehicle_start_time = std::option::Option::Some(v.into());
1857 self
1858 }
1859
1860 /// Sets or clears the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1861 ///
1862 /// # Example
1863 /// ```ignore,no_run
1864 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1865 /// use wkt::Timestamp;
1866 /// let x = Metrics::new().set_or_clear_earliest_vehicle_start_time(Some(Timestamp::default()/* use setters */));
1867 /// let x = Metrics::new().set_or_clear_earliest_vehicle_start_time(None::<Timestamp>);
1868 /// ```
1869 pub fn set_or_clear_earliest_vehicle_start_time<T>(
1870 mut self,
1871 v: std::option::Option<T>,
1872 ) -> Self
1873 where
1874 T: std::convert::Into<wkt::Timestamp>,
1875 {
1876 self.earliest_vehicle_start_time = v.map(|x| x.into());
1877 self
1878 }
1879
1880 /// Sets the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1881 ///
1882 /// # Example
1883 /// ```ignore,no_run
1884 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1885 /// use wkt::Timestamp;
1886 /// let x = Metrics::new().set_latest_vehicle_end_time(Timestamp::default()/* use setters */);
1887 /// ```
1888 pub fn set_latest_vehicle_end_time<T>(mut self, v: T) -> Self
1889 where
1890 T: std::convert::Into<wkt::Timestamp>,
1891 {
1892 self.latest_vehicle_end_time = std::option::Option::Some(v.into());
1893 self
1894 }
1895
1896 /// Sets or clears the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1897 ///
1898 /// # Example
1899 /// ```ignore,no_run
1900 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1901 /// use wkt::Timestamp;
1902 /// let x = Metrics::new().set_or_clear_latest_vehicle_end_time(Some(Timestamp::default()/* use setters */));
1903 /// let x = Metrics::new().set_or_clear_latest_vehicle_end_time(None::<Timestamp>);
1904 /// ```
1905 pub fn set_or_clear_latest_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
1906 where
1907 T: std::convert::Into<wkt::Timestamp>,
1908 {
1909 self.latest_vehicle_end_time = v.map(|x| x.into());
1910 self
1911 }
1912
1913 /// Sets the value of [costs][crate::model::optimize_tours_response::Metrics::costs].
1914 ///
1915 /// # Example
1916 /// ```ignore,no_run
1917 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1918 /// let x = Metrics::new().set_costs([
1919 /// ("key0", 123.5),
1920 /// ("key1", 456.5),
1921 /// ]);
1922 /// ```
1923 pub fn set_costs<T, K, V>(mut self, v: T) -> Self
1924 where
1925 T: std::iter::IntoIterator<Item = (K, V)>,
1926 K: std::convert::Into<std::string::String>,
1927 V: std::convert::Into<f64>,
1928 {
1929 use std::iter::Iterator;
1930 self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1931 self
1932 }
1933
1934 /// Sets the value of [total_cost][crate::model::optimize_tours_response::Metrics::total_cost].
1935 ///
1936 /// # Example
1937 /// ```ignore,no_run
1938 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1939 /// let x = Metrics::new().set_total_cost(42.0);
1940 /// ```
1941 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1942 self.total_cost = v.into();
1943 self
1944 }
1945 }
1946
1947 impl wkt::message::Message for Metrics {
1948 fn typename() -> &'static str {
1949 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse.Metrics"
1950 }
1951 }
1952}
1953
1954/// Request to batch optimize tours as an asynchronous operation.
1955/// Each input file should contain one `OptimizeToursRequest`, and each output
1956/// file will contain one `OptimizeToursResponse`. The request contains
1957/// information to read/write and parse the files. All the input and output files
1958/// should be under the same project.
1959#[derive(Clone, Default, PartialEq)]
1960#[non_exhaustive]
1961pub struct BatchOptimizeToursRequest {
1962 /// Required. Target project and location to make a call.
1963 ///
1964 /// Format: `projects/{project-id}/locations/{location-id}`.
1965 ///
1966 /// If no location is specified, a region will be chosen automatically.
1967 pub parent: std::string::String,
1968
1969 /// Required. Input/Output information each purchase model, such as file paths
1970 /// and data formats.
1971 pub model_configs: std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
1972
1973 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1974}
1975
1976impl BatchOptimizeToursRequest {
1977 /// Creates a new default instance.
1978 pub fn new() -> Self {
1979 std::default::Default::default()
1980 }
1981
1982 /// Sets the value of [parent][crate::model::BatchOptimizeToursRequest::parent].
1983 ///
1984 /// # Example
1985 /// ```ignore,no_run
1986 /// # use google_cloud_optimization_v1::model::BatchOptimizeToursRequest;
1987 /// let x = BatchOptimizeToursRequest::new().set_parent("example");
1988 /// ```
1989 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1990 self.parent = v.into();
1991 self
1992 }
1993
1994 /// Sets the value of [model_configs][crate::model::BatchOptimizeToursRequest::model_configs].
1995 ///
1996 /// # Example
1997 /// ```ignore,no_run
1998 /// # use google_cloud_optimization_v1::model::BatchOptimizeToursRequest;
1999 /// use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2000 /// let x = BatchOptimizeToursRequest::new()
2001 /// .set_model_configs([
2002 /// AsyncModelConfig::default()/* use setters */,
2003 /// AsyncModelConfig::default()/* use (different) setters */,
2004 /// ]);
2005 /// ```
2006 pub fn set_model_configs<T, V>(mut self, v: T) -> Self
2007 where
2008 T: std::iter::IntoIterator<Item = V>,
2009 V: std::convert::Into<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
2010 {
2011 use std::iter::Iterator;
2012 self.model_configs = v.into_iter().map(|i| i.into()).collect();
2013 self
2014 }
2015}
2016
2017impl wkt::message::Message for BatchOptimizeToursRequest {
2018 fn typename() -> &'static str {
2019 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest"
2020 }
2021}
2022
2023/// Defines additional types related to [BatchOptimizeToursRequest].
2024pub mod batch_optimize_tours_request {
2025 #[allow(unused_imports)]
2026 use super::*;
2027
2028 /// Information for solving one optimization model asynchronously.
2029 #[derive(Clone, Default, PartialEq)]
2030 #[non_exhaustive]
2031 pub struct AsyncModelConfig {
2032 /// User defined model name, can be used as alias by users to keep track of
2033 /// models.
2034 pub display_name: std::string::String,
2035
2036 /// Required. Information about the input model.
2037 pub input_config: std::option::Option<crate::model::InputConfig>,
2038
2039 /// Required. The desired output location information.
2040 pub output_config: std::option::Option<crate::model::OutputConfig>,
2041
2042 /// If this is set, the model will be solved in the checkpoint mode. In this
2043 /// mode, the input model can have a deadline longer than 30 mins without the
2044 /// risk of interruption. The model will be solved in multiple short-running
2045 /// stages. Each stage generates an intermediate checkpoint
2046 /// and stores it in the user's Cloud Storage buckets. The checkpoint
2047 /// mode should be preferred over
2048 /// allow_large_deadline_despite_interruption_risk since it prevents the risk
2049 /// of interruption.
2050 pub enable_checkpoints: bool,
2051
2052 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2053 }
2054
2055 impl AsyncModelConfig {
2056 /// Creates a new default instance.
2057 pub fn new() -> Self {
2058 std::default::Default::default()
2059 }
2060
2061 /// Sets the value of [display_name][crate::model::batch_optimize_tours_request::AsyncModelConfig::display_name].
2062 ///
2063 /// # Example
2064 /// ```ignore,no_run
2065 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2066 /// let x = AsyncModelConfig::new().set_display_name("example");
2067 /// ```
2068 pub fn set_display_name<T: std::convert::Into<std::string::String>>(
2069 mut self,
2070 v: T,
2071 ) -> Self {
2072 self.display_name = v.into();
2073 self
2074 }
2075
2076 /// Sets the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
2077 ///
2078 /// # Example
2079 /// ```ignore,no_run
2080 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2081 /// use google_cloud_optimization_v1::model::InputConfig;
2082 /// let x = AsyncModelConfig::new().set_input_config(InputConfig::default()/* use setters */);
2083 /// ```
2084 pub fn set_input_config<T>(mut self, v: T) -> Self
2085 where
2086 T: std::convert::Into<crate::model::InputConfig>,
2087 {
2088 self.input_config = std::option::Option::Some(v.into());
2089 self
2090 }
2091
2092 /// Sets or clears the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
2093 ///
2094 /// # Example
2095 /// ```ignore,no_run
2096 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2097 /// use google_cloud_optimization_v1::model::InputConfig;
2098 /// let x = AsyncModelConfig::new().set_or_clear_input_config(Some(InputConfig::default()/* use setters */));
2099 /// let x = AsyncModelConfig::new().set_or_clear_input_config(None::<InputConfig>);
2100 /// ```
2101 pub fn set_or_clear_input_config<T>(mut self, v: std::option::Option<T>) -> Self
2102 where
2103 T: std::convert::Into<crate::model::InputConfig>,
2104 {
2105 self.input_config = v.map(|x| x.into());
2106 self
2107 }
2108
2109 /// Sets the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
2110 ///
2111 /// # Example
2112 /// ```ignore,no_run
2113 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2114 /// use google_cloud_optimization_v1::model::OutputConfig;
2115 /// let x = AsyncModelConfig::new().set_output_config(OutputConfig::default()/* use setters */);
2116 /// ```
2117 pub fn set_output_config<T>(mut self, v: T) -> Self
2118 where
2119 T: std::convert::Into<crate::model::OutputConfig>,
2120 {
2121 self.output_config = std::option::Option::Some(v.into());
2122 self
2123 }
2124
2125 /// Sets or clears the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
2126 ///
2127 /// # Example
2128 /// ```ignore,no_run
2129 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2130 /// use google_cloud_optimization_v1::model::OutputConfig;
2131 /// let x = AsyncModelConfig::new().set_or_clear_output_config(Some(OutputConfig::default()/* use setters */));
2132 /// let x = AsyncModelConfig::new().set_or_clear_output_config(None::<OutputConfig>);
2133 /// ```
2134 pub fn set_or_clear_output_config<T>(mut self, v: std::option::Option<T>) -> Self
2135 where
2136 T: std::convert::Into<crate::model::OutputConfig>,
2137 {
2138 self.output_config = v.map(|x| x.into());
2139 self
2140 }
2141
2142 /// Sets the value of [enable_checkpoints][crate::model::batch_optimize_tours_request::AsyncModelConfig::enable_checkpoints].
2143 ///
2144 /// # Example
2145 /// ```ignore,no_run
2146 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2147 /// let x = AsyncModelConfig::new().set_enable_checkpoints(true);
2148 /// ```
2149 pub fn set_enable_checkpoints<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2150 self.enable_checkpoints = v.into();
2151 self
2152 }
2153 }
2154
2155 impl wkt::message::Message for AsyncModelConfig {
2156 fn typename() -> &'static str {
2157 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest.AsyncModelConfig"
2158 }
2159 }
2160}
2161
2162/// Response to a `BatchOptimizeToursRequest`. This is returned in
2163/// the LRO Operation after the operation is complete.
2164#[derive(Clone, Default, PartialEq)]
2165#[non_exhaustive]
2166pub struct BatchOptimizeToursResponse {
2167 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2168}
2169
2170impl BatchOptimizeToursResponse {
2171 /// Creates a new default instance.
2172 pub fn new() -> Self {
2173 std::default::Default::default()
2174 }
2175}
2176
2177impl wkt::message::Message for BatchOptimizeToursResponse {
2178 fn typename() -> &'static str {
2179 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursResponse"
2180 }
2181}
2182
2183/// A shipment model contains a set of shipments which must be performed by a
2184/// set of vehicles, while minimizing the overall cost, which is the sum of:
2185///
2186/// * the cost of routing the vehicles (sum of cost per total time, cost per
2187/// travel time, and fixed cost over all vehicles).
2188/// * the unperformed shipment penalties.
2189/// * the cost of the global duration of the shipments
2190#[derive(Clone, Default, PartialEq)]
2191#[non_exhaustive]
2192pub struct ShipmentModel {
2193 /// Set of shipments which must be performed in the model.
2194 pub shipments: std::vec::Vec<crate::model::Shipment>,
2195
2196 /// Set of vehicles which can be used to perform visits.
2197 pub vehicles: std::vec::Vec<crate::model::Vehicle>,
2198
2199 /// Constrains the maximum number of active vehicles. A vehicle is active if
2200 /// its route performs at least one shipment. This can be used to limit the
2201 /// number of routes in the case where there are fewer drivers than
2202 /// vehicles and that the fleet of vehicles is heterogeneous. The optimization
2203 /// will then select the best subset of vehicles to use.
2204 /// Must be strictly positive.
2205 pub max_active_vehicles: std::option::Option<i32>,
2206
2207 /// Global start and end time of the model: no times outside of this range
2208 /// can be considered valid.
2209 ///
2210 /// The model's time span must be less than a year, i.e. the `global_end_time`
2211 /// and the `global_start_time` must be within 31536000 seconds of each other.
2212 ///
2213 /// When using `cost_per_*hour` fields, you might want to set this window to a
2214 /// smaller interval to increase performance (eg. if you model a single day,
2215 /// you should set the global time limits to that day).
2216 /// If unset, 00:00:00 UTC, January 1, 1970 (i.e. seconds: 0, nanos: 0) is used
2217 /// as default.
2218 pub global_start_time: std::option::Option<wkt::Timestamp>,
2219
2220 /// If unset, 00:00:00 UTC, January 1, 1971 (i.e. seconds: 31536000, nanos: 0)
2221 /// is used as default.
2222 pub global_end_time: std::option::Option<wkt::Timestamp>,
2223
2224 /// The "global duration" of the overall plan is the difference between the
2225 /// earliest effective start time and the latest effective end time of
2226 /// all vehicles. Users can assign a cost per hour to that quantity to try
2227 /// and optimize for earliest job completion, for example. This cost must be in
2228 /// the same unit as
2229 /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
2230 ///
2231 /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
2232 pub global_duration_cost_per_hour: f64,
2233
2234 /// Specifies duration and distance matrices used in the model. If this field
2235 /// is empty, Google Maps or geodesic distances will be used instead, depending
2236 /// on the value of the `use_geodesic_distances` field. If it is not empty,
2237 /// `use_geodesic_distances` cannot be true and neither
2238 /// `duration_distance_matrix_src_tags` nor `duration_distance_matrix_dst_tags`
2239 /// can be empty.
2240 ///
2241 /// Usage examples:
2242 ///
2243 /// * There are two locations: locA and locB.
2244 /// * 1 vehicle starting its route at locA and ending it at locA.
2245 /// * 1 pickup visit request at locB.
2246 ///
2247 /// ```norust
2248 /// model {
2249 /// vehicles { start_tags: "locA" end_tags: "locA" }
2250 /// shipments { pickups { tags: "locB" } }
2251 /// duration_distance_matrix_src_tags: "locA"
2252 /// duration_distance_matrix_src_tags: "locB"
2253 /// duration_distance_matrix_dst_tags: "locA"
2254 /// duration_distance_matrix_dst_tags: "locB"
2255 /// duration_distance_matrices {
2256 /// rows { # from: locA
2257 /// durations { seconds: 0 } meters: 0 # to: locA
2258 /// durations { seconds: 100 } meters: 1000 # to: locB
2259 /// }
2260 /// rows { # from: locB
2261 /// durations { seconds: 102 } meters: 990 # to: locA
2262 /// durations { seconds: 0 } meters: 0 # to: locB
2263 /// }
2264 /// }
2265 /// }
2266 /// ```
2267 ///
2268 /// * There are three locations: locA, locB and locC.
2269 /// * 1 vehicle starting its route at locA and ending it at locB, using
2270 /// matrix "fast".
2271 /// * 1 vehicle starting its route at locB and ending it at locB, using
2272 /// matrix "slow".
2273 /// * 1 vehicle starting its route at locB and ending it at locB, using
2274 /// matrix "fast".
2275 /// * 1 pickup visit request at locC.
2276 ///
2277 /// ```norust
2278 /// model {
2279 /// vehicles { start_tags: "locA" end_tags: "locB" start_tags: "fast" }
2280 /// vehicles { start_tags: "locB" end_tags: "locB" start_tags: "slow" }
2281 /// vehicles { start_tags: "locB" end_tags: "locB" start_tags: "fast" }
2282 /// shipments { pickups { tags: "locC" } }
2283 /// duration_distance_matrix_src_tags: "locA"
2284 /// duration_distance_matrix_src_tags: "locB"
2285 /// duration_distance_matrix_src_tags: "locC"
2286 /// duration_distance_matrix_dst_tags: "locB"
2287 /// duration_distance_matrix_dst_tags: "locC"
2288 /// duration_distance_matrices {
2289 /// vehicle_start_tag: "fast"
2290 /// rows { # from: locA
2291 /// durations { seconds: 1000 } meters: 2000 # to: locB
2292 /// durations { seconds: 600 } meters: 1000 # to: locC
2293 /// }
2294 /// rows { # from: locB
2295 /// durations { seconds: 0 } meters: 0 # to: locB
2296 /// durations { seconds: 700 } meters: 1200 # to: locC
2297 /// }
2298 /// rows { # from: locC
2299 /// durations { seconds: 702 } meters: 1190 # to: locB
2300 /// durations { seconds: 0 } meters: 0 # to: locC
2301 /// }
2302 /// }
2303 /// duration_distance_matrices {
2304 /// vehicle_start_tag: "slow"
2305 /// rows { # from: locA
2306 /// durations { seconds: 1800 } meters: 2001 # to: locB
2307 /// durations { seconds: 900 } meters: 1002 # to: locC
2308 /// }
2309 /// rows { # from: locB
2310 /// durations { seconds: 0 } meters: 0 # to: locB
2311 /// durations { seconds: 1000 } meters: 1202 # to: locC
2312 /// }
2313 /// rows { # from: locC
2314 /// durations { seconds: 1001 } meters: 1195 # to: locB
2315 /// durations { seconds: 0 } meters: 0 # to: locC
2316 /// }
2317 /// }
2318 /// }
2319 /// ```
2320 pub duration_distance_matrices:
2321 std::vec::Vec<crate::model::shipment_model::DurationDistanceMatrix>,
2322
2323 /// Tags defining the sources of the duration and distance matrices;
2324 /// `duration_distance_matrices(i).rows(j)` defines durations and distances
2325 /// from visits with tag `duration_distance_matrix_src_tags(j)` to other visits
2326 /// in matrix i.
2327 ///
2328 /// Tags correspond to
2329 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
2330 /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
2331 /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
2332 /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
2333 /// the same; similarly a `VisitRequest`'s source and destination tags may be
2334 /// the same. All tags must be different and cannot be empty strings. If this
2335 /// field is not empty, then `duration_distance_matrices` must not be empty.
2336 ///
2337 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
2338 /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
2339 pub duration_distance_matrix_src_tags: std::vec::Vec<std::string::String>,
2340
2341 /// Tags defining the destinations of the duration and distance matrices;
2342 /// `duration_distance_matrices(i).rows(j).durations(k)` (resp.
2343 /// `duration_distance_matrices(i).rows(j).meters(k))` defines the duration
2344 /// (resp. the distance) of the travel from visits with tag
2345 /// `duration_distance_matrix_src_tags(j)` to visits with tag
2346 /// `duration_distance_matrix_dst_tags(k)` in matrix i.
2347 ///
2348 /// Tags correspond to
2349 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
2350 /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
2351 /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
2352 /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
2353 /// the same; similarly a `VisitRequest`'s source and destination tags may be
2354 /// the same. All tags must be different and cannot be empty strings. If this
2355 /// field is not empty, then `duration_distance_matrices` must not be empty.
2356 ///
2357 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
2358 /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
2359 pub duration_distance_matrix_dst_tags: std::vec::Vec<std::string::String>,
2360
2361 /// Transition attributes added to the model.
2362 pub transition_attributes: std::vec::Vec<crate::model::TransitionAttributes>,
2363
2364 /// Sets of incompatible shipment_types (see `ShipmentTypeIncompatibility`).
2365 pub shipment_type_incompatibilities: std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
2366
2367 /// Sets of `shipment_type` requirements (see `ShipmentTypeRequirement`).
2368 pub shipment_type_requirements: std::vec::Vec<crate::model::ShipmentTypeRequirement>,
2369
2370 /// Set of precedence rules which must be enforced in the model.
2371 pub precedence_rules: std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
2372
2373 /// Deprecated: No longer used.
2374 /// Set of break rules used in the model.
2375 /// Each vehicle specifies the `BreakRule` that applies to it via the
2376 /// [Vehicle.break_rule_indices][google.cloud.optimization.v1.Vehicle.break_rule_indices]
2377 /// field (which must be a singleton).
2378 ///
2379 /// [google.cloud.optimization.v1.Vehicle.break_rule_indices]: crate::model::Vehicle::break_rule_indices
2380 #[deprecated]
2381 pub break_rules: std::vec::Vec<crate::model::shipment_model::BreakRule>,
2382
2383 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2384}
2385
2386impl ShipmentModel {
2387 /// Creates a new default instance.
2388 pub fn new() -> Self {
2389 std::default::Default::default()
2390 }
2391
2392 /// Sets the value of [shipments][crate::model::ShipmentModel::shipments].
2393 ///
2394 /// # Example
2395 /// ```ignore,no_run
2396 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2397 /// use google_cloud_optimization_v1::model::Shipment;
2398 /// let x = ShipmentModel::new()
2399 /// .set_shipments([
2400 /// Shipment::default()/* use setters */,
2401 /// Shipment::default()/* use (different) setters */,
2402 /// ]);
2403 /// ```
2404 pub fn set_shipments<T, V>(mut self, v: T) -> Self
2405 where
2406 T: std::iter::IntoIterator<Item = V>,
2407 V: std::convert::Into<crate::model::Shipment>,
2408 {
2409 use std::iter::Iterator;
2410 self.shipments = v.into_iter().map(|i| i.into()).collect();
2411 self
2412 }
2413
2414 /// Sets the value of [vehicles][crate::model::ShipmentModel::vehicles].
2415 ///
2416 /// # Example
2417 /// ```ignore,no_run
2418 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2419 /// use google_cloud_optimization_v1::model::Vehicle;
2420 /// let x = ShipmentModel::new()
2421 /// .set_vehicles([
2422 /// Vehicle::default()/* use setters */,
2423 /// Vehicle::default()/* use (different) setters */,
2424 /// ]);
2425 /// ```
2426 pub fn set_vehicles<T, V>(mut self, v: T) -> Self
2427 where
2428 T: std::iter::IntoIterator<Item = V>,
2429 V: std::convert::Into<crate::model::Vehicle>,
2430 {
2431 use std::iter::Iterator;
2432 self.vehicles = v.into_iter().map(|i| i.into()).collect();
2433 self
2434 }
2435
2436 /// Sets the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
2437 ///
2438 /// # Example
2439 /// ```ignore,no_run
2440 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2441 /// let x = ShipmentModel::new().set_max_active_vehicles(42);
2442 /// ```
2443 pub fn set_max_active_vehicles<T>(mut self, v: T) -> Self
2444 where
2445 T: std::convert::Into<i32>,
2446 {
2447 self.max_active_vehicles = std::option::Option::Some(v.into());
2448 self
2449 }
2450
2451 /// Sets or clears the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
2452 ///
2453 /// # Example
2454 /// ```ignore,no_run
2455 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2456 /// let x = ShipmentModel::new().set_or_clear_max_active_vehicles(Some(42));
2457 /// let x = ShipmentModel::new().set_or_clear_max_active_vehicles(None::<i32>);
2458 /// ```
2459 pub fn set_or_clear_max_active_vehicles<T>(mut self, v: std::option::Option<T>) -> Self
2460 where
2461 T: std::convert::Into<i32>,
2462 {
2463 self.max_active_vehicles = v.map(|x| x.into());
2464 self
2465 }
2466
2467 /// Sets the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
2468 ///
2469 /// # Example
2470 /// ```ignore,no_run
2471 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2472 /// use wkt::Timestamp;
2473 /// let x = ShipmentModel::new().set_global_start_time(Timestamp::default()/* use setters */);
2474 /// ```
2475 pub fn set_global_start_time<T>(mut self, v: T) -> Self
2476 where
2477 T: std::convert::Into<wkt::Timestamp>,
2478 {
2479 self.global_start_time = std::option::Option::Some(v.into());
2480 self
2481 }
2482
2483 /// Sets or clears the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
2484 ///
2485 /// # Example
2486 /// ```ignore,no_run
2487 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2488 /// use wkt::Timestamp;
2489 /// let x = ShipmentModel::new().set_or_clear_global_start_time(Some(Timestamp::default()/* use setters */));
2490 /// let x = ShipmentModel::new().set_or_clear_global_start_time(None::<Timestamp>);
2491 /// ```
2492 pub fn set_or_clear_global_start_time<T>(mut self, v: std::option::Option<T>) -> Self
2493 where
2494 T: std::convert::Into<wkt::Timestamp>,
2495 {
2496 self.global_start_time = v.map(|x| x.into());
2497 self
2498 }
2499
2500 /// Sets the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
2501 ///
2502 /// # Example
2503 /// ```ignore,no_run
2504 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2505 /// use wkt::Timestamp;
2506 /// let x = ShipmentModel::new().set_global_end_time(Timestamp::default()/* use setters */);
2507 /// ```
2508 pub fn set_global_end_time<T>(mut self, v: T) -> Self
2509 where
2510 T: std::convert::Into<wkt::Timestamp>,
2511 {
2512 self.global_end_time = std::option::Option::Some(v.into());
2513 self
2514 }
2515
2516 /// Sets or clears the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
2517 ///
2518 /// # Example
2519 /// ```ignore,no_run
2520 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2521 /// use wkt::Timestamp;
2522 /// let x = ShipmentModel::new().set_or_clear_global_end_time(Some(Timestamp::default()/* use setters */));
2523 /// let x = ShipmentModel::new().set_or_clear_global_end_time(None::<Timestamp>);
2524 /// ```
2525 pub fn set_or_clear_global_end_time<T>(mut self, v: std::option::Option<T>) -> Self
2526 where
2527 T: std::convert::Into<wkt::Timestamp>,
2528 {
2529 self.global_end_time = v.map(|x| x.into());
2530 self
2531 }
2532
2533 /// Sets the value of [global_duration_cost_per_hour][crate::model::ShipmentModel::global_duration_cost_per_hour].
2534 ///
2535 /// # Example
2536 /// ```ignore,no_run
2537 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2538 /// let x = ShipmentModel::new().set_global_duration_cost_per_hour(42.0);
2539 /// ```
2540 pub fn set_global_duration_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2541 self.global_duration_cost_per_hour = v.into();
2542 self
2543 }
2544
2545 /// Sets the value of [duration_distance_matrices][crate::model::ShipmentModel::duration_distance_matrices].
2546 ///
2547 /// # Example
2548 /// ```ignore,no_run
2549 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2550 /// use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2551 /// let x = ShipmentModel::new()
2552 /// .set_duration_distance_matrices([
2553 /// DurationDistanceMatrix::default()/* use setters */,
2554 /// DurationDistanceMatrix::default()/* use (different) setters */,
2555 /// ]);
2556 /// ```
2557 pub fn set_duration_distance_matrices<T, V>(mut self, v: T) -> Self
2558 where
2559 T: std::iter::IntoIterator<Item = V>,
2560 V: std::convert::Into<crate::model::shipment_model::DurationDistanceMatrix>,
2561 {
2562 use std::iter::Iterator;
2563 self.duration_distance_matrices = v.into_iter().map(|i| i.into()).collect();
2564 self
2565 }
2566
2567 /// Sets the value of [duration_distance_matrix_src_tags][crate::model::ShipmentModel::duration_distance_matrix_src_tags].
2568 ///
2569 /// # Example
2570 /// ```ignore,no_run
2571 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2572 /// let x = ShipmentModel::new().set_duration_distance_matrix_src_tags(["a", "b", "c"]);
2573 /// ```
2574 pub fn set_duration_distance_matrix_src_tags<T, V>(mut self, v: T) -> Self
2575 where
2576 T: std::iter::IntoIterator<Item = V>,
2577 V: std::convert::Into<std::string::String>,
2578 {
2579 use std::iter::Iterator;
2580 self.duration_distance_matrix_src_tags = v.into_iter().map(|i| i.into()).collect();
2581 self
2582 }
2583
2584 /// Sets the value of [duration_distance_matrix_dst_tags][crate::model::ShipmentModel::duration_distance_matrix_dst_tags].
2585 ///
2586 /// # Example
2587 /// ```ignore,no_run
2588 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2589 /// let x = ShipmentModel::new().set_duration_distance_matrix_dst_tags(["a", "b", "c"]);
2590 /// ```
2591 pub fn set_duration_distance_matrix_dst_tags<T, V>(mut self, v: T) -> Self
2592 where
2593 T: std::iter::IntoIterator<Item = V>,
2594 V: std::convert::Into<std::string::String>,
2595 {
2596 use std::iter::Iterator;
2597 self.duration_distance_matrix_dst_tags = v.into_iter().map(|i| i.into()).collect();
2598 self
2599 }
2600
2601 /// Sets the value of [transition_attributes][crate::model::ShipmentModel::transition_attributes].
2602 ///
2603 /// # Example
2604 /// ```ignore,no_run
2605 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2606 /// use google_cloud_optimization_v1::model::TransitionAttributes;
2607 /// let x = ShipmentModel::new()
2608 /// .set_transition_attributes([
2609 /// TransitionAttributes::default()/* use setters */,
2610 /// TransitionAttributes::default()/* use (different) setters */,
2611 /// ]);
2612 /// ```
2613 pub fn set_transition_attributes<T, V>(mut self, v: T) -> Self
2614 where
2615 T: std::iter::IntoIterator<Item = V>,
2616 V: std::convert::Into<crate::model::TransitionAttributes>,
2617 {
2618 use std::iter::Iterator;
2619 self.transition_attributes = v.into_iter().map(|i| i.into()).collect();
2620 self
2621 }
2622
2623 /// Sets the value of [shipment_type_incompatibilities][crate::model::ShipmentModel::shipment_type_incompatibilities].
2624 ///
2625 /// # Example
2626 /// ```ignore,no_run
2627 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2628 /// use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
2629 /// let x = ShipmentModel::new()
2630 /// .set_shipment_type_incompatibilities([
2631 /// ShipmentTypeIncompatibility::default()/* use setters */,
2632 /// ShipmentTypeIncompatibility::default()/* use (different) setters */,
2633 /// ]);
2634 /// ```
2635 pub fn set_shipment_type_incompatibilities<T, V>(mut self, v: T) -> Self
2636 where
2637 T: std::iter::IntoIterator<Item = V>,
2638 V: std::convert::Into<crate::model::ShipmentTypeIncompatibility>,
2639 {
2640 use std::iter::Iterator;
2641 self.shipment_type_incompatibilities = v.into_iter().map(|i| i.into()).collect();
2642 self
2643 }
2644
2645 /// Sets the value of [shipment_type_requirements][crate::model::ShipmentModel::shipment_type_requirements].
2646 ///
2647 /// # Example
2648 /// ```ignore,no_run
2649 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2650 /// use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
2651 /// let x = ShipmentModel::new()
2652 /// .set_shipment_type_requirements([
2653 /// ShipmentTypeRequirement::default()/* use setters */,
2654 /// ShipmentTypeRequirement::default()/* use (different) setters */,
2655 /// ]);
2656 /// ```
2657 pub fn set_shipment_type_requirements<T, V>(mut self, v: T) -> Self
2658 where
2659 T: std::iter::IntoIterator<Item = V>,
2660 V: std::convert::Into<crate::model::ShipmentTypeRequirement>,
2661 {
2662 use std::iter::Iterator;
2663 self.shipment_type_requirements = v.into_iter().map(|i| i.into()).collect();
2664 self
2665 }
2666
2667 /// Sets the value of [precedence_rules][crate::model::ShipmentModel::precedence_rules].
2668 ///
2669 /// # Example
2670 /// ```ignore,no_run
2671 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2672 /// use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2673 /// let x = ShipmentModel::new()
2674 /// .set_precedence_rules([
2675 /// PrecedenceRule::default()/* use setters */,
2676 /// PrecedenceRule::default()/* use (different) setters */,
2677 /// ]);
2678 /// ```
2679 pub fn set_precedence_rules<T, V>(mut self, v: T) -> Self
2680 where
2681 T: std::iter::IntoIterator<Item = V>,
2682 V: std::convert::Into<crate::model::shipment_model::PrecedenceRule>,
2683 {
2684 use std::iter::Iterator;
2685 self.precedence_rules = v.into_iter().map(|i| i.into()).collect();
2686 self
2687 }
2688
2689 /// Sets the value of [break_rules][crate::model::ShipmentModel::break_rules].
2690 ///
2691 /// # Example
2692 /// ```ignore,no_run
2693 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2694 /// use google_cloud_optimization_v1::model::shipment_model::BreakRule;
2695 /// let x = ShipmentModel::new()
2696 /// .set_break_rules([
2697 /// BreakRule::default()/* use setters */,
2698 /// BreakRule::default()/* use (different) setters */,
2699 /// ]);
2700 /// ```
2701 #[deprecated]
2702 pub fn set_break_rules<T, V>(mut self, v: T) -> Self
2703 where
2704 T: std::iter::IntoIterator<Item = V>,
2705 V: std::convert::Into<crate::model::shipment_model::BreakRule>,
2706 {
2707 use std::iter::Iterator;
2708 self.break_rules = v.into_iter().map(|i| i.into()).collect();
2709 self
2710 }
2711}
2712
2713impl wkt::message::Message for ShipmentModel {
2714 fn typename() -> &'static str {
2715 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel"
2716 }
2717}
2718
2719/// Defines additional types related to [ShipmentModel].
2720pub mod shipment_model {
2721 #[allow(unused_imports)]
2722 use super::*;
2723
2724 /// Specifies a duration and distance matrix from visit and vehicle start
2725 /// locations to visit and vehicle end locations.
2726 #[derive(Clone, Default, PartialEq)]
2727 #[non_exhaustive]
2728 pub struct DurationDistanceMatrix {
2729 /// Specifies the rows of the duration and distance matrix. It must have as
2730 /// many elements as
2731 /// [ShipmentModel.duration_distance_matrix_src_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags].
2732 ///
2733 /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags]: crate::model::ShipmentModel::duration_distance_matrix_src_tags
2734 pub rows: std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>,
2735
2736 /// Tag defining to which vehicles this duration and distance matrix applies.
2737 /// If empty, this applies to all vehicles, and there can only be a single
2738 /// matrix.
2739 ///
2740 /// Each vehicle start must match exactly one matrix, i.e. exactly one of
2741 /// their `start_tags` field must match the `vehicle_start_tag` of a matrix
2742 /// (and of that matrix only).
2743 ///
2744 /// All matrices must have a different `vehicle_start_tag`.
2745 pub vehicle_start_tag: std::string::String,
2746
2747 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2748 }
2749
2750 impl DurationDistanceMatrix {
2751 /// Creates a new default instance.
2752 pub fn new() -> Self {
2753 std::default::Default::default()
2754 }
2755
2756 /// Sets the value of [rows][crate::model::shipment_model::DurationDistanceMatrix::rows].
2757 ///
2758 /// # Example
2759 /// ```ignore,no_run
2760 /// # use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2761 /// use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2762 /// let x = DurationDistanceMatrix::new()
2763 /// .set_rows([
2764 /// Row::default()/* use setters */,
2765 /// Row::default()/* use (different) setters */,
2766 /// ]);
2767 /// ```
2768 pub fn set_rows<T, V>(mut self, v: T) -> Self
2769 where
2770 T: std::iter::IntoIterator<Item = V>,
2771 V: std::convert::Into<crate::model::shipment_model::duration_distance_matrix::Row>,
2772 {
2773 use std::iter::Iterator;
2774 self.rows = v.into_iter().map(|i| i.into()).collect();
2775 self
2776 }
2777
2778 /// Sets the value of [vehicle_start_tag][crate::model::shipment_model::DurationDistanceMatrix::vehicle_start_tag].
2779 ///
2780 /// # Example
2781 /// ```ignore,no_run
2782 /// # use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2783 /// let x = DurationDistanceMatrix::new().set_vehicle_start_tag("example");
2784 /// ```
2785 pub fn set_vehicle_start_tag<T: std::convert::Into<std::string::String>>(
2786 mut self,
2787 v: T,
2788 ) -> Self {
2789 self.vehicle_start_tag = v.into();
2790 self
2791 }
2792 }
2793
2794 impl wkt::message::Message for DurationDistanceMatrix {
2795 fn typename() -> &'static str {
2796 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix"
2797 }
2798 }
2799
2800 /// Defines additional types related to [DurationDistanceMatrix].
2801 pub mod duration_distance_matrix {
2802 #[allow(unused_imports)]
2803 use super::*;
2804
2805 /// Specifies a row of the duration and distance matrix.
2806 #[derive(Clone, Default, PartialEq)]
2807 #[non_exhaustive]
2808 pub struct Row {
2809 /// Duration values for a given row. It must have as many elements as
2810 /// [ShipmentModel.duration_distance_matrix_dst_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags].
2811 ///
2812 /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags]: crate::model::ShipmentModel::duration_distance_matrix_dst_tags
2813 pub durations: std::vec::Vec<wkt::Duration>,
2814
2815 /// Distance values for a given row. If no costs or constraints refer to
2816 /// distances in the model, this can be left empty; otherwise it must have
2817 /// as many elements as `durations`.
2818 pub meters: std::vec::Vec<f64>,
2819
2820 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2821 }
2822
2823 impl Row {
2824 /// Creates a new default instance.
2825 pub fn new() -> Self {
2826 std::default::Default::default()
2827 }
2828
2829 /// Sets the value of [durations][crate::model::shipment_model::duration_distance_matrix::Row::durations].
2830 ///
2831 /// # Example
2832 /// ```ignore,no_run
2833 /// # use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2834 /// use wkt::Duration;
2835 /// let x = Row::new()
2836 /// .set_durations([
2837 /// Duration::default()/* use setters */,
2838 /// Duration::default()/* use (different) setters */,
2839 /// ]);
2840 /// ```
2841 pub fn set_durations<T, V>(mut self, v: T) -> Self
2842 where
2843 T: std::iter::IntoIterator<Item = V>,
2844 V: std::convert::Into<wkt::Duration>,
2845 {
2846 use std::iter::Iterator;
2847 self.durations = v.into_iter().map(|i| i.into()).collect();
2848 self
2849 }
2850
2851 /// Sets the value of [meters][crate::model::shipment_model::duration_distance_matrix::Row::meters].
2852 ///
2853 /// # Example
2854 /// ```ignore,no_run
2855 /// # use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2856 /// let x = Row::new().set_meters([1.0, 2.0, 3.0]);
2857 /// ```
2858 pub fn set_meters<T, V>(mut self, v: T) -> Self
2859 where
2860 T: std::iter::IntoIterator<Item = V>,
2861 V: std::convert::Into<f64>,
2862 {
2863 use std::iter::Iterator;
2864 self.meters = v.into_iter().map(|i| i.into()).collect();
2865 self
2866 }
2867 }
2868
2869 impl wkt::message::Message for Row {
2870 fn typename() -> &'static str {
2871 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix.Row"
2872 }
2873 }
2874 }
2875
2876 /// A precedence rule between two events (each event is the pickup or the
2877 /// delivery of a shipment): the "second" event has to start at least
2878 /// `offset_duration` after "first" has started.
2879 ///
2880 /// Several precedences can refer to the same (or related) events, e.g.,
2881 /// "pickup of B happens after delivery of A" and "pickup of C happens after
2882 /// pickup of B".
2883 ///
2884 /// Furthermore, precedences only apply when both shipments are performed and
2885 /// are otherwise ignored.
2886 #[derive(Clone, Default, PartialEq)]
2887 #[non_exhaustive]
2888 pub struct PrecedenceRule {
2889 /// Shipment index of the "first" event. This field must be specified.
2890 pub first_index: std::option::Option<i32>,
2891
2892 /// Indicates if the "first" event is a delivery.
2893 pub first_is_delivery: bool,
2894
2895 /// Shipment index of the "second" event. This field must be specified.
2896 pub second_index: std::option::Option<i32>,
2897
2898 /// Indicates if the "second" event is a delivery.
2899 pub second_is_delivery: bool,
2900
2901 /// The offset between the "first" and "second" event. It can be negative.
2902 pub offset_duration: std::option::Option<wkt::Duration>,
2903
2904 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2905 }
2906
2907 impl PrecedenceRule {
2908 /// Creates a new default instance.
2909 pub fn new() -> Self {
2910 std::default::Default::default()
2911 }
2912
2913 /// Sets the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2914 ///
2915 /// # Example
2916 /// ```ignore,no_run
2917 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2918 /// let x = PrecedenceRule::new().set_first_index(42);
2919 /// ```
2920 pub fn set_first_index<T>(mut self, v: T) -> Self
2921 where
2922 T: std::convert::Into<i32>,
2923 {
2924 self.first_index = std::option::Option::Some(v.into());
2925 self
2926 }
2927
2928 /// Sets or clears the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2929 ///
2930 /// # Example
2931 /// ```ignore,no_run
2932 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2933 /// let x = PrecedenceRule::new().set_or_clear_first_index(Some(42));
2934 /// let x = PrecedenceRule::new().set_or_clear_first_index(None::<i32>);
2935 /// ```
2936 pub fn set_or_clear_first_index<T>(mut self, v: std::option::Option<T>) -> Self
2937 where
2938 T: std::convert::Into<i32>,
2939 {
2940 self.first_index = v.map(|x| x.into());
2941 self
2942 }
2943
2944 /// Sets the value of [first_is_delivery][crate::model::shipment_model::PrecedenceRule::first_is_delivery].
2945 ///
2946 /// # Example
2947 /// ```ignore,no_run
2948 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2949 /// let x = PrecedenceRule::new().set_first_is_delivery(true);
2950 /// ```
2951 pub fn set_first_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2952 self.first_is_delivery = v.into();
2953 self
2954 }
2955
2956 /// Sets the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2957 ///
2958 /// # Example
2959 /// ```ignore,no_run
2960 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2961 /// let x = PrecedenceRule::new().set_second_index(42);
2962 /// ```
2963 pub fn set_second_index<T>(mut self, v: T) -> Self
2964 where
2965 T: std::convert::Into<i32>,
2966 {
2967 self.second_index = std::option::Option::Some(v.into());
2968 self
2969 }
2970
2971 /// Sets or clears the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2972 ///
2973 /// # Example
2974 /// ```ignore,no_run
2975 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2976 /// let x = PrecedenceRule::new().set_or_clear_second_index(Some(42));
2977 /// let x = PrecedenceRule::new().set_or_clear_second_index(None::<i32>);
2978 /// ```
2979 pub fn set_or_clear_second_index<T>(mut self, v: std::option::Option<T>) -> Self
2980 where
2981 T: std::convert::Into<i32>,
2982 {
2983 self.second_index = v.map(|x| x.into());
2984 self
2985 }
2986
2987 /// Sets the value of [second_is_delivery][crate::model::shipment_model::PrecedenceRule::second_is_delivery].
2988 ///
2989 /// # Example
2990 /// ```ignore,no_run
2991 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2992 /// let x = PrecedenceRule::new().set_second_is_delivery(true);
2993 /// ```
2994 pub fn set_second_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2995 self.second_is_delivery = v.into();
2996 self
2997 }
2998
2999 /// Sets the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
3000 ///
3001 /// # Example
3002 /// ```ignore,no_run
3003 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
3004 /// use wkt::Duration;
3005 /// let x = PrecedenceRule::new().set_offset_duration(Duration::default()/* use setters */);
3006 /// ```
3007 pub fn set_offset_duration<T>(mut self, v: T) -> Self
3008 where
3009 T: std::convert::Into<wkt::Duration>,
3010 {
3011 self.offset_duration = std::option::Option::Some(v.into());
3012 self
3013 }
3014
3015 /// Sets or clears the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
3016 ///
3017 /// # Example
3018 /// ```ignore,no_run
3019 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
3020 /// use wkt::Duration;
3021 /// let x = PrecedenceRule::new().set_or_clear_offset_duration(Some(Duration::default()/* use setters */));
3022 /// let x = PrecedenceRule::new().set_or_clear_offset_duration(None::<Duration>);
3023 /// ```
3024 pub fn set_or_clear_offset_duration<T>(mut self, v: std::option::Option<T>) -> Self
3025 where
3026 T: std::convert::Into<wkt::Duration>,
3027 {
3028 self.offset_duration = v.map(|x| x.into());
3029 self
3030 }
3031 }
3032
3033 impl wkt::message::Message for PrecedenceRule {
3034 fn typename() -> &'static str {
3035 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.PrecedenceRule"
3036 }
3037 }
3038
3039 /// Deprecated: Use top level
3040 /// [BreakRule][google.cloud.optimization.v1.ShipmentModel.BreakRule] instead.
3041 /// Rules to generate time breaks for a vehicle (e.g. lunch
3042 /// breaks). A break is a contiguous period of time during which the vehicle
3043 /// remains idle at its current position and cannot perform any visit. A break
3044 /// may occur:
3045 ///
3046 /// * during the travel between two visits (which includes the time right
3047 /// before or right after a visit, but not in the middle of a visit), in
3048 /// which case it extends the corresponding transit time between the visits
3049 /// * before the vehicle start (the vehicle may not start in the middle of
3050 /// a break), in which case it does not affect the vehicle start time.
3051 /// * after the vehicle end (ditto, with the vehicle end time).
3052 ///
3053 /// [google.cloud.optimization.v1.ShipmentModel.BreakRule]: crate::model::shipment_model::BreakRule
3054 #[derive(Clone, Default, PartialEq)]
3055 #[non_exhaustive]
3056 #[deprecated]
3057 pub struct BreakRule {
3058 /// Sequence of breaks. See the `BreakRequest` message.
3059 pub break_requests: std::vec::Vec<crate::model::shipment_model::break_rule::BreakRequest>,
3060
3061 /// Several `FrequencyConstraint` may apply. They must all be satisfied by
3062 /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
3063 pub frequency_constraints:
3064 std::vec::Vec<crate::model::shipment_model::break_rule::FrequencyConstraint>,
3065
3066 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3067 }
3068
3069 impl BreakRule {
3070 /// Creates a new default instance.
3071 pub fn new() -> Self {
3072 std::default::Default::default()
3073 }
3074
3075 /// Sets the value of [break_requests][crate::model::shipment_model::BreakRule::break_requests].
3076 ///
3077 /// # Example
3078 /// ```ignore,no_run
3079 /// # use google_cloud_optimization_v1::model::shipment_model::BreakRule;
3080 /// use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3081 /// let x = BreakRule::new()
3082 /// .set_break_requests([
3083 /// BreakRequest::default()/* use setters */,
3084 /// BreakRequest::default()/* use (different) setters */,
3085 /// ]);
3086 /// ```
3087 pub fn set_break_requests<T, V>(mut self, v: T) -> Self
3088 where
3089 T: std::iter::IntoIterator<Item = V>,
3090 V: std::convert::Into<crate::model::shipment_model::break_rule::BreakRequest>,
3091 {
3092 use std::iter::Iterator;
3093 self.break_requests = v.into_iter().map(|i| i.into()).collect();
3094 self
3095 }
3096
3097 /// Sets the value of [frequency_constraints][crate::model::shipment_model::BreakRule::frequency_constraints].
3098 ///
3099 /// # Example
3100 /// ```ignore,no_run
3101 /// # use google_cloud_optimization_v1::model::shipment_model::BreakRule;
3102 /// use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3103 /// let x = BreakRule::new()
3104 /// .set_frequency_constraints([
3105 /// FrequencyConstraint::default()/* use setters */,
3106 /// FrequencyConstraint::default()/* use (different) setters */,
3107 /// ]);
3108 /// ```
3109 pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
3110 where
3111 T: std::iter::IntoIterator<Item = V>,
3112 V: std::convert::Into<crate::model::shipment_model::break_rule::FrequencyConstraint>,
3113 {
3114 use std::iter::Iterator;
3115 self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
3116 self
3117 }
3118 }
3119
3120 impl wkt::message::Message for BreakRule {
3121 fn typename() -> &'static str {
3122 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule"
3123 }
3124 }
3125
3126 /// Defines additional types related to [BreakRule].
3127 pub mod break_rule {
3128 #[allow(unused_imports)]
3129 use super::*;
3130
3131 /// The sequence of breaks (i.e. their number and order) that apply to each
3132 /// vehicle must be known beforehand. The repeated `BreakRequest`s define
3133 /// that sequence, in the order in which they must occur. Their time windows
3134 /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
3135 /// be compatible with the order (this is checked).
3136 #[derive(Clone, Default, PartialEq)]
3137 #[non_exhaustive]
3138 pub struct BreakRequest {
3139 /// Required. Lower bound (inclusive) on the start of the break.
3140 pub earliest_start_time: std::option::Option<wkt::Timestamp>,
3141
3142 /// Required. Upper bound (inclusive) on the start of the break.
3143 pub latest_start_time: std::option::Option<wkt::Timestamp>,
3144
3145 /// Required. Minimum duration of the break. Must be positive.
3146 pub min_duration: std::option::Option<wkt::Duration>,
3147
3148 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3149 }
3150
3151 impl BreakRequest {
3152 /// Creates a new default instance.
3153 pub fn new() -> Self {
3154 std::default::Default::default()
3155 }
3156
3157 /// Sets the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
3158 ///
3159 /// # Example
3160 /// ```ignore,no_run
3161 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3162 /// use wkt::Timestamp;
3163 /// let x = BreakRequest::new().set_earliest_start_time(Timestamp::default()/* use setters */);
3164 /// ```
3165 pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
3166 where
3167 T: std::convert::Into<wkt::Timestamp>,
3168 {
3169 self.earliest_start_time = std::option::Option::Some(v.into());
3170 self
3171 }
3172
3173 /// Sets or clears the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
3174 ///
3175 /// # Example
3176 /// ```ignore,no_run
3177 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3178 /// use wkt::Timestamp;
3179 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(Some(Timestamp::default()/* use setters */));
3180 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(None::<Timestamp>);
3181 /// ```
3182 pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3183 where
3184 T: std::convert::Into<wkt::Timestamp>,
3185 {
3186 self.earliest_start_time = v.map(|x| x.into());
3187 self
3188 }
3189
3190 /// Sets the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
3191 ///
3192 /// # Example
3193 /// ```ignore,no_run
3194 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3195 /// use wkt::Timestamp;
3196 /// let x = BreakRequest::new().set_latest_start_time(Timestamp::default()/* use setters */);
3197 /// ```
3198 pub fn set_latest_start_time<T>(mut self, v: T) -> Self
3199 where
3200 T: std::convert::Into<wkt::Timestamp>,
3201 {
3202 self.latest_start_time = std::option::Option::Some(v.into());
3203 self
3204 }
3205
3206 /// Sets or clears the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
3207 ///
3208 /// # Example
3209 /// ```ignore,no_run
3210 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3211 /// use wkt::Timestamp;
3212 /// let x = BreakRequest::new().set_or_clear_latest_start_time(Some(Timestamp::default()/* use setters */));
3213 /// let x = BreakRequest::new().set_or_clear_latest_start_time(None::<Timestamp>);
3214 /// ```
3215 pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3216 where
3217 T: std::convert::Into<wkt::Timestamp>,
3218 {
3219 self.latest_start_time = v.map(|x| x.into());
3220 self
3221 }
3222
3223 /// Sets the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
3224 ///
3225 /// # Example
3226 /// ```ignore,no_run
3227 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3228 /// use wkt::Duration;
3229 /// let x = BreakRequest::new().set_min_duration(Duration::default()/* use setters */);
3230 /// ```
3231 pub fn set_min_duration<T>(mut self, v: T) -> Self
3232 where
3233 T: std::convert::Into<wkt::Duration>,
3234 {
3235 self.min_duration = std::option::Option::Some(v.into());
3236 self
3237 }
3238
3239 /// Sets or clears the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
3240 ///
3241 /// # Example
3242 /// ```ignore,no_run
3243 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3244 /// use wkt::Duration;
3245 /// let x = BreakRequest::new().set_or_clear_min_duration(Some(Duration::default()/* use setters */));
3246 /// let x = BreakRequest::new().set_or_clear_min_duration(None::<Duration>);
3247 /// ```
3248 pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
3249 where
3250 T: std::convert::Into<wkt::Duration>,
3251 {
3252 self.min_duration = v.map(|x| x.into());
3253 self
3254 }
3255 }
3256
3257 impl wkt::message::Message for BreakRequest {
3258 fn typename() -> &'static str {
3259 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.BreakRequest"
3260 }
3261 }
3262
3263 /// One may further constrain the frequency and duration of the breaks
3264 /// specified above, by enforcing a minimum break frequency, such as
3265 /// "There must be a break of at least 1 hour every 12 hours". Assuming that
3266 /// this can be interpreted as "Within any sliding time window of 12h, there
3267 /// must be at least one break of at least one hour", that example would
3268 /// translate to the following `FrequencyConstraint`:
3269 ///
3270 /// ```norust
3271 /// {
3272 /// min_break_duration { seconds: 3600 } # 1 hour.
3273 /// max_inter_break_duration { seconds: 39600 } # 11 hours (12 - 1 = 11).
3274 /// }
3275 /// ```
3276 ///
3277 /// The timing and duration of the breaks in the solution will respect all
3278 /// such constraints, in addition to the time windows and minimum durations
3279 /// already specified in the `BreakRequest`.
3280 ///
3281 /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
3282 /// For example, the following schedule honors the "1h every 12h" example:
3283 ///
3284 /// ```norust
3285 /// 04:00 vehicle start
3286 /// .. performing travel and visits ..
3287 /// 09:00 1 hour break
3288 /// 10:00 end of the break
3289 /// .. performing travel and visits ..
3290 /// 12:00 20-min lunch break
3291 /// 12:20 end of the break
3292 /// .. performing travel and visits ..
3293 /// 21:00 1 hour break
3294 /// 22:00 end of the break
3295 /// .. performing travel and visits ..
3296 /// 23:59 vehicle end
3297 /// ```
3298 #[derive(Clone, Default, PartialEq)]
3299 #[non_exhaustive]
3300 pub struct FrequencyConstraint {
3301 /// Required. Minimum break duration for this constraint. Nonnegative.
3302 /// See description of `FrequencyConstraint`.
3303 pub min_break_duration: std::option::Option<wkt::Duration>,
3304
3305 /// Required. Maximum allowed span of any interval of time in the route
3306 /// that does not include at least partially a break of `duration >=
3307 /// min_break_duration`. Must be positive.
3308 pub max_inter_break_duration: std::option::Option<wkt::Duration>,
3309
3310 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3311 }
3312
3313 impl FrequencyConstraint {
3314 /// Creates a new default instance.
3315 pub fn new() -> Self {
3316 std::default::Default::default()
3317 }
3318
3319 /// Sets the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
3320 ///
3321 /// # Example
3322 /// ```ignore,no_run
3323 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3324 /// use wkt::Duration;
3325 /// let x = FrequencyConstraint::new().set_min_break_duration(Duration::default()/* use setters */);
3326 /// ```
3327 pub fn set_min_break_duration<T>(mut self, v: T) -> Self
3328 where
3329 T: std::convert::Into<wkt::Duration>,
3330 {
3331 self.min_break_duration = std::option::Option::Some(v.into());
3332 self
3333 }
3334
3335 /// Sets or clears the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
3336 ///
3337 /// # Example
3338 /// ```ignore,no_run
3339 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3340 /// use wkt::Duration;
3341 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(Some(Duration::default()/* use setters */));
3342 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(None::<Duration>);
3343 /// ```
3344 pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
3345 where
3346 T: std::convert::Into<wkt::Duration>,
3347 {
3348 self.min_break_duration = v.map(|x| x.into());
3349 self
3350 }
3351
3352 /// Sets the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
3353 ///
3354 /// # Example
3355 /// ```ignore,no_run
3356 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3357 /// use wkt::Duration;
3358 /// let x = FrequencyConstraint::new().set_max_inter_break_duration(Duration::default()/* use setters */);
3359 /// ```
3360 pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
3361 where
3362 T: std::convert::Into<wkt::Duration>,
3363 {
3364 self.max_inter_break_duration = std::option::Option::Some(v.into());
3365 self
3366 }
3367
3368 /// Sets or clears the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
3369 ///
3370 /// # Example
3371 /// ```ignore,no_run
3372 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3373 /// use wkt::Duration;
3374 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(Some(Duration::default()/* use setters */));
3375 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(None::<Duration>);
3376 /// ```
3377 pub fn set_or_clear_max_inter_break_duration<T>(
3378 mut self,
3379 v: std::option::Option<T>,
3380 ) -> Self
3381 where
3382 T: std::convert::Into<wkt::Duration>,
3383 {
3384 self.max_inter_break_duration = v.map(|x| x.into());
3385 self
3386 }
3387 }
3388
3389 impl wkt::message::Message for FrequencyConstraint {
3390 fn typename() -> &'static str {
3391 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.FrequencyConstraint"
3392 }
3393 }
3394 }
3395}
3396
3397/// The shipment of a single item, from one of its pickups to one of its
3398/// deliveries. For the shipment to be considered as performed, a unique vehicle
3399/// must visit one of its pickup locations (and decrease its spare capacities
3400/// accordingly), then visit one of its delivery locations later on (and
3401/// therefore re-increase its spare capacities accordingly).
3402#[derive(Clone, Default, PartialEq)]
3403#[non_exhaustive]
3404pub struct Shipment {
3405 /// Set of pickup alternatives associated to the shipment. If not specified,
3406 /// the vehicle only needs to visit a location corresponding to the deliveries.
3407 pub pickups: std::vec::Vec<crate::model::shipment::VisitRequest>,
3408
3409 /// Set of delivery alternatives associated to the shipment. If not specified,
3410 /// the vehicle only needs to visit a location corresponding to the pickups.
3411 pub deliveries: std::vec::Vec<crate::model::shipment::VisitRequest>,
3412
3413 /// Load demands of the shipment (for example weight, volume, number of
3414 /// pallets etc). The keys in the map should be identifiers describing the type
3415 /// of the corresponding load, ideally also including the units.
3416 /// For example: "weight_kg", "volume_gallons", "pallet_count", etc.
3417 /// If a given key does not appear in the map, the corresponding load is
3418 /// considered as null.
3419 pub load_demands: std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
3420
3421 /// If the shipment is not completed, this penalty is added to the overall
3422 /// cost of the routes. A shipment is considered completed if one of its pickup
3423 /// and delivery alternatives is visited. The cost may be expressed in the
3424 /// same unit used for all other cost-related fields in the model and must be
3425 /// positive.
3426 ///
3427 /// *IMPORTANT*: If this penalty is not specified, it is considered infinite,
3428 /// i.e. the shipment must be completed.
3429 pub penalty_cost: std::option::Option<f64>,
3430
3431 /// The set of vehicles that may perform this shipment. If empty, all vehicles
3432 /// may perform it. Vehicles are given by their index in the `ShipmentModel`'s
3433 /// `vehicles` list.
3434 pub allowed_vehicle_indices: std::vec::Vec<i32>,
3435
3436 /// Specifies the cost that is incurred when this shipment is delivered by each
3437 /// vehicle. If specified, it must have EITHER:
3438 ///
3439 /// * the same number of elements as `costs_per_vehicle_indices`.
3440 /// `costs_per_vehicle[i]` corresponds to vehicle
3441 /// `costs_per_vehicle_indices[i]` of the model.
3442 /// * the same number of elements as there are vehicles in the model. The
3443 /// i-th element corresponds to vehicle #i of the model.
3444 ///
3445 /// These costs must be in the same unit as `penalty_cost` and must not be
3446 /// negative. Leave this field empty, if there are no such costs.
3447 pub costs_per_vehicle: std::vec::Vec<f64>,
3448
3449 /// Indices of the vehicles to which `costs_per_vehicle` applies. If non-empty,
3450 /// it must have the same number of elements as `costs_per_vehicle`. A vehicle
3451 /// index may not be specified more than once. If a vehicle is excluded from
3452 /// `costs_per_vehicle_indices`, its cost is zero.
3453 pub costs_per_vehicle_indices: std::vec::Vec<i32>,
3454
3455 /// Specifies the maximum relative detour time compared to the shortest path
3456 /// from pickup to delivery. If specified, it must be nonnegative, and the
3457 /// shipment must contain at least a pickup and a delivery.
3458 ///
3459 /// For example, let t be the shortest time taken to go from the selected
3460 /// pickup alternative directly to the selected delivery alternative. Then
3461 /// setting `pickup_to_delivery_relative_detour_limit` enforces:
3462 ///
3463 /// ```norust
3464 /// start_time(delivery) - start_time(pickup) <=
3465 /// std::ceil(t * (1.0 + pickup_to_delivery_relative_detour_limit))
3466 /// ```
3467 ///
3468 /// If both relative and absolute limits are specified on the same shipment,
3469 /// the more constraining limit is used for each possible pickup/delivery pair.
3470 /// As of 2017/10, detours are only supported when travel durations do not
3471 /// depend on vehicles.
3472 pub pickup_to_delivery_relative_detour_limit: std::option::Option<f64>,
3473
3474 /// Specifies the maximum absolute detour time compared to the shortest path
3475 /// from pickup to delivery. If specified, it must be nonnegative, and the
3476 /// shipment must contain at least a pickup and a delivery.
3477 ///
3478 /// For example, let t be the shortest time taken to go from the selected
3479 /// pickup alternative directly to the selected delivery alternative. Then
3480 /// setting `pickup_to_delivery_absolute_detour_limit` enforces:
3481 ///
3482 /// ```norust
3483 /// start_time(delivery) - start_time(pickup) <=
3484 /// t + pickup_to_delivery_absolute_detour_limit
3485 /// ```
3486 ///
3487 /// If both relative and absolute limits are specified on the same shipment,
3488 /// the more constraining limit is used for each possible pickup/delivery pair.
3489 /// As of 2017/10, detours are only supported when travel durations do not
3490 /// depend on vehicles.
3491 pub pickup_to_delivery_absolute_detour_limit: std::option::Option<wkt::Duration>,
3492
3493 /// Specifies the maximum duration from start of pickup to start of delivery of
3494 /// a shipment. If specified, it must be nonnegative, and the shipment must
3495 /// contain at least a pickup and a delivery. This does not depend on which
3496 /// alternatives are selected for pickup and delivery, nor on vehicle speed.
3497 /// This can be specified alongside maximum detour constraints: the solution
3498 /// will respect both specifications.
3499 pub pickup_to_delivery_time_limit: std::option::Option<wkt::Duration>,
3500
3501 /// Non-empty string specifying a "type" for this shipment.
3502 /// This feature can be used to define incompatibilities or requirements
3503 /// between `shipment_types` (see `shipment_type_incompatibilities` and
3504 /// `shipment_type_requirements` in `ShipmentModel`).
3505 ///
3506 /// Differs from `visit_types` which is specified for a single visit: All
3507 /// pickup/deliveries belonging to the same shipment share the same
3508 /// `shipment_type`.
3509 pub shipment_type: std::string::String,
3510
3511 /// Specifies a label for this shipment. This label is reported in the response
3512 /// in the `shipment_label` of the corresponding
3513 /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
3514 ///
3515 /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
3516 pub label: std::string::String,
3517
3518 /// If true, skip this shipment, but don't apply a `penalty_cost`.
3519 ///
3520 /// Ignoring a shipment results in a validation error when there are any
3521 /// `shipment_type_requirements` in the model.
3522 ///
3523 /// Ignoring a shipment that is performed in `injected_first_solution_routes`
3524 /// or `injected_solution_constraint` is permitted; the solver removes the
3525 /// related pickup/delivery visits from the performing route.
3526 /// `precedence_rules` that reference ignored shipments will also be ignored.
3527 pub ignore: bool,
3528
3529 /// Deprecated: Use
3530 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
3531 /// instead.
3532 ///
3533 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3534 #[deprecated]
3535 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
3536
3537 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3538}
3539
3540impl Shipment {
3541 /// Creates a new default instance.
3542 pub fn new() -> Self {
3543 std::default::Default::default()
3544 }
3545
3546 /// Sets the value of [pickups][crate::model::Shipment::pickups].
3547 ///
3548 /// # Example
3549 /// ```ignore,no_run
3550 /// # use google_cloud_optimization_v1::model::Shipment;
3551 /// use google_cloud_optimization_v1::model::shipment::VisitRequest;
3552 /// let x = Shipment::new()
3553 /// .set_pickups([
3554 /// VisitRequest::default()/* use setters */,
3555 /// VisitRequest::default()/* use (different) setters */,
3556 /// ]);
3557 /// ```
3558 pub fn set_pickups<T, V>(mut self, v: T) -> Self
3559 where
3560 T: std::iter::IntoIterator<Item = V>,
3561 V: std::convert::Into<crate::model::shipment::VisitRequest>,
3562 {
3563 use std::iter::Iterator;
3564 self.pickups = v.into_iter().map(|i| i.into()).collect();
3565 self
3566 }
3567
3568 /// Sets the value of [deliveries][crate::model::Shipment::deliveries].
3569 ///
3570 /// # Example
3571 /// ```ignore,no_run
3572 /// # use google_cloud_optimization_v1::model::Shipment;
3573 /// use google_cloud_optimization_v1::model::shipment::VisitRequest;
3574 /// let x = Shipment::new()
3575 /// .set_deliveries([
3576 /// VisitRequest::default()/* use setters */,
3577 /// VisitRequest::default()/* use (different) setters */,
3578 /// ]);
3579 /// ```
3580 pub fn set_deliveries<T, V>(mut self, v: T) -> Self
3581 where
3582 T: std::iter::IntoIterator<Item = V>,
3583 V: std::convert::Into<crate::model::shipment::VisitRequest>,
3584 {
3585 use std::iter::Iterator;
3586 self.deliveries = v.into_iter().map(|i| i.into()).collect();
3587 self
3588 }
3589
3590 /// Sets the value of [load_demands][crate::model::Shipment::load_demands].
3591 ///
3592 /// # Example
3593 /// ```ignore,no_run
3594 /// # use google_cloud_optimization_v1::model::Shipment;
3595 /// use google_cloud_optimization_v1::model::shipment::Load;
3596 /// let x = Shipment::new().set_load_demands([
3597 /// ("key0", Load::default()/* use setters */),
3598 /// ("key1", Load::default()/* use (different) setters */),
3599 /// ]);
3600 /// ```
3601 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
3602 where
3603 T: std::iter::IntoIterator<Item = (K, V)>,
3604 K: std::convert::Into<std::string::String>,
3605 V: std::convert::Into<crate::model::shipment::Load>,
3606 {
3607 use std::iter::Iterator;
3608 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3609 self
3610 }
3611
3612 /// Sets the value of [penalty_cost][crate::model::Shipment::penalty_cost].
3613 ///
3614 /// # Example
3615 /// ```ignore,no_run
3616 /// # use google_cloud_optimization_v1::model::Shipment;
3617 /// let x = Shipment::new().set_penalty_cost(42.0);
3618 /// ```
3619 pub fn set_penalty_cost<T>(mut self, v: T) -> Self
3620 where
3621 T: std::convert::Into<f64>,
3622 {
3623 self.penalty_cost = std::option::Option::Some(v.into());
3624 self
3625 }
3626
3627 /// Sets or clears the value of [penalty_cost][crate::model::Shipment::penalty_cost].
3628 ///
3629 /// # Example
3630 /// ```ignore,no_run
3631 /// # use google_cloud_optimization_v1::model::Shipment;
3632 /// let x = Shipment::new().set_or_clear_penalty_cost(Some(42.0));
3633 /// let x = Shipment::new().set_or_clear_penalty_cost(None::<f32>);
3634 /// ```
3635 pub fn set_or_clear_penalty_cost<T>(mut self, v: std::option::Option<T>) -> Self
3636 where
3637 T: std::convert::Into<f64>,
3638 {
3639 self.penalty_cost = v.map(|x| x.into());
3640 self
3641 }
3642
3643 /// Sets the value of [allowed_vehicle_indices][crate::model::Shipment::allowed_vehicle_indices].
3644 ///
3645 /// # Example
3646 /// ```ignore,no_run
3647 /// # use google_cloud_optimization_v1::model::Shipment;
3648 /// let x = Shipment::new().set_allowed_vehicle_indices([1, 2, 3]);
3649 /// ```
3650 pub fn set_allowed_vehicle_indices<T, V>(mut self, v: T) -> Self
3651 where
3652 T: std::iter::IntoIterator<Item = V>,
3653 V: std::convert::Into<i32>,
3654 {
3655 use std::iter::Iterator;
3656 self.allowed_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
3657 self
3658 }
3659
3660 /// Sets the value of [costs_per_vehicle][crate::model::Shipment::costs_per_vehicle].
3661 ///
3662 /// # Example
3663 /// ```ignore,no_run
3664 /// # use google_cloud_optimization_v1::model::Shipment;
3665 /// let x = Shipment::new().set_costs_per_vehicle([1.0, 2.0, 3.0]);
3666 /// ```
3667 pub fn set_costs_per_vehicle<T, V>(mut self, v: T) -> Self
3668 where
3669 T: std::iter::IntoIterator<Item = V>,
3670 V: std::convert::Into<f64>,
3671 {
3672 use std::iter::Iterator;
3673 self.costs_per_vehicle = v.into_iter().map(|i| i.into()).collect();
3674 self
3675 }
3676
3677 /// Sets the value of [costs_per_vehicle_indices][crate::model::Shipment::costs_per_vehicle_indices].
3678 ///
3679 /// # Example
3680 /// ```ignore,no_run
3681 /// # use google_cloud_optimization_v1::model::Shipment;
3682 /// let x = Shipment::new().set_costs_per_vehicle_indices([1, 2, 3]);
3683 /// ```
3684 pub fn set_costs_per_vehicle_indices<T, V>(mut self, v: T) -> Self
3685 where
3686 T: std::iter::IntoIterator<Item = V>,
3687 V: std::convert::Into<i32>,
3688 {
3689 use std::iter::Iterator;
3690 self.costs_per_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
3691 self
3692 }
3693
3694 /// Sets the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
3695 ///
3696 /// # Example
3697 /// ```ignore,no_run
3698 /// # use google_cloud_optimization_v1::model::Shipment;
3699 /// let x = Shipment::new().set_pickup_to_delivery_relative_detour_limit(42.0);
3700 /// ```
3701 pub fn set_pickup_to_delivery_relative_detour_limit<T>(mut self, v: T) -> Self
3702 where
3703 T: std::convert::Into<f64>,
3704 {
3705 self.pickup_to_delivery_relative_detour_limit = std::option::Option::Some(v.into());
3706 self
3707 }
3708
3709 /// Sets or clears the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
3710 ///
3711 /// # Example
3712 /// ```ignore,no_run
3713 /// # use google_cloud_optimization_v1::model::Shipment;
3714 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_relative_detour_limit(Some(42.0));
3715 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_relative_detour_limit(None::<f32>);
3716 /// ```
3717 pub fn set_or_clear_pickup_to_delivery_relative_detour_limit<T>(
3718 mut self,
3719 v: std::option::Option<T>,
3720 ) -> Self
3721 where
3722 T: std::convert::Into<f64>,
3723 {
3724 self.pickup_to_delivery_relative_detour_limit = v.map(|x| x.into());
3725 self
3726 }
3727
3728 /// Sets the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
3729 ///
3730 /// # Example
3731 /// ```ignore,no_run
3732 /// # use google_cloud_optimization_v1::model::Shipment;
3733 /// use wkt::Duration;
3734 /// let x = Shipment::new().set_pickup_to_delivery_absolute_detour_limit(Duration::default()/* use setters */);
3735 /// ```
3736 pub fn set_pickup_to_delivery_absolute_detour_limit<T>(mut self, v: T) -> Self
3737 where
3738 T: std::convert::Into<wkt::Duration>,
3739 {
3740 self.pickup_to_delivery_absolute_detour_limit = std::option::Option::Some(v.into());
3741 self
3742 }
3743
3744 /// Sets or clears the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
3745 ///
3746 /// # Example
3747 /// ```ignore,no_run
3748 /// # use google_cloud_optimization_v1::model::Shipment;
3749 /// use wkt::Duration;
3750 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_absolute_detour_limit(Some(Duration::default()/* use setters */));
3751 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_absolute_detour_limit(None::<Duration>);
3752 /// ```
3753 pub fn set_or_clear_pickup_to_delivery_absolute_detour_limit<T>(
3754 mut self,
3755 v: std::option::Option<T>,
3756 ) -> Self
3757 where
3758 T: std::convert::Into<wkt::Duration>,
3759 {
3760 self.pickup_to_delivery_absolute_detour_limit = v.map(|x| x.into());
3761 self
3762 }
3763
3764 /// Sets the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
3765 ///
3766 /// # Example
3767 /// ```ignore,no_run
3768 /// # use google_cloud_optimization_v1::model::Shipment;
3769 /// use wkt::Duration;
3770 /// let x = Shipment::new().set_pickup_to_delivery_time_limit(Duration::default()/* use setters */);
3771 /// ```
3772 pub fn set_pickup_to_delivery_time_limit<T>(mut self, v: T) -> Self
3773 where
3774 T: std::convert::Into<wkt::Duration>,
3775 {
3776 self.pickup_to_delivery_time_limit = std::option::Option::Some(v.into());
3777 self
3778 }
3779
3780 /// Sets or clears the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
3781 ///
3782 /// # Example
3783 /// ```ignore,no_run
3784 /// # use google_cloud_optimization_v1::model::Shipment;
3785 /// use wkt::Duration;
3786 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_time_limit(Some(Duration::default()/* use setters */));
3787 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_time_limit(None::<Duration>);
3788 /// ```
3789 pub fn set_or_clear_pickup_to_delivery_time_limit<T>(
3790 mut self,
3791 v: std::option::Option<T>,
3792 ) -> Self
3793 where
3794 T: std::convert::Into<wkt::Duration>,
3795 {
3796 self.pickup_to_delivery_time_limit = v.map(|x| x.into());
3797 self
3798 }
3799
3800 /// Sets the value of [shipment_type][crate::model::Shipment::shipment_type].
3801 ///
3802 /// # Example
3803 /// ```ignore,no_run
3804 /// # use google_cloud_optimization_v1::model::Shipment;
3805 /// let x = Shipment::new().set_shipment_type("example");
3806 /// ```
3807 pub fn set_shipment_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3808 self.shipment_type = v.into();
3809 self
3810 }
3811
3812 /// Sets the value of [label][crate::model::Shipment::label].
3813 ///
3814 /// # Example
3815 /// ```ignore,no_run
3816 /// # use google_cloud_optimization_v1::model::Shipment;
3817 /// let x = Shipment::new().set_label("example");
3818 /// ```
3819 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3820 self.label = v.into();
3821 self
3822 }
3823
3824 /// Sets the value of [ignore][crate::model::Shipment::ignore].
3825 ///
3826 /// # Example
3827 /// ```ignore,no_run
3828 /// # use google_cloud_optimization_v1::model::Shipment;
3829 /// let x = Shipment::new().set_ignore(true);
3830 /// ```
3831 pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3832 self.ignore = v.into();
3833 self
3834 }
3835
3836 /// Sets the value of [demands][crate::model::Shipment::demands].
3837 ///
3838 /// # Example
3839 /// ```ignore,no_run
3840 /// # use google_cloud_optimization_v1::model::Shipment;
3841 /// use google_cloud_optimization_v1::model::CapacityQuantity;
3842 /// let x = Shipment::new()
3843 /// .set_demands([
3844 /// CapacityQuantity::default()/* use setters */,
3845 /// CapacityQuantity::default()/* use (different) setters */,
3846 /// ]);
3847 /// ```
3848 #[deprecated]
3849 pub fn set_demands<T, V>(mut self, v: T) -> Self
3850 where
3851 T: std::iter::IntoIterator<Item = V>,
3852 V: std::convert::Into<crate::model::CapacityQuantity>,
3853 {
3854 use std::iter::Iterator;
3855 self.demands = v.into_iter().map(|i| i.into()).collect();
3856 self
3857 }
3858}
3859
3860impl wkt::message::Message for Shipment {
3861 fn typename() -> &'static str {
3862 "type.googleapis.com/google.cloud.optimization.v1.Shipment"
3863 }
3864}
3865
3866/// Defines additional types related to [Shipment].
3867pub mod shipment {
3868 #[allow(unused_imports)]
3869 use super::*;
3870
3871 /// Request for a visit which can be done by a vehicle: it has a geo-location
3872 /// (or two, see below), opening and closing times represented by time windows,
3873 /// and a service duration time (time spent by the vehicle once it has arrived
3874 /// to pickup or drop off goods).
3875 #[derive(Clone, Default, PartialEq)]
3876 #[non_exhaustive]
3877 pub struct VisitRequest {
3878 /// The geo-location where the vehicle arrives when performing this
3879 /// `VisitRequest`. If the shipment model has duration distance matrices,
3880 /// `arrival_location` must not be specified.
3881 pub arrival_location: std::option::Option<google_cloud_type::model::LatLng>,
3882
3883 /// The waypoint where the vehicle arrives when performing this
3884 /// `VisitRequest`. If the shipment model has duration distance matrices,
3885 /// `arrival_waypoint` must not be specified.
3886 pub arrival_waypoint: std::option::Option<crate::model::Waypoint>,
3887
3888 /// The geo-location where the vehicle departs after completing this
3889 /// `VisitRequest`. Can be omitted if it is the same as `arrival_location`.
3890 /// If the shipment model has duration distance matrices,
3891 /// `departure_location` must not be specified.
3892 pub departure_location: std::option::Option<google_cloud_type::model::LatLng>,
3893
3894 /// The waypoint where the vehicle departs after completing this
3895 /// `VisitRequest`. Can be omitted if it is the same as `arrival_waypoint`.
3896 /// If the shipment model has duration distance matrices,
3897 /// `departure_waypoint` must not be specified.
3898 pub departure_waypoint: std::option::Option<crate::model::Waypoint>,
3899
3900 /// Specifies tags attached to the visit request.
3901 /// Empty or duplicate strings are not allowed.
3902 pub tags: std::vec::Vec<std::string::String>,
3903
3904 /// Time windows which constrain the arrival time at a visit.
3905 /// Note that a vehicle may depart outside of the arrival time window, i.e.
3906 /// arrival time + duration do not need to be inside a time window. This can
3907 /// result in waiting time if the vehicle arrives before
3908 /// [TimeWindow.start_time][google.cloud.optimization.v1.TimeWindow.start_time].
3909 ///
3910 /// The absence of `TimeWindow` means that the vehicle can perform this visit
3911 /// at any time.
3912 ///
3913 /// Time windows must be disjoint, i.e. no time window must overlap with or
3914 /// be adjacent to another, and they must be in increasing order.
3915 ///
3916 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only
3917 /// be set if there is a single time window.
3918 ///
3919 /// [google.cloud.optimization.v1.TimeWindow.start_time]: crate::model::TimeWindow::start_time
3920 pub time_windows: std::vec::Vec<crate::model::TimeWindow>,
3921
3922 /// Duration of the visit, i.e. time spent by the vehicle between arrival
3923 /// and departure (to be added to the possible waiting time; see
3924 /// `time_windows`).
3925 pub duration: std::option::Option<wkt::Duration>,
3926
3927 /// Cost to service this visit request on a vehicle route. This can be used
3928 /// to pay different costs for each alternative pickup or delivery of a
3929 /// shipment. This cost must be in the same unit as `Shipment.penalty_cost`
3930 /// and must not be negative.
3931 pub cost: f64,
3932
3933 /// Load demands of this visit request. This is just like
3934 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
3935 /// field, except that it only applies to this
3936 /// [VisitRequest][google.cloud.optimization.v1.Shipment.VisitRequest]
3937 /// instead of the whole [Shipment][google.cloud.optimization.v1.Shipment].
3938 /// The demands listed here are added to the demands listed in
3939 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands].
3940 ///
3941 /// [google.cloud.optimization.v1.Shipment]: crate::model::Shipment
3942 /// [google.cloud.optimization.v1.Shipment.VisitRequest]: crate::model::shipment::VisitRequest
3943 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3944 pub load_demands:
3945 std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
3946
3947 /// Specifies the types of the visit. This may be used to allocate additional
3948 /// time required for a vehicle to complete this visit (see
3949 /// [Vehicle.extra_visit_duration_for_visit_type][google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]).
3950 ///
3951 /// A type can only appear once.
3952 ///
3953 /// [google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]: crate::model::Vehicle::extra_visit_duration_for_visit_type
3954 pub visit_types: std::vec::Vec<std::string::String>,
3955
3956 /// Specifies a label for this `VisitRequest`. This label is reported in the
3957 /// response as `visit_label` in the corresponding
3958 /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
3959 ///
3960 /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
3961 pub label: std::string::String,
3962
3963 /// Deprecated: Use
3964 /// [VisitRequest.load_demands][google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]
3965 /// instead.
3966 ///
3967 /// [google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]: crate::model::shipment::VisitRequest::load_demands
3968 #[deprecated]
3969 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
3970
3971 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3972 }
3973
3974 impl VisitRequest {
3975 /// Creates a new default instance.
3976 pub fn new() -> Self {
3977 std::default::Default::default()
3978 }
3979
3980 /// Sets the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3981 ///
3982 /// # Example
3983 /// ```ignore,no_run
3984 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
3985 /// use google_cloud_type::model::LatLng;
3986 /// let x = VisitRequest::new().set_arrival_location(LatLng::default()/* use setters */);
3987 /// ```
3988 pub fn set_arrival_location<T>(mut self, v: T) -> Self
3989 where
3990 T: std::convert::Into<google_cloud_type::model::LatLng>,
3991 {
3992 self.arrival_location = std::option::Option::Some(v.into());
3993 self
3994 }
3995
3996 /// Sets or clears the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3997 ///
3998 /// # Example
3999 /// ```ignore,no_run
4000 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4001 /// use google_cloud_type::model::LatLng;
4002 /// let x = VisitRequest::new().set_or_clear_arrival_location(Some(LatLng::default()/* use setters */));
4003 /// let x = VisitRequest::new().set_or_clear_arrival_location(None::<LatLng>);
4004 /// ```
4005 pub fn set_or_clear_arrival_location<T>(mut self, v: std::option::Option<T>) -> Self
4006 where
4007 T: std::convert::Into<google_cloud_type::model::LatLng>,
4008 {
4009 self.arrival_location = v.map(|x| x.into());
4010 self
4011 }
4012
4013 /// Sets the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
4014 ///
4015 /// # Example
4016 /// ```ignore,no_run
4017 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4018 /// use google_cloud_optimization_v1::model::Waypoint;
4019 /// let x = VisitRequest::new().set_arrival_waypoint(Waypoint::default()/* use setters */);
4020 /// ```
4021 pub fn set_arrival_waypoint<T>(mut self, v: T) -> Self
4022 where
4023 T: std::convert::Into<crate::model::Waypoint>,
4024 {
4025 self.arrival_waypoint = std::option::Option::Some(v.into());
4026 self
4027 }
4028
4029 /// Sets or clears the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
4030 ///
4031 /// # Example
4032 /// ```ignore,no_run
4033 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4034 /// use google_cloud_optimization_v1::model::Waypoint;
4035 /// let x = VisitRequest::new().set_or_clear_arrival_waypoint(Some(Waypoint::default()/* use setters */));
4036 /// let x = VisitRequest::new().set_or_clear_arrival_waypoint(None::<Waypoint>);
4037 /// ```
4038 pub fn set_or_clear_arrival_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4039 where
4040 T: std::convert::Into<crate::model::Waypoint>,
4041 {
4042 self.arrival_waypoint = v.map(|x| x.into());
4043 self
4044 }
4045
4046 /// Sets the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
4047 ///
4048 /// # Example
4049 /// ```ignore,no_run
4050 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4051 /// use google_cloud_type::model::LatLng;
4052 /// let x = VisitRequest::new().set_departure_location(LatLng::default()/* use setters */);
4053 /// ```
4054 pub fn set_departure_location<T>(mut self, v: T) -> Self
4055 where
4056 T: std::convert::Into<google_cloud_type::model::LatLng>,
4057 {
4058 self.departure_location = std::option::Option::Some(v.into());
4059 self
4060 }
4061
4062 /// Sets or clears the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
4063 ///
4064 /// # Example
4065 /// ```ignore,no_run
4066 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4067 /// use google_cloud_type::model::LatLng;
4068 /// let x = VisitRequest::new().set_or_clear_departure_location(Some(LatLng::default()/* use setters */));
4069 /// let x = VisitRequest::new().set_or_clear_departure_location(None::<LatLng>);
4070 /// ```
4071 pub fn set_or_clear_departure_location<T>(mut self, v: std::option::Option<T>) -> Self
4072 where
4073 T: std::convert::Into<google_cloud_type::model::LatLng>,
4074 {
4075 self.departure_location = v.map(|x| x.into());
4076 self
4077 }
4078
4079 /// Sets the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
4080 ///
4081 /// # Example
4082 /// ```ignore,no_run
4083 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4084 /// use google_cloud_optimization_v1::model::Waypoint;
4085 /// let x = VisitRequest::new().set_departure_waypoint(Waypoint::default()/* use setters */);
4086 /// ```
4087 pub fn set_departure_waypoint<T>(mut self, v: T) -> Self
4088 where
4089 T: std::convert::Into<crate::model::Waypoint>,
4090 {
4091 self.departure_waypoint = std::option::Option::Some(v.into());
4092 self
4093 }
4094
4095 /// Sets or clears the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
4096 ///
4097 /// # Example
4098 /// ```ignore,no_run
4099 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4100 /// use google_cloud_optimization_v1::model::Waypoint;
4101 /// let x = VisitRequest::new().set_or_clear_departure_waypoint(Some(Waypoint::default()/* use setters */));
4102 /// let x = VisitRequest::new().set_or_clear_departure_waypoint(None::<Waypoint>);
4103 /// ```
4104 pub fn set_or_clear_departure_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4105 where
4106 T: std::convert::Into<crate::model::Waypoint>,
4107 {
4108 self.departure_waypoint = v.map(|x| x.into());
4109 self
4110 }
4111
4112 /// Sets the value of [tags][crate::model::shipment::VisitRequest::tags].
4113 ///
4114 /// # Example
4115 /// ```ignore,no_run
4116 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4117 /// let x = VisitRequest::new().set_tags(["a", "b", "c"]);
4118 /// ```
4119 pub fn set_tags<T, V>(mut self, v: T) -> Self
4120 where
4121 T: std::iter::IntoIterator<Item = V>,
4122 V: std::convert::Into<std::string::String>,
4123 {
4124 use std::iter::Iterator;
4125 self.tags = v.into_iter().map(|i| i.into()).collect();
4126 self
4127 }
4128
4129 /// Sets the value of [time_windows][crate::model::shipment::VisitRequest::time_windows].
4130 ///
4131 /// # Example
4132 /// ```ignore,no_run
4133 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4134 /// use google_cloud_optimization_v1::model::TimeWindow;
4135 /// let x = VisitRequest::new()
4136 /// .set_time_windows([
4137 /// TimeWindow::default()/* use setters */,
4138 /// TimeWindow::default()/* use (different) setters */,
4139 /// ]);
4140 /// ```
4141 pub fn set_time_windows<T, V>(mut self, v: T) -> Self
4142 where
4143 T: std::iter::IntoIterator<Item = V>,
4144 V: std::convert::Into<crate::model::TimeWindow>,
4145 {
4146 use std::iter::Iterator;
4147 self.time_windows = v.into_iter().map(|i| i.into()).collect();
4148 self
4149 }
4150
4151 /// Sets the value of [duration][crate::model::shipment::VisitRequest::duration].
4152 ///
4153 /// # Example
4154 /// ```ignore,no_run
4155 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4156 /// use wkt::Duration;
4157 /// let x = VisitRequest::new().set_duration(Duration::default()/* use setters */);
4158 /// ```
4159 pub fn set_duration<T>(mut self, v: T) -> Self
4160 where
4161 T: std::convert::Into<wkt::Duration>,
4162 {
4163 self.duration = std::option::Option::Some(v.into());
4164 self
4165 }
4166
4167 /// Sets or clears the value of [duration][crate::model::shipment::VisitRequest::duration].
4168 ///
4169 /// # Example
4170 /// ```ignore,no_run
4171 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4172 /// use wkt::Duration;
4173 /// let x = VisitRequest::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
4174 /// let x = VisitRequest::new().set_or_clear_duration(None::<Duration>);
4175 /// ```
4176 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
4177 where
4178 T: std::convert::Into<wkt::Duration>,
4179 {
4180 self.duration = v.map(|x| x.into());
4181 self
4182 }
4183
4184 /// Sets the value of [cost][crate::model::shipment::VisitRequest::cost].
4185 ///
4186 /// # Example
4187 /// ```ignore,no_run
4188 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4189 /// let x = VisitRequest::new().set_cost(42.0);
4190 /// ```
4191 pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4192 self.cost = v.into();
4193 self
4194 }
4195
4196 /// Sets the value of [load_demands][crate::model::shipment::VisitRequest::load_demands].
4197 ///
4198 /// # Example
4199 /// ```ignore,no_run
4200 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4201 /// use google_cloud_optimization_v1::model::shipment::Load;
4202 /// let x = VisitRequest::new().set_load_demands([
4203 /// ("key0", Load::default()/* use setters */),
4204 /// ("key1", Load::default()/* use (different) setters */),
4205 /// ]);
4206 /// ```
4207 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
4208 where
4209 T: std::iter::IntoIterator<Item = (K, V)>,
4210 K: std::convert::Into<std::string::String>,
4211 V: std::convert::Into<crate::model::shipment::Load>,
4212 {
4213 use std::iter::Iterator;
4214 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4215 self
4216 }
4217
4218 /// Sets the value of [visit_types][crate::model::shipment::VisitRequest::visit_types].
4219 ///
4220 /// # Example
4221 /// ```ignore,no_run
4222 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4223 /// let x = VisitRequest::new().set_visit_types(["a", "b", "c"]);
4224 /// ```
4225 pub fn set_visit_types<T, V>(mut self, v: T) -> Self
4226 where
4227 T: std::iter::IntoIterator<Item = V>,
4228 V: std::convert::Into<std::string::String>,
4229 {
4230 use std::iter::Iterator;
4231 self.visit_types = v.into_iter().map(|i| i.into()).collect();
4232 self
4233 }
4234
4235 /// Sets the value of [label][crate::model::shipment::VisitRequest::label].
4236 ///
4237 /// # Example
4238 /// ```ignore,no_run
4239 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4240 /// let x = VisitRequest::new().set_label("example");
4241 /// ```
4242 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4243 self.label = v.into();
4244 self
4245 }
4246
4247 /// Sets the value of [demands][crate::model::shipment::VisitRequest::demands].
4248 ///
4249 /// # Example
4250 /// ```ignore,no_run
4251 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4252 /// use google_cloud_optimization_v1::model::CapacityQuantity;
4253 /// let x = VisitRequest::new()
4254 /// .set_demands([
4255 /// CapacityQuantity::default()/* use setters */,
4256 /// CapacityQuantity::default()/* use (different) setters */,
4257 /// ]);
4258 /// ```
4259 #[deprecated]
4260 pub fn set_demands<T, V>(mut self, v: T) -> Self
4261 where
4262 T: std::iter::IntoIterator<Item = V>,
4263 V: std::convert::Into<crate::model::CapacityQuantity>,
4264 {
4265 use std::iter::Iterator;
4266 self.demands = v.into_iter().map(|i| i.into()).collect();
4267 self
4268 }
4269 }
4270
4271 impl wkt::message::Message for VisitRequest {
4272 fn typename() -> &'static str {
4273 "type.googleapis.com/google.cloud.optimization.v1.Shipment.VisitRequest"
4274 }
4275 }
4276
4277 /// When performing a visit, a predefined amount may be added to the vehicle
4278 /// load if it's a pickup, or subtracted if it's a delivery. This message
4279 /// defines such amount. See
4280 /// [load_demands][google.cloud.optimization.v1.Shipment.load_demands].
4281 ///
4282 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
4283 #[derive(Clone, Default, PartialEq)]
4284 #[non_exhaustive]
4285 pub struct Load {
4286 /// The amount by which the load of the vehicle performing the corresponding
4287 /// visit will vary. Since it is an integer, users are advised to choose an
4288 /// appropriate unit to avoid loss of precision. Must be ≥ 0.
4289 pub amount: i64,
4290
4291 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4292 }
4293
4294 impl Load {
4295 /// Creates a new default instance.
4296 pub fn new() -> Self {
4297 std::default::Default::default()
4298 }
4299
4300 /// Sets the value of [amount][crate::model::shipment::Load::amount].
4301 ///
4302 /// # Example
4303 /// ```ignore,no_run
4304 /// # use google_cloud_optimization_v1::model::shipment::Load;
4305 /// let x = Load::new().set_amount(42);
4306 /// ```
4307 pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
4308 self.amount = v.into();
4309 self
4310 }
4311 }
4312
4313 impl wkt::message::Message for Load {
4314 fn typename() -> &'static str {
4315 "type.googleapis.com/google.cloud.optimization.v1.Shipment.Load"
4316 }
4317 }
4318}
4319
4320/// Specifies incompatibilties between shipments depending on their
4321/// shipment_type. The appearance of incompatible shipments on the same route is
4322/// restricted based on the incompatibility mode.
4323#[derive(Clone, Default, PartialEq)]
4324#[non_exhaustive]
4325pub struct ShipmentTypeIncompatibility {
4326 /// List of incompatible types. Two shipments having different `shipment_types`
4327 /// among those listed are "incompatible".
4328 pub types: std::vec::Vec<std::string::String>,
4329
4330 /// Mode applied to the incompatibility.
4331 pub incompatibility_mode: crate::model::shipment_type_incompatibility::IncompatibilityMode,
4332
4333 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4334}
4335
4336impl ShipmentTypeIncompatibility {
4337 /// Creates a new default instance.
4338 pub fn new() -> Self {
4339 std::default::Default::default()
4340 }
4341
4342 /// Sets the value of [types][crate::model::ShipmentTypeIncompatibility::types].
4343 ///
4344 /// # Example
4345 /// ```ignore,no_run
4346 /// # use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
4347 /// let x = ShipmentTypeIncompatibility::new().set_types(["a", "b", "c"]);
4348 /// ```
4349 pub fn set_types<T, V>(mut self, v: T) -> Self
4350 where
4351 T: std::iter::IntoIterator<Item = V>,
4352 V: std::convert::Into<std::string::String>,
4353 {
4354 use std::iter::Iterator;
4355 self.types = v.into_iter().map(|i| i.into()).collect();
4356 self
4357 }
4358
4359 /// Sets the value of [incompatibility_mode][crate::model::ShipmentTypeIncompatibility::incompatibility_mode].
4360 ///
4361 /// # Example
4362 /// ```ignore,no_run
4363 /// # use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
4364 /// use google_cloud_optimization_v1::model::shipment_type_incompatibility::IncompatibilityMode;
4365 /// let x0 = ShipmentTypeIncompatibility::new().set_incompatibility_mode(IncompatibilityMode::NotPerformedBySameVehicle);
4366 /// let x1 = ShipmentTypeIncompatibility::new().set_incompatibility_mode(IncompatibilityMode::NotInSameVehicleSimultaneously);
4367 /// ```
4368 pub fn set_incompatibility_mode<
4369 T: std::convert::Into<crate::model::shipment_type_incompatibility::IncompatibilityMode>,
4370 >(
4371 mut self,
4372 v: T,
4373 ) -> Self {
4374 self.incompatibility_mode = v.into();
4375 self
4376 }
4377}
4378
4379impl wkt::message::Message for ShipmentTypeIncompatibility {
4380 fn typename() -> &'static str {
4381 "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeIncompatibility"
4382 }
4383}
4384
4385/// Defines additional types related to [ShipmentTypeIncompatibility].
4386pub mod shipment_type_incompatibility {
4387 #[allow(unused_imports)]
4388 use super::*;
4389
4390 /// Modes defining how the appearance of incompatible shipments are restricted
4391 /// on the same route.
4392 ///
4393 /// # Working with unknown values
4394 ///
4395 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4396 /// additional enum variants at any time. Adding new variants is not considered
4397 /// a breaking change. Applications should write their code in anticipation of:
4398 ///
4399 /// - New values appearing in future releases of the client library, **and**
4400 /// - New values received dynamically, without application changes.
4401 ///
4402 /// Please consult the [Working with enums] section in the user guide for some
4403 /// guidelines.
4404 ///
4405 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4406 #[derive(Clone, Debug, PartialEq)]
4407 #[non_exhaustive]
4408 pub enum IncompatibilityMode {
4409 /// Unspecified incompatibility mode. This value should never be used.
4410 Unspecified,
4411 /// In this mode, two shipments with incompatible types can never share the
4412 /// same vehicle.
4413 NotPerformedBySameVehicle,
4414 /// For two shipments with incompatible types with the
4415 /// `NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY` incompatibility mode:
4416 ///
4417 /// * If both are pickups only (no deliveries) or deliveries only (no
4418 /// pickups), they cannot share the same vehicle at all.
4419 /// * If one of the shipments has a delivery and the other a pickup, the two
4420 /// shipments can share the same vehicle iff the former shipment is
4421 /// delivered before the latter is picked up.
4422 NotInSameVehicleSimultaneously,
4423 /// If set, the enum was initialized with an unknown value.
4424 ///
4425 /// Applications can examine the value using [IncompatibilityMode::value] or
4426 /// [IncompatibilityMode::name].
4427 UnknownValue(incompatibility_mode::UnknownValue),
4428 }
4429
4430 #[doc(hidden)]
4431 pub mod incompatibility_mode {
4432 #[allow(unused_imports)]
4433 use super::*;
4434 #[derive(Clone, Debug, PartialEq)]
4435 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4436 }
4437
4438 impl IncompatibilityMode {
4439 /// Gets the enum value.
4440 ///
4441 /// Returns `None` if the enum contains an unknown value deserialized from
4442 /// the string representation of enums.
4443 pub fn value(&self) -> std::option::Option<i32> {
4444 match self {
4445 Self::Unspecified => std::option::Option::Some(0),
4446 Self::NotPerformedBySameVehicle => std::option::Option::Some(1),
4447 Self::NotInSameVehicleSimultaneously => std::option::Option::Some(2),
4448 Self::UnknownValue(u) => u.0.value(),
4449 }
4450 }
4451
4452 /// Gets the enum value as a string.
4453 ///
4454 /// Returns `None` if the enum contains an unknown value deserialized from
4455 /// the integer representation of enums.
4456 pub fn name(&self) -> std::option::Option<&str> {
4457 match self {
4458 Self::Unspecified => std::option::Option::Some("INCOMPATIBILITY_MODE_UNSPECIFIED"),
4459 Self::NotPerformedBySameVehicle => {
4460 std::option::Option::Some("NOT_PERFORMED_BY_SAME_VEHICLE")
4461 }
4462 Self::NotInSameVehicleSimultaneously => {
4463 std::option::Option::Some("NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY")
4464 }
4465 Self::UnknownValue(u) => u.0.name(),
4466 }
4467 }
4468 }
4469
4470 impl std::default::Default for IncompatibilityMode {
4471 fn default() -> Self {
4472 use std::convert::From;
4473 Self::from(0)
4474 }
4475 }
4476
4477 impl std::fmt::Display for IncompatibilityMode {
4478 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4479 wkt::internal::display_enum(f, self.name(), self.value())
4480 }
4481 }
4482
4483 impl std::convert::From<i32> for IncompatibilityMode {
4484 fn from(value: i32) -> Self {
4485 match value {
4486 0 => Self::Unspecified,
4487 1 => Self::NotPerformedBySameVehicle,
4488 2 => Self::NotInSameVehicleSimultaneously,
4489 _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
4490 wkt::internal::UnknownEnumValue::Integer(value),
4491 )),
4492 }
4493 }
4494 }
4495
4496 impl std::convert::From<&str> for IncompatibilityMode {
4497 fn from(value: &str) -> Self {
4498 use std::string::ToString;
4499 match value {
4500 "INCOMPATIBILITY_MODE_UNSPECIFIED" => Self::Unspecified,
4501 "NOT_PERFORMED_BY_SAME_VEHICLE" => Self::NotPerformedBySameVehicle,
4502 "NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY" => Self::NotInSameVehicleSimultaneously,
4503 _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
4504 wkt::internal::UnknownEnumValue::String(value.to_string()),
4505 )),
4506 }
4507 }
4508 }
4509
4510 impl serde::ser::Serialize for IncompatibilityMode {
4511 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4512 where
4513 S: serde::Serializer,
4514 {
4515 match self {
4516 Self::Unspecified => serializer.serialize_i32(0),
4517 Self::NotPerformedBySameVehicle => serializer.serialize_i32(1),
4518 Self::NotInSameVehicleSimultaneously => serializer.serialize_i32(2),
4519 Self::UnknownValue(u) => u.0.serialize(serializer),
4520 }
4521 }
4522 }
4523
4524 impl<'de> serde::de::Deserialize<'de> for IncompatibilityMode {
4525 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4526 where
4527 D: serde::Deserializer<'de>,
4528 {
4529 deserializer.deserialize_any(wkt::internal::EnumVisitor::<IncompatibilityMode>::new(
4530 ".google.cloud.optimization.v1.ShipmentTypeIncompatibility.IncompatibilityMode",
4531 ))
4532 }
4533 }
4534}
4535
4536/// Specifies requirements between shipments based on their shipment_type.
4537/// The specifics of the requirement are defined by the requirement mode.
4538#[derive(Clone, Default, PartialEq)]
4539#[non_exhaustive]
4540pub struct ShipmentTypeRequirement {
4541 /// List of alternative shipment types required by the
4542 /// `dependent_shipment_types`.
4543 pub required_shipment_type_alternatives: std::vec::Vec<std::string::String>,
4544
4545 /// All shipments with a type in the `dependent_shipment_types` field require
4546 /// at least one shipment of type `required_shipment_type_alternatives` to be
4547 /// visited on the same route.
4548 ///
4549 /// NOTE: Chains of requirements such that a `shipment_type` depends on itself
4550 /// are not allowed.
4551 pub dependent_shipment_types: std::vec::Vec<std::string::String>,
4552
4553 /// Mode applied to the requirement.
4554 pub requirement_mode: crate::model::shipment_type_requirement::RequirementMode,
4555
4556 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4557}
4558
4559impl ShipmentTypeRequirement {
4560 /// Creates a new default instance.
4561 pub fn new() -> Self {
4562 std::default::Default::default()
4563 }
4564
4565 /// Sets the value of [required_shipment_type_alternatives][crate::model::ShipmentTypeRequirement::required_shipment_type_alternatives].
4566 ///
4567 /// # Example
4568 /// ```ignore,no_run
4569 /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4570 /// let x = ShipmentTypeRequirement::new().set_required_shipment_type_alternatives(["a", "b", "c"]);
4571 /// ```
4572 pub fn set_required_shipment_type_alternatives<T, V>(mut self, v: T) -> Self
4573 where
4574 T: std::iter::IntoIterator<Item = V>,
4575 V: std::convert::Into<std::string::String>,
4576 {
4577 use std::iter::Iterator;
4578 self.required_shipment_type_alternatives = v.into_iter().map(|i| i.into()).collect();
4579 self
4580 }
4581
4582 /// Sets the value of [dependent_shipment_types][crate::model::ShipmentTypeRequirement::dependent_shipment_types].
4583 ///
4584 /// # Example
4585 /// ```ignore,no_run
4586 /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4587 /// let x = ShipmentTypeRequirement::new().set_dependent_shipment_types(["a", "b", "c"]);
4588 /// ```
4589 pub fn set_dependent_shipment_types<T, V>(mut self, v: T) -> Self
4590 where
4591 T: std::iter::IntoIterator<Item = V>,
4592 V: std::convert::Into<std::string::String>,
4593 {
4594 use std::iter::Iterator;
4595 self.dependent_shipment_types = v.into_iter().map(|i| i.into()).collect();
4596 self
4597 }
4598
4599 /// Sets the value of [requirement_mode][crate::model::ShipmentTypeRequirement::requirement_mode].
4600 ///
4601 /// # Example
4602 /// ```ignore,no_run
4603 /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4604 /// use google_cloud_optimization_v1::model::shipment_type_requirement::RequirementMode;
4605 /// let x0 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::PerformedBySameVehicle);
4606 /// let x1 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::InSameVehicleAtPickupTime);
4607 /// let x2 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::InSameVehicleAtDeliveryTime);
4608 /// ```
4609 pub fn set_requirement_mode<
4610 T: std::convert::Into<crate::model::shipment_type_requirement::RequirementMode>,
4611 >(
4612 mut self,
4613 v: T,
4614 ) -> Self {
4615 self.requirement_mode = v.into();
4616 self
4617 }
4618}
4619
4620impl wkt::message::Message for ShipmentTypeRequirement {
4621 fn typename() -> &'static str {
4622 "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeRequirement"
4623 }
4624}
4625
4626/// Defines additional types related to [ShipmentTypeRequirement].
4627pub mod shipment_type_requirement {
4628 #[allow(unused_imports)]
4629 use super::*;
4630
4631 /// Modes defining the appearance of dependent shipments on a route.
4632 ///
4633 /// # Working with unknown values
4634 ///
4635 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4636 /// additional enum variants at any time. Adding new variants is not considered
4637 /// a breaking change. Applications should write their code in anticipation of:
4638 ///
4639 /// - New values appearing in future releases of the client library, **and**
4640 /// - New values received dynamically, without application changes.
4641 ///
4642 /// Please consult the [Working with enums] section in the user guide for some
4643 /// guidelines.
4644 ///
4645 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4646 #[derive(Clone, Debug, PartialEq)]
4647 #[non_exhaustive]
4648 pub enum RequirementMode {
4649 /// Unspecified requirement mode. This value should never be used.
4650 Unspecified,
4651 /// In this mode, all "dependent" shipments must share the same vehicle as at
4652 /// least one of their "required" shipments.
4653 PerformedBySameVehicle,
4654 /// With the `IN_SAME_VEHICLE_AT_PICKUP_TIME` mode, all "dependent"
4655 /// shipments need to have at least one "required" shipment on their vehicle
4656 /// at the time of their pickup.
4657 ///
4658 /// A "dependent" shipment pickup must therefore have either:
4659 ///
4660 /// * A delivery-only "required" shipment delivered on the route after, or
4661 /// * A "required" shipment picked up on the route before it, and if the
4662 /// "required" shipment has a delivery, this delivery must be performed
4663 /// after the "dependent" shipment's pickup.
4664 InSameVehicleAtPickupTime,
4665 /// Same as before, except the "dependent" shipments need to have a
4666 /// "required" shipment on their vehicle at the time of their *delivery*.
4667 InSameVehicleAtDeliveryTime,
4668 /// If set, the enum was initialized with an unknown value.
4669 ///
4670 /// Applications can examine the value using [RequirementMode::value] or
4671 /// [RequirementMode::name].
4672 UnknownValue(requirement_mode::UnknownValue),
4673 }
4674
4675 #[doc(hidden)]
4676 pub mod requirement_mode {
4677 #[allow(unused_imports)]
4678 use super::*;
4679 #[derive(Clone, Debug, PartialEq)]
4680 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4681 }
4682
4683 impl RequirementMode {
4684 /// Gets the enum value.
4685 ///
4686 /// Returns `None` if the enum contains an unknown value deserialized from
4687 /// the string representation of enums.
4688 pub fn value(&self) -> std::option::Option<i32> {
4689 match self {
4690 Self::Unspecified => std::option::Option::Some(0),
4691 Self::PerformedBySameVehicle => std::option::Option::Some(1),
4692 Self::InSameVehicleAtPickupTime => std::option::Option::Some(2),
4693 Self::InSameVehicleAtDeliveryTime => std::option::Option::Some(3),
4694 Self::UnknownValue(u) => u.0.value(),
4695 }
4696 }
4697
4698 /// Gets the enum value as a string.
4699 ///
4700 /// Returns `None` if the enum contains an unknown value deserialized from
4701 /// the integer representation of enums.
4702 pub fn name(&self) -> std::option::Option<&str> {
4703 match self {
4704 Self::Unspecified => std::option::Option::Some("REQUIREMENT_MODE_UNSPECIFIED"),
4705 Self::PerformedBySameVehicle => {
4706 std::option::Option::Some("PERFORMED_BY_SAME_VEHICLE")
4707 }
4708 Self::InSameVehicleAtPickupTime => {
4709 std::option::Option::Some("IN_SAME_VEHICLE_AT_PICKUP_TIME")
4710 }
4711 Self::InSameVehicleAtDeliveryTime => {
4712 std::option::Option::Some("IN_SAME_VEHICLE_AT_DELIVERY_TIME")
4713 }
4714 Self::UnknownValue(u) => u.0.name(),
4715 }
4716 }
4717 }
4718
4719 impl std::default::Default for RequirementMode {
4720 fn default() -> Self {
4721 use std::convert::From;
4722 Self::from(0)
4723 }
4724 }
4725
4726 impl std::fmt::Display for RequirementMode {
4727 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4728 wkt::internal::display_enum(f, self.name(), self.value())
4729 }
4730 }
4731
4732 impl std::convert::From<i32> for RequirementMode {
4733 fn from(value: i32) -> Self {
4734 match value {
4735 0 => Self::Unspecified,
4736 1 => Self::PerformedBySameVehicle,
4737 2 => Self::InSameVehicleAtPickupTime,
4738 3 => Self::InSameVehicleAtDeliveryTime,
4739 _ => Self::UnknownValue(requirement_mode::UnknownValue(
4740 wkt::internal::UnknownEnumValue::Integer(value),
4741 )),
4742 }
4743 }
4744 }
4745
4746 impl std::convert::From<&str> for RequirementMode {
4747 fn from(value: &str) -> Self {
4748 use std::string::ToString;
4749 match value {
4750 "REQUIREMENT_MODE_UNSPECIFIED" => Self::Unspecified,
4751 "PERFORMED_BY_SAME_VEHICLE" => Self::PerformedBySameVehicle,
4752 "IN_SAME_VEHICLE_AT_PICKUP_TIME" => Self::InSameVehicleAtPickupTime,
4753 "IN_SAME_VEHICLE_AT_DELIVERY_TIME" => Self::InSameVehicleAtDeliveryTime,
4754 _ => Self::UnknownValue(requirement_mode::UnknownValue(
4755 wkt::internal::UnknownEnumValue::String(value.to_string()),
4756 )),
4757 }
4758 }
4759 }
4760
4761 impl serde::ser::Serialize for RequirementMode {
4762 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4763 where
4764 S: serde::Serializer,
4765 {
4766 match self {
4767 Self::Unspecified => serializer.serialize_i32(0),
4768 Self::PerformedBySameVehicle => serializer.serialize_i32(1),
4769 Self::InSameVehicleAtPickupTime => serializer.serialize_i32(2),
4770 Self::InSameVehicleAtDeliveryTime => serializer.serialize_i32(3),
4771 Self::UnknownValue(u) => u.0.serialize(serializer),
4772 }
4773 }
4774 }
4775
4776 impl<'de> serde::de::Deserialize<'de> for RequirementMode {
4777 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4778 where
4779 D: serde::Deserializer<'de>,
4780 {
4781 deserializer.deserialize_any(wkt::internal::EnumVisitor::<RequirementMode>::new(
4782 ".google.cloud.optimization.v1.ShipmentTypeRequirement.RequirementMode",
4783 ))
4784 }
4785 }
4786}
4787
4788/// Encapsulates a set of optional conditions to satisfy when calculating
4789/// vehicle routes. This is similar to `RouteModifiers` in the Google Maps
4790/// Platform API; see:
4791/// <https://developers.google.com/maps/documentation/routes/reference/rest/v2/RouteModifiers>.
4792#[derive(Clone, Default, PartialEq)]
4793#[non_exhaustive]
4794pub struct RouteModifiers {
4795 /// Specifies whether to avoid toll roads where reasonable. Preference will be
4796 /// given to routes not containing toll roads. Applies only to motorized travel
4797 /// modes.
4798 pub avoid_tolls: bool,
4799
4800 /// Specifies whether to avoid highways where reasonable. Preference will be
4801 /// given to routes not containing highways. Applies only to motorized travel
4802 /// modes.
4803 pub avoid_highways: bool,
4804
4805 /// Specifies whether to avoid ferries where reasonable. Preference will be
4806 /// given to routes not containing travel by ferries. Applies only to motorized
4807 /// travel modes.
4808 pub avoid_ferries: bool,
4809
4810 /// Optional. Specifies whether to avoid navigating indoors where reasonable.
4811 /// Preference will be given to routes not containing indoor navigation.
4812 /// Applies only to the `WALKING` travel mode.
4813 pub avoid_indoor: bool,
4814
4815 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4816}
4817
4818impl RouteModifiers {
4819 /// Creates a new default instance.
4820 pub fn new() -> Self {
4821 std::default::Default::default()
4822 }
4823
4824 /// Sets the value of [avoid_tolls][crate::model::RouteModifiers::avoid_tolls].
4825 ///
4826 /// # Example
4827 /// ```ignore,no_run
4828 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4829 /// let x = RouteModifiers::new().set_avoid_tolls(true);
4830 /// ```
4831 pub fn set_avoid_tolls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4832 self.avoid_tolls = v.into();
4833 self
4834 }
4835
4836 /// Sets the value of [avoid_highways][crate::model::RouteModifiers::avoid_highways].
4837 ///
4838 /// # Example
4839 /// ```ignore,no_run
4840 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4841 /// let x = RouteModifiers::new().set_avoid_highways(true);
4842 /// ```
4843 pub fn set_avoid_highways<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4844 self.avoid_highways = v.into();
4845 self
4846 }
4847
4848 /// Sets the value of [avoid_ferries][crate::model::RouteModifiers::avoid_ferries].
4849 ///
4850 /// # Example
4851 /// ```ignore,no_run
4852 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4853 /// let x = RouteModifiers::new().set_avoid_ferries(true);
4854 /// ```
4855 pub fn set_avoid_ferries<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4856 self.avoid_ferries = v.into();
4857 self
4858 }
4859
4860 /// Sets the value of [avoid_indoor][crate::model::RouteModifiers::avoid_indoor].
4861 ///
4862 /// # Example
4863 /// ```ignore,no_run
4864 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4865 /// let x = RouteModifiers::new().set_avoid_indoor(true);
4866 /// ```
4867 pub fn set_avoid_indoor<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4868 self.avoid_indoor = v.into();
4869 self
4870 }
4871}
4872
4873impl wkt::message::Message for RouteModifiers {
4874 fn typename() -> &'static str {
4875 "type.googleapis.com/google.cloud.optimization.v1.RouteModifiers"
4876 }
4877}
4878
4879/// Models a vehicle in a shipment problem. Solving a shipment problem will
4880/// build a route starting from `start_location` and ending at `end_location`
4881/// for this vehicle. A route is a sequence of visits (see `ShipmentRoute`).
4882#[derive(Clone, Default, PartialEq)]
4883#[non_exhaustive]
4884pub struct Vehicle {
4885 /// The travel mode which affects the roads usable by the vehicle and its
4886 /// speed. See also `travel_duration_multiple`.
4887 pub travel_mode: crate::model::vehicle::TravelMode,
4888
4889 /// Optional. A set of conditions to satisfy that affect the way routes are
4890 /// calculated for the given vehicle.
4891 pub route_modifiers: std::option::Option<crate::model::RouteModifiers>,
4892
4893 /// Geographic location where the vehicle starts before picking up any
4894 /// shipments. If not specified, the vehicle starts at its first pickup.
4895 /// If the shipment model has duration and distance matrices, `start_location`
4896 /// must not be specified.
4897 pub start_location: std::option::Option<google_cloud_type::model::LatLng>,
4898
4899 /// Waypoint representing a geographic location where the vehicle starts before
4900 /// picking up any shipments. If neither `start_waypoint` nor `start_location`
4901 /// is specified, the vehicle starts at its first pickup.
4902 /// If the shipment model has duration and distance matrices, `start_waypoint`
4903 /// must not be specified.
4904 pub start_waypoint: std::option::Option<crate::model::Waypoint>,
4905
4906 /// Geographic location where the vehicle ends after it has completed its last
4907 /// `VisitRequest`. If not specified the vehicle's `ShipmentRoute` ends
4908 /// immediately when it completes its last `VisitRequest`.
4909 /// If the shipment model has duration and distance matrices, `end_location`
4910 /// must not be specified.
4911 pub end_location: std::option::Option<google_cloud_type::model::LatLng>,
4912
4913 /// Waypoint representing a geographic location where the vehicle ends after
4914 /// it has completed its last `VisitRequest`. If neither `end_waypoint` nor
4915 /// `end_location` is specified, the vehicle's `ShipmentRoute` ends immediately
4916 /// when it completes its last `VisitRequest`.
4917 /// If the shipment model has duration and distance matrices, `end_waypoint`
4918 /// must not be specified.
4919 pub end_waypoint: std::option::Option<crate::model::Waypoint>,
4920
4921 /// Specifies tags attached to the start of the vehicle's route.
4922 ///
4923 /// Empty or duplicate strings are not allowed.
4924 pub start_tags: std::vec::Vec<std::string::String>,
4925
4926 /// Specifies tags attached to the end of the vehicle's route.
4927 ///
4928 /// Empty or duplicate strings are not allowed.
4929 pub end_tags: std::vec::Vec<std::string::String>,
4930
4931 /// Time windows during which the vehicle may depart its start location.
4932 /// They must be within the global time limits (see
4933 /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
4934 /// fields). If unspecified, there is no limitation besides those global time
4935 /// limits.
4936 ///
4937 /// Time windows belonging to the same repeated field must be disjoint, i.e. no
4938 /// time window can overlap with or be adjacent to another, and they must be in
4939 /// chronological order.
4940 ///
4941 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
4942 /// there is a single time window.
4943 ///
4944 /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
4945 pub start_time_windows: std::vec::Vec<crate::model::TimeWindow>,
4946
4947 /// Time windows during which the vehicle may arrive at its end location.
4948 /// They must be within the global time limits (see
4949 /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
4950 /// fields). If unspecified, there is no limitation besides those global time
4951 /// limits.
4952 ///
4953 /// Time windows belonging to the same repeated field must be disjoint, i.e. no
4954 /// time window can overlap with or be adjacent to another, and they must be in
4955 /// chronological order.
4956 ///
4957 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
4958 /// there is a single time window.
4959 ///
4960 /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
4961 pub end_time_windows: std::vec::Vec<crate::model::TimeWindow>,
4962
4963 /// Specifies a multiplicative factor that can be used to increase or decrease
4964 /// travel times of this vehicle. For example, setting this to 2.0 means
4965 /// that this vehicle is slower and has travel times that are twice what they
4966 /// are for standard vehicles. This multiple does not affect visit durations.
4967 /// It does affect cost if `cost_per_hour` or `cost_per_traveled_hour` are
4968 /// specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle
4969 /// is standard, and this multiple is considered 1.0.
4970 ///
4971 /// WARNING: Travel times will be rounded to the nearest second after this
4972 /// multiple is applied but before performing any numerical operations, thus,
4973 /// a small multiple may result in a loss of precision.
4974 ///
4975 /// See also `extra_visit_duration_for_visit_type` below.
4976 pub travel_duration_multiple: std::option::Option<f64>,
4977
4978 /// Unloading policy enforced on the vehicle.
4979 pub unloading_policy: crate::model::vehicle::UnloadingPolicy,
4980
4981 /// Capacities of the vehicle (weight, volume, # of pallets for example).
4982 /// The keys in the map are the identifiers of the type of load, consistent
4983 /// with the keys of the
4984 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
4985 /// field. If a given key is absent from this map, the corresponding capacity
4986 /// is considered to be limitless.
4987 ///
4988 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
4989 pub load_limits:
4990 std::collections::HashMap<std::string::String, crate::model::vehicle::LoadLimit>,
4991
4992 /// Vehicle costs: all costs add up and must be in the same unit as
4993 /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
4994 ///
4995 /// Cost per hour of the vehicle route. This cost is applied to the total time
4996 /// taken by the route, and includes travel time, waiting time, and visit time.
4997 /// Using `cost_per_hour` instead of just `cost_per_traveled_hour` may result
4998 /// in additional latency.
4999 ///
5000 /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
5001 pub cost_per_hour: f64,
5002
5003 /// Cost per traveled hour of the vehicle route. This cost is applied only to
5004 /// travel time taken by the route (i.e., that reported in
5005 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]),
5006 /// and excludes waiting time and visit time.
5007 ///
5008 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
5009 pub cost_per_traveled_hour: f64,
5010
5011 /// Cost per kilometer of the vehicle route. This cost is applied to the
5012 /// distance reported in the
5013 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
5014 /// and does not apply to any distance implicitly traveled from the
5015 /// `arrival_location` to the `departure_location` of a single `VisitRequest`.
5016 ///
5017 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
5018 pub cost_per_kilometer: f64,
5019
5020 /// Fixed cost applied if this vehicle is used to handle a shipment.
5021 pub fixed_cost: f64,
5022
5023 /// This field only applies to vehicles when their route does not serve any
5024 /// shipments. It indicates if the vehicle should be considered as used or not
5025 /// in this case.
5026 ///
5027 /// If true, the vehicle goes from its start to its end location even if it
5028 /// doesn't serve any shipments, and time and distance costs resulting from its
5029 /// start --> end travel are taken into account.
5030 ///
5031 /// Otherwise, it doesn't travel from its start to its end location, and no
5032 /// `break_rule` or delay (from `TransitionAttributes`) are scheduled for this
5033 /// vehicle. In this case, the vehicle's `ShipmentRoute` doesn't contain any
5034 /// information except for the vehicle index and label.
5035 pub used_if_route_is_empty: bool,
5036
5037 /// Limit applied to the total duration of the vehicle's route. In a given
5038 /// `OptimizeToursResponse`, the route duration of a vehicle is the
5039 /// difference between its `vehicle_end_time` and `vehicle_start_time`.
5040 pub route_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
5041
5042 /// Limit applied to the travel duration of the vehicle's route. In a given
5043 /// `OptimizeToursResponse`, the route travel duration is the sum of all its
5044 /// [transitions.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration].
5045 ///
5046 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
5047 pub travel_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
5048
5049 /// Limit applied to the total distance of the vehicle's route. In a given
5050 /// `OptimizeToursResponse`, the route distance is the sum of all its
5051 /// [transitions.travel_distance_meters][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters].
5052 ///
5053 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters]: crate::model::shipment_route::Transition::travel_distance_meters
5054 pub route_distance_limit: std::option::Option<crate::model::DistanceLimit>,
5055
5056 /// Specifies a map from visit_types strings to durations. The duration is time
5057 /// in addition to
5058 /// [VisitRequest.duration][google.cloud.optimization.v1.Shipment.VisitRequest.duration]
5059 /// to be taken at visits with the specified `visit_types`. This extra visit
5060 /// duration adds cost if `cost_per_hour` is specified. Keys (i.e.
5061 /// `visit_types`) cannot be empty strings.
5062 ///
5063 /// If a visit request has multiple types, a duration will be added for each
5064 /// type in the map.
5065 ///
5066 /// [google.cloud.optimization.v1.Shipment.VisitRequest.duration]: crate::model::shipment::VisitRequest::duration
5067 pub extra_visit_duration_for_visit_type:
5068 std::collections::HashMap<std::string::String, wkt::Duration>,
5069
5070 /// Describes the break schedule to be enforced on this vehicle.
5071 /// If empty, no breaks will be scheduled for this vehicle.
5072 pub break_rule: std::option::Option<crate::model::BreakRule>,
5073
5074 /// Specifies a label for this vehicle. This label is reported in the response
5075 /// as the `vehicle_label` of the corresponding
5076 /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
5077 ///
5078 /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
5079 pub label: std::string::String,
5080
5081 /// If true, `used_if_route_is_empty` must be false, and this vehicle will
5082 /// remain unused.
5083 ///
5084 /// If a shipment is performed by an ignored vehicle in
5085 /// `injected_first_solution_routes`, it is skipped in the first solution but
5086 /// is free to be performed in the response.
5087 ///
5088 /// If a shipment is performed by an ignored vehicle in
5089 /// `injected_solution_constraint` and any related pickup/delivery is
5090 /// constrained to remain on the vehicle (i.e., not relaxed to level
5091 /// `RELAX_ALL_AFTER_THRESHOLD`), it is skipped in the response.
5092 /// If a shipment has a non-empty `allowed_vehicle_indices` field and all of
5093 /// the allowed vehicles are ignored, it is skipped in the response.
5094 pub ignore: bool,
5095
5096 /// Deprecated: No longer used.
5097 /// Indices in the `break_rule` field in the source
5098 /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel]. They
5099 /// correspond to break rules enforced on the vehicle.
5100 ///
5101 /// As of 2018/03, at most one rule index per vehicle can be specified.
5102 ///
5103 /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
5104 #[deprecated]
5105 pub break_rule_indices: std::vec::Vec<i32>,
5106
5107 /// Deprecated: Use
5108 /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits]
5109 /// instead.
5110 ///
5111 /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
5112 #[deprecated]
5113 pub capacities: std::vec::Vec<crate::model::CapacityQuantity>,
5114
5115 /// Deprecated: Use
5116 /// [Vehicle.LoadLimit.start_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]
5117 /// instead.
5118 ///
5119 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]: crate::model::vehicle::LoadLimit::start_load_interval
5120 #[deprecated]
5121 pub start_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
5122
5123 /// Deprecated: Use
5124 /// [Vehicle.LoadLimit.end_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]
5125 /// instead.
5126 ///
5127 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]: crate::model::vehicle::LoadLimit::end_load_interval
5128 #[deprecated]
5129 pub end_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
5130
5131 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5132}
5133
5134impl Vehicle {
5135 /// Creates a new default instance.
5136 pub fn new() -> Self {
5137 std::default::Default::default()
5138 }
5139
5140 /// Sets the value of [travel_mode][crate::model::Vehicle::travel_mode].
5141 ///
5142 /// # Example
5143 /// ```ignore,no_run
5144 /// # use google_cloud_optimization_v1::model::Vehicle;
5145 /// use google_cloud_optimization_v1::model::vehicle::TravelMode;
5146 /// let x0 = Vehicle::new().set_travel_mode(TravelMode::Driving);
5147 /// let x1 = Vehicle::new().set_travel_mode(TravelMode::Walking);
5148 /// ```
5149 pub fn set_travel_mode<T: std::convert::Into<crate::model::vehicle::TravelMode>>(
5150 mut self,
5151 v: T,
5152 ) -> Self {
5153 self.travel_mode = v.into();
5154 self
5155 }
5156
5157 /// Sets the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
5158 ///
5159 /// # Example
5160 /// ```ignore,no_run
5161 /// # use google_cloud_optimization_v1::model::Vehicle;
5162 /// use google_cloud_optimization_v1::model::RouteModifiers;
5163 /// let x = Vehicle::new().set_route_modifiers(RouteModifiers::default()/* use setters */);
5164 /// ```
5165 pub fn set_route_modifiers<T>(mut self, v: T) -> Self
5166 where
5167 T: std::convert::Into<crate::model::RouteModifiers>,
5168 {
5169 self.route_modifiers = std::option::Option::Some(v.into());
5170 self
5171 }
5172
5173 /// Sets or clears the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
5174 ///
5175 /// # Example
5176 /// ```ignore,no_run
5177 /// # use google_cloud_optimization_v1::model::Vehicle;
5178 /// use google_cloud_optimization_v1::model::RouteModifiers;
5179 /// let x = Vehicle::new().set_or_clear_route_modifiers(Some(RouteModifiers::default()/* use setters */));
5180 /// let x = Vehicle::new().set_or_clear_route_modifiers(None::<RouteModifiers>);
5181 /// ```
5182 pub fn set_or_clear_route_modifiers<T>(mut self, v: std::option::Option<T>) -> Self
5183 where
5184 T: std::convert::Into<crate::model::RouteModifiers>,
5185 {
5186 self.route_modifiers = v.map(|x| x.into());
5187 self
5188 }
5189
5190 /// Sets the value of [start_location][crate::model::Vehicle::start_location].
5191 ///
5192 /// # Example
5193 /// ```ignore,no_run
5194 /// # use google_cloud_optimization_v1::model::Vehicle;
5195 /// use google_cloud_type::model::LatLng;
5196 /// let x = Vehicle::new().set_start_location(LatLng::default()/* use setters */);
5197 /// ```
5198 pub fn set_start_location<T>(mut self, v: T) -> Self
5199 where
5200 T: std::convert::Into<google_cloud_type::model::LatLng>,
5201 {
5202 self.start_location = std::option::Option::Some(v.into());
5203 self
5204 }
5205
5206 /// Sets or clears the value of [start_location][crate::model::Vehicle::start_location].
5207 ///
5208 /// # Example
5209 /// ```ignore,no_run
5210 /// # use google_cloud_optimization_v1::model::Vehicle;
5211 /// use google_cloud_type::model::LatLng;
5212 /// let x = Vehicle::new().set_or_clear_start_location(Some(LatLng::default()/* use setters */));
5213 /// let x = Vehicle::new().set_or_clear_start_location(None::<LatLng>);
5214 /// ```
5215 pub fn set_or_clear_start_location<T>(mut self, v: std::option::Option<T>) -> Self
5216 where
5217 T: std::convert::Into<google_cloud_type::model::LatLng>,
5218 {
5219 self.start_location = v.map(|x| x.into());
5220 self
5221 }
5222
5223 /// Sets the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
5224 ///
5225 /// # Example
5226 /// ```ignore,no_run
5227 /// # use google_cloud_optimization_v1::model::Vehicle;
5228 /// use google_cloud_optimization_v1::model::Waypoint;
5229 /// let x = Vehicle::new().set_start_waypoint(Waypoint::default()/* use setters */);
5230 /// ```
5231 pub fn set_start_waypoint<T>(mut self, v: T) -> Self
5232 where
5233 T: std::convert::Into<crate::model::Waypoint>,
5234 {
5235 self.start_waypoint = std::option::Option::Some(v.into());
5236 self
5237 }
5238
5239 /// Sets or clears the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
5240 ///
5241 /// # Example
5242 /// ```ignore,no_run
5243 /// # use google_cloud_optimization_v1::model::Vehicle;
5244 /// use google_cloud_optimization_v1::model::Waypoint;
5245 /// let x = Vehicle::new().set_or_clear_start_waypoint(Some(Waypoint::default()/* use setters */));
5246 /// let x = Vehicle::new().set_or_clear_start_waypoint(None::<Waypoint>);
5247 /// ```
5248 pub fn set_or_clear_start_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
5249 where
5250 T: std::convert::Into<crate::model::Waypoint>,
5251 {
5252 self.start_waypoint = v.map(|x| x.into());
5253 self
5254 }
5255
5256 /// Sets the value of [end_location][crate::model::Vehicle::end_location].
5257 ///
5258 /// # Example
5259 /// ```ignore,no_run
5260 /// # use google_cloud_optimization_v1::model::Vehicle;
5261 /// use google_cloud_type::model::LatLng;
5262 /// let x = Vehicle::new().set_end_location(LatLng::default()/* use setters */);
5263 /// ```
5264 pub fn set_end_location<T>(mut self, v: T) -> Self
5265 where
5266 T: std::convert::Into<google_cloud_type::model::LatLng>,
5267 {
5268 self.end_location = std::option::Option::Some(v.into());
5269 self
5270 }
5271
5272 /// Sets or clears the value of [end_location][crate::model::Vehicle::end_location].
5273 ///
5274 /// # Example
5275 /// ```ignore,no_run
5276 /// # use google_cloud_optimization_v1::model::Vehicle;
5277 /// use google_cloud_type::model::LatLng;
5278 /// let x = Vehicle::new().set_or_clear_end_location(Some(LatLng::default()/* use setters */));
5279 /// let x = Vehicle::new().set_or_clear_end_location(None::<LatLng>);
5280 /// ```
5281 pub fn set_or_clear_end_location<T>(mut self, v: std::option::Option<T>) -> Self
5282 where
5283 T: std::convert::Into<google_cloud_type::model::LatLng>,
5284 {
5285 self.end_location = v.map(|x| x.into());
5286 self
5287 }
5288
5289 /// Sets the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
5290 ///
5291 /// # Example
5292 /// ```ignore,no_run
5293 /// # use google_cloud_optimization_v1::model::Vehicle;
5294 /// use google_cloud_optimization_v1::model::Waypoint;
5295 /// let x = Vehicle::new().set_end_waypoint(Waypoint::default()/* use setters */);
5296 /// ```
5297 pub fn set_end_waypoint<T>(mut self, v: T) -> Self
5298 where
5299 T: std::convert::Into<crate::model::Waypoint>,
5300 {
5301 self.end_waypoint = std::option::Option::Some(v.into());
5302 self
5303 }
5304
5305 /// Sets or clears the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
5306 ///
5307 /// # Example
5308 /// ```ignore,no_run
5309 /// # use google_cloud_optimization_v1::model::Vehicle;
5310 /// use google_cloud_optimization_v1::model::Waypoint;
5311 /// let x = Vehicle::new().set_or_clear_end_waypoint(Some(Waypoint::default()/* use setters */));
5312 /// let x = Vehicle::new().set_or_clear_end_waypoint(None::<Waypoint>);
5313 /// ```
5314 pub fn set_or_clear_end_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
5315 where
5316 T: std::convert::Into<crate::model::Waypoint>,
5317 {
5318 self.end_waypoint = v.map(|x| x.into());
5319 self
5320 }
5321
5322 /// Sets the value of [start_tags][crate::model::Vehicle::start_tags].
5323 ///
5324 /// # Example
5325 /// ```ignore,no_run
5326 /// # use google_cloud_optimization_v1::model::Vehicle;
5327 /// let x = Vehicle::new().set_start_tags(["a", "b", "c"]);
5328 /// ```
5329 pub fn set_start_tags<T, V>(mut self, v: T) -> Self
5330 where
5331 T: std::iter::IntoIterator<Item = V>,
5332 V: std::convert::Into<std::string::String>,
5333 {
5334 use std::iter::Iterator;
5335 self.start_tags = v.into_iter().map(|i| i.into()).collect();
5336 self
5337 }
5338
5339 /// Sets the value of [end_tags][crate::model::Vehicle::end_tags].
5340 ///
5341 /// # Example
5342 /// ```ignore,no_run
5343 /// # use google_cloud_optimization_v1::model::Vehicle;
5344 /// let x = Vehicle::new().set_end_tags(["a", "b", "c"]);
5345 /// ```
5346 pub fn set_end_tags<T, V>(mut self, v: T) -> Self
5347 where
5348 T: std::iter::IntoIterator<Item = V>,
5349 V: std::convert::Into<std::string::String>,
5350 {
5351 use std::iter::Iterator;
5352 self.end_tags = v.into_iter().map(|i| i.into()).collect();
5353 self
5354 }
5355
5356 /// Sets the value of [start_time_windows][crate::model::Vehicle::start_time_windows].
5357 ///
5358 /// # Example
5359 /// ```ignore,no_run
5360 /// # use google_cloud_optimization_v1::model::Vehicle;
5361 /// use google_cloud_optimization_v1::model::TimeWindow;
5362 /// let x = Vehicle::new()
5363 /// .set_start_time_windows([
5364 /// TimeWindow::default()/* use setters */,
5365 /// TimeWindow::default()/* use (different) setters */,
5366 /// ]);
5367 /// ```
5368 pub fn set_start_time_windows<T, V>(mut self, v: T) -> Self
5369 where
5370 T: std::iter::IntoIterator<Item = V>,
5371 V: std::convert::Into<crate::model::TimeWindow>,
5372 {
5373 use std::iter::Iterator;
5374 self.start_time_windows = v.into_iter().map(|i| i.into()).collect();
5375 self
5376 }
5377
5378 /// Sets the value of [end_time_windows][crate::model::Vehicle::end_time_windows].
5379 ///
5380 /// # Example
5381 /// ```ignore,no_run
5382 /// # use google_cloud_optimization_v1::model::Vehicle;
5383 /// use google_cloud_optimization_v1::model::TimeWindow;
5384 /// let x = Vehicle::new()
5385 /// .set_end_time_windows([
5386 /// TimeWindow::default()/* use setters */,
5387 /// TimeWindow::default()/* use (different) setters */,
5388 /// ]);
5389 /// ```
5390 pub fn set_end_time_windows<T, V>(mut self, v: T) -> Self
5391 where
5392 T: std::iter::IntoIterator<Item = V>,
5393 V: std::convert::Into<crate::model::TimeWindow>,
5394 {
5395 use std::iter::Iterator;
5396 self.end_time_windows = v.into_iter().map(|i| i.into()).collect();
5397 self
5398 }
5399
5400 /// Sets the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
5401 ///
5402 /// # Example
5403 /// ```ignore,no_run
5404 /// # use google_cloud_optimization_v1::model::Vehicle;
5405 /// let x = Vehicle::new().set_travel_duration_multiple(42.0);
5406 /// ```
5407 pub fn set_travel_duration_multiple<T>(mut self, v: T) -> Self
5408 where
5409 T: std::convert::Into<f64>,
5410 {
5411 self.travel_duration_multiple = std::option::Option::Some(v.into());
5412 self
5413 }
5414
5415 /// Sets or clears the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
5416 ///
5417 /// # Example
5418 /// ```ignore,no_run
5419 /// # use google_cloud_optimization_v1::model::Vehicle;
5420 /// let x = Vehicle::new().set_or_clear_travel_duration_multiple(Some(42.0));
5421 /// let x = Vehicle::new().set_or_clear_travel_duration_multiple(None::<f32>);
5422 /// ```
5423 pub fn set_or_clear_travel_duration_multiple<T>(mut self, v: std::option::Option<T>) -> Self
5424 where
5425 T: std::convert::Into<f64>,
5426 {
5427 self.travel_duration_multiple = v.map(|x| x.into());
5428 self
5429 }
5430
5431 /// Sets the value of [unloading_policy][crate::model::Vehicle::unloading_policy].
5432 ///
5433 /// # Example
5434 /// ```ignore,no_run
5435 /// # use google_cloud_optimization_v1::model::Vehicle;
5436 /// use google_cloud_optimization_v1::model::vehicle::UnloadingPolicy;
5437 /// let x0 = Vehicle::new().set_unloading_policy(UnloadingPolicy::LastInFirstOut);
5438 /// let x1 = Vehicle::new().set_unloading_policy(UnloadingPolicy::FirstInFirstOut);
5439 /// ```
5440 pub fn set_unloading_policy<T: std::convert::Into<crate::model::vehicle::UnloadingPolicy>>(
5441 mut self,
5442 v: T,
5443 ) -> Self {
5444 self.unloading_policy = v.into();
5445 self
5446 }
5447
5448 /// Sets the value of [load_limits][crate::model::Vehicle::load_limits].
5449 ///
5450 /// # Example
5451 /// ```ignore,no_run
5452 /// # use google_cloud_optimization_v1::model::Vehicle;
5453 /// use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5454 /// let x = Vehicle::new().set_load_limits([
5455 /// ("key0", LoadLimit::default()/* use setters */),
5456 /// ("key1", LoadLimit::default()/* use (different) setters */),
5457 /// ]);
5458 /// ```
5459 pub fn set_load_limits<T, K, V>(mut self, v: T) -> Self
5460 where
5461 T: std::iter::IntoIterator<Item = (K, V)>,
5462 K: std::convert::Into<std::string::String>,
5463 V: std::convert::Into<crate::model::vehicle::LoadLimit>,
5464 {
5465 use std::iter::Iterator;
5466 self.load_limits = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5467 self
5468 }
5469
5470 /// Sets the value of [cost_per_hour][crate::model::Vehicle::cost_per_hour].
5471 ///
5472 /// # Example
5473 /// ```ignore,no_run
5474 /// # use google_cloud_optimization_v1::model::Vehicle;
5475 /// let x = Vehicle::new().set_cost_per_hour(42.0);
5476 /// ```
5477 pub fn set_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5478 self.cost_per_hour = v.into();
5479 self
5480 }
5481
5482 /// Sets the value of [cost_per_traveled_hour][crate::model::Vehicle::cost_per_traveled_hour].
5483 ///
5484 /// # Example
5485 /// ```ignore,no_run
5486 /// # use google_cloud_optimization_v1::model::Vehicle;
5487 /// let x = Vehicle::new().set_cost_per_traveled_hour(42.0);
5488 /// ```
5489 pub fn set_cost_per_traveled_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5490 self.cost_per_traveled_hour = v.into();
5491 self
5492 }
5493
5494 /// Sets the value of [cost_per_kilometer][crate::model::Vehicle::cost_per_kilometer].
5495 ///
5496 /// # Example
5497 /// ```ignore,no_run
5498 /// # use google_cloud_optimization_v1::model::Vehicle;
5499 /// let x = Vehicle::new().set_cost_per_kilometer(42.0);
5500 /// ```
5501 pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5502 self.cost_per_kilometer = v.into();
5503 self
5504 }
5505
5506 /// Sets the value of [fixed_cost][crate::model::Vehicle::fixed_cost].
5507 ///
5508 /// # Example
5509 /// ```ignore,no_run
5510 /// # use google_cloud_optimization_v1::model::Vehicle;
5511 /// let x = Vehicle::new().set_fixed_cost(42.0);
5512 /// ```
5513 pub fn set_fixed_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5514 self.fixed_cost = v.into();
5515 self
5516 }
5517
5518 /// Sets the value of [used_if_route_is_empty][crate::model::Vehicle::used_if_route_is_empty].
5519 ///
5520 /// # Example
5521 /// ```ignore,no_run
5522 /// # use google_cloud_optimization_v1::model::Vehicle;
5523 /// let x = Vehicle::new().set_used_if_route_is_empty(true);
5524 /// ```
5525 pub fn set_used_if_route_is_empty<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5526 self.used_if_route_is_empty = v.into();
5527 self
5528 }
5529
5530 /// Sets the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
5531 ///
5532 /// # Example
5533 /// ```ignore,no_run
5534 /// # use google_cloud_optimization_v1::model::Vehicle;
5535 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5536 /// let x = Vehicle::new().set_route_duration_limit(DurationLimit::default()/* use setters */);
5537 /// ```
5538 pub fn set_route_duration_limit<T>(mut self, v: T) -> Self
5539 where
5540 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5541 {
5542 self.route_duration_limit = std::option::Option::Some(v.into());
5543 self
5544 }
5545
5546 /// Sets or clears the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
5547 ///
5548 /// # Example
5549 /// ```ignore,no_run
5550 /// # use google_cloud_optimization_v1::model::Vehicle;
5551 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5552 /// let x = Vehicle::new().set_or_clear_route_duration_limit(Some(DurationLimit::default()/* use setters */));
5553 /// let x = Vehicle::new().set_or_clear_route_duration_limit(None::<DurationLimit>);
5554 /// ```
5555 pub fn set_or_clear_route_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
5556 where
5557 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5558 {
5559 self.route_duration_limit = v.map(|x| x.into());
5560 self
5561 }
5562
5563 /// Sets the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
5564 ///
5565 /// # Example
5566 /// ```ignore,no_run
5567 /// # use google_cloud_optimization_v1::model::Vehicle;
5568 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5569 /// let x = Vehicle::new().set_travel_duration_limit(DurationLimit::default()/* use setters */);
5570 /// ```
5571 pub fn set_travel_duration_limit<T>(mut self, v: T) -> Self
5572 where
5573 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5574 {
5575 self.travel_duration_limit = std::option::Option::Some(v.into());
5576 self
5577 }
5578
5579 /// Sets or clears the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
5580 ///
5581 /// # Example
5582 /// ```ignore,no_run
5583 /// # use google_cloud_optimization_v1::model::Vehicle;
5584 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5585 /// let x = Vehicle::new().set_or_clear_travel_duration_limit(Some(DurationLimit::default()/* use setters */));
5586 /// let x = Vehicle::new().set_or_clear_travel_duration_limit(None::<DurationLimit>);
5587 /// ```
5588 pub fn set_or_clear_travel_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
5589 where
5590 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5591 {
5592 self.travel_duration_limit = v.map(|x| x.into());
5593 self
5594 }
5595
5596 /// Sets the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
5597 ///
5598 /// # Example
5599 /// ```ignore,no_run
5600 /// # use google_cloud_optimization_v1::model::Vehicle;
5601 /// use google_cloud_optimization_v1::model::DistanceLimit;
5602 /// let x = Vehicle::new().set_route_distance_limit(DistanceLimit::default()/* use setters */);
5603 /// ```
5604 pub fn set_route_distance_limit<T>(mut self, v: T) -> Self
5605 where
5606 T: std::convert::Into<crate::model::DistanceLimit>,
5607 {
5608 self.route_distance_limit = std::option::Option::Some(v.into());
5609 self
5610 }
5611
5612 /// Sets or clears the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
5613 ///
5614 /// # Example
5615 /// ```ignore,no_run
5616 /// # use google_cloud_optimization_v1::model::Vehicle;
5617 /// use google_cloud_optimization_v1::model::DistanceLimit;
5618 /// let x = Vehicle::new().set_or_clear_route_distance_limit(Some(DistanceLimit::default()/* use setters */));
5619 /// let x = Vehicle::new().set_or_clear_route_distance_limit(None::<DistanceLimit>);
5620 /// ```
5621 pub fn set_or_clear_route_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
5622 where
5623 T: std::convert::Into<crate::model::DistanceLimit>,
5624 {
5625 self.route_distance_limit = v.map(|x| x.into());
5626 self
5627 }
5628
5629 /// Sets the value of [extra_visit_duration_for_visit_type][crate::model::Vehicle::extra_visit_duration_for_visit_type].
5630 ///
5631 /// # Example
5632 /// ```ignore,no_run
5633 /// # use google_cloud_optimization_v1::model::Vehicle;
5634 /// use wkt::Duration;
5635 /// let x = Vehicle::new().set_extra_visit_duration_for_visit_type([
5636 /// ("key0", Duration::default()/* use setters */),
5637 /// ("key1", Duration::default()/* use (different) setters */),
5638 /// ]);
5639 /// ```
5640 pub fn set_extra_visit_duration_for_visit_type<T, K, V>(mut self, v: T) -> Self
5641 where
5642 T: std::iter::IntoIterator<Item = (K, V)>,
5643 K: std::convert::Into<std::string::String>,
5644 V: std::convert::Into<wkt::Duration>,
5645 {
5646 use std::iter::Iterator;
5647 self.extra_visit_duration_for_visit_type =
5648 v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5649 self
5650 }
5651
5652 /// Sets the value of [break_rule][crate::model::Vehicle::break_rule].
5653 ///
5654 /// # Example
5655 /// ```ignore,no_run
5656 /// # use google_cloud_optimization_v1::model::Vehicle;
5657 /// use google_cloud_optimization_v1::model::BreakRule;
5658 /// let x = Vehicle::new().set_break_rule(BreakRule::default()/* use setters */);
5659 /// ```
5660 pub fn set_break_rule<T>(mut self, v: T) -> Self
5661 where
5662 T: std::convert::Into<crate::model::BreakRule>,
5663 {
5664 self.break_rule = std::option::Option::Some(v.into());
5665 self
5666 }
5667
5668 /// Sets or clears the value of [break_rule][crate::model::Vehicle::break_rule].
5669 ///
5670 /// # Example
5671 /// ```ignore,no_run
5672 /// # use google_cloud_optimization_v1::model::Vehicle;
5673 /// use google_cloud_optimization_v1::model::BreakRule;
5674 /// let x = Vehicle::new().set_or_clear_break_rule(Some(BreakRule::default()/* use setters */));
5675 /// let x = Vehicle::new().set_or_clear_break_rule(None::<BreakRule>);
5676 /// ```
5677 pub fn set_or_clear_break_rule<T>(mut self, v: std::option::Option<T>) -> Self
5678 where
5679 T: std::convert::Into<crate::model::BreakRule>,
5680 {
5681 self.break_rule = v.map(|x| x.into());
5682 self
5683 }
5684
5685 /// Sets the value of [label][crate::model::Vehicle::label].
5686 ///
5687 /// # Example
5688 /// ```ignore,no_run
5689 /// # use google_cloud_optimization_v1::model::Vehicle;
5690 /// let x = Vehicle::new().set_label("example");
5691 /// ```
5692 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5693 self.label = v.into();
5694 self
5695 }
5696
5697 /// Sets the value of [ignore][crate::model::Vehicle::ignore].
5698 ///
5699 /// # Example
5700 /// ```ignore,no_run
5701 /// # use google_cloud_optimization_v1::model::Vehicle;
5702 /// let x = Vehicle::new().set_ignore(true);
5703 /// ```
5704 pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5705 self.ignore = v.into();
5706 self
5707 }
5708
5709 /// Sets the value of [break_rule_indices][crate::model::Vehicle::break_rule_indices].
5710 ///
5711 /// # Example
5712 /// ```ignore,no_run
5713 /// # use google_cloud_optimization_v1::model::Vehicle;
5714 /// let x = Vehicle::new().set_break_rule_indices([1, 2, 3]);
5715 /// ```
5716 #[deprecated]
5717 pub fn set_break_rule_indices<T, V>(mut self, v: T) -> Self
5718 where
5719 T: std::iter::IntoIterator<Item = V>,
5720 V: std::convert::Into<i32>,
5721 {
5722 use std::iter::Iterator;
5723 self.break_rule_indices = v.into_iter().map(|i| i.into()).collect();
5724 self
5725 }
5726
5727 /// Sets the value of [capacities][crate::model::Vehicle::capacities].
5728 ///
5729 /// # Example
5730 /// ```ignore,no_run
5731 /// # use google_cloud_optimization_v1::model::Vehicle;
5732 /// use google_cloud_optimization_v1::model::CapacityQuantity;
5733 /// let x = Vehicle::new()
5734 /// .set_capacities([
5735 /// CapacityQuantity::default()/* use setters */,
5736 /// CapacityQuantity::default()/* use (different) setters */,
5737 /// ]);
5738 /// ```
5739 #[deprecated]
5740 pub fn set_capacities<T, V>(mut self, v: T) -> Self
5741 where
5742 T: std::iter::IntoIterator<Item = V>,
5743 V: std::convert::Into<crate::model::CapacityQuantity>,
5744 {
5745 use std::iter::Iterator;
5746 self.capacities = v.into_iter().map(|i| i.into()).collect();
5747 self
5748 }
5749
5750 /// Sets the value of [start_load_intervals][crate::model::Vehicle::start_load_intervals].
5751 ///
5752 /// # Example
5753 /// ```ignore,no_run
5754 /// # use google_cloud_optimization_v1::model::Vehicle;
5755 /// use google_cloud_optimization_v1::model::CapacityQuantityInterval;
5756 /// let x = Vehicle::new()
5757 /// .set_start_load_intervals([
5758 /// CapacityQuantityInterval::default()/* use setters */,
5759 /// CapacityQuantityInterval::default()/* use (different) setters */,
5760 /// ]);
5761 /// ```
5762 #[deprecated]
5763 pub fn set_start_load_intervals<T, V>(mut self, v: T) -> Self
5764 where
5765 T: std::iter::IntoIterator<Item = V>,
5766 V: std::convert::Into<crate::model::CapacityQuantityInterval>,
5767 {
5768 use std::iter::Iterator;
5769 self.start_load_intervals = v.into_iter().map(|i| i.into()).collect();
5770 self
5771 }
5772
5773 /// Sets the value of [end_load_intervals][crate::model::Vehicle::end_load_intervals].
5774 ///
5775 /// # Example
5776 /// ```ignore,no_run
5777 /// # use google_cloud_optimization_v1::model::Vehicle;
5778 /// use google_cloud_optimization_v1::model::CapacityQuantityInterval;
5779 /// let x = Vehicle::new()
5780 /// .set_end_load_intervals([
5781 /// CapacityQuantityInterval::default()/* use setters */,
5782 /// CapacityQuantityInterval::default()/* use (different) setters */,
5783 /// ]);
5784 /// ```
5785 #[deprecated]
5786 pub fn set_end_load_intervals<T, V>(mut self, v: T) -> Self
5787 where
5788 T: std::iter::IntoIterator<Item = V>,
5789 V: std::convert::Into<crate::model::CapacityQuantityInterval>,
5790 {
5791 use std::iter::Iterator;
5792 self.end_load_intervals = v.into_iter().map(|i| i.into()).collect();
5793 self
5794 }
5795}
5796
5797impl wkt::message::Message for Vehicle {
5798 fn typename() -> &'static str {
5799 "type.googleapis.com/google.cloud.optimization.v1.Vehicle"
5800 }
5801}
5802
5803/// Defines additional types related to [Vehicle].
5804pub mod vehicle {
5805 #[allow(unused_imports)]
5806 use super::*;
5807
5808 /// Defines a load limit applying to a vehicle, e.g. "this truck may only
5809 /// carry up to 3500 kg". See
5810 /// [load_limits][google.cloud.optimization.v1.Vehicle.load_limits].
5811 ///
5812 /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
5813 #[derive(Clone, Default, PartialEq)]
5814 #[non_exhaustive]
5815 pub struct LoadLimit {
5816 /// The maximum acceptable amount of load.
5817 pub max_load: std::option::Option<i64>,
5818
5819 /// A soft limit of the load. See
5820 /// [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max].
5821 ///
5822 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
5823 pub soft_max_load: i64,
5824
5825 /// If the load ever exceeds
5826 /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]
5827 /// along this vehicle's route, the following cost penalty applies (only once
5828 /// per vehicle): (load -
5829 /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load])
5830 ///
5831 /// * [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. All costs
5832 /// add up and must be in the same unit as
5833 /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
5834 ///
5835 /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
5836 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
5837 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]: crate::model::vehicle::LoadLimit::soft_max_load
5838 pub cost_per_unit_above_soft_max: f64,
5839
5840 /// The acceptable load interval of the vehicle at the start of the route.
5841 pub start_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
5842
5843 /// The acceptable load interval of the vehicle at the end of the route.
5844 pub end_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
5845
5846 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5847 }
5848
5849 impl LoadLimit {
5850 /// Creates a new default instance.
5851 pub fn new() -> Self {
5852 std::default::Default::default()
5853 }
5854
5855 /// Sets the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
5856 ///
5857 /// # Example
5858 /// ```ignore,no_run
5859 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5860 /// let x = LoadLimit::new().set_max_load(42);
5861 /// ```
5862 pub fn set_max_load<T>(mut self, v: T) -> Self
5863 where
5864 T: std::convert::Into<i64>,
5865 {
5866 self.max_load = std::option::Option::Some(v.into());
5867 self
5868 }
5869
5870 /// Sets or clears the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
5871 ///
5872 /// # Example
5873 /// ```ignore,no_run
5874 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5875 /// let x = LoadLimit::new().set_or_clear_max_load(Some(42));
5876 /// let x = LoadLimit::new().set_or_clear_max_load(None::<i32>);
5877 /// ```
5878 pub fn set_or_clear_max_load<T>(mut self, v: std::option::Option<T>) -> Self
5879 where
5880 T: std::convert::Into<i64>,
5881 {
5882 self.max_load = v.map(|x| x.into());
5883 self
5884 }
5885
5886 /// Sets the value of [soft_max_load][crate::model::vehicle::LoadLimit::soft_max_load].
5887 ///
5888 /// # Example
5889 /// ```ignore,no_run
5890 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5891 /// let x = LoadLimit::new().set_soft_max_load(42);
5892 /// ```
5893 pub fn set_soft_max_load<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5894 self.soft_max_load = v.into();
5895 self
5896 }
5897
5898 /// Sets the value of [cost_per_unit_above_soft_max][crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max].
5899 ///
5900 /// # Example
5901 /// ```ignore,no_run
5902 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5903 /// let x = LoadLimit::new().set_cost_per_unit_above_soft_max(42.0);
5904 /// ```
5905 pub fn set_cost_per_unit_above_soft_max<T: std::convert::Into<f64>>(
5906 mut self,
5907 v: T,
5908 ) -> Self {
5909 self.cost_per_unit_above_soft_max = v.into();
5910 self
5911 }
5912
5913 /// Sets the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
5914 ///
5915 /// # Example
5916 /// ```ignore,no_run
5917 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5918 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5919 /// let x = LoadLimit::new().set_start_load_interval(Interval::default()/* use setters */);
5920 /// ```
5921 pub fn set_start_load_interval<T>(mut self, v: T) -> Self
5922 where
5923 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5924 {
5925 self.start_load_interval = std::option::Option::Some(v.into());
5926 self
5927 }
5928
5929 /// Sets or clears the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
5930 ///
5931 /// # Example
5932 /// ```ignore,no_run
5933 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5934 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5935 /// let x = LoadLimit::new().set_or_clear_start_load_interval(Some(Interval::default()/* use setters */));
5936 /// let x = LoadLimit::new().set_or_clear_start_load_interval(None::<Interval>);
5937 /// ```
5938 pub fn set_or_clear_start_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
5939 where
5940 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5941 {
5942 self.start_load_interval = v.map(|x| x.into());
5943 self
5944 }
5945
5946 /// Sets the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
5947 ///
5948 /// # Example
5949 /// ```ignore,no_run
5950 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5951 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5952 /// let x = LoadLimit::new().set_end_load_interval(Interval::default()/* use setters */);
5953 /// ```
5954 pub fn set_end_load_interval<T>(mut self, v: T) -> Self
5955 where
5956 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5957 {
5958 self.end_load_interval = std::option::Option::Some(v.into());
5959 self
5960 }
5961
5962 /// Sets or clears the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
5963 ///
5964 /// # Example
5965 /// ```ignore,no_run
5966 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5967 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5968 /// let x = LoadLimit::new().set_or_clear_end_load_interval(Some(Interval::default()/* use setters */));
5969 /// let x = LoadLimit::new().set_or_clear_end_load_interval(None::<Interval>);
5970 /// ```
5971 pub fn set_or_clear_end_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
5972 where
5973 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5974 {
5975 self.end_load_interval = v.map(|x| x.into());
5976 self
5977 }
5978 }
5979
5980 impl wkt::message::Message for LoadLimit {
5981 fn typename() -> &'static str {
5982 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit"
5983 }
5984 }
5985
5986 /// Defines additional types related to [LoadLimit].
5987 pub mod load_limit {
5988 #[allow(unused_imports)]
5989 use super::*;
5990
5991 /// Interval of acceptable load amounts.
5992 #[derive(Clone, Default, PartialEq)]
5993 #[non_exhaustive]
5994 pub struct Interval {
5995 /// A minimum acceptable load. Must be ≥ 0.
5996 /// If they're both specified,
5997 /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
5998 /// be ≤
5999 /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
6000 ///
6001 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
6002 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
6003 pub min: i64,
6004
6005 /// A maximum acceptable load. Must be ≥ 0. If unspecified, the maximum
6006 /// load is unrestricted by this message.
6007 /// If they're both specified,
6008 /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
6009 /// be ≤
6010 /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
6011 ///
6012 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
6013 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
6014 pub max: std::option::Option<i64>,
6015
6016 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6017 }
6018
6019 impl Interval {
6020 /// Creates a new default instance.
6021 pub fn new() -> Self {
6022 std::default::Default::default()
6023 }
6024
6025 /// Sets the value of [min][crate::model::vehicle::load_limit::Interval::min].
6026 ///
6027 /// # Example
6028 /// ```ignore,no_run
6029 /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6030 /// let x = Interval::new().set_min(42);
6031 /// ```
6032 pub fn set_min<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6033 self.min = v.into();
6034 self
6035 }
6036
6037 /// Sets the value of [max][crate::model::vehicle::load_limit::Interval::max].
6038 ///
6039 /// # Example
6040 /// ```ignore,no_run
6041 /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6042 /// let x = Interval::new().set_max(42);
6043 /// ```
6044 pub fn set_max<T>(mut self, v: T) -> Self
6045 where
6046 T: std::convert::Into<i64>,
6047 {
6048 self.max = std::option::Option::Some(v.into());
6049 self
6050 }
6051
6052 /// Sets or clears the value of [max][crate::model::vehicle::load_limit::Interval::max].
6053 ///
6054 /// # Example
6055 /// ```ignore,no_run
6056 /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6057 /// let x = Interval::new().set_or_clear_max(Some(42));
6058 /// let x = Interval::new().set_or_clear_max(None::<i32>);
6059 /// ```
6060 pub fn set_or_clear_max<T>(mut self, v: std::option::Option<T>) -> Self
6061 where
6062 T: std::convert::Into<i64>,
6063 {
6064 self.max = v.map(|x| x.into());
6065 self
6066 }
6067 }
6068
6069 impl wkt::message::Message for Interval {
6070 fn typename() -> &'static str {
6071 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit.Interval"
6072 }
6073 }
6074 }
6075
6076 /// A limit defining a maximum duration of the route of a vehicle. It can be
6077 /// either hard or soft.
6078 ///
6079 /// When a soft limit field is defined, both the soft max threshold and its
6080 /// associated cost must be defined together.
6081 #[derive(Clone, Default, PartialEq)]
6082 #[non_exhaustive]
6083 pub struct DurationLimit {
6084 /// A hard limit constraining the duration to be at most max_duration.
6085 pub max_duration: std::option::Option<wkt::Duration>,
6086
6087 /// A soft limit not enforcing a maximum duration limit, but when violated
6088 /// makes the route incur a cost. This cost adds up to other costs defined in
6089 /// the model, with the same unit.
6090 ///
6091 /// If defined, `soft_max_duration` must be nonnegative. If max_duration is
6092 /// also defined, `soft_max_duration` must be less than max_duration.
6093 pub soft_max_duration: std::option::Option<wkt::Duration>,
6094
6095 /// Cost per hour incurred if the `soft_max_duration` threshold is violated.
6096 /// The additional cost is 0 if the duration is under the threshold,
6097 /// otherwise the cost depends on the duration as follows:
6098 ///
6099 /// ```norust
6100 /// cost_per_hour_after_soft_max * (duration - soft_max_duration)
6101 /// ```
6102 ///
6103 /// The cost must be nonnegative.
6104 pub cost_per_hour_after_soft_max: std::option::Option<f64>,
6105
6106 /// A soft limit not enforcing a maximum duration limit, but when violated
6107 /// makes the route incur a cost, quadratic in the duration. This cost adds
6108 /// up to other costs defined in the model, with the same unit.
6109 ///
6110 /// If defined, `quadratic_soft_max_duration` must be nonnegative. If
6111 /// `max_duration` is also defined, `quadratic_soft_max_duration` must be
6112 /// less than `max_duration`, and the difference must be no larger than one
6113 /// day:
6114 ///
6115 /// `max_duration - quadratic_soft_max_duration <= 86400 seconds`
6116 pub quadratic_soft_max_duration: std::option::Option<wkt::Duration>,
6117
6118 /// Cost per square hour incurred if the
6119 /// `quadratic_soft_max_duration` threshold is violated.
6120 ///
6121 /// The additional cost is 0 if the duration is under the threshold,
6122 /// otherwise the cost depends on the duration as follows:
6123 ///
6124 /// ```norust
6125 /// cost_per_square_hour_after_quadratic_soft_max *
6126 /// (duration - quadratic_soft_max_duration)^2
6127 /// ```
6128 ///
6129 /// The cost must be nonnegative.
6130 pub cost_per_square_hour_after_quadratic_soft_max: std::option::Option<f64>,
6131
6132 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6133 }
6134
6135 impl DurationLimit {
6136 /// Creates a new default instance.
6137 pub fn new() -> Self {
6138 std::default::Default::default()
6139 }
6140
6141 /// Sets the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
6142 ///
6143 /// # Example
6144 /// ```ignore,no_run
6145 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6146 /// use wkt::Duration;
6147 /// let x = DurationLimit::new().set_max_duration(Duration::default()/* use setters */);
6148 /// ```
6149 pub fn set_max_duration<T>(mut self, v: T) -> Self
6150 where
6151 T: std::convert::Into<wkt::Duration>,
6152 {
6153 self.max_duration = std::option::Option::Some(v.into());
6154 self
6155 }
6156
6157 /// Sets or clears the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
6158 ///
6159 /// # Example
6160 /// ```ignore,no_run
6161 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6162 /// use wkt::Duration;
6163 /// let x = DurationLimit::new().set_or_clear_max_duration(Some(Duration::default()/* use setters */));
6164 /// let x = DurationLimit::new().set_or_clear_max_duration(None::<Duration>);
6165 /// ```
6166 pub fn set_or_clear_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
6167 where
6168 T: std::convert::Into<wkt::Duration>,
6169 {
6170 self.max_duration = v.map(|x| x.into());
6171 self
6172 }
6173
6174 /// Sets the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
6175 ///
6176 /// # Example
6177 /// ```ignore,no_run
6178 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6179 /// use wkt::Duration;
6180 /// let x = DurationLimit::new().set_soft_max_duration(Duration::default()/* use setters */);
6181 /// ```
6182 pub fn set_soft_max_duration<T>(mut self, v: T) -> Self
6183 where
6184 T: std::convert::Into<wkt::Duration>,
6185 {
6186 self.soft_max_duration = std::option::Option::Some(v.into());
6187 self
6188 }
6189
6190 /// Sets or clears the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
6191 ///
6192 /// # Example
6193 /// ```ignore,no_run
6194 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6195 /// use wkt::Duration;
6196 /// let x = DurationLimit::new().set_or_clear_soft_max_duration(Some(Duration::default()/* use setters */));
6197 /// let x = DurationLimit::new().set_or_clear_soft_max_duration(None::<Duration>);
6198 /// ```
6199 pub fn set_or_clear_soft_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
6200 where
6201 T: std::convert::Into<wkt::Duration>,
6202 {
6203 self.soft_max_duration = v.map(|x| x.into());
6204 self
6205 }
6206
6207 /// Sets the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
6208 ///
6209 /// # Example
6210 /// ```ignore,no_run
6211 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6212 /// let x = DurationLimit::new().set_cost_per_hour_after_soft_max(42.0);
6213 /// ```
6214 pub fn set_cost_per_hour_after_soft_max<T>(mut self, v: T) -> Self
6215 where
6216 T: std::convert::Into<f64>,
6217 {
6218 self.cost_per_hour_after_soft_max = std::option::Option::Some(v.into());
6219 self
6220 }
6221
6222 /// Sets or clears the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
6223 ///
6224 /// # Example
6225 /// ```ignore,no_run
6226 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6227 /// let x = DurationLimit::new().set_or_clear_cost_per_hour_after_soft_max(Some(42.0));
6228 /// let x = DurationLimit::new().set_or_clear_cost_per_hour_after_soft_max(None::<f32>);
6229 /// ```
6230 pub fn set_or_clear_cost_per_hour_after_soft_max<T>(
6231 mut self,
6232 v: std::option::Option<T>,
6233 ) -> Self
6234 where
6235 T: std::convert::Into<f64>,
6236 {
6237 self.cost_per_hour_after_soft_max = v.map(|x| x.into());
6238 self
6239 }
6240
6241 /// Sets the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
6242 ///
6243 /// # Example
6244 /// ```ignore,no_run
6245 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6246 /// use wkt::Duration;
6247 /// let x = DurationLimit::new().set_quadratic_soft_max_duration(Duration::default()/* use setters */);
6248 /// ```
6249 pub fn set_quadratic_soft_max_duration<T>(mut self, v: T) -> Self
6250 where
6251 T: std::convert::Into<wkt::Duration>,
6252 {
6253 self.quadratic_soft_max_duration = std::option::Option::Some(v.into());
6254 self
6255 }
6256
6257 /// Sets or clears the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
6258 ///
6259 /// # Example
6260 /// ```ignore,no_run
6261 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6262 /// use wkt::Duration;
6263 /// let x = DurationLimit::new().set_or_clear_quadratic_soft_max_duration(Some(Duration::default()/* use setters */));
6264 /// let x = DurationLimit::new().set_or_clear_quadratic_soft_max_duration(None::<Duration>);
6265 /// ```
6266 pub fn set_or_clear_quadratic_soft_max_duration<T>(
6267 mut self,
6268 v: std::option::Option<T>,
6269 ) -> Self
6270 where
6271 T: std::convert::Into<wkt::Duration>,
6272 {
6273 self.quadratic_soft_max_duration = v.map(|x| x.into());
6274 self
6275 }
6276
6277 /// Sets the value of [cost_per_square_hour_after_quadratic_soft_max][crate::model::vehicle::DurationLimit::cost_per_square_hour_after_quadratic_soft_max].
6278 ///
6279 /// # Example
6280 /// ```ignore,no_run
6281 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6282 /// let x = DurationLimit::new().set_cost_per_square_hour_after_quadratic_soft_max(42.0);
6283 /// ```
6284 pub fn set_cost_per_square_hour_after_quadratic_soft_max<T>(mut self, v: T) -> Self
6285 where
6286 T: std::convert::Into<f64>,
6287 {
6288 self.cost_per_square_hour_after_quadratic_soft_max =
6289 std::option::Option::Some(v.into());
6290 self
6291 }
6292
6293 /// 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].
6294 ///
6295 /// # Example
6296 /// ```ignore,no_run
6297 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6298 /// let x = DurationLimit::new().set_or_clear_cost_per_square_hour_after_quadratic_soft_max(Some(42.0));
6299 /// let x = DurationLimit::new().set_or_clear_cost_per_square_hour_after_quadratic_soft_max(None::<f32>);
6300 /// ```
6301 pub fn set_or_clear_cost_per_square_hour_after_quadratic_soft_max<T>(
6302 mut self,
6303 v: std::option::Option<T>,
6304 ) -> Self
6305 where
6306 T: std::convert::Into<f64>,
6307 {
6308 self.cost_per_square_hour_after_quadratic_soft_max = v.map(|x| x.into());
6309 self
6310 }
6311 }
6312
6313 impl wkt::message::Message for DurationLimit {
6314 fn typename() -> &'static str {
6315 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.DurationLimit"
6316 }
6317 }
6318
6319 /// Travel modes which can be used by vehicles.
6320 ///
6321 /// These should be a subset of the Google Maps Platform Routes Preferred API
6322 /// travel modes, see:
6323 /// <https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelMode>.
6324 ///
6325 /// # Working with unknown values
6326 ///
6327 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6328 /// additional enum variants at any time. Adding new variants is not considered
6329 /// a breaking change. Applications should write their code in anticipation of:
6330 ///
6331 /// - New values appearing in future releases of the client library, **and**
6332 /// - New values received dynamically, without application changes.
6333 ///
6334 /// Please consult the [Working with enums] section in the user guide for some
6335 /// guidelines.
6336 ///
6337 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6338 #[derive(Clone, Debug, PartialEq)]
6339 #[non_exhaustive]
6340 pub enum TravelMode {
6341 /// Unspecified travel mode, equivalent to `DRIVING`.
6342 Unspecified,
6343 /// Travel mode corresponding to driving directions (car, ...).
6344 Driving,
6345 /// Travel mode corresponding to walking directions.
6346 Walking,
6347 /// If set, the enum was initialized with an unknown value.
6348 ///
6349 /// Applications can examine the value using [TravelMode::value] or
6350 /// [TravelMode::name].
6351 UnknownValue(travel_mode::UnknownValue),
6352 }
6353
6354 #[doc(hidden)]
6355 pub mod travel_mode {
6356 #[allow(unused_imports)]
6357 use super::*;
6358 #[derive(Clone, Debug, PartialEq)]
6359 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6360 }
6361
6362 impl TravelMode {
6363 /// Gets the enum value.
6364 ///
6365 /// Returns `None` if the enum contains an unknown value deserialized from
6366 /// the string representation of enums.
6367 pub fn value(&self) -> std::option::Option<i32> {
6368 match self {
6369 Self::Unspecified => std::option::Option::Some(0),
6370 Self::Driving => std::option::Option::Some(1),
6371 Self::Walking => std::option::Option::Some(2),
6372 Self::UnknownValue(u) => u.0.value(),
6373 }
6374 }
6375
6376 /// Gets the enum value as a string.
6377 ///
6378 /// Returns `None` if the enum contains an unknown value deserialized from
6379 /// the integer representation of enums.
6380 pub fn name(&self) -> std::option::Option<&str> {
6381 match self {
6382 Self::Unspecified => std::option::Option::Some("TRAVEL_MODE_UNSPECIFIED"),
6383 Self::Driving => std::option::Option::Some("DRIVING"),
6384 Self::Walking => std::option::Option::Some("WALKING"),
6385 Self::UnknownValue(u) => u.0.name(),
6386 }
6387 }
6388 }
6389
6390 impl std::default::Default for TravelMode {
6391 fn default() -> Self {
6392 use std::convert::From;
6393 Self::from(0)
6394 }
6395 }
6396
6397 impl std::fmt::Display for TravelMode {
6398 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6399 wkt::internal::display_enum(f, self.name(), self.value())
6400 }
6401 }
6402
6403 impl std::convert::From<i32> for TravelMode {
6404 fn from(value: i32) -> Self {
6405 match value {
6406 0 => Self::Unspecified,
6407 1 => Self::Driving,
6408 2 => Self::Walking,
6409 _ => Self::UnknownValue(travel_mode::UnknownValue(
6410 wkt::internal::UnknownEnumValue::Integer(value),
6411 )),
6412 }
6413 }
6414 }
6415
6416 impl std::convert::From<&str> for TravelMode {
6417 fn from(value: &str) -> Self {
6418 use std::string::ToString;
6419 match value {
6420 "TRAVEL_MODE_UNSPECIFIED" => Self::Unspecified,
6421 "DRIVING" => Self::Driving,
6422 "WALKING" => Self::Walking,
6423 _ => Self::UnknownValue(travel_mode::UnknownValue(
6424 wkt::internal::UnknownEnumValue::String(value.to_string()),
6425 )),
6426 }
6427 }
6428 }
6429
6430 impl serde::ser::Serialize for TravelMode {
6431 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6432 where
6433 S: serde::Serializer,
6434 {
6435 match self {
6436 Self::Unspecified => serializer.serialize_i32(0),
6437 Self::Driving => serializer.serialize_i32(1),
6438 Self::Walking => serializer.serialize_i32(2),
6439 Self::UnknownValue(u) => u.0.serialize(serializer),
6440 }
6441 }
6442 }
6443
6444 impl<'de> serde::de::Deserialize<'de> for TravelMode {
6445 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6446 where
6447 D: serde::Deserializer<'de>,
6448 {
6449 deserializer.deserialize_any(wkt::internal::EnumVisitor::<TravelMode>::new(
6450 ".google.cloud.optimization.v1.Vehicle.TravelMode",
6451 ))
6452 }
6453 }
6454
6455 /// Policy on how a vehicle can be unloaded. Applies only to shipments having
6456 /// both a pickup and a delivery.
6457 ///
6458 /// Other shipments are free to occur anywhere on the route independent of
6459 /// `unloading_policy`.
6460 ///
6461 /// # Working with unknown values
6462 ///
6463 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6464 /// additional enum variants at any time. Adding new variants is not considered
6465 /// a breaking change. Applications should write their code in anticipation of:
6466 ///
6467 /// - New values appearing in future releases of the client library, **and**
6468 /// - New values received dynamically, without application changes.
6469 ///
6470 /// Please consult the [Working with enums] section in the user guide for some
6471 /// guidelines.
6472 ///
6473 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6474 #[derive(Clone, Debug, PartialEq)]
6475 #[non_exhaustive]
6476 pub enum UnloadingPolicy {
6477 /// Unspecified unloading policy; deliveries must just occur after their
6478 /// corresponding pickups.
6479 Unspecified,
6480 /// Deliveries must occur in reverse order of pickups
6481 LastInFirstOut,
6482 /// Deliveries must occur in the same order as pickups
6483 FirstInFirstOut,
6484 /// If set, the enum was initialized with an unknown value.
6485 ///
6486 /// Applications can examine the value using [UnloadingPolicy::value] or
6487 /// [UnloadingPolicy::name].
6488 UnknownValue(unloading_policy::UnknownValue),
6489 }
6490
6491 #[doc(hidden)]
6492 pub mod unloading_policy {
6493 #[allow(unused_imports)]
6494 use super::*;
6495 #[derive(Clone, Debug, PartialEq)]
6496 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6497 }
6498
6499 impl UnloadingPolicy {
6500 /// Gets the enum value.
6501 ///
6502 /// Returns `None` if the enum contains an unknown value deserialized from
6503 /// the string representation of enums.
6504 pub fn value(&self) -> std::option::Option<i32> {
6505 match self {
6506 Self::Unspecified => std::option::Option::Some(0),
6507 Self::LastInFirstOut => std::option::Option::Some(1),
6508 Self::FirstInFirstOut => std::option::Option::Some(2),
6509 Self::UnknownValue(u) => u.0.value(),
6510 }
6511 }
6512
6513 /// Gets the enum value as a string.
6514 ///
6515 /// Returns `None` if the enum contains an unknown value deserialized from
6516 /// the integer representation of enums.
6517 pub fn name(&self) -> std::option::Option<&str> {
6518 match self {
6519 Self::Unspecified => std::option::Option::Some("UNLOADING_POLICY_UNSPECIFIED"),
6520 Self::LastInFirstOut => std::option::Option::Some("LAST_IN_FIRST_OUT"),
6521 Self::FirstInFirstOut => std::option::Option::Some("FIRST_IN_FIRST_OUT"),
6522 Self::UnknownValue(u) => u.0.name(),
6523 }
6524 }
6525 }
6526
6527 impl std::default::Default for UnloadingPolicy {
6528 fn default() -> Self {
6529 use std::convert::From;
6530 Self::from(0)
6531 }
6532 }
6533
6534 impl std::fmt::Display for UnloadingPolicy {
6535 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6536 wkt::internal::display_enum(f, self.name(), self.value())
6537 }
6538 }
6539
6540 impl std::convert::From<i32> for UnloadingPolicy {
6541 fn from(value: i32) -> Self {
6542 match value {
6543 0 => Self::Unspecified,
6544 1 => Self::LastInFirstOut,
6545 2 => Self::FirstInFirstOut,
6546 _ => Self::UnknownValue(unloading_policy::UnknownValue(
6547 wkt::internal::UnknownEnumValue::Integer(value),
6548 )),
6549 }
6550 }
6551 }
6552
6553 impl std::convert::From<&str> for UnloadingPolicy {
6554 fn from(value: &str) -> Self {
6555 use std::string::ToString;
6556 match value {
6557 "UNLOADING_POLICY_UNSPECIFIED" => Self::Unspecified,
6558 "LAST_IN_FIRST_OUT" => Self::LastInFirstOut,
6559 "FIRST_IN_FIRST_OUT" => Self::FirstInFirstOut,
6560 _ => Self::UnknownValue(unloading_policy::UnknownValue(
6561 wkt::internal::UnknownEnumValue::String(value.to_string()),
6562 )),
6563 }
6564 }
6565 }
6566
6567 impl serde::ser::Serialize for UnloadingPolicy {
6568 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6569 where
6570 S: serde::Serializer,
6571 {
6572 match self {
6573 Self::Unspecified => serializer.serialize_i32(0),
6574 Self::LastInFirstOut => serializer.serialize_i32(1),
6575 Self::FirstInFirstOut => serializer.serialize_i32(2),
6576 Self::UnknownValue(u) => u.0.serialize(serializer),
6577 }
6578 }
6579 }
6580
6581 impl<'de> serde::de::Deserialize<'de> for UnloadingPolicy {
6582 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6583 where
6584 D: serde::Deserializer<'de>,
6585 {
6586 deserializer.deserialize_any(wkt::internal::EnumVisitor::<UnloadingPolicy>::new(
6587 ".google.cloud.optimization.v1.Vehicle.UnloadingPolicy",
6588 ))
6589 }
6590 }
6591}
6592
6593/// Time windows constrain the time of an event, such as the arrival time at a
6594/// visit, or the start and end time of a vehicle.
6595///
6596/// Hard time window bounds, `start_time` and `end_time`, enforce the earliest
6597/// and latest time of the event, such that `start_time <= event_time <=
6598/// end_time`. The soft time window lower bound, `soft_start_time`, expresses a
6599/// preference for the event to happen at or after `soft_start_time` by incurring
6600/// a cost proportional to how long before soft_start_time the event occurs. The
6601/// soft time window upper bound, `soft_end_time`, expresses a preference for the
6602/// event to happen at or before `soft_end_time` by incurring a cost proportional
6603/// to how long after `soft_end_time` the event occurs. `start_time`, `end_time`,
6604/// `soft_start_time` and `soft_end_time` should be within the global time limits
6605/// (see
6606/// [ShipmentModel.global_start_time][google.cloud.optimization.v1.ShipmentModel.global_start_time]
6607/// and
6608/// [ShipmentModel.global_end_time][google.cloud.optimization.v1.ShipmentModel.global_end_time])
6609/// and should respect:
6610///
6611/// ```norust
6612/// 0 <= `start_time` <= `soft_start_time` <= `end_time` and
6613/// 0 <= `start_time` <= `soft_end_time` <= `end_time`.
6614/// ```
6615///
6616/// [google.cloud.optimization.v1.ShipmentModel.global_end_time]: crate::model::ShipmentModel::global_end_time
6617/// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
6618#[derive(Clone, Default, PartialEq)]
6619#[non_exhaustive]
6620pub struct TimeWindow {
6621 /// The hard time window start time. If unspecified it will be set to
6622 /// `ShipmentModel.global_start_time`.
6623 pub start_time: std::option::Option<wkt::Timestamp>,
6624
6625 /// The hard time window end time. If unspecified it will be set to
6626 /// `ShipmentModel.global_end_time`.
6627 pub end_time: std::option::Option<wkt::Timestamp>,
6628
6629 /// The soft start time of the time window.
6630 pub soft_start_time: std::option::Option<wkt::Timestamp>,
6631
6632 /// The soft end time of the time window.
6633 pub soft_end_time: std::option::Option<wkt::Timestamp>,
6634
6635 /// A cost per hour added to other costs in the model if the event occurs
6636 /// before soft_start_time, computed as:
6637 ///
6638 /// ```norust
6639 /// max(0, soft_start_time - t.seconds)
6640 /// * cost_per_hour_before_soft_start_time / 3600,
6641 /// t being the time of the event.
6642 /// ```
6643 ///
6644 /// This cost must be positive, and the field can only be set if
6645 /// soft_start_time has been set.
6646 pub cost_per_hour_before_soft_start_time: std::option::Option<f64>,
6647
6648 /// A cost per hour added to other costs in the model if the event occurs after
6649 /// `soft_end_time`, computed as:
6650 ///
6651 /// ```norust
6652 /// max(0, t.seconds - soft_end_time.seconds)
6653 /// * cost_per_hour_after_soft_end_time / 3600,
6654 /// t being the time of the event.
6655 /// ```
6656 ///
6657 /// This cost must be positive, and the field can only be set if
6658 /// `soft_end_time` has been set.
6659 pub cost_per_hour_after_soft_end_time: std::option::Option<f64>,
6660
6661 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6662}
6663
6664impl TimeWindow {
6665 /// Creates a new default instance.
6666 pub fn new() -> Self {
6667 std::default::Default::default()
6668 }
6669
6670 /// Sets the value of [start_time][crate::model::TimeWindow::start_time].
6671 ///
6672 /// # Example
6673 /// ```ignore,no_run
6674 /// # use google_cloud_optimization_v1::model::TimeWindow;
6675 /// use wkt::Timestamp;
6676 /// let x = TimeWindow::new().set_start_time(Timestamp::default()/* use setters */);
6677 /// ```
6678 pub fn set_start_time<T>(mut self, v: T) -> Self
6679 where
6680 T: std::convert::Into<wkt::Timestamp>,
6681 {
6682 self.start_time = std::option::Option::Some(v.into());
6683 self
6684 }
6685
6686 /// Sets or clears the value of [start_time][crate::model::TimeWindow::start_time].
6687 ///
6688 /// # Example
6689 /// ```ignore,no_run
6690 /// # use google_cloud_optimization_v1::model::TimeWindow;
6691 /// use wkt::Timestamp;
6692 /// let x = TimeWindow::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
6693 /// let x = TimeWindow::new().set_or_clear_start_time(None::<Timestamp>);
6694 /// ```
6695 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6696 where
6697 T: std::convert::Into<wkt::Timestamp>,
6698 {
6699 self.start_time = v.map(|x| x.into());
6700 self
6701 }
6702
6703 /// Sets the value of [end_time][crate::model::TimeWindow::end_time].
6704 ///
6705 /// # Example
6706 /// ```ignore,no_run
6707 /// # use google_cloud_optimization_v1::model::TimeWindow;
6708 /// use wkt::Timestamp;
6709 /// let x = TimeWindow::new().set_end_time(Timestamp::default()/* use setters */);
6710 /// ```
6711 pub fn set_end_time<T>(mut self, v: T) -> Self
6712 where
6713 T: std::convert::Into<wkt::Timestamp>,
6714 {
6715 self.end_time = std::option::Option::Some(v.into());
6716 self
6717 }
6718
6719 /// Sets or clears the value of [end_time][crate::model::TimeWindow::end_time].
6720 ///
6721 /// # Example
6722 /// ```ignore,no_run
6723 /// # use google_cloud_optimization_v1::model::TimeWindow;
6724 /// use wkt::Timestamp;
6725 /// let x = TimeWindow::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
6726 /// let x = TimeWindow::new().set_or_clear_end_time(None::<Timestamp>);
6727 /// ```
6728 pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
6729 where
6730 T: std::convert::Into<wkt::Timestamp>,
6731 {
6732 self.end_time = v.map(|x| x.into());
6733 self
6734 }
6735
6736 /// Sets the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
6737 ///
6738 /// # Example
6739 /// ```ignore,no_run
6740 /// # use google_cloud_optimization_v1::model::TimeWindow;
6741 /// use wkt::Timestamp;
6742 /// let x = TimeWindow::new().set_soft_start_time(Timestamp::default()/* use setters */);
6743 /// ```
6744 pub fn set_soft_start_time<T>(mut self, v: T) -> Self
6745 where
6746 T: std::convert::Into<wkt::Timestamp>,
6747 {
6748 self.soft_start_time = std::option::Option::Some(v.into());
6749 self
6750 }
6751
6752 /// Sets or clears the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
6753 ///
6754 /// # Example
6755 /// ```ignore,no_run
6756 /// # use google_cloud_optimization_v1::model::TimeWindow;
6757 /// use wkt::Timestamp;
6758 /// let x = TimeWindow::new().set_or_clear_soft_start_time(Some(Timestamp::default()/* use setters */));
6759 /// let x = TimeWindow::new().set_or_clear_soft_start_time(None::<Timestamp>);
6760 /// ```
6761 pub fn set_or_clear_soft_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6762 where
6763 T: std::convert::Into<wkt::Timestamp>,
6764 {
6765 self.soft_start_time = v.map(|x| x.into());
6766 self
6767 }
6768
6769 /// Sets the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
6770 ///
6771 /// # Example
6772 /// ```ignore,no_run
6773 /// # use google_cloud_optimization_v1::model::TimeWindow;
6774 /// use wkt::Timestamp;
6775 /// let x = TimeWindow::new().set_soft_end_time(Timestamp::default()/* use setters */);
6776 /// ```
6777 pub fn set_soft_end_time<T>(mut self, v: T) -> Self
6778 where
6779 T: std::convert::Into<wkt::Timestamp>,
6780 {
6781 self.soft_end_time = std::option::Option::Some(v.into());
6782 self
6783 }
6784
6785 /// Sets or clears the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
6786 ///
6787 /// # Example
6788 /// ```ignore,no_run
6789 /// # use google_cloud_optimization_v1::model::TimeWindow;
6790 /// use wkt::Timestamp;
6791 /// let x = TimeWindow::new().set_or_clear_soft_end_time(Some(Timestamp::default()/* use setters */));
6792 /// let x = TimeWindow::new().set_or_clear_soft_end_time(None::<Timestamp>);
6793 /// ```
6794 pub fn set_or_clear_soft_end_time<T>(mut self, v: std::option::Option<T>) -> Self
6795 where
6796 T: std::convert::Into<wkt::Timestamp>,
6797 {
6798 self.soft_end_time = v.map(|x| x.into());
6799 self
6800 }
6801
6802 /// Sets the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
6803 ///
6804 /// # Example
6805 /// ```ignore,no_run
6806 /// # use google_cloud_optimization_v1::model::TimeWindow;
6807 /// let x = TimeWindow::new().set_cost_per_hour_before_soft_start_time(42.0);
6808 /// ```
6809 pub fn set_cost_per_hour_before_soft_start_time<T>(mut self, v: T) -> Self
6810 where
6811 T: std::convert::Into<f64>,
6812 {
6813 self.cost_per_hour_before_soft_start_time = std::option::Option::Some(v.into());
6814 self
6815 }
6816
6817 /// Sets or clears the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
6818 ///
6819 /// # Example
6820 /// ```ignore,no_run
6821 /// # use google_cloud_optimization_v1::model::TimeWindow;
6822 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_before_soft_start_time(Some(42.0));
6823 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_before_soft_start_time(None::<f32>);
6824 /// ```
6825 pub fn set_or_clear_cost_per_hour_before_soft_start_time<T>(
6826 mut self,
6827 v: std::option::Option<T>,
6828 ) -> Self
6829 where
6830 T: std::convert::Into<f64>,
6831 {
6832 self.cost_per_hour_before_soft_start_time = v.map(|x| x.into());
6833 self
6834 }
6835
6836 /// Sets the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
6837 ///
6838 /// # Example
6839 /// ```ignore,no_run
6840 /// # use google_cloud_optimization_v1::model::TimeWindow;
6841 /// let x = TimeWindow::new().set_cost_per_hour_after_soft_end_time(42.0);
6842 /// ```
6843 pub fn set_cost_per_hour_after_soft_end_time<T>(mut self, v: T) -> Self
6844 where
6845 T: std::convert::Into<f64>,
6846 {
6847 self.cost_per_hour_after_soft_end_time = std::option::Option::Some(v.into());
6848 self
6849 }
6850
6851 /// Sets or clears the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
6852 ///
6853 /// # Example
6854 /// ```ignore,no_run
6855 /// # use google_cloud_optimization_v1::model::TimeWindow;
6856 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_after_soft_end_time(Some(42.0));
6857 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_after_soft_end_time(None::<f32>);
6858 /// ```
6859 pub fn set_or_clear_cost_per_hour_after_soft_end_time<T>(
6860 mut self,
6861 v: std::option::Option<T>,
6862 ) -> Self
6863 where
6864 T: std::convert::Into<f64>,
6865 {
6866 self.cost_per_hour_after_soft_end_time = v.map(|x| x.into());
6867 self
6868 }
6869}
6870
6871impl wkt::message::Message for TimeWindow {
6872 fn typename() -> &'static str {
6873 "type.googleapis.com/google.cloud.optimization.v1.TimeWindow"
6874 }
6875}
6876
6877/// Deprecated: Use
6878/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
6879/// instead.
6880///
6881/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
6882#[derive(Clone, Default, PartialEq)]
6883#[non_exhaustive]
6884#[deprecated]
6885pub struct CapacityQuantity {
6886 #[allow(missing_docs)]
6887 pub r#type: std::string::String,
6888
6889 #[allow(missing_docs)]
6890 pub value: i64,
6891
6892 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6893}
6894
6895impl CapacityQuantity {
6896 /// Creates a new default instance.
6897 pub fn new() -> Self {
6898 std::default::Default::default()
6899 }
6900
6901 /// Sets the value of [r#type][crate::model::CapacityQuantity::type].
6902 ///
6903 /// # Example
6904 /// ```ignore,no_run
6905 /// # use google_cloud_optimization_v1::model::CapacityQuantity;
6906 /// let x = CapacityQuantity::new().set_type("example");
6907 /// ```
6908 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6909 self.r#type = v.into();
6910 self
6911 }
6912
6913 /// Sets the value of [value][crate::model::CapacityQuantity::value].
6914 ///
6915 /// # Example
6916 /// ```ignore,no_run
6917 /// # use google_cloud_optimization_v1::model::CapacityQuantity;
6918 /// let x = CapacityQuantity::new().set_value(42);
6919 /// ```
6920 pub fn set_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6921 self.value = v.into();
6922 self
6923 }
6924}
6925
6926impl wkt::message::Message for CapacityQuantity {
6927 fn typename() -> &'static str {
6928 "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantity"
6929 }
6930}
6931
6932/// Deprecated: Use
6933/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
6934/// instead.
6935///
6936/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
6937#[derive(Clone, Default, PartialEq)]
6938#[non_exhaustive]
6939#[deprecated]
6940pub struct CapacityQuantityInterval {
6941 #[allow(missing_docs)]
6942 pub r#type: std::string::String,
6943
6944 #[allow(missing_docs)]
6945 pub min_value: std::option::Option<i64>,
6946
6947 #[allow(missing_docs)]
6948 pub max_value: std::option::Option<i64>,
6949
6950 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6951}
6952
6953impl CapacityQuantityInterval {
6954 /// Creates a new default instance.
6955 pub fn new() -> Self {
6956 std::default::Default::default()
6957 }
6958
6959 /// Sets the value of [r#type][crate::model::CapacityQuantityInterval::type].
6960 ///
6961 /// # Example
6962 /// ```ignore,no_run
6963 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6964 /// let x = CapacityQuantityInterval::new().set_type("example");
6965 /// ```
6966 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6967 self.r#type = v.into();
6968 self
6969 }
6970
6971 /// Sets the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
6972 ///
6973 /// # Example
6974 /// ```ignore,no_run
6975 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6976 /// let x = CapacityQuantityInterval::new().set_min_value(42);
6977 /// ```
6978 pub fn set_min_value<T>(mut self, v: T) -> Self
6979 where
6980 T: std::convert::Into<i64>,
6981 {
6982 self.min_value = std::option::Option::Some(v.into());
6983 self
6984 }
6985
6986 /// Sets or clears the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
6987 ///
6988 /// # Example
6989 /// ```ignore,no_run
6990 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6991 /// let x = CapacityQuantityInterval::new().set_or_clear_min_value(Some(42));
6992 /// let x = CapacityQuantityInterval::new().set_or_clear_min_value(None::<i32>);
6993 /// ```
6994 pub fn set_or_clear_min_value<T>(mut self, v: std::option::Option<T>) -> Self
6995 where
6996 T: std::convert::Into<i64>,
6997 {
6998 self.min_value = v.map(|x| x.into());
6999 self
7000 }
7001
7002 /// Sets the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
7003 ///
7004 /// # Example
7005 /// ```ignore,no_run
7006 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
7007 /// let x = CapacityQuantityInterval::new().set_max_value(42);
7008 /// ```
7009 pub fn set_max_value<T>(mut self, v: T) -> Self
7010 where
7011 T: std::convert::Into<i64>,
7012 {
7013 self.max_value = std::option::Option::Some(v.into());
7014 self
7015 }
7016
7017 /// Sets or clears the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
7018 ///
7019 /// # Example
7020 /// ```ignore,no_run
7021 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
7022 /// let x = CapacityQuantityInterval::new().set_or_clear_max_value(Some(42));
7023 /// let x = CapacityQuantityInterval::new().set_or_clear_max_value(None::<i32>);
7024 /// ```
7025 pub fn set_or_clear_max_value<T>(mut self, v: std::option::Option<T>) -> Self
7026 where
7027 T: std::convert::Into<i64>,
7028 {
7029 self.max_value = v.map(|x| x.into());
7030 self
7031 }
7032}
7033
7034impl wkt::message::Message for CapacityQuantityInterval {
7035 fn typename() -> &'static str {
7036 "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantityInterval"
7037 }
7038}
7039
7040/// A limit defining a maximum distance which can be traveled. It can be either
7041/// hard or soft.
7042///
7043/// If a soft limit is defined, both `soft_max_meters` and
7044/// `cost_per_kilometer_above_soft_max` must be defined and be nonnegative.
7045#[derive(Clone, Default, PartialEq)]
7046#[non_exhaustive]
7047pub struct DistanceLimit {
7048 /// A hard limit constraining the distance to be at most max_meters. The limit
7049 /// must be nonnegative.
7050 pub max_meters: std::option::Option<i64>,
7051
7052 /// A soft limit not enforcing a maximum distance limit, but when violated
7053 /// results in a cost which adds up to other costs defined in the model,
7054 /// with the same unit.
7055 ///
7056 /// If defined soft_max_meters must be less than max_meters and must be
7057 /// nonnegative.
7058 pub soft_max_meters: std::option::Option<i64>,
7059
7060 /// Cost per kilometer incurred, increasing up to `soft_max_meters`, with
7061 /// formula:
7062 ///
7063 /// ```norust
7064 /// min(distance_meters, soft_max_meters) / 1000.0 *
7065 /// cost_per_kilometer_below_soft_max.
7066 /// ```
7067 ///
7068 /// This cost is not supported in `route_distance_limit`.
7069 pub cost_per_kilometer_below_soft_max: std::option::Option<f64>,
7070
7071 /// Cost per kilometer incurred if distance is above `soft_max_meters` limit.
7072 /// The additional cost is 0 if the distance is under the limit, otherwise the
7073 /// formula used to compute the cost is the following:
7074 ///
7075 /// ```norust
7076 /// (distance_meters - soft_max_meters) / 1000.0 *
7077 /// cost_per_kilometer_above_soft_max.
7078 /// ```
7079 ///
7080 /// The cost must be nonnegative.
7081 pub cost_per_kilometer_above_soft_max: std::option::Option<f64>,
7082
7083 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7084}
7085
7086impl DistanceLimit {
7087 /// Creates a new default instance.
7088 pub fn new() -> Self {
7089 std::default::Default::default()
7090 }
7091
7092 /// Sets the value of [max_meters][crate::model::DistanceLimit::max_meters].
7093 ///
7094 /// # Example
7095 /// ```ignore,no_run
7096 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7097 /// let x = DistanceLimit::new().set_max_meters(42);
7098 /// ```
7099 pub fn set_max_meters<T>(mut self, v: T) -> Self
7100 where
7101 T: std::convert::Into<i64>,
7102 {
7103 self.max_meters = std::option::Option::Some(v.into());
7104 self
7105 }
7106
7107 /// Sets or clears the value of [max_meters][crate::model::DistanceLimit::max_meters].
7108 ///
7109 /// # Example
7110 /// ```ignore,no_run
7111 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7112 /// let x = DistanceLimit::new().set_or_clear_max_meters(Some(42));
7113 /// let x = DistanceLimit::new().set_or_clear_max_meters(None::<i32>);
7114 /// ```
7115 pub fn set_or_clear_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
7116 where
7117 T: std::convert::Into<i64>,
7118 {
7119 self.max_meters = v.map(|x| x.into());
7120 self
7121 }
7122
7123 /// Sets the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
7124 ///
7125 /// # Example
7126 /// ```ignore,no_run
7127 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7128 /// let x = DistanceLimit::new().set_soft_max_meters(42);
7129 /// ```
7130 pub fn set_soft_max_meters<T>(mut self, v: T) -> Self
7131 where
7132 T: std::convert::Into<i64>,
7133 {
7134 self.soft_max_meters = std::option::Option::Some(v.into());
7135 self
7136 }
7137
7138 /// Sets or clears the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
7139 ///
7140 /// # Example
7141 /// ```ignore,no_run
7142 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7143 /// let x = DistanceLimit::new().set_or_clear_soft_max_meters(Some(42));
7144 /// let x = DistanceLimit::new().set_or_clear_soft_max_meters(None::<i32>);
7145 /// ```
7146 pub fn set_or_clear_soft_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
7147 where
7148 T: std::convert::Into<i64>,
7149 {
7150 self.soft_max_meters = v.map(|x| x.into());
7151 self
7152 }
7153
7154 /// Sets the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
7155 ///
7156 /// # Example
7157 /// ```ignore,no_run
7158 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7159 /// let x = DistanceLimit::new().set_cost_per_kilometer_below_soft_max(42.0);
7160 /// ```
7161 pub fn set_cost_per_kilometer_below_soft_max<T>(mut self, v: T) -> Self
7162 where
7163 T: std::convert::Into<f64>,
7164 {
7165 self.cost_per_kilometer_below_soft_max = std::option::Option::Some(v.into());
7166 self
7167 }
7168
7169 /// Sets or clears the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
7170 ///
7171 /// # Example
7172 /// ```ignore,no_run
7173 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7174 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_below_soft_max(Some(42.0));
7175 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_below_soft_max(None::<f32>);
7176 /// ```
7177 pub fn set_or_clear_cost_per_kilometer_below_soft_max<T>(
7178 mut self,
7179 v: std::option::Option<T>,
7180 ) -> Self
7181 where
7182 T: std::convert::Into<f64>,
7183 {
7184 self.cost_per_kilometer_below_soft_max = v.map(|x| x.into());
7185 self
7186 }
7187
7188 /// Sets the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
7189 ///
7190 /// # Example
7191 /// ```ignore,no_run
7192 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7193 /// let x = DistanceLimit::new().set_cost_per_kilometer_above_soft_max(42.0);
7194 /// ```
7195 pub fn set_cost_per_kilometer_above_soft_max<T>(mut self, v: T) -> Self
7196 where
7197 T: std::convert::Into<f64>,
7198 {
7199 self.cost_per_kilometer_above_soft_max = std::option::Option::Some(v.into());
7200 self
7201 }
7202
7203 /// Sets or clears the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
7204 ///
7205 /// # Example
7206 /// ```ignore,no_run
7207 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7208 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_above_soft_max(Some(42.0));
7209 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_above_soft_max(None::<f32>);
7210 /// ```
7211 pub fn set_or_clear_cost_per_kilometer_above_soft_max<T>(
7212 mut self,
7213 v: std::option::Option<T>,
7214 ) -> Self
7215 where
7216 T: std::convert::Into<f64>,
7217 {
7218 self.cost_per_kilometer_above_soft_max = v.map(|x| x.into());
7219 self
7220 }
7221}
7222
7223impl wkt::message::Message for DistanceLimit {
7224 fn typename() -> &'static str {
7225 "type.googleapis.com/google.cloud.optimization.v1.DistanceLimit"
7226 }
7227}
7228
7229/// Specifies attributes of transitions between two consecutive visits on a
7230/// route. Several `TransitionAttributes` may apply to the same transition: in
7231/// that case, all extra costs add up and the strictest constraint or limit
7232/// applies (following natural "AND" semantics).
7233#[derive(Clone, Default, PartialEq)]
7234#[non_exhaustive]
7235pub struct TransitionAttributes {
7236 /// Tags defining the set of (src->dst) transitions these attributes apply to.
7237 ///
7238 /// A source visit or vehicle start matches iff its
7239 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
7240 /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags]
7241 /// either contains `src_tag` or does not contain `excluded_src_tag` (depending
7242 /// on which of these two fields is non-empty).
7243 ///
7244 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
7245 /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
7246 pub src_tag: std::string::String,
7247
7248 /// See `src_tag`. Exactly one of `src_tag` and `excluded_src_tag` must be
7249 /// non-empty.
7250 pub excluded_src_tag: std::string::String,
7251
7252 /// A destination visit or vehicle end matches iff its
7253 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
7254 /// or [Vehicle.end_tags][google.cloud.optimization.v1.Vehicle.end_tags] either
7255 /// contains `dst_tag` or does not contain `excluded_dst_tag` (depending on
7256 /// which of these two fields is non-empty).
7257 ///
7258 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
7259 /// [google.cloud.optimization.v1.Vehicle.end_tags]: crate::model::Vehicle::end_tags
7260 pub dst_tag: std::string::String,
7261
7262 /// See `dst_tag`. Exactly one of `dst_tag` and `excluded_dst_tag` must be
7263 /// non-empty.
7264 pub excluded_dst_tag: std::string::String,
7265
7266 /// Specifies a cost for performing this transition. This is in the same unit
7267 /// as all other costs in the model and must not be negative. It is applied on
7268 /// top of all other existing costs.
7269 pub cost: f64,
7270
7271 /// Specifies a cost per kilometer applied to the distance traveled while
7272 /// performing this transition. It adds up to any
7273 /// [Vehicle.cost_per_kilometer][google.cloud.optimization.v1.Vehicle.cost_per_kilometer]
7274 /// specified on vehicles.
7275 ///
7276 /// [google.cloud.optimization.v1.Vehicle.cost_per_kilometer]: crate::model::Vehicle::cost_per_kilometer
7277 pub cost_per_kilometer: f64,
7278
7279 /// Specifies a limit on the distance traveled while performing this
7280 /// transition.
7281 ///
7282 /// As of 2021/06, only soft limits are supported.
7283 pub distance_limit: std::option::Option<crate::model::DistanceLimit>,
7284
7285 /// Specifies a delay incurred when performing this transition.
7286 ///
7287 /// This delay always occurs *after* finishing the source visit and *before*
7288 /// starting the destination visit.
7289 pub delay: std::option::Option<wkt::Duration>,
7290
7291 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7292}
7293
7294impl TransitionAttributes {
7295 /// Creates a new default instance.
7296 pub fn new() -> Self {
7297 std::default::Default::default()
7298 }
7299
7300 /// Sets the value of [src_tag][crate::model::TransitionAttributes::src_tag].
7301 ///
7302 /// # Example
7303 /// ```ignore,no_run
7304 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7305 /// let x = TransitionAttributes::new().set_src_tag("example");
7306 /// ```
7307 pub fn set_src_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7308 self.src_tag = v.into();
7309 self
7310 }
7311
7312 /// Sets the value of [excluded_src_tag][crate::model::TransitionAttributes::excluded_src_tag].
7313 ///
7314 /// # Example
7315 /// ```ignore,no_run
7316 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7317 /// let x = TransitionAttributes::new().set_excluded_src_tag("example");
7318 /// ```
7319 pub fn set_excluded_src_tag<T: std::convert::Into<std::string::String>>(
7320 mut self,
7321 v: T,
7322 ) -> Self {
7323 self.excluded_src_tag = v.into();
7324 self
7325 }
7326
7327 /// Sets the value of [dst_tag][crate::model::TransitionAttributes::dst_tag].
7328 ///
7329 /// # Example
7330 /// ```ignore,no_run
7331 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7332 /// let x = TransitionAttributes::new().set_dst_tag("example");
7333 /// ```
7334 pub fn set_dst_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7335 self.dst_tag = v.into();
7336 self
7337 }
7338
7339 /// Sets the value of [excluded_dst_tag][crate::model::TransitionAttributes::excluded_dst_tag].
7340 ///
7341 /// # Example
7342 /// ```ignore,no_run
7343 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7344 /// let x = TransitionAttributes::new().set_excluded_dst_tag("example");
7345 /// ```
7346 pub fn set_excluded_dst_tag<T: std::convert::Into<std::string::String>>(
7347 mut self,
7348 v: T,
7349 ) -> Self {
7350 self.excluded_dst_tag = v.into();
7351 self
7352 }
7353
7354 /// Sets the value of [cost][crate::model::TransitionAttributes::cost].
7355 ///
7356 /// # Example
7357 /// ```ignore,no_run
7358 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7359 /// let x = TransitionAttributes::new().set_cost(42.0);
7360 /// ```
7361 pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7362 self.cost = v.into();
7363 self
7364 }
7365
7366 /// Sets the value of [cost_per_kilometer][crate::model::TransitionAttributes::cost_per_kilometer].
7367 ///
7368 /// # Example
7369 /// ```ignore,no_run
7370 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7371 /// let x = TransitionAttributes::new().set_cost_per_kilometer(42.0);
7372 /// ```
7373 pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7374 self.cost_per_kilometer = v.into();
7375 self
7376 }
7377
7378 /// Sets the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
7379 ///
7380 /// # Example
7381 /// ```ignore,no_run
7382 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7383 /// use google_cloud_optimization_v1::model::DistanceLimit;
7384 /// let x = TransitionAttributes::new().set_distance_limit(DistanceLimit::default()/* use setters */);
7385 /// ```
7386 pub fn set_distance_limit<T>(mut self, v: T) -> Self
7387 where
7388 T: std::convert::Into<crate::model::DistanceLimit>,
7389 {
7390 self.distance_limit = std::option::Option::Some(v.into());
7391 self
7392 }
7393
7394 /// Sets or clears the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
7395 ///
7396 /// # Example
7397 /// ```ignore,no_run
7398 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7399 /// use google_cloud_optimization_v1::model::DistanceLimit;
7400 /// let x = TransitionAttributes::new().set_or_clear_distance_limit(Some(DistanceLimit::default()/* use setters */));
7401 /// let x = TransitionAttributes::new().set_or_clear_distance_limit(None::<DistanceLimit>);
7402 /// ```
7403 pub fn set_or_clear_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
7404 where
7405 T: std::convert::Into<crate::model::DistanceLimit>,
7406 {
7407 self.distance_limit = v.map(|x| x.into());
7408 self
7409 }
7410
7411 /// Sets the value of [delay][crate::model::TransitionAttributes::delay].
7412 ///
7413 /// # Example
7414 /// ```ignore,no_run
7415 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7416 /// use wkt::Duration;
7417 /// let x = TransitionAttributes::new().set_delay(Duration::default()/* use setters */);
7418 /// ```
7419 pub fn set_delay<T>(mut self, v: T) -> Self
7420 where
7421 T: std::convert::Into<wkt::Duration>,
7422 {
7423 self.delay = std::option::Option::Some(v.into());
7424 self
7425 }
7426
7427 /// Sets or clears the value of [delay][crate::model::TransitionAttributes::delay].
7428 ///
7429 /// # Example
7430 /// ```ignore,no_run
7431 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7432 /// use wkt::Duration;
7433 /// let x = TransitionAttributes::new().set_or_clear_delay(Some(Duration::default()/* use setters */));
7434 /// let x = TransitionAttributes::new().set_or_clear_delay(None::<Duration>);
7435 /// ```
7436 pub fn set_or_clear_delay<T>(mut self, v: std::option::Option<T>) -> Self
7437 where
7438 T: std::convert::Into<wkt::Duration>,
7439 {
7440 self.delay = v.map(|x| x.into());
7441 self
7442 }
7443}
7444
7445impl wkt::message::Message for TransitionAttributes {
7446 fn typename() -> &'static str {
7447 "type.googleapis.com/google.cloud.optimization.v1.TransitionAttributes"
7448 }
7449}
7450
7451/// Encapsulates a waypoint. Waypoints mark arrival and departure locations of
7452/// VisitRequests, and start and end locations of Vehicles.
7453#[derive(Clone, Default, PartialEq)]
7454#[non_exhaustive]
7455pub struct Waypoint {
7456 /// Indicates that the location of this waypoint is meant to have a preference
7457 /// for the vehicle to stop at a particular side of road. When you set this
7458 /// value, the route will pass through the location so that the vehicle can
7459 /// stop at the side of road that the location is biased towards from the
7460 /// center of the road. This option works only for the 'DRIVING' travel mode,
7461 /// and when the 'location_type' is set to 'location'.
7462 pub side_of_road: bool,
7463
7464 /// Different ways to represent a location.
7465 pub location_type: std::option::Option<crate::model::waypoint::LocationType>,
7466
7467 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7468}
7469
7470impl Waypoint {
7471 /// Creates a new default instance.
7472 pub fn new() -> Self {
7473 std::default::Default::default()
7474 }
7475
7476 /// Sets the value of [side_of_road][crate::model::Waypoint::side_of_road].
7477 ///
7478 /// # Example
7479 /// ```ignore,no_run
7480 /// # use google_cloud_optimization_v1::model::Waypoint;
7481 /// let x = Waypoint::new().set_side_of_road(true);
7482 /// ```
7483 pub fn set_side_of_road<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7484 self.side_of_road = v.into();
7485 self
7486 }
7487
7488 /// Sets the value of [location_type][crate::model::Waypoint::location_type].
7489 ///
7490 /// Note that all the setters affecting `location_type` are mutually
7491 /// exclusive.
7492 ///
7493 /// # Example
7494 /// ```ignore,no_run
7495 /// # use google_cloud_optimization_v1::model::Waypoint;
7496 /// use google_cloud_optimization_v1::model::waypoint::LocationType;
7497 /// let x = Waypoint::new().set_location_type(Some(LocationType::PlaceId("example".to_string())));
7498 /// ```
7499 pub fn set_location_type<
7500 T: std::convert::Into<std::option::Option<crate::model::waypoint::LocationType>>,
7501 >(
7502 mut self,
7503 v: T,
7504 ) -> Self {
7505 self.location_type = v.into();
7506 self
7507 }
7508
7509 /// The value of [location_type][crate::model::Waypoint::location_type]
7510 /// if it holds a `Location`, `None` if the field is not set or
7511 /// holds a different branch.
7512 pub fn location(&self) -> std::option::Option<&std::boxed::Box<crate::model::Location>> {
7513 #[allow(unreachable_patterns)]
7514 self.location_type.as_ref().and_then(|v| match v {
7515 crate::model::waypoint::LocationType::Location(v) => std::option::Option::Some(v),
7516 _ => std::option::Option::None,
7517 })
7518 }
7519
7520 /// Sets the value of [location_type][crate::model::Waypoint::location_type]
7521 /// to hold a `Location`.
7522 ///
7523 /// Note that all the setters affecting `location_type` are
7524 /// mutually exclusive.
7525 ///
7526 /// # Example
7527 /// ```ignore,no_run
7528 /// # use google_cloud_optimization_v1::model::Waypoint;
7529 /// use google_cloud_optimization_v1::model::Location;
7530 /// let x = Waypoint::new().set_location(Location::default()/* use setters */);
7531 /// assert!(x.location().is_some());
7532 /// assert!(x.place_id().is_none());
7533 /// ```
7534 pub fn set_location<T: std::convert::Into<std::boxed::Box<crate::model::Location>>>(
7535 mut self,
7536 v: T,
7537 ) -> Self {
7538 self.location_type =
7539 std::option::Option::Some(crate::model::waypoint::LocationType::Location(v.into()));
7540 self
7541 }
7542
7543 /// The value of [location_type][crate::model::Waypoint::location_type]
7544 /// if it holds a `PlaceId`, `None` if the field is not set or
7545 /// holds a different branch.
7546 pub fn place_id(&self) -> std::option::Option<&std::string::String> {
7547 #[allow(unreachable_patterns)]
7548 self.location_type.as_ref().and_then(|v| match v {
7549 crate::model::waypoint::LocationType::PlaceId(v) => std::option::Option::Some(v),
7550 _ => std::option::Option::None,
7551 })
7552 }
7553
7554 /// Sets the value of [location_type][crate::model::Waypoint::location_type]
7555 /// to hold a `PlaceId`.
7556 ///
7557 /// Note that all the setters affecting `location_type` are
7558 /// mutually exclusive.
7559 ///
7560 /// # Example
7561 /// ```ignore,no_run
7562 /// # use google_cloud_optimization_v1::model::Waypoint;
7563 /// let x = Waypoint::new().set_place_id("example");
7564 /// assert!(x.place_id().is_some());
7565 /// assert!(x.location().is_none());
7566 /// ```
7567 pub fn set_place_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7568 self.location_type =
7569 std::option::Option::Some(crate::model::waypoint::LocationType::PlaceId(v.into()));
7570 self
7571 }
7572}
7573
7574impl wkt::message::Message for Waypoint {
7575 fn typename() -> &'static str {
7576 "type.googleapis.com/google.cloud.optimization.v1.Waypoint"
7577 }
7578}
7579
7580/// Defines additional types related to [Waypoint].
7581pub mod waypoint {
7582 #[allow(unused_imports)]
7583 use super::*;
7584
7585 /// Different ways to represent a location.
7586 #[derive(Clone, Debug, PartialEq)]
7587 #[non_exhaustive]
7588 pub enum LocationType {
7589 /// A point specified using geographic coordinates, including an optional
7590 /// heading.
7591 Location(std::boxed::Box<crate::model::Location>),
7592 /// The POI Place ID associated with the waypoint.
7593 PlaceId(std::string::String),
7594 }
7595}
7596
7597/// Encapsulates a location (a geographic point, and an optional heading).
7598#[derive(Clone, Default, PartialEq)]
7599#[non_exhaustive]
7600pub struct Location {
7601 /// The waypoint's geographic coordinates.
7602 pub lat_lng: std::option::Option<google_cloud_type::model::LatLng>,
7603
7604 /// The compass heading associated with the direction of the flow of traffic.
7605 /// This value is used to specify the side of the road to use for pickup and
7606 /// drop-off. Heading values can be from 0 to 360, where 0 specifies a heading
7607 /// of due North, 90 specifies a heading of due East, etc.
7608 pub heading: std::option::Option<i32>,
7609
7610 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7611}
7612
7613impl Location {
7614 /// Creates a new default instance.
7615 pub fn new() -> Self {
7616 std::default::Default::default()
7617 }
7618
7619 /// Sets the value of [lat_lng][crate::model::Location::lat_lng].
7620 ///
7621 /// # Example
7622 /// ```ignore,no_run
7623 /// # use google_cloud_optimization_v1::model::Location;
7624 /// use google_cloud_type::model::LatLng;
7625 /// let x = Location::new().set_lat_lng(LatLng::default()/* use setters */);
7626 /// ```
7627 pub fn set_lat_lng<T>(mut self, v: T) -> Self
7628 where
7629 T: std::convert::Into<google_cloud_type::model::LatLng>,
7630 {
7631 self.lat_lng = std::option::Option::Some(v.into());
7632 self
7633 }
7634
7635 /// Sets or clears the value of [lat_lng][crate::model::Location::lat_lng].
7636 ///
7637 /// # Example
7638 /// ```ignore,no_run
7639 /// # use google_cloud_optimization_v1::model::Location;
7640 /// use google_cloud_type::model::LatLng;
7641 /// let x = Location::new().set_or_clear_lat_lng(Some(LatLng::default()/* use setters */));
7642 /// let x = Location::new().set_or_clear_lat_lng(None::<LatLng>);
7643 /// ```
7644 pub fn set_or_clear_lat_lng<T>(mut self, v: std::option::Option<T>) -> Self
7645 where
7646 T: std::convert::Into<google_cloud_type::model::LatLng>,
7647 {
7648 self.lat_lng = v.map(|x| x.into());
7649 self
7650 }
7651
7652 /// Sets the value of [heading][crate::model::Location::heading].
7653 ///
7654 /// # Example
7655 /// ```ignore,no_run
7656 /// # use google_cloud_optimization_v1::model::Location;
7657 /// let x = Location::new().set_heading(42);
7658 /// ```
7659 pub fn set_heading<T>(mut self, v: T) -> Self
7660 where
7661 T: std::convert::Into<i32>,
7662 {
7663 self.heading = std::option::Option::Some(v.into());
7664 self
7665 }
7666
7667 /// Sets or clears the value of [heading][crate::model::Location::heading].
7668 ///
7669 /// # Example
7670 /// ```ignore,no_run
7671 /// # use google_cloud_optimization_v1::model::Location;
7672 /// let x = Location::new().set_or_clear_heading(Some(42));
7673 /// let x = Location::new().set_or_clear_heading(None::<i32>);
7674 /// ```
7675 pub fn set_or_clear_heading<T>(mut self, v: std::option::Option<T>) -> Self
7676 where
7677 T: std::convert::Into<i32>,
7678 {
7679 self.heading = v.map(|x| x.into());
7680 self
7681 }
7682}
7683
7684impl wkt::message::Message for Location {
7685 fn typename() -> &'static str {
7686 "type.googleapis.com/google.cloud.optimization.v1.Location"
7687 }
7688}
7689
7690/// Rules to generate time breaks for a vehicle (e.g. lunch breaks). A break
7691/// is a contiguous period of time during which the vehicle remains idle at its
7692/// current position and cannot perform any visit. A break may occur:
7693///
7694/// * during the travel between two visits (which includes the time right
7695/// before or right after a visit, but not in the middle of a visit), in
7696/// which case it extends the corresponding transit time between the visits,
7697/// * or before the vehicle start (the vehicle may not start in the middle of
7698/// a break), in which case it does not affect the vehicle start time.
7699/// * or after the vehicle end (ditto, with the vehicle end time).
7700#[derive(Clone, Default, PartialEq)]
7701#[non_exhaustive]
7702pub struct BreakRule {
7703 /// Sequence of breaks. See the `BreakRequest` message.
7704 pub break_requests: std::vec::Vec<crate::model::break_rule::BreakRequest>,
7705
7706 /// Several `FrequencyConstraint` may apply. They must all be satisfied by
7707 /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
7708 pub frequency_constraints: std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
7709
7710 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7711}
7712
7713impl BreakRule {
7714 /// Creates a new default instance.
7715 pub fn new() -> Self {
7716 std::default::Default::default()
7717 }
7718
7719 /// Sets the value of [break_requests][crate::model::BreakRule::break_requests].
7720 ///
7721 /// # Example
7722 /// ```ignore,no_run
7723 /// # use google_cloud_optimization_v1::model::BreakRule;
7724 /// use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7725 /// let x = BreakRule::new()
7726 /// .set_break_requests([
7727 /// BreakRequest::default()/* use setters */,
7728 /// BreakRequest::default()/* use (different) setters */,
7729 /// ]);
7730 /// ```
7731 pub fn set_break_requests<T, V>(mut self, v: T) -> Self
7732 where
7733 T: std::iter::IntoIterator<Item = V>,
7734 V: std::convert::Into<crate::model::break_rule::BreakRequest>,
7735 {
7736 use std::iter::Iterator;
7737 self.break_requests = v.into_iter().map(|i| i.into()).collect();
7738 self
7739 }
7740
7741 /// Sets the value of [frequency_constraints][crate::model::BreakRule::frequency_constraints].
7742 ///
7743 /// # Example
7744 /// ```ignore,no_run
7745 /// # use google_cloud_optimization_v1::model::BreakRule;
7746 /// use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7747 /// let x = BreakRule::new()
7748 /// .set_frequency_constraints([
7749 /// FrequencyConstraint::default()/* use setters */,
7750 /// FrequencyConstraint::default()/* use (different) setters */,
7751 /// ]);
7752 /// ```
7753 pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
7754 where
7755 T: std::iter::IntoIterator<Item = V>,
7756 V: std::convert::Into<crate::model::break_rule::FrequencyConstraint>,
7757 {
7758 use std::iter::Iterator;
7759 self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
7760 self
7761 }
7762}
7763
7764impl wkt::message::Message for BreakRule {
7765 fn typename() -> &'static str {
7766 "type.googleapis.com/google.cloud.optimization.v1.BreakRule"
7767 }
7768}
7769
7770/// Defines additional types related to [BreakRule].
7771pub mod break_rule {
7772 #[allow(unused_imports)]
7773 use super::*;
7774
7775 /// The sequence of breaks (i.e. their number and order) that apply to each
7776 /// vehicle must be known beforehand. The repeated `BreakRequest`s define
7777 /// that sequence, in the order in which they must occur. Their time windows
7778 /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
7779 /// be compatible with the order (this is checked).
7780 #[derive(Clone, Default, PartialEq)]
7781 #[non_exhaustive]
7782 pub struct BreakRequest {
7783 /// Required. Lower bound (inclusive) on the start of the break.
7784 pub earliest_start_time: std::option::Option<wkt::Timestamp>,
7785
7786 /// Required. Upper bound (inclusive) on the start of the break.
7787 pub latest_start_time: std::option::Option<wkt::Timestamp>,
7788
7789 /// Required. Minimum duration of the break. Must be positive.
7790 pub min_duration: std::option::Option<wkt::Duration>,
7791
7792 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7793 }
7794
7795 impl BreakRequest {
7796 /// Creates a new default instance.
7797 pub fn new() -> Self {
7798 std::default::Default::default()
7799 }
7800
7801 /// Sets the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
7802 ///
7803 /// # Example
7804 /// ```ignore,no_run
7805 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7806 /// use wkt::Timestamp;
7807 /// let x = BreakRequest::new().set_earliest_start_time(Timestamp::default()/* use setters */);
7808 /// ```
7809 pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
7810 where
7811 T: std::convert::Into<wkt::Timestamp>,
7812 {
7813 self.earliest_start_time = std::option::Option::Some(v.into());
7814 self
7815 }
7816
7817 /// Sets or clears the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
7818 ///
7819 /// # Example
7820 /// ```ignore,no_run
7821 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7822 /// use wkt::Timestamp;
7823 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(Some(Timestamp::default()/* use setters */));
7824 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(None::<Timestamp>);
7825 /// ```
7826 pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7827 where
7828 T: std::convert::Into<wkt::Timestamp>,
7829 {
7830 self.earliest_start_time = v.map(|x| x.into());
7831 self
7832 }
7833
7834 /// Sets the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
7835 ///
7836 /// # Example
7837 /// ```ignore,no_run
7838 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7839 /// use wkt::Timestamp;
7840 /// let x = BreakRequest::new().set_latest_start_time(Timestamp::default()/* use setters */);
7841 /// ```
7842 pub fn set_latest_start_time<T>(mut self, v: T) -> Self
7843 where
7844 T: std::convert::Into<wkt::Timestamp>,
7845 {
7846 self.latest_start_time = std::option::Option::Some(v.into());
7847 self
7848 }
7849
7850 /// Sets or clears the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
7851 ///
7852 /// # Example
7853 /// ```ignore,no_run
7854 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7855 /// use wkt::Timestamp;
7856 /// let x = BreakRequest::new().set_or_clear_latest_start_time(Some(Timestamp::default()/* use setters */));
7857 /// let x = BreakRequest::new().set_or_clear_latest_start_time(None::<Timestamp>);
7858 /// ```
7859 pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7860 where
7861 T: std::convert::Into<wkt::Timestamp>,
7862 {
7863 self.latest_start_time = v.map(|x| x.into());
7864 self
7865 }
7866
7867 /// Sets the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
7868 ///
7869 /// # Example
7870 /// ```ignore,no_run
7871 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7872 /// use wkt::Duration;
7873 /// let x = BreakRequest::new().set_min_duration(Duration::default()/* use setters */);
7874 /// ```
7875 pub fn set_min_duration<T>(mut self, v: T) -> Self
7876 where
7877 T: std::convert::Into<wkt::Duration>,
7878 {
7879 self.min_duration = std::option::Option::Some(v.into());
7880 self
7881 }
7882
7883 /// Sets or clears the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
7884 ///
7885 /// # Example
7886 /// ```ignore,no_run
7887 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7888 /// use wkt::Duration;
7889 /// let x = BreakRequest::new().set_or_clear_min_duration(Some(Duration::default()/* use setters */));
7890 /// let x = BreakRequest::new().set_or_clear_min_duration(None::<Duration>);
7891 /// ```
7892 pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
7893 where
7894 T: std::convert::Into<wkt::Duration>,
7895 {
7896 self.min_duration = v.map(|x| x.into());
7897 self
7898 }
7899 }
7900
7901 impl wkt::message::Message for BreakRequest {
7902 fn typename() -> &'static str {
7903 "type.googleapis.com/google.cloud.optimization.v1.BreakRule.BreakRequest"
7904 }
7905 }
7906
7907 /// One may further constrain the frequency and duration of the breaks
7908 /// specified above, by enforcing a minimum break frequency, such as
7909 /// "There must be a break of at least 1 hour every 12 hours". Assuming that
7910 /// this can be interpreted as "Within any sliding time window of 12h, there
7911 /// must be at least one break of at least one hour", that example would
7912 /// translate to the following `FrequencyConstraint`:
7913 ///
7914 /// ```norust
7915 /// {
7916 /// min_break_duration { seconds: 3600 } # 1 hour.
7917 /// max_inter_break_duration { seconds: 39600 } # 11 hours (12 - 1 = 11).
7918 /// }
7919 /// ```
7920 ///
7921 /// The timing and duration of the breaks in the solution will respect all
7922 /// such constraints, in addition to the time windows and minimum durations
7923 /// already specified in the `BreakRequest`.
7924 ///
7925 /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
7926 /// For example, the following schedule honors the "1h every 12h" example:
7927 ///
7928 /// ```norust
7929 /// 04:00 vehicle start
7930 /// .. performing travel and visits ..
7931 /// 09:00 1 hour break
7932 /// 10:00 end of the break
7933 /// .. performing travel and visits ..
7934 /// 12:00 20-min lunch break
7935 /// 12:20 end of the break
7936 /// .. performing travel and visits ..
7937 /// 21:00 1 hour break
7938 /// 22:00 end of the break
7939 /// .. performing travel and visits ..
7940 /// 23:59 vehicle end
7941 /// ```
7942 #[derive(Clone, Default, PartialEq)]
7943 #[non_exhaustive]
7944 pub struct FrequencyConstraint {
7945 /// Required. Minimum break duration for this constraint. Nonnegative.
7946 /// See description of `FrequencyConstraint`.
7947 pub min_break_duration: std::option::Option<wkt::Duration>,
7948
7949 /// Required. Maximum allowed span of any interval of time in the route that
7950 /// does not include at least partially a break of `duration >=
7951 /// min_break_duration`. Must be positive.
7952 pub max_inter_break_duration: std::option::Option<wkt::Duration>,
7953
7954 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7955 }
7956
7957 impl FrequencyConstraint {
7958 /// Creates a new default instance.
7959 pub fn new() -> Self {
7960 std::default::Default::default()
7961 }
7962
7963 /// Sets the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
7964 ///
7965 /// # Example
7966 /// ```ignore,no_run
7967 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7968 /// use wkt::Duration;
7969 /// let x = FrequencyConstraint::new().set_min_break_duration(Duration::default()/* use setters */);
7970 /// ```
7971 pub fn set_min_break_duration<T>(mut self, v: T) -> Self
7972 where
7973 T: std::convert::Into<wkt::Duration>,
7974 {
7975 self.min_break_duration = std::option::Option::Some(v.into());
7976 self
7977 }
7978
7979 /// Sets or clears the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
7980 ///
7981 /// # Example
7982 /// ```ignore,no_run
7983 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7984 /// use wkt::Duration;
7985 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(Some(Duration::default()/* use setters */));
7986 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(None::<Duration>);
7987 /// ```
7988 pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
7989 where
7990 T: std::convert::Into<wkt::Duration>,
7991 {
7992 self.min_break_duration = v.map(|x| x.into());
7993 self
7994 }
7995
7996 /// Sets the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
7997 ///
7998 /// # Example
7999 /// ```ignore,no_run
8000 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
8001 /// use wkt::Duration;
8002 /// let x = FrequencyConstraint::new().set_max_inter_break_duration(Duration::default()/* use setters */);
8003 /// ```
8004 pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
8005 where
8006 T: std::convert::Into<wkt::Duration>,
8007 {
8008 self.max_inter_break_duration = std::option::Option::Some(v.into());
8009 self
8010 }
8011
8012 /// Sets or clears the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
8013 ///
8014 /// # Example
8015 /// ```ignore,no_run
8016 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
8017 /// use wkt::Duration;
8018 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(Some(Duration::default()/* use setters */));
8019 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(None::<Duration>);
8020 /// ```
8021 pub fn set_or_clear_max_inter_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
8022 where
8023 T: std::convert::Into<wkt::Duration>,
8024 {
8025 self.max_inter_break_duration = v.map(|x| x.into());
8026 self
8027 }
8028 }
8029
8030 impl wkt::message::Message for FrequencyConstraint {
8031 fn typename() -> &'static str {
8032 "type.googleapis.com/google.cloud.optimization.v1.BreakRule.FrequencyConstraint"
8033 }
8034 }
8035}
8036
8037/// A vehicle's route can be decomposed, along the time axis, like this (we
8038/// assume there are n visits):
8039///
8040/// ```norust
8041/// | | | | | T[2], | | |
8042/// | Transition | Visit #0 | | | V[2], | | |
8043/// | #0 | aka | T[1] | V[1] | ... | V[n-1] | T[n] |
8044/// | aka T[0] | V[0] | | | V[n-2],| | |
8045/// | | | | | T[n-1] | | |
8046/// ^ ^ ^ ^ ^ ^ ^ ^
8047/// vehicle V[0].start V[0].end V[1]. V[1]. V[n]. V[n]. vehicle
8048/// start (arrival) (departure) start end start end end
8049/// ```
8050///
8051/// Note that we make a difference between:
8052///
8053/// * "punctual events", such as the vehicle start and end and each visit's start
8054/// and end (aka arrival and departure). They happen at a given second.
8055/// * "time intervals", such as the visits themselves, and the transition between
8056/// visits. Though time intervals can sometimes have zero duration, i.e. start
8057/// and end at the same second, they often have a positive duration.
8058///
8059/// Invariants:
8060///
8061/// * If there are n visits, there are n+1 transitions.
8062/// * A visit is always surrounded by a transition before it (same index) and a
8063/// transition after it (index + 1).
8064/// * The vehicle start is always followed by transition #0.
8065/// * The vehicle end is always preceded by transition #n.
8066///
8067/// Zooming in, here is what happens during a `Transition` and a `Visit`:
8068///
8069/// ```norust
8070/// ---+-------------------------------------+-----------------------------+-->
8071/// | TRANSITION[i] | VISIT[i] |
8072/// | | |
8073/// | * TRAVEL: the vehicle moves from | PERFORM the visit: |
8074/// | VISIT[i-1].departure_location to | |
8075/// | VISIT[i].arrival_location, which | * Spend some time: |
8076/// | takes a given travel duration | the "visit duration". |
8077/// | and distance | |
8078/// | | * Load or unload |
8079/// | * BREAKS: the driver may have | some quantities from the |
8080/// | breaks (e.g. lunch break). | vehicle: the "demand". |
8081/// | | |
8082/// | * WAIT: the driver/vehicle does | |
8083/// | nothing. This can happen for | |
8084/// | many reasons, for example when | |
8085/// | the vehicle reaches the next | |
8086/// | event's destination before the | |
8087/// | start of its time window | |
8088/// | | |
8089/// | * DELAY: *right before* the next | |
8090/// | arrival. E.g. the vehicle and/or | |
8091/// | driver spends time unloading. | |
8092/// | | |
8093/// ---+-------------------------------------+-----------------------------+-->
8094/// ^ ^ ^
8095/// V[i-1].end V[i].start V[i].end
8096/// ```
8097///
8098/// Lastly, here is how the TRAVEL, BREAKS, DELAY and WAIT can be arranged
8099/// during a transition.
8100///
8101/// * They don't overlap.
8102/// * The DELAY is unique and *must* be a contiguous period of time right
8103/// before the next visit (or vehicle end). Thus, it suffice to know the
8104/// delay duration to know its start and end time.
8105/// * The BREAKS are contiguous, non-overlapping periods of time. The
8106/// response specifies the start time and duration of each break.
8107/// * TRAVEL and WAIT are "preemptable": they can be interrupted several times
8108/// during this transition. Clients can assume that travel happens "as soon as
8109/// possible" and that "wait" fills the remaining time.
8110///
8111/// A (complex) example:
8112///
8113/// ```norust
8114/// TRANSITION[i]
8115/// --++-----+-----------------------------------------------------------++-->
8116/// || | | | | | | ||
8117/// || T | B | T | | B | | D ||
8118/// || r | r | r | W | r | W | e ||
8119/// || a | e | a | a | e | a | l ||
8120/// || v | a | v | i | a | i | a ||
8121/// || e | k | e | t | k | t | y ||
8122/// || l | | l | | | | ||
8123/// || | | | | | | ||
8124/// --++-----------------------------------------------------------------++-->
8125/// ```
8126#[derive(Clone, Default, PartialEq)]
8127#[non_exhaustive]
8128pub struct ShipmentRoute {
8129 /// Vehicle performing the route, identified by its index in the source
8130 /// `ShipmentModel`.
8131 pub vehicle_index: i32,
8132
8133 /// Label of the vehicle performing this route, equal to
8134 /// `ShipmentModel.vehicles(vehicle_index).label`, if specified.
8135 pub vehicle_label: std::string::String,
8136
8137 /// Time at which the vehicle starts its route.
8138 pub vehicle_start_time: std::option::Option<wkt::Timestamp>,
8139
8140 /// Time at which the vehicle finishes its route.
8141 pub vehicle_end_time: std::option::Option<wkt::Timestamp>,
8142
8143 /// Ordered sequence of visits representing a route.
8144 /// visits[i] is the i-th visit in the route.
8145 /// If this field is empty, the vehicle is considered as unused.
8146 pub visits: std::vec::Vec<crate::model::shipment_route::Visit>,
8147
8148 /// Ordered list of transitions for the route.
8149 pub transitions: std::vec::Vec<crate::model::shipment_route::Transition>,
8150
8151 /// When
8152 /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
8153 /// is set to true, this field indicates that inconsistencies in route timings
8154 /// are predicted using traffic-based travel duration estimates. There may be
8155 /// insufficient time to complete traffic-adjusted travel, delays, and breaks
8156 /// between visits, before the first visit, or after the last visit, while
8157 /// still satisfying the visit and vehicle time windows. For example,
8158 ///
8159 /// ```norust
8160 /// start_time(previous_visit) + duration(previous_visit) +
8161 /// travel_duration(previous_visit, next_visit) > start_time(next_visit)
8162 /// ```
8163 ///
8164 /// Arrival at next_visit will likely happen later than its current
8165 /// time window due the increased estimate of travel time
8166 /// `travel_duration(previous_visit, next_visit)` due to traffic. Also, a break
8167 /// may be forced to overlap with a visit due to an increase in travel time
8168 /// estimates and visit or break time window restrictions.
8169 ///
8170 /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
8171 pub has_traffic_infeasibilities: bool,
8172
8173 /// The encoded polyline representation of the route.
8174 /// This field is only populated if
8175 /// [OptimizeToursRequest.populate_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]
8176 /// is set to true.
8177 ///
8178 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]: crate::model::OptimizeToursRequest::populate_polylines
8179 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
8180
8181 /// Breaks scheduled for the vehicle performing this route.
8182 /// The `breaks` sequence represents time intervals, each starting at the
8183 /// corresponding `start_time` and lasting `duration` seconds.
8184 pub breaks: std::vec::Vec<crate::model::shipment_route::Break>,
8185
8186 /// Duration, distance and load metrics for this route. The fields of
8187 /// [AggregatedMetrics][google.cloud.optimization.v1.AggregatedMetrics] are
8188 /// summed over all
8189 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
8190 /// or
8191 /// [ShipmentRoute.visits][google.cloud.optimization.v1.ShipmentRoute.visits],
8192 /// depending on the context.
8193 ///
8194 /// [google.cloud.optimization.v1.AggregatedMetrics]: crate::model::AggregatedMetrics
8195 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8196 /// [google.cloud.optimization.v1.ShipmentRoute.visits]: crate::model::ShipmentRoute::visits
8197 pub metrics: std::option::Option<crate::model::AggregatedMetrics>,
8198
8199 /// Cost of the route, broken down by cost-related request fields.
8200 /// The keys are proto paths, relative to the input OptimizeToursRequest, e.g.
8201 /// "model.shipments.pickups.cost", and the values are the total cost
8202 /// generated by the corresponding cost field, aggregated over the whole route.
8203 /// In other words, costs["model.shipments.pickups.cost"] is the sum of all
8204 /// pickup costs over the route. All costs defined in the model are reported in
8205 /// detail here with the exception of costs related to TransitionAttributes
8206 /// that are only reported in an aggregated way as of 2022/01.
8207 pub route_costs: std::collections::HashMap<std::string::String, f64>,
8208
8209 /// Total cost of the route. The sum of all costs in the cost map.
8210 pub route_total_cost: f64,
8211
8212 /// Deprecated: Use
8213 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
8214 /// instead. Vehicle loads upon arrival at its end location, for each type
8215 /// specified in
8216 /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
8217 /// `start_load_intervals`, `end_load_intervals` or demands. Exception: we omit
8218 /// loads for quantity types unconstrained by intervals and that don't have any
8219 /// non-zero demand on the route.
8220 ///
8221 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
8222 /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
8223 #[deprecated]
8224 pub end_loads: std::vec::Vec<crate::model::CapacityQuantity>,
8225
8226 /// Deprecated: Use
8227 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
8228 /// instead. Ordered list of travel steps for the route.
8229 ///
8230 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8231 #[deprecated]
8232 pub travel_steps: std::vec::Vec<crate::model::shipment_route::TravelStep>,
8233
8234 /// Deprecated: No longer used.
8235 /// This field will only be populated at the
8236 /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit]
8237 /// level.
8238 ///
8239 /// This field is the extra detour time due to the shipments visited on the
8240 /// route.
8241 ///
8242 /// It is equal to `vehicle_end_time` - `vehicle_start_time` - travel duration
8243 /// from the vehicle's start_location to its `end_location`.
8244 ///
8245 /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
8246 #[deprecated]
8247 pub vehicle_detour: std::option::Option<wkt::Duration>,
8248
8249 /// Deprecated: Delay occurring before the vehicle end. See
8250 /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
8251 ///
8252 /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
8253 #[deprecated]
8254 pub delay_before_vehicle_end: std::option::Option<crate::model::shipment_route::Delay>,
8255
8256 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8257}
8258
8259impl ShipmentRoute {
8260 /// Creates a new default instance.
8261 pub fn new() -> Self {
8262 std::default::Default::default()
8263 }
8264
8265 /// Sets the value of [vehicle_index][crate::model::ShipmentRoute::vehicle_index].
8266 ///
8267 /// # Example
8268 /// ```ignore,no_run
8269 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8270 /// let x = ShipmentRoute::new().set_vehicle_index(42);
8271 /// ```
8272 pub fn set_vehicle_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8273 self.vehicle_index = v.into();
8274 self
8275 }
8276
8277 /// Sets the value of [vehicle_label][crate::model::ShipmentRoute::vehicle_label].
8278 ///
8279 /// # Example
8280 /// ```ignore,no_run
8281 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8282 /// let x = ShipmentRoute::new().set_vehicle_label("example");
8283 /// ```
8284 pub fn set_vehicle_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8285 self.vehicle_label = v.into();
8286 self
8287 }
8288
8289 /// Sets the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
8290 ///
8291 /// # Example
8292 /// ```ignore,no_run
8293 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8294 /// use wkt::Timestamp;
8295 /// let x = ShipmentRoute::new().set_vehicle_start_time(Timestamp::default()/* use setters */);
8296 /// ```
8297 pub fn set_vehicle_start_time<T>(mut self, v: T) -> Self
8298 where
8299 T: std::convert::Into<wkt::Timestamp>,
8300 {
8301 self.vehicle_start_time = std::option::Option::Some(v.into());
8302 self
8303 }
8304
8305 /// Sets or clears the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
8306 ///
8307 /// # Example
8308 /// ```ignore,no_run
8309 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8310 /// use wkt::Timestamp;
8311 /// let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(Some(Timestamp::default()/* use setters */));
8312 /// let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(None::<Timestamp>);
8313 /// ```
8314 pub fn set_or_clear_vehicle_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8315 where
8316 T: std::convert::Into<wkt::Timestamp>,
8317 {
8318 self.vehicle_start_time = v.map(|x| x.into());
8319 self
8320 }
8321
8322 /// Sets the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
8323 ///
8324 /// # Example
8325 /// ```ignore,no_run
8326 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8327 /// use wkt::Timestamp;
8328 /// let x = ShipmentRoute::new().set_vehicle_end_time(Timestamp::default()/* use setters */);
8329 /// ```
8330 pub fn set_vehicle_end_time<T>(mut self, v: T) -> Self
8331 where
8332 T: std::convert::Into<wkt::Timestamp>,
8333 {
8334 self.vehicle_end_time = std::option::Option::Some(v.into());
8335 self
8336 }
8337
8338 /// Sets or clears the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
8339 ///
8340 /// # Example
8341 /// ```ignore,no_run
8342 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8343 /// use wkt::Timestamp;
8344 /// let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(Some(Timestamp::default()/* use setters */));
8345 /// let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(None::<Timestamp>);
8346 /// ```
8347 pub fn set_or_clear_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
8348 where
8349 T: std::convert::Into<wkt::Timestamp>,
8350 {
8351 self.vehicle_end_time = v.map(|x| x.into());
8352 self
8353 }
8354
8355 /// Sets the value of [visits][crate::model::ShipmentRoute::visits].
8356 ///
8357 /// # Example
8358 /// ```ignore,no_run
8359 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8360 /// use google_cloud_optimization_v1::model::shipment_route::Visit;
8361 /// let x = ShipmentRoute::new()
8362 /// .set_visits([
8363 /// Visit::default()/* use setters */,
8364 /// Visit::default()/* use (different) setters */,
8365 /// ]);
8366 /// ```
8367 pub fn set_visits<T, V>(mut self, v: T) -> Self
8368 where
8369 T: std::iter::IntoIterator<Item = V>,
8370 V: std::convert::Into<crate::model::shipment_route::Visit>,
8371 {
8372 use std::iter::Iterator;
8373 self.visits = v.into_iter().map(|i| i.into()).collect();
8374 self
8375 }
8376
8377 /// Sets the value of [transitions][crate::model::ShipmentRoute::transitions].
8378 ///
8379 /// # Example
8380 /// ```ignore,no_run
8381 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8382 /// use google_cloud_optimization_v1::model::shipment_route::Transition;
8383 /// let x = ShipmentRoute::new()
8384 /// .set_transitions([
8385 /// Transition::default()/* use setters */,
8386 /// Transition::default()/* use (different) setters */,
8387 /// ]);
8388 /// ```
8389 pub fn set_transitions<T, V>(mut self, v: T) -> Self
8390 where
8391 T: std::iter::IntoIterator<Item = V>,
8392 V: std::convert::Into<crate::model::shipment_route::Transition>,
8393 {
8394 use std::iter::Iterator;
8395 self.transitions = v.into_iter().map(|i| i.into()).collect();
8396 self
8397 }
8398
8399 /// Sets the value of [has_traffic_infeasibilities][crate::model::ShipmentRoute::has_traffic_infeasibilities].
8400 ///
8401 /// # Example
8402 /// ```ignore,no_run
8403 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8404 /// let x = ShipmentRoute::new().set_has_traffic_infeasibilities(true);
8405 /// ```
8406 pub fn set_has_traffic_infeasibilities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8407 self.has_traffic_infeasibilities = v.into();
8408 self
8409 }
8410
8411 /// Sets the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
8412 ///
8413 /// # Example
8414 /// ```ignore,no_run
8415 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8416 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
8417 /// let x = ShipmentRoute::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
8418 /// ```
8419 pub fn set_route_polyline<T>(mut self, v: T) -> Self
8420 where
8421 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8422 {
8423 self.route_polyline = std::option::Option::Some(v.into());
8424 self
8425 }
8426
8427 /// Sets or clears the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
8428 ///
8429 /// # Example
8430 /// ```ignore,no_run
8431 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8432 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
8433 /// let x = ShipmentRoute::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
8434 /// let x = ShipmentRoute::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
8435 /// ```
8436 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
8437 where
8438 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8439 {
8440 self.route_polyline = v.map(|x| x.into());
8441 self
8442 }
8443
8444 /// Sets the value of [breaks][crate::model::ShipmentRoute::breaks].
8445 ///
8446 /// # Example
8447 /// ```ignore,no_run
8448 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8449 /// use google_cloud_optimization_v1::model::shipment_route::Break;
8450 /// let x = ShipmentRoute::new()
8451 /// .set_breaks([
8452 /// Break::default()/* use setters */,
8453 /// Break::default()/* use (different) setters */,
8454 /// ]);
8455 /// ```
8456 pub fn set_breaks<T, V>(mut self, v: T) -> Self
8457 where
8458 T: std::iter::IntoIterator<Item = V>,
8459 V: std::convert::Into<crate::model::shipment_route::Break>,
8460 {
8461 use std::iter::Iterator;
8462 self.breaks = v.into_iter().map(|i| i.into()).collect();
8463 self
8464 }
8465
8466 /// Sets the value of [metrics][crate::model::ShipmentRoute::metrics].
8467 ///
8468 /// # Example
8469 /// ```ignore,no_run
8470 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8471 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
8472 /// let x = ShipmentRoute::new().set_metrics(AggregatedMetrics::default()/* use setters */);
8473 /// ```
8474 pub fn set_metrics<T>(mut self, v: T) -> Self
8475 where
8476 T: std::convert::Into<crate::model::AggregatedMetrics>,
8477 {
8478 self.metrics = std::option::Option::Some(v.into());
8479 self
8480 }
8481
8482 /// Sets or clears the value of [metrics][crate::model::ShipmentRoute::metrics].
8483 ///
8484 /// # Example
8485 /// ```ignore,no_run
8486 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8487 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
8488 /// let x = ShipmentRoute::new().set_or_clear_metrics(Some(AggregatedMetrics::default()/* use setters */));
8489 /// let x = ShipmentRoute::new().set_or_clear_metrics(None::<AggregatedMetrics>);
8490 /// ```
8491 pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
8492 where
8493 T: std::convert::Into<crate::model::AggregatedMetrics>,
8494 {
8495 self.metrics = v.map(|x| x.into());
8496 self
8497 }
8498
8499 /// Sets the value of [route_costs][crate::model::ShipmentRoute::route_costs].
8500 ///
8501 /// # Example
8502 /// ```ignore,no_run
8503 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8504 /// let x = ShipmentRoute::new().set_route_costs([
8505 /// ("key0", 123.5),
8506 /// ("key1", 456.5),
8507 /// ]);
8508 /// ```
8509 pub fn set_route_costs<T, K, V>(mut self, v: T) -> Self
8510 where
8511 T: std::iter::IntoIterator<Item = (K, V)>,
8512 K: std::convert::Into<std::string::String>,
8513 V: std::convert::Into<f64>,
8514 {
8515 use std::iter::Iterator;
8516 self.route_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8517 self
8518 }
8519
8520 /// Sets the value of [route_total_cost][crate::model::ShipmentRoute::route_total_cost].
8521 ///
8522 /// # Example
8523 /// ```ignore,no_run
8524 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8525 /// let x = ShipmentRoute::new().set_route_total_cost(42.0);
8526 /// ```
8527 pub fn set_route_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8528 self.route_total_cost = v.into();
8529 self
8530 }
8531
8532 /// Sets the value of [end_loads][crate::model::ShipmentRoute::end_loads].
8533 ///
8534 /// # Example
8535 /// ```ignore,no_run
8536 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8537 /// use google_cloud_optimization_v1::model::CapacityQuantity;
8538 /// let x = ShipmentRoute::new()
8539 /// .set_end_loads([
8540 /// CapacityQuantity::default()/* use setters */,
8541 /// CapacityQuantity::default()/* use (different) setters */,
8542 /// ]);
8543 /// ```
8544 #[deprecated]
8545 pub fn set_end_loads<T, V>(mut self, v: T) -> Self
8546 where
8547 T: std::iter::IntoIterator<Item = V>,
8548 V: std::convert::Into<crate::model::CapacityQuantity>,
8549 {
8550 use std::iter::Iterator;
8551 self.end_loads = v.into_iter().map(|i| i.into()).collect();
8552 self
8553 }
8554
8555 /// Sets the value of [travel_steps][crate::model::ShipmentRoute::travel_steps].
8556 ///
8557 /// # Example
8558 /// ```ignore,no_run
8559 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8560 /// use google_cloud_optimization_v1::model::shipment_route::TravelStep;
8561 /// let x = ShipmentRoute::new()
8562 /// .set_travel_steps([
8563 /// TravelStep::default()/* use setters */,
8564 /// TravelStep::default()/* use (different) setters */,
8565 /// ]);
8566 /// ```
8567 #[deprecated]
8568 pub fn set_travel_steps<T, V>(mut self, v: T) -> Self
8569 where
8570 T: std::iter::IntoIterator<Item = V>,
8571 V: std::convert::Into<crate::model::shipment_route::TravelStep>,
8572 {
8573 use std::iter::Iterator;
8574 self.travel_steps = v.into_iter().map(|i| i.into()).collect();
8575 self
8576 }
8577
8578 /// Sets the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
8579 ///
8580 /// # Example
8581 /// ```ignore,no_run
8582 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8583 /// use wkt::Duration;
8584 /// let x = ShipmentRoute::new().set_vehicle_detour(Duration::default()/* use setters */);
8585 /// ```
8586 #[deprecated]
8587 pub fn set_vehicle_detour<T>(mut self, v: T) -> Self
8588 where
8589 T: std::convert::Into<wkt::Duration>,
8590 {
8591 self.vehicle_detour = std::option::Option::Some(v.into());
8592 self
8593 }
8594
8595 /// Sets or clears the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
8596 ///
8597 /// # Example
8598 /// ```ignore,no_run
8599 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8600 /// use wkt::Duration;
8601 /// let x = ShipmentRoute::new().set_or_clear_vehicle_detour(Some(Duration::default()/* use setters */));
8602 /// let x = ShipmentRoute::new().set_or_clear_vehicle_detour(None::<Duration>);
8603 /// ```
8604 #[deprecated]
8605 pub fn set_or_clear_vehicle_detour<T>(mut self, v: std::option::Option<T>) -> Self
8606 where
8607 T: std::convert::Into<wkt::Duration>,
8608 {
8609 self.vehicle_detour = v.map(|x| x.into());
8610 self
8611 }
8612
8613 /// Sets the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
8614 ///
8615 /// # Example
8616 /// ```ignore,no_run
8617 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8618 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
8619 /// let x = ShipmentRoute::new().set_delay_before_vehicle_end(Delay::default()/* use setters */);
8620 /// ```
8621 #[deprecated]
8622 pub fn set_delay_before_vehicle_end<T>(mut self, v: T) -> Self
8623 where
8624 T: std::convert::Into<crate::model::shipment_route::Delay>,
8625 {
8626 self.delay_before_vehicle_end = std::option::Option::Some(v.into());
8627 self
8628 }
8629
8630 /// Sets or clears the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
8631 ///
8632 /// # Example
8633 /// ```ignore,no_run
8634 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8635 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
8636 /// let x = ShipmentRoute::new().set_or_clear_delay_before_vehicle_end(Some(Delay::default()/* use setters */));
8637 /// let x = ShipmentRoute::new().set_or_clear_delay_before_vehicle_end(None::<Delay>);
8638 /// ```
8639 #[deprecated]
8640 pub fn set_or_clear_delay_before_vehicle_end<T>(mut self, v: std::option::Option<T>) -> Self
8641 where
8642 T: std::convert::Into<crate::model::shipment_route::Delay>,
8643 {
8644 self.delay_before_vehicle_end = v.map(|x| x.into());
8645 self
8646 }
8647}
8648
8649impl wkt::message::Message for ShipmentRoute {
8650 fn typename() -> &'static str {
8651 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute"
8652 }
8653}
8654
8655/// Defines additional types related to [ShipmentRoute].
8656pub mod shipment_route {
8657 #[allow(unused_imports)]
8658 use super::*;
8659
8660 /// Deprecated: Use
8661 /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
8662 /// instead. Time interval spent on the route resulting from a
8663 /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
8664 ///
8665 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
8666 /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
8667 #[derive(Clone, Default, PartialEq)]
8668 #[non_exhaustive]
8669 #[deprecated]
8670 pub struct Delay {
8671 /// Start of the delay.
8672 pub start_time: std::option::Option<wkt::Timestamp>,
8673
8674 /// Duration of the delay.
8675 pub duration: std::option::Option<wkt::Duration>,
8676
8677 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8678 }
8679
8680 impl Delay {
8681 /// Creates a new default instance.
8682 pub fn new() -> Self {
8683 std::default::Default::default()
8684 }
8685
8686 /// Sets the value of [start_time][crate::model::shipment_route::Delay::start_time].
8687 ///
8688 /// # Example
8689 /// ```ignore,no_run
8690 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8691 /// use wkt::Timestamp;
8692 /// let x = Delay::new().set_start_time(Timestamp::default()/* use setters */);
8693 /// ```
8694 pub fn set_start_time<T>(mut self, v: T) -> Self
8695 where
8696 T: std::convert::Into<wkt::Timestamp>,
8697 {
8698 self.start_time = std::option::Option::Some(v.into());
8699 self
8700 }
8701
8702 /// Sets or clears the value of [start_time][crate::model::shipment_route::Delay::start_time].
8703 ///
8704 /// # Example
8705 /// ```ignore,no_run
8706 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8707 /// use wkt::Timestamp;
8708 /// let x = Delay::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
8709 /// let x = Delay::new().set_or_clear_start_time(None::<Timestamp>);
8710 /// ```
8711 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8712 where
8713 T: std::convert::Into<wkt::Timestamp>,
8714 {
8715 self.start_time = v.map(|x| x.into());
8716 self
8717 }
8718
8719 /// Sets the value of [duration][crate::model::shipment_route::Delay::duration].
8720 ///
8721 /// # Example
8722 /// ```ignore,no_run
8723 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8724 /// use wkt::Duration;
8725 /// let x = Delay::new().set_duration(Duration::default()/* use setters */);
8726 /// ```
8727 pub fn set_duration<T>(mut self, v: T) -> Self
8728 where
8729 T: std::convert::Into<wkt::Duration>,
8730 {
8731 self.duration = std::option::Option::Some(v.into());
8732 self
8733 }
8734
8735 /// Sets or clears the value of [duration][crate::model::shipment_route::Delay::duration].
8736 ///
8737 /// # Example
8738 /// ```ignore,no_run
8739 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8740 /// use wkt::Duration;
8741 /// let x = Delay::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
8742 /// let x = Delay::new().set_or_clear_duration(None::<Duration>);
8743 /// ```
8744 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
8745 where
8746 T: std::convert::Into<wkt::Duration>,
8747 {
8748 self.duration = v.map(|x| x.into());
8749 self
8750 }
8751 }
8752
8753 impl wkt::message::Message for Delay {
8754 fn typename() -> &'static str {
8755 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Delay"
8756 }
8757 }
8758
8759 /// A visit performed during a route. This visit corresponds to a pickup or a
8760 /// delivery of a `Shipment`.
8761 #[derive(Clone, Default, PartialEq)]
8762 #[non_exhaustive]
8763 pub struct Visit {
8764 /// Index of the `shipments` field in the source
8765 /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel].
8766 ///
8767 /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
8768 pub shipment_index: i32,
8769
8770 /// If true the visit corresponds to a pickup of a `Shipment`. Otherwise, it
8771 /// corresponds to a delivery.
8772 pub is_pickup: bool,
8773
8774 /// Index of `VisitRequest` in either the pickup or delivery field of the
8775 /// `Shipment` (see `is_pickup`).
8776 pub visit_request_index: i32,
8777
8778 /// Time at which the visit starts. Note that the vehicle may arrive earlier
8779 /// than this at the visit location. Times are consistent with the
8780 /// `ShipmentModel`.
8781 pub start_time: std::option::Option<wkt::Timestamp>,
8782
8783 /// Total visit load demand as the sum of the shipment and the visit request
8784 /// `load_demands`. The values are negative if the visit is a delivery.
8785 /// Demands are reported for the same types as the
8786 /// [Transition.loads][google.cloud.optimization.v1.ShipmentRoute.Transition]
8787 /// (see this field).
8788 ///
8789 /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
8790 pub load_demands:
8791 std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
8792
8793 /// Extra detour time due to the shipments visited on the route before the
8794 /// visit and to the potential waiting time induced by time windows.
8795 /// If the visit is a delivery, the detour is computed from the corresponding
8796 /// pickup visit and is equal to:
8797 ///
8798 /// ```norust
8799 /// start_time(delivery) - start_time(pickup)
8800 /// - (duration(pickup) + travel duration from the pickup location
8801 /// to the delivery location).
8802 /// ```
8803 ///
8804 /// Otherwise, it is computed from the vehicle `start_location` and is equal
8805 /// to:
8806 ///
8807 /// ```norust
8808 /// start_time - vehicle_start_time - travel duration from
8809 /// the vehicle's `start_location` to the visit.
8810 /// ```
8811 pub detour: std::option::Option<wkt::Duration>,
8812
8813 /// Copy of the corresponding `Shipment.label`, if specified in the
8814 /// `Shipment`.
8815 pub shipment_label: std::string::String,
8816
8817 /// Copy of the corresponding
8818 /// [VisitRequest.label][google.cloud.optimization.v1.Shipment.VisitRequest.label],
8819 /// if specified in the `VisitRequest`.
8820 ///
8821 /// [google.cloud.optimization.v1.Shipment.VisitRequest.label]: crate::model::shipment::VisitRequest::label
8822 pub visit_label: std::string::String,
8823
8824 /// Deprecated: Use
8825 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
8826 /// instead. Vehicle loads upon arrival at the visit location, for each type
8827 /// specified in
8828 /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
8829 /// `start_load_intervals`, `end_load_intervals` or `demands`.
8830 ///
8831 /// Exception: we omit loads for quantity types unconstrained by intervals
8832 /// and that don't have any non-zero demand on the route.
8833 ///
8834 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
8835 /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
8836 #[deprecated]
8837 pub arrival_loads: std::vec::Vec<crate::model::CapacityQuantity>,
8838
8839 /// Deprecated: Use
8840 /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
8841 /// instead. Delay occurring before the visit starts.
8842 ///
8843 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
8844 #[deprecated]
8845 pub delay_before_start: std::option::Option<crate::model::shipment_route::Delay>,
8846
8847 /// Deprecated: Use
8848 /// [Visit.load_demands][google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]
8849 /// instead.
8850 ///
8851 /// [google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]: crate::model::shipment_route::Visit::load_demands
8852 #[deprecated]
8853 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
8854
8855 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8856 }
8857
8858 impl Visit {
8859 /// Creates a new default instance.
8860 pub fn new() -> Self {
8861 std::default::Default::default()
8862 }
8863
8864 /// Sets the value of [shipment_index][crate::model::shipment_route::Visit::shipment_index].
8865 ///
8866 /// # Example
8867 /// ```ignore,no_run
8868 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8869 /// let x = Visit::new().set_shipment_index(42);
8870 /// ```
8871 pub fn set_shipment_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8872 self.shipment_index = v.into();
8873 self
8874 }
8875
8876 /// Sets the value of [is_pickup][crate::model::shipment_route::Visit::is_pickup].
8877 ///
8878 /// # Example
8879 /// ```ignore,no_run
8880 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8881 /// let x = Visit::new().set_is_pickup(true);
8882 /// ```
8883 pub fn set_is_pickup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8884 self.is_pickup = v.into();
8885 self
8886 }
8887
8888 /// Sets the value of [visit_request_index][crate::model::shipment_route::Visit::visit_request_index].
8889 ///
8890 /// # Example
8891 /// ```ignore,no_run
8892 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8893 /// let x = Visit::new().set_visit_request_index(42);
8894 /// ```
8895 pub fn set_visit_request_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8896 self.visit_request_index = v.into();
8897 self
8898 }
8899
8900 /// Sets the value of [start_time][crate::model::shipment_route::Visit::start_time].
8901 ///
8902 /// # Example
8903 /// ```ignore,no_run
8904 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8905 /// use wkt::Timestamp;
8906 /// let x = Visit::new().set_start_time(Timestamp::default()/* use setters */);
8907 /// ```
8908 pub fn set_start_time<T>(mut self, v: T) -> Self
8909 where
8910 T: std::convert::Into<wkt::Timestamp>,
8911 {
8912 self.start_time = std::option::Option::Some(v.into());
8913 self
8914 }
8915
8916 /// Sets or clears the value of [start_time][crate::model::shipment_route::Visit::start_time].
8917 ///
8918 /// # Example
8919 /// ```ignore,no_run
8920 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8921 /// use wkt::Timestamp;
8922 /// let x = Visit::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
8923 /// let x = Visit::new().set_or_clear_start_time(None::<Timestamp>);
8924 /// ```
8925 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8926 where
8927 T: std::convert::Into<wkt::Timestamp>,
8928 {
8929 self.start_time = v.map(|x| x.into());
8930 self
8931 }
8932
8933 /// Sets the value of [load_demands][crate::model::shipment_route::Visit::load_demands].
8934 ///
8935 /// # Example
8936 /// ```ignore,no_run
8937 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8938 /// use google_cloud_optimization_v1::model::shipment::Load;
8939 /// let x = Visit::new().set_load_demands([
8940 /// ("key0", Load::default()/* use setters */),
8941 /// ("key1", Load::default()/* use (different) setters */),
8942 /// ]);
8943 /// ```
8944 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
8945 where
8946 T: std::iter::IntoIterator<Item = (K, V)>,
8947 K: std::convert::Into<std::string::String>,
8948 V: std::convert::Into<crate::model::shipment::Load>,
8949 {
8950 use std::iter::Iterator;
8951 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8952 self
8953 }
8954
8955 /// Sets the value of [detour][crate::model::shipment_route::Visit::detour].
8956 ///
8957 /// # Example
8958 /// ```ignore,no_run
8959 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8960 /// use wkt::Duration;
8961 /// let x = Visit::new().set_detour(Duration::default()/* use setters */);
8962 /// ```
8963 pub fn set_detour<T>(mut self, v: T) -> Self
8964 where
8965 T: std::convert::Into<wkt::Duration>,
8966 {
8967 self.detour = std::option::Option::Some(v.into());
8968 self
8969 }
8970
8971 /// Sets or clears the value of [detour][crate::model::shipment_route::Visit::detour].
8972 ///
8973 /// # Example
8974 /// ```ignore,no_run
8975 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8976 /// use wkt::Duration;
8977 /// let x = Visit::new().set_or_clear_detour(Some(Duration::default()/* use setters */));
8978 /// let x = Visit::new().set_or_clear_detour(None::<Duration>);
8979 /// ```
8980 pub fn set_or_clear_detour<T>(mut self, v: std::option::Option<T>) -> Self
8981 where
8982 T: std::convert::Into<wkt::Duration>,
8983 {
8984 self.detour = v.map(|x| x.into());
8985 self
8986 }
8987
8988 /// Sets the value of [shipment_label][crate::model::shipment_route::Visit::shipment_label].
8989 ///
8990 /// # Example
8991 /// ```ignore,no_run
8992 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8993 /// let x = Visit::new().set_shipment_label("example");
8994 /// ```
8995 pub fn set_shipment_label<T: std::convert::Into<std::string::String>>(
8996 mut self,
8997 v: T,
8998 ) -> Self {
8999 self.shipment_label = v.into();
9000 self
9001 }
9002
9003 /// Sets the value of [visit_label][crate::model::shipment_route::Visit::visit_label].
9004 ///
9005 /// # Example
9006 /// ```ignore,no_run
9007 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9008 /// let x = Visit::new().set_visit_label("example");
9009 /// ```
9010 pub fn set_visit_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9011 self.visit_label = v.into();
9012 self
9013 }
9014
9015 /// Sets the value of [arrival_loads][crate::model::shipment_route::Visit::arrival_loads].
9016 ///
9017 /// # Example
9018 /// ```ignore,no_run
9019 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9020 /// use google_cloud_optimization_v1::model::CapacityQuantity;
9021 /// let x = Visit::new()
9022 /// .set_arrival_loads([
9023 /// CapacityQuantity::default()/* use setters */,
9024 /// CapacityQuantity::default()/* use (different) setters */,
9025 /// ]);
9026 /// ```
9027 #[deprecated]
9028 pub fn set_arrival_loads<T, V>(mut self, v: T) -> Self
9029 where
9030 T: std::iter::IntoIterator<Item = V>,
9031 V: std::convert::Into<crate::model::CapacityQuantity>,
9032 {
9033 use std::iter::Iterator;
9034 self.arrival_loads = v.into_iter().map(|i| i.into()).collect();
9035 self
9036 }
9037
9038 /// Sets the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
9039 ///
9040 /// # Example
9041 /// ```ignore,no_run
9042 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9043 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
9044 /// let x = Visit::new().set_delay_before_start(Delay::default()/* use setters */);
9045 /// ```
9046 #[deprecated]
9047 pub fn set_delay_before_start<T>(mut self, v: T) -> Self
9048 where
9049 T: std::convert::Into<crate::model::shipment_route::Delay>,
9050 {
9051 self.delay_before_start = std::option::Option::Some(v.into());
9052 self
9053 }
9054
9055 /// Sets or clears the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
9056 ///
9057 /// # Example
9058 /// ```ignore,no_run
9059 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9060 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
9061 /// let x = Visit::new().set_or_clear_delay_before_start(Some(Delay::default()/* use setters */));
9062 /// let x = Visit::new().set_or_clear_delay_before_start(None::<Delay>);
9063 /// ```
9064 #[deprecated]
9065 pub fn set_or_clear_delay_before_start<T>(mut self, v: std::option::Option<T>) -> Self
9066 where
9067 T: std::convert::Into<crate::model::shipment_route::Delay>,
9068 {
9069 self.delay_before_start = v.map(|x| x.into());
9070 self
9071 }
9072
9073 /// Sets the value of [demands][crate::model::shipment_route::Visit::demands].
9074 ///
9075 /// # Example
9076 /// ```ignore,no_run
9077 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9078 /// use google_cloud_optimization_v1::model::CapacityQuantity;
9079 /// let x = Visit::new()
9080 /// .set_demands([
9081 /// CapacityQuantity::default()/* use setters */,
9082 /// CapacityQuantity::default()/* use (different) setters */,
9083 /// ]);
9084 /// ```
9085 #[deprecated]
9086 pub fn set_demands<T, V>(mut self, v: T) -> Self
9087 where
9088 T: std::iter::IntoIterator<Item = V>,
9089 V: std::convert::Into<crate::model::CapacityQuantity>,
9090 {
9091 use std::iter::Iterator;
9092 self.demands = v.into_iter().map(|i| i.into()).collect();
9093 self
9094 }
9095 }
9096
9097 impl wkt::message::Message for Visit {
9098 fn typename() -> &'static str {
9099 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Visit"
9100 }
9101 }
9102
9103 /// Transition between two events on the route. See the description of
9104 /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
9105 ///
9106 /// If the vehicle does not have a `start_location` and/or `end_location`, the
9107 /// corresponding travel metrics are 0.
9108 ///
9109 /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
9110 #[derive(Clone, Default, PartialEq)]
9111 #[non_exhaustive]
9112 pub struct Transition {
9113 /// Travel duration during this transition.
9114 pub travel_duration: std::option::Option<wkt::Duration>,
9115
9116 /// Distance traveled during the transition.
9117 pub travel_distance_meters: f64,
9118
9119 /// When traffic is requested via
9120 /// [OptimizeToursRequest.consider_road_traffic]
9121 /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
9122 /// and the traffic info couldn't be retrieved for a `Transition`, this
9123 /// boolean is set to true. This may be temporary (rare hiccup in the
9124 /// realtime traffic servers) or permanent (no data for this location).
9125 pub traffic_info_unavailable: bool,
9126
9127 /// Sum of the delay durations applied to this transition. If any, the delay
9128 /// starts exactly `delay_duration` seconds before the next event (visit or
9129 /// vehicle end). See
9130 /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
9131 ///
9132 /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
9133 pub delay_duration: std::option::Option<wkt::Duration>,
9134
9135 /// Sum of the duration of the breaks occurring during this transition, if
9136 /// any. Details about each break's start time and duration are stored in
9137 /// [ShipmentRoute.breaks][google.cloud.optimization.v1.ShipmentRoute.breaks].
9138 ///
9139 /// [google.cloud.optimization.v1.ShipmentRoute.breaks]: crate::model::ShipmentRoute::breaks
9140 pub break_duration: std::option::Option<wkt::Duration>,
9141
9142 /// Time spent waiting during this transition. Wait duration corresponds to
9143 /// idle time and does not include break time. Also note that this wait time
9144 /// may be split into several non-contiguous intervals.
9145 pub wait_duration: std::option::Option<wkt::Duration>,
9146
9147 /// Total duration of the transition, provided for convenience. It is equal
9148 /// to:
9149 ///
9150 /// * next visit `start_time` (or `vehicle_end_time` if this is the last
9151 /// transition) - this transition's `start_time`;
9152 /// * if `ShipmentRoute.has_traffic_infeasibilities` is false, the following
9153 /// additionally holds: `total_duration = travel_duration + delay_duration
9154 ///
9155 /// + break_duration + wait_duration`.
9156 pub total_duration: std::option::Option<wkt::Duration>,
9157
9158 /// Start time of this transition.
9159 pub start_time: std::option::Option<wkt::Timestamp>,
9160
9161 /// The encoded polyline representation of the route followed during the
9162 /// transition.
9163 /// This field is only populated if [populate_transition_polylines]
9164 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
9165 /// is set to true.
9166 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
9167
9168 /// Vehicle loads during this transition, for each type that either appears
9169 /// in this vehicle's
9170 /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits],
9171 /// or that have non-zero
9172 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
9173 /// on some shipment performed on this route.
9174 ///
9175 /// The loads during the first transition are the starting loads of the
9176 /// vehicle route. Then, after each visit, the visit's `load_demands` are
9177 /// either added or subtracted to get the next transition's loads, depending
9178 /// on whether the visit was a pickup or a delivery.
9179 ///
9180 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
9181 /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
9182 pub vehicle_loads: std::collections::HashMap<
9183 std::string::String,
9184 crate::model::shipment_route::VehicleLoad,
9185 >,
9186
9187 /// Deprecated: Use
9188 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
9189 /// instead.
9190 ///
9191 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9192 #[deprecated]
9193 pub loads: std::vec::Vec<crate::model::CapacityQuantity>,
9194
9195 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9196 }
9197
9198 impl Transition {
9199 /// Creates a new default instance.
9200 pub fn new() -> Self {
9201 std::default::Default::default()
9202 }
9203
9204 /// Sets the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
9205 ///
9206 /// # Example
9207 /// ```ignore,no_run
9208 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9209 /// use wkt::Duration;
9210 /// let x = Transition::new().set_travel_duration(Duration::default()/* use setters */);
9211 /// ```
9212 pub fn set_travel_duration<T>(mut self, v: T) -> Self
9213 where
9214 T: std::convert::Into<wkt::Duration>,
9215 {
9216 self.travel_duration = std::option::Option::Some(v.into());
9217 self
9218 }
9219
9220 /// Sets or clears the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
9221 ///
9222 /// # Example
9223 /// ```ignore,no_run
9224 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9225 /// use wkt::Duration;
9226 /// let x = Transition::new().set_or_clear_travel_duration(Some(Duration::default()/* use setters */));
9227 /// let x = Transition::new().set_or_clear_travel_duration(None::<Duration>);
9228 /// ```
9229 pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
9230 where
9231 T: std::convert::Into<wkt::Duration>,
9232 {
9233 self.travel_duration = v.map(|x| x.into());
9234 self
9235 }
9236
9237 /// Sets the value of [travel_distance_meters][crate::model::shipment_route::Transition::travel_distance_meters].
9238 ///
9239 /// # Example
9240 /// ```ignore,no_run
9241 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9242 /// let x = Transition::new().set_travel_distance_meters(42.0);
9243 /// ```
9244 pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9245 self.travel_distance_meters = v.into();
9246 self
9247 }
9248
9249 /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::Transition::traffic_info_unavailable].
9250 ///
9251 /// # Example
9252 /// ```ignore,no_run
9253 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9254 /// let x = Transition::new().set_traffic_info_unavailable(true);
9255 /// ```
9256 pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9257 self.traffic_info_unavailable = v.into();
9258 self
9259 }
9260
9261 /// Sets the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
9262 ///
9263 /// # Example
9264 /// ```ignore,no_run
9265 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9266 /// use wkt::Duration;
9267 /// let x = Transition::new().set_delay_duration(Duration::default()/* use setters */);
9268 /// ```
9269 pub fn set_delay_duration<T>(mut self, v: T) -> Self
9270 where
9271 T: std::convert::Into<wkt::Duration>,
9272 {
9273 self.delay_duration = std::option::Option::Some(v.into());
9274 self
9275 }
9276
9277 /// Sets or clears the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
9278 ///
9279 /// # Example
9280 /// ```ignore,no_run
9281 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9282 /// use wkt::Duration;
9283 /// let x = Transition::new().set_or_clear_delay_duration(Some(Duration::default()/* use setters */));
9284 /// let x = Transition::new().set_or_clear_delay_duration(None::<Duration>);
9285 /// ```
9286 pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
9287 where
9288 T: std::convert::Into<wkt::Duration>,
9289 {
9290 self.delay_duration = v.map(|x| x.into());
9291 self
9292 }
9293
9294 /// Sets the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
9295 ///
9296 /// # Example
9297 /// ```ignore,no_run
9298 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9299 /// use wkt::Duration;
9300 /// let x = Transition::new().set_break_duration(Duration::default()/* use setters */);
9301 /// ```
9302 pub fn set_break_duration<T>(mut self, v: T) -> Self
9303 where
9304 T: std::convert::Into<wkt::Duration>,
9305 {
9306 self.break_duration = std::option::Option::Some(v.into());
9307 self
9308 }
9309
9310 /// Sets or clears the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
9311 ///
9312 /// # Example
9313 /// ```ignore,no_run
9314 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9315 /// use wkt::Duration;
9316 /// let x = Transition::new().set_or_clear_break_duration(Some(Duration::default()/* use setters */));
9317 /// let x = Transition::new().set_or_clear_break_duration(None::<Duration>);
9318 /// ```
9319 pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
9320 where
9321 T: std::convert::Into<wkt::Duration>,
9322 {
9323 self.break_duration = v.map(|x| x.into());
9324 self
9325 }
9326
9327 /// Sets the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
9328 ///
9329 /// # Example
9330 /// ```ignore,no_run
9331 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9332 /// use wkt::Duration;
9333 /// let x = Transition::new().set_wait_duration(Duration::default()/* use setters */);
9334 /// ```
9335 pub fn set_wait_duration<T>(mut self, v: T) -> Self
9336 where
9337 T: std::convert::Into<wkt::Duration>,
9338 {
9339 self.wait_duration = std::option::Option::Some(v.into());
9340 self
9341 }
9342
9343 /// Sets or clears the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
9344 ///
9345 /// # Example
9346 /// ```ignore,no_run
9347 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9348 /// use wkt::Duration;
9349 /// let x = Transition::new().set_or_clear_wait_duration(Some(Duration::default()/* use setters */));
9350 /// let x = Transition::new().set_or_clear_wait_duration(None::<Duration>);
9351 /// ```
9352 pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
9353 where
9354 T: std::convert::Into<wkt::Duration>,
9355 {
9356 self.wait_duration = v.map(|x| x.into());
9357 self
9358 }
9359
9360 /// Sets the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
9361 ///
9362 /// # Example
9363 /// ```ignore,no_run
9364 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9365 /// use wkt::Duration;
9366 /// let x = Transition::new().set_total_duration(Duration::default()/* use setters */);
9367 /// ```
9368 pub fn set_total_duration<T>(mut self, v: T) -> Self
9369 where
9370 T: std::convert::Into<wkt::Duration>,
9371 {
9372 self.total_duration = std::option::Option::Some(v.into());
9373 self
9374 }
9375
9376 /// Sets or clears the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
9377 ///
9378 /// # Example
9379 /// ```ignore,no_run
9380 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9381 /// use wkt::Duration;
9382 /// let x = Transition::new().set_or_clear_total_duration(Some(Duration::default()/* use setters */));
9383 /// let x = Transition::new().set_or_clear_total_duration(None::<Duration>);
9384 /// ```
9385 pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
9386 where
9387 T: std::convert::Into<wkt::Duration>,
9388 {
9389 self.total_duration = v.map(|x| x.into());
9390 self
9391 }
9392
9393 /// Sets the value of [start_time][crate::model::shipment_route::Transition::start_time].
9394 ///
9395 /// # Example
9396 /// ```ignore,no_run
9397 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9398 /// use wkt::Timestamp;
9399 /// let x = Transition::new().set_start_time(Timestamp::default()/* use setters */);
9400 /// ```
9401 pub fn set_start_time<T>(mut self, v: T) -> Self
9402 where
9403 T: std::convert::Into<wkt::Timestamp>,
9404 {
9405 self.start_time = std::option::Option::Some(v.into());
9406 self
9407 }
9408
9409 /// Sets or clears the value of [start_time][crate::model::shipment_route::Transition::start_time].
9410 ///
9411 /// # Example
9412 /// ```ignore,no_run
9413 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9414 /// use wkt::Timestamp;
9415 /// let x = Transition::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
9416 /// let x = Transition::new().set_or_clear_start_time(None::<Timestamp>);
9417 /// ```
9418 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
9419 where
9420 T: std::convert::Into<wkt::Timestamp>,
9421 {
9422 self.start_time = v.map(|x| x.into());
9423 self
9424 }
9425
9426 /// Sets the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
9427 ///
9428 /// # Example
9429 /// ```ignore,no_run
9430 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9431 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9432 /// let x = Transition::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
9433 /// ```
9434 pub fn set_route_polyline<T>(mut self, v: T) -> Self
9435 where
9436 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9437 {
9438 self.route_polyline = std::option::Option::Some(v.into());
9439 self
9440 }
9441
9442 /// Sets or clears the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
9443 ///
9444 /// # Example
9445 /// ```ignore,no_run
9446 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9447 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9448 /// let x = Transition::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
9449 /// let x = Transition::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
9450 /// ```
9451 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
9452 where
9453 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9454 {
9455 self.route_polyline = v.map(|x| x.into());
9456 self
9457 }
9458
9459 /// Sets the value of [vehicle_loads][crate::model::shipment_route::Transition::vehicle_loads].
9460 ///
9461 /// # Example
9462 /// ```ignore,no_run
9463 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9464 /// use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
9465 /// let x = Transition::new().set_vehicle_loads([
9466 /// ("key0", VehicleLoad::default()/* use setters */),
9467 /// ("key1", VehicleLoad::default()/* use (different) setters */),
9468 /// ]);
9469 /// ```
9470 pub fn set_vehicle_loads<T, K, V>(mut self, v: T) -> Self
9471 where
9472 T: std::iter::IntoIterator<Item = (K, V)>,
9473 K: std::convert::Into<std::string::String>,
9474 V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
9475 {
9476 use std::iter::Iterator;
9477 self.vehicle_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
9478 self
9479 }
9480
9481 /// Sets the value of [loads][crate::model::shipment_route::Transition::loads].
9482 ///
9483 /// # Example
9484 /// ```ignore,no_run
9485 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9486 /// use google_cloud_optimization_v1::model::CapacityQuantity;
9487 /// let x = Transition::new()
9488 /// .set_loads([
9489 /// CapacityQuantity::default()/* use setters */,
9490 /// CapacityQuantity::default()/* use (different) setters */,
9491 /// ]);
9492 /// ```
9493 #[deprecated]
9494 pub fn set_loads<T, V>(mut self, v: T) -> Self
9495 where
9496 T: std::iter::IntoIterator<Item = V>,
9497 V: std::convert::Into<crate::model::CapacityQuantity>,
9498 {
9499 use std::iter::Iterator;
9500 self.loads = v.into_iter().map(|i| i.into()).collect();
9501 self
9502 }
9503 }
9504
9505 impl wkt::message::Message for Transition {
9506 fn typename() -> &'static str {
9507 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Transition"
9508 }
9509 }
9510
9511 /// Reports the actual load of the vehicle at some point along the route,
9512 /// for a given type (see
9513 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]).
9514 ///
9515 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9516 #[derive(Clone, Default, PartialEq)]
9517 #[non_exhaustive]
9518 pub struct VehicleLoad {
9519 /// The amount of load on the vehicle, for the given type. The unit of load
9520 /// is usually indicated by the type. See
9521 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads].
9522 ///
9523 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9524 pub amount: i64,
9525
9526 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9527 }
9528
9529 impl VehicleLoad {
9530 /// Creates a new default instance.
9531 pub fn new() -> Self {
9532 std::default::Default::default()
9533 }
9534
9535 /// Sets the value of [amount][crate::model::shipment_route::VehicleLoad::amount].
9536 ///
9537 /// # Example
9538 /// ```ignore,no_run
9539 /// # use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
9540 /// let x = VehicleLoad::new().set_amount(42);
9541 /// ```
9542 pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
9543 self.amount = v.into();
9544 self
9545 }
9546 }
9547
9548 impl wkt::message::Message for VehicleLoad {
9549 fn typename() -> &'static str {
9550 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.VehicleLoad"
9551 }
9552 }
9553
9554 /// The encoded representation of a polyline. More information on polyline
9555 /// encoding can be found here:
9556 /// <https://developers.google.com/maps/documentation/utilities/polylinealgorithm>
9557 /// <https://developers.google.com/maps/documentation/javascript/reference/geometry#encoding>.
9558 #[derive(Clone, Default, PartialEq)]
9559 #[non_exhaustive]
9560 pub struct EncodedPolyline {
9561 /// String representing encoded points of the polyline.
9562 pub points: std::string::String,
9563
9564 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9565 }
9566
9567 impl EncodedPolyline {
9568 /// Creates a new default instance.
9569 pub fn new() -> Self {
9570 std::default::Default::default()
9571 }
9572
9573 /// Sets the value of [points][crate::model::shipment_route::EncodedPolyline::points].
9574 ///
9575 /// # Example
9576 /// ```ignore,no_run
9577 /// # use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9578 /// let x = EncodedPolyline::new().set_points("example");
9579 /// ```
9580 pub fn set_points<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9581 self.points = v.into();
9582 self
9583 }
9584 }
9585
9586 impl wkt::message::Message for EncodedPolyline {
9587 fn typename() -> &'static str {
9588 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.EncodedPolyline"
9589 }
9590 }
9591
9592 /// Data representing the execution of a break.
9593 #[derive(Clone, Default, PartialEq)]
9594 #[non_exhaustive]
9595 pub struct Break {
9596 /// Start time of a break.
9597 pub start_time: std::option::Option<wkt::Timestamp>,
9598
9599 /// Duration of a break.
9600 pub duration: std::option::Option<wkt::Duration>,
9601
9602 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9603 }
9604
9605 impl Break {
9606 /// Creates a new default instance.
9607 pub fn new() -> Self {
9608 std::default::Default::default()
9609 }
9610
9611 /// Sets the value of [start_time][crate::model::shipment_route::Break::start_time].
9612 ///
9613 /// # Example
9614 /// ```ignore,no_run
9615 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9616 /// use wkt::Timestamp;
9617 /// let x = Break::new().set_start_time(Timestamp::default()/* use setters */);
9618 /// ```
9619 pub fn set_start_time<T>(mut self, v: T) -> Self
9620 where
9621 T: std::convert::Into<wkt::Timestamp>,
9622 {
9623 self.start_time = std::option::Option::Some(v.into());
9624 self
9625 }
9626
9627 /// Sets or clears the value of [start_time][crate::model::shipment_route::Break::start_time].
9628 ///
9629 /// # Example
9630 /// ```ignore,no_run
9631 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9632 /// use wkt::Timestamp;
9633 /// let x = Break::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
9634 /// let x = Break::new().set_or_clear_start_time(None::<Timestamp>);
9635 /// ```
9636 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
9637 where
9638 T: std::convert::Into<wkt::Timestamp>,
9639 {
9640 self.start_time = v.map(|x| x.into());
9641 self
9642 }
9643
9644 /// Sets the value of [duration][crate::model::shipment_route::Break::duration].
9645 ///
9646 /// # Example
9647 /// ```ignore,no_run
9648 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9649 /// use wkt::Duration;
9650 /// let x = Break::new().set_duration(Duration::default()/* use setters */);
9651 /// ```
9652 pub fn set_duration<T>(mut self, v: T) -> Self
9653 where
9654 T: std::convert::Into<wkt::Duration>,
9655 {
9656 self.duration = std::option::Option::Some(v.into());
9657 self
9658 }
9659
9660 /// Sets or clears the value of [duration][crate::model::shipment_route::Break::duration].
9661 ///
9662 /// # Example
9663 /// ```ignore,no_run
9664 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9665 /// use wkt::Duration;
9666 /// let x = Break::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
9667 /// let x = Break::new().set_or_clear_duration(None::<Duration>);
9668 /// ```
9669 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
9670 where
9671 T: std::convert::Into<wkt::Duration>,
9672 {
9673 self.duration = v.map(|x| x.into());
9674 self
9675 }
9676 }
9677
9678 impl wkt::message::Message for Break {
9679 fn typename() -> &'static str {
9680 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Break"
9681 }
9682 }
9683
9684 /// Deprecated: Use
9685 /// [ShipmentRoute.Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
9686 /// instead. Travel between each visit along the route: from the vehicle's
9687 /// `start_location` to the first visit's `arrival_location`, then from the
9688 /// first visit's `departure_location` to the second visit's
9689 /// `arrival_location`, and so on until the vehicle's `end_location`. This
9690 /// accounts only for the actual travel between visits, not counting the
9691 /// waiting time, the time spent performing a visit, nor the distance covered
9692 /// during a visit.
9693 ///
9694 /// Invariant: `travel_steps_size() == visits_size() + 1`.
9695 ///
9696 /// If the vehicle does not have a start_ and/or end_location, the
9697 /// corresponding travel metrics are 0 and/or empty.
9698 ///
9699 /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
9700 #[derive(Clone, Default, PartialEq)]
9701 #[non_exhaustive]
9702 #[deprecated]
9703 pub struct TravelStep {
9704 /// Duration of the travel step.
9705 pub duration: std::option::Option<wkt::Duration>,
9706
9707 /// Distance traveled during the step.
9708 pub distance_meters: f64,
9709
9710 /// When traffic is requested via
9711 /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
9712 /// and the traffic info couldn't be retrieved for a TravelStep, this boolean
9713 /// is set to true. This may be temporary (rare hiccup in the realtime
9714 /// traffic servers) or permanent (no data for this location).
9715 ///
9716 /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
9717 pub traffic_info_unavailable: bool,
9718
9719 /// The encoded polyline representation of the route followed during the
9720 /// step.
9721 ///
9722 /// This field is only populated if
9723 /// [OptimizeToursRequest.populate_travel_step_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]
9724 /// is set to true.
9725 ///
9726 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]: crate::model::OptimizeToursRequest::populate_travel_step_polylines
9727 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
9728
9729 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9730 }
9731
9732 impl TravelStep {
9733 /// Creates a new default instance.
9734 pub fn new() -> Self {
9735 std::default::Default::default()
9736 }
9737
9738 /// Sets the value of [duration][crate::model::shipment_route::TravelStep::duration].
9739 ///
9740 /// # Example
9741 /// ```ignore,no_run
9742 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9743 /// use wkt::Duration;
9744 /// let x = TravelStep::new().set_duration(Duration::default()/* use setters */);
9745 /// ```
9746 pub fn set_duration<T>(mut self, v: T) -> Self
9747 where
9748 T: std::convert::Into<wkt::Duration>,
9749 {
9750 self.duration = std::option::Option::Some(v.into());
9751 self
9752 }
9753
9754 /// Sets or clears the value of [duration][crate::model::shipment_route::TravelStep::duration].
9755 ///
9756 /// # Example
9757 /// ```ignore,no_run
9758 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9759 /// use wkt::Duration;
9760 /// let x = TravelStep::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
9761 /// let x = TravelStep::new().set_or_clear_duration(None::<Duration>);
9762 /// ```
9763 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
9764 where
9765 T: std::convert::Into<wkt::Duration>,
9766 {
9767 self.duration = v.map(|x| x.into());
9768 self
9769 }
9770
9771 /// Sets the value of [distance_meters][crate::model::shipment_route::TravelStep::distance_meters].
9772 ///
9773 /// # Example
9774 /// ```ignore,no_run
9775 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9776 /// let x = TravelStep::new().set_distance_meters(42.0);
9777 /// ```
9778 pub fn set_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9779 self.distance_meters = v.into();
9780 self
9781 }
9782
9783 /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::TravelStep::traffic_info_unavailable].
9784 ///
9785 /// # Example
9786 /// ```ignore,no_run
9787 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9788 /// let x = TravelStep::new().set_traffic_info_unavailable(true);
9789 /// ```
9790 pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9791 self.traffic_info_unavailable = v.into();
9792 self
9793 }
9794
9795 /// Sets the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
9796 ///
9797 /// # Example
9798 /// ```ignore,no_run
9799 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9800 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9801 /// let x = TravelStep::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
9802 /// ```
9803 pub fn set_route_polyline<T>(mut self, v: T) -> Self
9804 where
9805 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9806 {
9807 self.route_polyline = std::option::Option::Some(v.into());
9808 self
9809 }
9810
9811 /// Sets or clears the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
9812 ///
9813 /// # Example
9814 /// ```ignore,no_run
9815 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9816 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9817 /// let x = TravelStep::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
9818 /// let x = TravelStep::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
9819 /// ```
9820 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
9821 where
9822 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9823 {
9824 self.route_polyline = v.map(|x| x.into());
9825 self
9826 }
9827 }
9828
9829 impl wkt::message::Message for TravelStep {
9830 fn typename() -> &'static str {
9831 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.TravelStep"
9832 }
9833 }
9834}
9835
9836/// Specifies details of unperformed shipments in a solution. For trivial cases
9837/// and/or if we are able to identify the cause for skipping, we report the
9838/// reason here.
9839#[derive(Clone, Default, PartialEq)]
9840#[non_exhaustive]
9841pub struct SkippedShipment {
9842 /// The index corresponds to the index of the shipment in the source
9843 /// `ShipmentModel`.
9844 pub index: i32,
9845
9846 /// Copy of the corresponding
9847 /// [Shipment.label][google.cloud.optimization.v1.Shipment.label], if specified
9848 /// in the `Shipment`.
9849 ///
9850 /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
9851 pub label: std::string::String,
9852
9853 /// A list of reasons that explain why the shipment was skipped. See comment
9854 /// above `Reason`.
9855 pub reasons: std::vec::Vec<crate::model::skipped_shipment::Reason>,
9856
9857 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9858}
9859
9860impl SkippedShipment {
9861 /// Creates a new default instance.
9862 pub fn new() -> Self {
9863 std::default::Default::default()
9864 }
9865
9866 /// Sets the value of [index][crate::model::SkippedShipment::index].
9867 ///
9868 /// # Example
9869 /// ```ignore,no_run
9870 /// # use google_cloud_optimization_v1::model::SkippedShipment;
9871 /// let x = SkippedShipment::new().set_index(42);
9872 /// ```
9873 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9874 self.index = v.into();
9875 self
9876 }
9877
9878 /// Sets the value of [label][crate::model::SkippedShipment::label].
9879 ///
9880 /// # Example
9881 /// ```ignore,no_run
9882 /// # use google_cloud_optimization_v1::model::SkippedShipment;
9883 /// let x = SkippedShipment::new().set_label("example");
9884 /// ```
9885 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9886 self.label = v.into();
9887 self
9888 }
9889
9890 /// Sets the value of [reasons][crate::model::SkippedShipment::reasons].
9891 ///
9892 /// # Example
9893 /// ```ignore,no_run
9894 /// # use google_cloud_optimization_v1::model::SkippedShipment;
9895 /// use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9896 /// let x = SkippedShipment::new()
9897 /// .set_reasons([
9898 /// Reason::default()/* use setters */,
9899 /// Reason::default()/* use (different) setters */,
9900 /// ]);
9901 /// ```
9902 pub fn set_reasons<T, V>(mut self, v: T) -> Self
9903 where
9904 T: std::iter::IntoIterator<Item = V>,
9905 V: std::convert::Into<crate::model::skipped_shipment::Reason>,
9906 {
9907 use std::iter::Iterator;
9908 self.reasons = v.into_iter().map(|i| i.into()).collect();
9909 self
9910 }
9911}
9912
9913impl wkt::message::Message for SkippedShipment {
9914 fn typename() -> &'static str {
9915 "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment"
9916 }
9917}
9918
9919/// Defines additional types related to [SkippedShipment].
9920pub mod skipped_shipment {
9921 #[allow(unused_imports)]
9922 use super::*;
9923
9924 /// If we can explain why the shipment was skipped, reasons will be listed
9925 /// here. If the reason is not the same for all vehicles, `reason` will have
9926 /// more than 1 element. A skipped shipment cannot have duplicate reasons,
9927 /// i.e. where all fields are the same except for `example_vehicle_index`.
9928 /// Example:
9929 ///
9930 /// ```norust
9931 /// reasons {
9932 /// code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
9933 /// example_vehicle_index: 1
9934 /// example_exceeded_capacity_type: "Apples"
9935 /// }
9936 /// reasons {
9937 /// code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
9938 /// example_vehicle_index: 3
9939 /// example_exceeded_capacity_type: "Pears"
9940 /// }
9941 /// reasons {
9942 /// code: CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT
9943 /// example_vehicle_index: 1
9944 /// }
9945 /// ```
9946 ///
9947 /// The skipped shipment is incompatible with all vehicles. The reasons may
9948 /// be different for all vehicles but at least one vehicle's "Apples"
9949 /// capacity would be exceeded (including vehicle 1), at least one vehicle's
9950 /// "Pears" capacity would be exceeded (including vehicle 3) and at least one
9951 /// vehicle's distance limit would be exceeded (including vehicle 1).
9952 #[derive(Clone, Default, PartialEq)]
9953 #[non_exhaustive]
9954 pub struct Reason {
9955 /// Refer to the comments of Code.
9956 pub code: crate::model::skipped_shipment::reason::Code,
9957
9958 /// If the reason is related to a shipment-vehicle incompatibility, this
9959 /// field provides the index of one relevant vehicle.
9960 pub example_vehicle_index: std::option::Option<i32>,
9961
9962 /// If the reason code is `DEMAND_EXCEEDS_VEHICLE_CAPACITY`, documents one
9963 /// capacity type that is exceeded.
9964 pub example_exceeded_capacity_type: std::string::String,
9965
9966 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9967 }
9968
9969 impl Reason {
9970 /// Creates a new default instance.
9971 pub fn new() -> Self {
9972 std::default::Default::default()
9973 }
9974
9975 /// Sets the value of [code][crate::model::skipped_shipment::Reason::code].
9976 ///
9977 /// # Example
9978 /// ```ignore,no_run
9979 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9980 /// use google_cloud_optimization_v1::model::skipped_shipment::reason::Code;
9981 /// let x0 = Reason::new().set_code(Code::NoVehicle);
9982 /// let x1 = Reason::new().set_code(Code::DemandExceedsVehicleCapacity);
9983 /// let x2 = Reason::new().set_code(Code::CannotBePerformedWithinVehicleDistanceLimit);
9984 /// ```
9985 pub fn set_code<T: std::convert::Into<crate::model::skipped_shipment::reason::Code>>(
9986 mut self,
9987 v: T,
9988 ) -> Self {
9989 self.code = v.into();
9990 self
9991 }
9992
9993 /// Sets the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
9994 ///
9995 /// # Example
9996 /// ```ignore,no_run
9997 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9998 /// let x = Reason::new().set_example_vehicle_index(42);
9999 /// ```
10000 pub fn set_example_vehicle_index<T>(mut self, v: T) -> Self
10001 where
10002 T: std::convert::Into<i32>,
10003 {
10004 self.example_vehicle_index = std::option::Option::Some(v.into());
10005 self
10006 }
10007
10008 /// Sets or clears the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
10009 ///
10010 /// # Example
10011 /// ```ignore,no_run
10012 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
10013 /// let x = Reason::new().set_or_clear_example_vehicle_index(Some(42));
10014 /// let x = Reason::new().set_or_clear_example_vehicle_index(None::<i32>);
10015 /// ```
10016 pub fn set_or_clear_example_vehicle_index<T>(mut self, v: std::option::Option<T>) -> Self
10017 where
10018 T: std::convert::Into<i32>,
10019 {
10020 self.example_vehicle_index = v.map(|x| x.into());
10021 self
10022 }
10023
10024 /// Sets the value of [example_exceeded_capacity_type][crate::model::skipped_shipment::Reason::example_exceeded_capacity_type].
10025 ///
10026 /// # Example
10027 /// ```ignore,no_run
10028 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
10029 /// let x = Reason::new().set_example_exceeded_capacity_type("example");
10030 /// ```
10031 pub fn set_example_exceeded_capacity_type<T: std::convert::Into<std::string::String>>(
10032 mut self,
10033 v: T,
10034 ) -> Self {
10035 self.example_exceeded_capacity_type = v.into();
10036 self
10037 }
10038 }
10039
10040 impl wkt::message::Message for Reason {
10041 fn typename() -> &'static str {
10042 "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment.Reason"
10043 }
10044 }
10045
10046 /// Defines additional types related to [Reason].
10047 pub mod reason {
10048 #[allow(unused_imports)]
10049 use super::*;
10050
10051 /// Code identifying the reason type. The order here is meaningless. In
10052 /// particular, it gives no indication of whether a given reason will
10053 /// appear before another in the solution, if both apply.
10054 ///
10055 /// # Working with unknown values
10056 ///
10057 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10058 /// additional enum variants at any time. Adding new variants is not considered
10059 /// a breaking change. Applications should write their code in anticipation of:
10060 ///
10061 /// - New values appearing in future releases of the client library, **and**
10062 /// - New values received dynamically, without application changes.
10063 ///
10064 /// Please consult the [Working with enums] section in the user guide for some
10065 /// guidelines.
10066 ///
10067 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
10068 #[derive(Clone, Debug, PartialEq)]
10069 #[non_exhaustive]
10070 pub enum Code {
10071 /// This should never be used. If we are unable to understand why a
10072 /// shipment was skipped, we simply return an empty set of reasons.
10073 Unspecified,
10074 /// There is no vehicle in the model making all shipments infeasible.
10075 NoVehicle,
10076 /// The demand of the shipment exceeds a vehicle's capacity for some
10077 /// capacity types, one of which is `example_exceeded_capacity_type`.
10078 DemandExceedsVehicleCapacity,
10079 /// The minimum distance necessary to perform this shipment, i.e. from
10080 /// the vehicle's `start_location` to the shipment's pickup and/or delivery
10081 /// locations and to the vehicle's end location exceeds the vehicle's
10082 /// `route_distance_limit`.
10083 ///
10084 /// Note that for this computation we use the geodesic distances.
10085 CannotBePerformedWithinVehicleDistanceLimit,
10086 /// The minimum time necessary to perform this shipment, including travel
10087 /// time, wait time and service time exceeds the vehicle's
10088 /// `route_duration_limit`.
10089 ///
10090 /// Note: travel time is computed in the best-case scenario, namely as
10091 /// geodesic distance x 36 m/s (roughly 130 km/hour).
10092 CannotBePerformedWithinVehicleDurationLimit,
10093 /// Same as above but we only compare minimum travel time and the
10094 /// vehicle's `travel_duration_limit`.
10095 CannotBePerformedWithinVehicleTravelDurationLimit,
10096 /// The vehicle cannot perform this shipment in the best-case scenario
10097 /// (see `CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT` for time
10098 /// computation) if it starts at its earliest start time: the total time
10099 /// would make the vehicle end after its latest end time.
10100 CannotBePerformedWithinVehicleTimeWindows,
10101 /// The `allowed_vehicle_indices` field of the shipment is not empty and
10102 /// this vehicle does not belong to it.
10103 VehicleNotAllowed,
10104 /// If set, the enum was initialized with an unknown value.
10105 ///
10106 /// Applications can examine the value using [Code::value] or
10107 /// [Code::name].
10108 UnknownValue(code::UnknownValue),
10109 }
10110
10111 #[doc(hidden)]
10112 pub mod code {
10113 #[allow(unused_imports)]
10114 use super::*;
10115 #[derive(Clone, Debug, PartialEq)]
10116 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10117 }
10118
10119 impl Code {
10120 /// Gets the enum value.
10121 ///
10122 /// Returns `None` if the enum contains an unknown value deserialized from
10123 /// the string representation of enums.
10124 pub fn value(&self) -> std::option::Option<i32> {
10125 match self {
10126 Self::Unspecified => std::option::Option::Some(0),
10127 Self::NoVehicle => std::option::Option::Some(1),
10128 Self::DemandExceedsVehicleCapacity => std::option::Option::Some(2),
10129 Self::CannotBePerformedWithinVehicleDistanceLimit => {
10130 std::option::Option::Some(3)
10131 }
10132 Self::CannotBePerformedWithinVehicleDurationLimit => {
10133 std::option::Option::Some(4)
10134 }
10135 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10136 std::option::Option::Some(5)
10137 }
10138 Self::CannotBePerformedWithinVehicleTimeWindows => std::option::Option::Some(6),
10139 Self::VehicleNotAllowed => std::option::Option::Some(7),
10140 Self::UnknownValue(u) => u.0.value(),
10141 }
10142 }
10143
10144 /// Gets the enum value as a string.
10145 ///
10146 /// Returns `None` if the enum contains an unknown value deserialized from
10147 /// the integer representation of enums.
10148 pub fn name(&self) -> std::option::Option<&str> {
10149 match self {
10150 Self::Unspecified => std::option::Option::Some("CODE_UNSPECIFIED"),
10151 Self::NoVehicle => std::option::Option::Some("NO_VEHICLE"),
10152 Self::DemandExceedsVehicleCapacity => {
10153 std::option::Option::Some("DEMAND_EXCEEDS_VEHICLE_CAPACITY")
10154 }
10155 Self::CannotBePerformedWithinVehicleDistanceLimit => std::option::Option::Some(
10156 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT",
10157 ),
10158 Self::CannotBePerformedWithinVehicleDurationLimit => std::option::Option::Some(
10159 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT",
10160 ),
10161 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10162 std::option::Option::Some(
10163 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT",
10164 )
10165 }
10166 Self::CannotBePerformedWithinVehicleTimeWindows => {
10167 std::option::Option::Some("CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS")
10168 }
10169 Self::VehicleNotAllowed => std::option::Option::Some("VEHICLE_NOT_ALLOWED"),
10170 Self::UnknownValue(u) => u.0.name(),
10171 }
10172 }
10173 }
10174
10175 impl std::default::Default for Code {
10176 fn default() -> Self {
10177 use std::convert::From;
10178 Self::from(0)
10179 }
10180 }
10181
10182 impl std::fmt::Display for Code {
10183 fn fmt(
10184 &self,
10185 f: &mut std::fmt::Formatter<'_>,
10186 ) -> std::result::Result<(), std::fmt::Error> {
10187 wkt::internal::display_enum(f, self.name(), self.value())
10188 }
10189 }
10190
10191 impl std::convert::From<i32> for Code {
10192 fn from(value: i32) -> Self {
10193 match value {
10194 0 => Self::Unspecified,
10195 1 => Self::NoVehicle,
10196 2 => Self::DemandExceedsVehicleCapacity,
10197 3 => Self::CannotBePerformedWithinVehicleDistanceLimit,
10198 4 => Self::CannotBePerformedWithinVehicleDurationLimit,
10199 5 => Self::CannotBePerformedWithinVehicleTravelDurationLimit,
10200 6 => Self::CannotBePerformedWithinVehicleTimeWindows,
10201 7 => Self::VehicleNotAllowed,
10202 _ => Self::UnknownValue(code::UnknownValue(
10203 wkt::internal::UnknownEnumValue::Integer(value),
10204 )),
10205 }
10206 }
10207 }
10208
10209 impl std::convert::From<&str> for Code {
10210 fn from(value: &str) -> Self {
10211 use std::string::ToString;
10212 match value {
10213 "CODE_UNSPECIFIED" => Self::Unspecified,
10214 "NO_VEHICLE" => Self::NoVehicle,
10215 "DEMAND_EXCEEDS_VEHICLE_CAPACITY" => Self::DemandExceedsVehicleCapacity,
10216 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT" => {
10217 Self::CannotBePerformedWithinVehicleDistanceLimit
10218 }
10219 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT" => {
10220 Self::CannotBePerformedWithinVehicleDurationLimit
10221 }
10222 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT" => {
10223 Self::CannotBePerformedWithinVehicleTravelDurationLimit
10224 }
10225 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS" => {
10226 Self::CannotBePerformedWithinVehicleTimeWindows
10227 }
10228 "VEHICLE_NOT_ALLOWED" => Self::VehicleNotAllowed,
10229 _ => Self::UnknownValue(code::UnknownValue(
10230 wkt::internal::UnknownEnumValue::String(value.to_string()),
10231 )),
10232 }
10233 }
10234 }
10235
10236 impl serde::ser::Serialize for Code {
10237 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10238 where
10239 S: serde::Serializer,
10240 {
10241 match self {
10242 Self::Unspecified => serializer.serialize_i32(0),
10243 Self::NoVehicle => serializer.serialize_i32(1),
10244 Self::DemandExceedsVehicleCapacity => serializer.serialize_i32(2),
10245 Self::CannotBePerformedWithinVehicleDistanceLimit => {
10246 serializer.serialize_i32(3)
10247 }
10248 Self::CannotBePerformedWithinVehicleDurationLimit => {
10249 serializer.serialize_i32(4)
10250 }
10251 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10252 serializer.serialize_i32(5)
10253 }
10254 Self::CannotBePerformedWithinVehicleTimeWindows => serializer.serialize_i32(6),
10255 Self::VehicleNotAllowed => serializer.serialize_i32(7),
10256 Self::UnknownValue(u) => u.0.serialize(serializer),
10257 }
10258 }
10259 }
10260
10261 impl<'de> serde::de::Deserialize<'de> for Code {
10262 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10263 where
10264 D: serde::Deserializer<'de>,
10265 {
10266 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
10267 ".google.cloud.optimization.v1.SkippedShipment.Reason.Code",
10268 ))
10269 }
10270 }
10271 }
10272}
10273
10274/// Aggregated metrics for
10275/// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute] (resp. for
10276/// [OptimizeToursResponse][google.cloud.optimization.v1.OptimizeToursResponse]
10277/// over all [Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
10278/// and/or [Visit][google.cloud.optimization.v1.ShipmentRoute.Visit] (resp. over
10279/// all [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]) elements.
10280///
10281/// [google.cloud.optimization.v1.OptimizeToursResponse]: crate::model::OptimizeToursResponse
10282/// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
10283/// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
10284/// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
10285#[derive(Clone, Default, PartialEq)]
10286#[non_exhaustive]
10287pub struct AggregatedMetrics {
10288 /// Number of shipments performed. Note that a pickup and delivery pair only
10289 /// counts once.
10290 pub performed_shipment_count: i32,
10291
10292 /// Total travel duration for a route or a solution.
10293 pub travel_duration: std::option::Option<wkt::Duration>,
10294
10295 /// Total wait duration for a route or a solution.
10296 pub wait_duration: std::option::Option<wkt::Duration>,
10297
10298 /// Total delay duration for a route or a solution.
10299 pub delay_duration: std::option::Option<wkt::Duration>,
10300
10301 /// Total break duration for a route or a solution.
10302 pub break_duration: std::option::Option<wkt::Duration>,
10303
10304 /// Total visit duration for a route or a solution.
10305 pub visit_duration: std::option::Option<wkt::Duration>,
10306
10307 /// The total duration should be equal to the sum of all durations above.
10308 /// For routes, it also corresponds to:
10309 /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]
10310 /// `-`
10311 /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]
10312 ///
10313 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
10314 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
10315 pub total_duration: std::option::Option<wkt::Duration>,
10316
10317 /// Total travel distance for a route or a solution.
10318 pub travel_distance_meters: f64,
10319
10320 /// Maximum load achieved over the entire route (resp. solution), for each of
10321 /// the quantities on this route (resp. solution), computed as the maximum over
10322 /// all
10323 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
10324 /// (resp.
10325 /// [ShipmentRoute.metrics.max_loads][google.cloud.optimization.v1.AggregatedMetrics.max_loads].
10326 ///
10327 /// [google.cloud.optimization.v1.AggregatedMetrics.max_loads]: crate::model::AggregatedMetrics::max_loads
10328 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
10329 pub max_loads:
10330 std::collections::HashMap<std::string::String, crate::model::shipment_route::VehicleLoad>,
10331
10332 /// Deprecated: Use
10333 /// [ShipmentRoute.route_costs][google.cloud.optimization.v1.ShipmentRoute.route_costs]
10334 /// and
10335 /// [OptimizeToursResponse.Metrics.costs][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]
10336 /// instead.
10337 ///
10338 /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]: crate::model::optimize_tours_response::Metrics::costs
10339 /// [google.cloud.optimization.v1.ShipmentRoute.route_costs]: crate::model::ShipmentRoute::route_costs
10340 #[deprecated]
10341 pub costs: std::collections::HashMap<std::string::String, f64>,
10342
10343 /// Deprecated: Use
10344 /// [ShipmentRoute.route_total_cost][google.cloud.optimization.v1.ShipmentRoute.route_total_cost]
10345 /// and
10346 /// [OptimizeToursResponse.Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
10347 /// instead.
10348 ///
10349 /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
10350 /// [google.cloud.optimization.v1.ShipmentRoute.route_total_cost]: crate::model::ShipmentRoute::route_total_cost
10351 #[deprecated]
10352 pub total_cost: f64,
10353
10354 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10355}
10356
10357impl AggregatedMetrics {
10358 /// Creates a new default instance.
10359 pub fn new() -> Self {
10360 std::default::Default::default()
10361 }
10362
10363 /// Sets the value of [performed_shipment_count][crate::model::AggregatedMetrics::performed_shipment_count].
10364 ///
10365 /// # Example
10366 /// ```ignore,no_run
10367 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10368 /// let x = AggregatedMetrics::new().set_performed_shipment_count(42);
10369 /// ```
10370 pub fn set_performed_shipment_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10371 self.performed_shipment_count = v.into();
10372 self
10373 }
10374
10375 /// Sets the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
10376 ///
10377 /// # Example
10378 /// ```ignore,no_run
10379 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10380 /// use wkt::Duration;
10381 /// let x = AggregatedMetrics::new().set_travel_duration(Duration::default()/* use setters */);
10382 /// ```
10383 pub fn set_travel_duration<T>(mut self, v: T) -> Self
10384 where
10385 T: std::convert::Into<wkt::Duration>,
10386 {
10387 self.travel_duration = std::option::Option::Some(v.into());
10388 self
10389 }
10390
10391 /// Sets or clears the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
10392 ///
10393 /// # Example
10394 /// ```ignore,no_run
10395 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10396 /// use wkt::Duration;
10397 /// let x = AggregatedMetrics::new().set_or_clear_travel_duration(Some(Duration::default()/* use setters */));
10398 /// let x = AggregatedMetrics::new().set_or_clear_travel_duration(None::<Duration>);
10399 /// ```
10400 pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
10401 where
10402 T: std::convert::Into<wkt::Duration>,
10403 {
10404 self.travel_duration = v.map(|x| x.into());
10405 self
10406 }
10407
10408 /// Sets the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
10409 ///
10410 /// # Example
10411 /// ```ignore,no_run
10412 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10413 /// use wkt::Duration;
10414 /// let x = AggregatedMetrics::new().set_wait_duration(Duration::default()/* use setters */);
10415 /// ```
10416 pub fn set_wait_duration<T>(mut self, v: T) -> Self
10417 where
10418 T: std::convert::Into<wkt::Duration>,
10419 {
10420 self.wait_duration = std::option::Option::Some(v.into());
10421 self
10422 }
10423
10424 /// Sets or clears the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
10425 ///
10426 /// # Example
10427 /// ```ignore,no_run
10428 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10429 /// use wkt::Duration;
10430 /// let x = AggregatedMetrics::new().set_or_clear_wait_duration(Some(Duration::default()/* use setters */));
10431 /// let x = AggregatedMetrics::new().set_or_clear_wait_duration(None::<Duration>);
10432 /// ```
10433 pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
10434 where
10435 T: std::convert::Into<wkt::Duration>,
10436 {
10437 self.wait_duration = v.map(|x| x.into());
10438 self
10439 }
10440
10441 /// Sets the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
10442 ///
10443 /// # Example
10444 /// ```ignore,no_run
10445 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10446 /// use wkt::Duration;
10447 /// let x = AggregatedMetrics::new().set_delay_duration(Duration::default()/* use setters */);
10448 /// ```
10449 pub fn set_delay_duration<T>(mut self, v: T) -> Self
10450 where
10451 T: std::convert::Into<wkt::Duration>,
10452 {
10453 self.delay_duration = std::option::Option::Some(v.into());
10454 self
10455 }
10456
10457 /// Sets or clears the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
10458 ///
10459 /// # Example
10460 /// ```ignore,no_run
10461 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10462 /// use wkt::Duration;
10463 /// let x = AggregatedMetrics::new().set_or_clear_delay_duration(Some(Duration::default()/* use setters */));
10464 /// let x = AggregatedMetrics::new().set_or_clear_delay_duration(None::<Duration>);
10465 /// ```
10466 pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
10467 where
10468 T: std::convert::Into<wkt::Duration>,
10469 {
10470 self.delay_duration = v.map(|x| x.into());
10471 self
10472 }
10473
10474 /// Sets the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
10475 ///
10476 /// # Example
10477 /// ```ignore,no_run
10478 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10479 /// use wkt::Duration;
10480 /// let x = AggregatedMetrics::new().set_break_duration(Duration::default()/* use setters */);
10481 /// ```
10482 pub fn set_break_duration<T>(mut self, v: T) -> Self
10483 where
10484 T: std::convert::Into<wkt::Duration>,
10485 {
10486 self.break_duration = std::option::Option::Some(v.into());
10487 self
10488 }
10489
10490 /// Sets or clears the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
10491 ///
10492 /// # Example
10493 /// ```ignore,no_run
10494 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10495 /// use wkt::Duration;
10496 /// let x = AggregatedMetrics::new().set_or_clear_break_duration(Some(Duration::default()/* use setters */));
10497 /// let x = AggregatedMetrics::new().set_or_clear_break_duration(None::<Duration>);
10498 /// ```
10499 pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
10500 where
10501 T: std::convert::Into<wkt::Duration>,
10502 {
10503 self.break_duration = v.map(|x| x.into());
10504 self
10505 }
10506
10507 /// Sets the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
10508 ///
10509 /// # Example
10510 /// ```ignore,no_run
10511 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10512 /// use wkt::Duration;
10513 /// let x = AggregatedMetrics::new().set_visit_duration(Duration::default()/* use setters */);
10514 /// ```
10515 pub fn set_visit_duration<T>(mut self, v: T) -> Self
10516 where
10517 T: std::convert::Into<wkt::Duration>,
10518 {
10519 self.visit_duration = std::option::Option::Some(v.into());
10520 self
10521 }
10522
10523 /// Sets or clears the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
10524 ///
10525 /// # Example
10526 /// ```ignore,no_run
10527 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10528 /// use wkt::Duration;
10529 /// let x = AggregatedMetrics::new().set_or_clear_visit_duration(Some(Duration::default()/* use setters */));
10530 /// let x = AggregatedMetrics::new().set_or_clear_visit_duration(None::<Duration>);
10531 /// ```
10532 pub fn set_or_clear_visit_duration<T>(mut self, v: std::option::Option<T>) -> Self
10533 where
10534 T: std::convert::Into<wkt::Duration>,
10535 {
10536 self.visit_duration = v.map(|x| x.into());
10537 self
10538 }
10539
10540 /// Sets the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
10541 ///
10542 /// # Example
10543 /// ```ignore,no_run
10544 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10545 /// use wkt::Duration;
10546 /// let x = AggregatedMetrics::new().set_total_duration(Duration::default()/* use setters */);
10547 /// ```
10548 pub fn set_total_duration<T>(mut self, v: T) -> Self
10549 where
10550 T: std::convert::Into<wkt::Duration>,
10551 {
10552 self.total_duration = std::option::Option::Some(v.into());
10553 self
10554 }
10555
10556 /// Sets or clears the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
10557 ///
10558 /// # Example
10559 /// ```ignore,no_run
10560 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10561 /// use wkt::Duration;
10562 /// let x = AggregatedMetrics::new().set_or_clear_total_duration(Some(Duration::default()/* use setters */));
10563 /// let x = AggregatedMetrics::new().set_or_clear_total_duration(None::<Duration>);
10564 /// ```
10565 pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
10566 where
10567 T: std::convert::Into<wkt::Duration>,
10568 {
10569 self.total_duration = v.map(|x| x.into());
10570 self
10571 }
10572
10573 /// Sets the value of [travel_distance_meters][crate::model::AggregatedMetrics::travel_distance_meters].
10574 ///
10575 /// # Example
10576 /// ```ignore,no_run
10577 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10578 /// let x = AggregatedMetrics::new().set_travel_distance_meters(42.0);
10579 /// ```
10580 pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
10581 self.travel_distance_meters = v.into();
10582 self
10583 }
10584
10585 /// Sets the value of [max_loads][crate::model::AggregatedMetrics::max_loads].
10586 ///
10587 /// # Example
10588 /// ```ignore,no_run
10589 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10590 /// use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
10591 /// let x = AggregatedMetrics::new().set_max_loads([
10592 /// ("key0", VehicleLoad::default()/* use setters */),
10593 /// ("key1", VehicleLoad::default()/* use (different) setters */),
10594 /// ]);
10595 /// ```
10596 pub fn set_max_loads<T, K, V>(mut self, v: T) -> Self
10597 where
10598 T: std::iter::IntoIterator<Item = (K, V)>,
10599 K: std::convert::Into<std::string::String>,
10600 V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
10601 {
10602 use std::iter::Iterator;
10603 self.max_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
10604 self
10605 }
10606
10607 /// Sets the value of [costs][crate::model::AggregatedMetrics::costs].
10608 ///
10609 /// # Example
10610 /// ```ignore,no_run
10611 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10612 /// let x = AggregatedMetrics::new().set_costs([
10613 /// ("key0", 123.5),
10614 /// ("key1", 456.5),
10615 /// ]);
10616 /// ```
10617 #[deprecated]
10618 pub fn set_costs<T, K, V>(mut self, v: T) -> Self
10619 where
10620 T: std::iter::IntoIterator<Item = (K, V)>,
10621 K: std::convert::Into<std::string::String>,
10622 V: std::convert::Into<f64>,
10623 {
10624 use std::iter::Iterator;
10625 self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
10626 self
10627 }
10628
10629 /// Sets the value of [total_cost][crate::model::AggregatedMetrics::total_cost].
10630 ///
10631 /// # Example
10632 /// ```ignore,no_run
10633 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10634 /// let x = AggregatedMetrics::new().set_total_cost(42.0);
10635 /// ```
10636 #[deprecated]
10637 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
10638 self.total_cost = v.into();
10639 self
10640 }
10641}
10642
10643impl wkt::message::Message for AggregatedMetrics {
10644 fn typename() -> &'static str {
10645 "type.googleapis.com/google.cloud.optimization.v1.AggregatedMetrics"
10646 }
10647}
10648
10649/// Solution injected in the request including information about which visits
10650/// must be constrained and how they must be constrained.
10651#[derive(Clone, Default, PartialEq)]
10652#[non_exhaustive]
10653pub struct InjectedSolutionConstraint {
10654 /// Routes of the solution to inject. Some routes may be omitted from the
10655 /// original solution. The routes and skipped shipments must satisfy the basic
10656 /// validity assumptions listed for `injected_first_solution_routes`.
10657 pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
10658
10659 /// Skipped shipments of the solution to inject. Some may be omitted from the
10660 /// original solution. See the `routes` field.
10661 pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
10662
10663 /// For zero or more groups of vehicles, specifies when and how much to relax
10664 /// constraints. If this field is empty, all non-empty vehicle routes are
10665 /// fully constrained.
10666 pub constraint_relaxations:
10667 std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>,
10668
10669 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10670}
10671
10672impl InjectedSolutionConstraint {
10673 /// Creates a new default instance.
10674 pub fn new() -> Self {
10675 std::default::Default::default()
10676 }
10677
10678 /// Sets the value of [routes][crate::model::InjectedSolutionConstraint::routes].
10679 ///
10680 /// # Example
10681 /// ```ignore,no_run
10682 /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10683 /// use google_cloud_optimization_v1::model::ShipmentRoute;
10684 /// let x = InjectedSolutionConstraint::new()
10685 /// .set_routes([
10686 /// ShipmentRoute::default()/* use setters */,
10687 /// ShipmentRoute::default()/* use (different) setters */,
10688 /// ]);
10689 /// ```
10690 pub fn set_routes<T, V>(mut self, v: T) -> Self
10691 where
10692 T: std::iter::IntoIterator<Item = V>,
10693 V: std::convert::Into<crate::model::ShipmentRoute>,
10694 {
10695 use std::iter::Iterator;
10696 self.routes = v.into_iter().map(|i| i.into()).collect();
10697 self
10698 }
10699
10700 /// Sets the value of [skipped_shipments][crate::model::InjectedSolutionConstraint::skipped_shipments].
10701 ///
10702 /// # Example
10703 /// ```ignore,no_run
10704 /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10705 /// use google_cloud_optimization_v1::model::SkippedShipment;
10706 /// let x = InjectedSolutionConstraint::new()
10707 /// .set_skipped_shipments([
10708 /// SkippedShipment::default()/* use setters */,
10709 /// SkippedShipment::default()/* use (different) setters */,
10710 /// ]);
10711 /// ```
10712 pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
10713 where
10714 T: std::iter::IntoIterator<Item = V>,
10715 V: std::convert::Into<crate::model::SkippedShipment>,
10716 {
10717 use std::iter::Iterator;
10718 self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
10719 self
10720 }
10721
10722 /// Sets the value of [constraint_relaxations][crate::model::InjectedSolutionConstraint::constraint_relaxations].
10723 ///
10724 /// # Example
10725 /// ```ignore,no_run
10726 /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10727 /// use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10728 /// let x = InjectedSolutionConstraint::new()
10729 /// .set_constraint_relaxations([
10730 /// ConstraintRelaxation::default()/* use setters */,
10731 /// ConstraintRelaxation::default()/* use (different) setters */,
10732 /// ]);
10733 /// ```
10734 pub fn set_constraint_relaxations<T, V>(mut self, v: T) -> Self
10735 where
10736 T: std::iter::IntoIterator<Item = V>,
10737 V: std::convert::Into<crate::model::injected_solution_constraint::ConstraintRelaxation>,
10738 {
10739 use std::iter::Iterator;
10740 self.constraint_relaxations = v.into_iter().map(|i| i.into()).collect();
10741 self
10742 }
10743}
10744
10745impl wkt::message::Message for InjectedSolutionConstraint {
10746 fn typename() -> &'static str {
10747 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint"
10748 }
10749}
10750
10751/// Defines additional types related to [InjectedSolutionConstraint].
10752pub mod injected_solution_constraint {
10753 #[allow(unused_imports)]
10754 use super::*;
10755
10756 /// For a group of vehicles, specifies at what threshold(s) constraints on
10757 /// visits will be relaxed and to which level. Shipments listed in
10758 /// the `skipped_shipment` field are constrained to be skipped; i.e., they
10759 /// cannot be performed.
10760 #[derive(Clone, Default, PartialEq)]
10761 #[non_exhaustive]
10762 pub struct ConstraintRelaxation {
10763 /// All the visit constraint relaxations that will apply to visits on
10764 /// routes with vehicles in `vehicle_indices`.
10765 pub relaxations: std::vec::Vec<
10766 crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
10767 >,
10768
10769 /// Specifies the vehicle indices to which the visit constraint
10770 /// `relaxations` apply. If empty, this is considered the default and the
10771 /// `relaxations` apply to all vehicles that are not specified in other
10772 /// `constraint_relaxations`. There can be at most one default, i.e., at
10773 /// most one constraint relaxation field is allowed empty
10774 /// `vehicle_indices`. A vehicle index can only be listed once, even within
10775 /// several `constraint_relaxations`.
10776 ///
10777 /// A vehicle index is mapped the same as
10778 /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index],
10779 /// if `interpret_injected_solutions_using_labels` is true (see `fields`
10780 /// comment).
10781 ///
10782 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
10783 pub vehicle_indices: std::vec::Vec<i32>,
10784
10785 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10786 }
10787
10788 impl ConstraintRelaxation {
10789 /// Creates a new default instance.
10790 pub fn new() -> Self {
10791 std::default::Default::default()
10792 }
10793
10794 /// Sets the value of [relaxations][crate::model::injected_solution_constraint::ConstraintRelaxation::relaxations].
10795 ///
10796 /// # Example
10797 /// ```ignore,no_run
10798 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10799 /// use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10800 /// let x = ConstraintRelaxation::new()
10801 /// .set_relaxations([
10802 /// Relaxation::default()/* use setters */,
10803 /// Relaxation::default()/* use (different) setters */,
10804 /// ]);
10805 /// ```
10806 pub fn set_relaxations<T, V>(mut self, v: T) -> Self
10807 where
10808 T: std::iter::IntoIterator<Item = V>,
10809 V: std::convert::Into<
10810 crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
10811 >,
10812 {
10813 use std::iter::Iterator;
10814 self.relaxations = v.into_iter().map(|i| i.into()).collect();
10815 self
10816 }
10817
10818 /// Sets the value of [vehicle_indices][crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices].
10819 ///
10820 /// # Example
10821 /// ```ignore,no_run
10822 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10823 /// let x = ConstraintRelaxation::new().set_vehicle_indices([1, 2, 3]);
10824 /// ```
10825 pub fn set_vehicle_indices<T, V>(mut self, v: T) -> Self
10826 where
10827 T: std::iter::IntoIterator<Item = V>,
10828 V: std::convert::Into<i32>,
10829 {
10830 use std::iter::Iterator;
10831 self.vehicle_indices = v.into_iter().map(|i| i.into()).collect();
10832 self
10833 }
10834 }
10835
10836 impl wkt::message::Message for ConstraintRelaxation {
10837 fn typename() -> &'static str {
10838 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation"
10839 }
10840 }
10841
10842 /// Defines additional types related to [ConstraintRelaxation].
10843 pub mod constraint_relaxation {
10844 #[allow(unused_imports)]
10845 use super::*;
10846
10847 /// If `relaxations` is empty, the start time and sequence of all visits
10848 /// on `routes` are fully constrained and no new visits may be inserted or
10849 /// added to those routes. Also, a vehicle's start and end time in
10850 /// `routes` is fully constrained, unless the vehicle is empty (i.e., has no
10851 /// visits and has `used_if_route_is_empty` set to false in the model).
10852 ///
10853 /// `relaxations(i).level` specifies the constraint relaxation level applied
10854 /// to a visit #j that satisfies:
10855 ///
10856 /// * `route.visits(j).start_time >= relaxations(i).threshold_time` AND
10857 /// * `j + 1 >= relaxations(i).threshold_visit_count`
10858 ///
10859 /// Similarly, the vehicle start is relaxed to `relaxations(i).level` if it
10860 /// satisfies:
10861 ///
10862 /// * `vehicle_start_time >= relaxations(i).threshold_time` AND
10863 /// * `relaxations(i).threshold_visit_count == 0`
10864 /// and the vehicle end is relaxed to `relaxations(i).level` if it satisfies:
10865 /// * `vehicle_end_time >= relaxations(i).threshold_time` AND
10866 /// * `route.visits_size() + 1 >= relaxations(i).threshold_visit_count`
10867 ///
10868 /// To apply a relaxation level if a visit meets the `threshold_visit_count`
10869 /// OR the `threshold_time` add two `relaxations` with the same `level`:
10870 /// one with only `threshold_visit_count` set and the other with only
10871 /// `threshold_time` set. If a visit satisfies the conditions of multiple
10872 /// `relaxations`, the most relaxed level applies. As a result, from the
10873 /// vehicle start through the route visits in order to the vehicle end, the
10874 /// relaxation level becomes more relaxed: i.e., the relaxation level is
10875 /// non-decreasing as the route progresses.
10876 ///
10877 /// The timing and sequence of route visits that do not satisfy the
10878 /// threshold conditions of any `relaxations` are fully constrained
10879 /// and no visits may be inserted into these sequences. Also, if a
10880 /// vehicle start or end does not satisfy the conditions of any
10881 /// relaxation the time is fixed, unless the vehicle is empty.
10882 #[derive(Clone, Default, PartialEq)]
10883 #[non_exhaustive]
10884 pub struct Relaxation {
10885
10886 /// The constraint relaxation level that applies when the conditions
10887 /// at or after `threshold_time` AND at least `threshold_visit_count` are
10888 /// satisfied.
10889 pub level: crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level,
10890
10891 /// The time at or after which the relaxation `level` may be applied.
10892 pub threshold_time: std::option::Option<wkt::Timestamp>,
10893
10894 /// The number of visits at or after which the relaxation `level` may be
10895 /// applied. If `threshold_visit_count` is 0 (or unset), the `level` may be
10896 /// applied directly at the vehicle start.
10897 ///
10898 /// If it is `route.visits_size() + 1`, the `level` may only be applied to
10899 /// the vehicle end. If it is more than `route.visits_size() + 1`,
10900 /// `level` is not applied at all for that route.
10901 pub threshold_visit_count: i32,
10902
10903 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10904 }
10905
10906 impl Relaxation {
10907 /// Creates a new default instance.
10908 pub fn new() -> Self {
10909 std::default::Default::default()
10910 }
10911
10912 /// Sets the value of [level][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::level].
10913 ///
10914 /// # Example
10915 /// ```ignore,no_run
10916 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10917 /// use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::relaxation::Level;
10918 /// let x0 = Relaxation::new().set_level(Level::RelaxVisitTimesAfterThreshold);
10919 /// let x1 = Relaxation::new().set_level(Level::RelaxVisitTimesAndSequenceAfterThreshold);
10920 /// let x2 = Relaxation::new().set_level(Level::RelaxAllAfterThreshold);
10921 /// ```
10922 pub fn set_level<T: std::convert::Into<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>(mut self, v: T) -> Self{
10923 self.level = v.into();
10924 self
10925 }
10926
10927 /// Sets the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
10928 ///
10929 /// # Example
10930 /// ```ignore,no_run
10931 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10932 /// use wkt::Timestamp;
10933 /// let x = Relaxation::new().set_threshold_time(Timestamp::default()/* use setters */);
10934 /// ```
10935 pub fn set_threshold_time<T>(mut self, v: T) -> Self
10936 where
10937 T: std::convert::Into<wkt::Timestamp>,
10938 {
10939 self.threshold_time = std::option::Option::Some(v.into());
10940 self
10941 }
10942
10943 /// Sets or clears the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
10944 ///
10945 /// # Example
10946 /// ```ignore,no_run
10947 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10948 /// use wkt::Timestamp;
10949 /// let x = Relaxation::new().set_or_clear_threshold_time(Some(Timestamp::default()/* use setters */));
10950 /// let x = Relaxation::new().set_or_clear_threshold_time(None::<Timestamp>);
10951 /// ```
10952 pub fn set_or_clear_threshold_time<T>(mut self, v: std::option::Option<T>) -> Self
10953 where
10954 T: std::convert::Into<wkt::Timestamp>,
10955 {
10956 self.threshold_time = v.map(|x| x.into());
10957 self
10958 }
10959
10960 /// Sets the value of [threshold_visit_count][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_visit_count].
10961 ///
10962 /// # Example
10963 /// ```ignore,no_run
10964 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10965 /// let x = Relaxation::new().set_threshold_visit_count(42);
10966 /// ```
10967 pub fn set_threshold_visit_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10968 self.threshold_visit_count = v.into();
10969 self
10970 }
10971 }
10972
10973 impl wkt::message::Message for Relaxation {
10974 fn typename() -> &'static str {
10975 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation"
10976 }
10977 }
10978
10979 /// Defines additional types related to [Relaxation].
10980 pub mod relaxation {
10981 #[allow(unused_imports)]
10982 use super::*;
10983
10984 /// Expresses the different constraint relaxation levels, which are
10985 /// applied for a visit and those that follow when it satisfies the
10986 /// threshold conditions.
10987 ///
10988 /// The enumeration below is in order of increasing relaxation.
10989 ///
10990 /// # Working with unknown values
10991 ///
10992 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10993 /// additional enum variants at any time. Adding new variants is not considered
10994 /// a breaking change. Applications should write their code in anticipation of:
10995 ///
10996 /// - New values appearing in future releases of the client library, **and**
10997 /// - New values received dynamically, without application changes.
10998 ///
10999 /// Please consult the [Working with enums] section in the user guide for some
11000 /// guidelines.
11001 ///
11002 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
11003 #[derive(Clone, Debug, PartialEq)]
11004 #[non_exhaustive]
11005 pub enum Level {
11006 /// Implicit default relaxation level: no constraints are relaxed,
11007 /// i.e., all visits are fully constrained.
11008 ///
11009 /// This value must not be explicitly used in `level`.
11010 Unspecified,
11011 /// Visit start times and vehicle start/end times will be relaxed, but
11012 /// each visit remains bound to the same vehicle and the visit sequence
11013 /// must be observed: no visit can be inserted between them or before
11014 /// them.
11015 RelaxVisitTimesAfterThreshold,
11016 /// Same as `RELAX_VISIT_TIMES_AFTER_THRESHOLD`, but the visit sequence
11017 /// is also relaxed: visits can only be performed by this vehicle, but
11018 /// can potentially become unperformed.
11019 RelaxVisitTimesAndSequenceAfterThreshold,
11020 /// Same as `RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD`, but the
11021 /// vehicle is also relaxed: visits are completely free at or after the
11022 /// threshold time and can potentially become unperformed.
11023 RelaxAllAfterThreshold,
11024 /// If set, the enum was initialized with an unknown value.
11025 ///
11026 /// Applications can examine the value using [Level::value] or
11027 /// [Level::name].
11028 UnknownValue(level::UnknownValue),
11029 }
11030
11031 #[doc(hidden)]
11032 pub mod level {
11033 #[allow(unused_imports)]
11034 use super::*;
11035 #[derive(Clone, Debug, PartialEq)]
11036 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11037 }
11038
11039 impl Level {
11040 /// Gets the enum value.
11041 ///
11042 /// Returns `None` if the enum contains an unknown value deserialized from
11043 /// the string representation of enums.
11044 pub fn value(&self) -> std::option::Option<i32> {
11045 match self {
11046 Self::Unspecified => std::option::Option::Some(0),
11047 Self::RelaxVisitTimesAfterThreshold => std::option::Option::Some(1),
11048 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
11049 std::option::Option::Some(2)
11050 }
11051 Self::RelaxAllAfterThreshold => std::option::Option::Some(3),
11052 Self::UnknownValue(u) => u.0.value(),
11053 }
11054 }
11055
11056 /// Gets the enum value as a string.
11057 ///
11058 /// Returns `None` if the enum contains an unknown value deserialized from
11059 /// the integer representation of enums.
11060 pub fn name(&self) -> std::option::Option<&str> {
11061 match self {
11062 Self::Unspecified => std::option::Option::Some("LEVEL_UNSPECIFIED"),
11063 Self::RelaxVisitTimesAfterThreshold => {
11064 std::option::Option::Some("RELAX_VISIT_TIMES_AFTER_THRESHOLD")
11065 }
11066 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
11067 std::option::Option::Some(
11068 "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD",
11069 )
11070 }
11071 Self::RelaxAllAfterThreshold => {
11072 std::option::Option::Some("RELAX_ALL_AFTER_THRESHOLD")
11073 }
11074 Self::UnknownValue(u) => u.0.name(),
11075 }
11076 }
11077 }
11078
11079 impl std::default::Default for Level {
11080 fn default() -> Self {
11081 use std::convert::From;
11082 Self::from(0)
11083 }
11084 }
11085
11086 impl std::fmt::Display for Level {
11087 fn fmt(
11088 &self,
11089 f: &mut std::fmt::Formatter<'_>,
11090 ) -> std::result::Result<(), std::fmt::Error> {
11091 wkt::internal::display_enum(f, self.name(), self.value())
11092 }
11093 }
11094
11095 impl std::convert::From<i32> for Level {
11096 fn from(value: i32) -> Self {
11097 match value {
11098 0 => Self::Unspecified,
11099 1 => Self::RelaxVisitTimesAfterThreshold,
11100 2 => Self::RelaxVisitTimesAndSequenceAfterThreshold,
11101 3 => Self::RelaxAllAfterThreshold,
11102 _ => Self::UnknownValue(level::UnknownValue(
11103 wkt::internal::UnknownEnumValue::Integer(value),
11104 )),
11105 }
11106 }
11107 }
11108
11109 impl std::convert::From<&str> for Level {
11110 fn from(value: &str) -> Self {
11111 use std::string::ToString;
11112 match value {
11113 "LEVEL_UNSPECIFIED" => Self::Unspecified,
11114 "RELAX_VISIT_TIMES_AFTER_THRESHOLD" => Self::RelaxVisitTimesAfterThreshold,
11115 "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD" => {
11116 Self::RelaxVisitTimesAndSequenceAfterThreshold
11117 }
11118 "RELAX_ALL_AFTER_THRESHOLD" => Self::RelaxAllAfterThreshold,
11119 _ => Self::UnknownValue(level::UnknownValue(
11120 wkt::internal::UnknownEnumValue::String(value.to_string()),
11121 )),
11122 }
11123 }
11124 }
11125
11126 impl serde::ser::Serialize for Level {
11127 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11128 where
11129 S: serde::Serializer,
11130 {
11131 match self {
11132 Self::Unspecified => serializer.serialize_i32(0),
11133 Self::RelaxVisitTimesAfterThreshold => serializer.serialize_i32(1),
11134 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
11135 serializer.serialize_i32(2)
11136 }
11137 Self::RelaxAllAfterThreshold => serializer.serialize_i32(3),
11138 Self::UnknownValue(u) => u.0.serialize(serializer),
11139 }
11140 }
11141 }
11142
11143 impl<'de> serde::de::Deserialize<'de> for Level {
11144 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11145 where
11146 D: serde::Deserializer<'de>,
11147 {
11148 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Level>::new(
11149 ".google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation.Level"))
11150 }
11151 }
11152 }
11153 }
11154}
11155
11156/// Describes an error encountered when validating an `OptimizeToursRequest`.
11157#[derive(Clone, Default, PartialEq)]
11158#[non_exhaustive]
11159pub struct OptimizeToursValidationError {
11160 /// A validation error is defined by the pair (`code`, `display_name`) which
11161 /// are always present.
11162 ///
11163 /// Other fields (below) provide more context about the error.
11164 ///
11165 /// *MULTIPLE ERRORS*:
11166 /// When there are multiple errors, the validation process tries to output
11167 /// several of them. Much like a compiler, this is an imperfect process. Some
11168 /// validation errors will be "fatal", meaning that they stop the entire
11169 /// validation process. This is the case for `display_name="UNSPECIFIED"`
11170 /// errors, among others. Some may cause the validation process to skip other
11171 /// errors.
11172 ///
11173 /// *STABILITY*:
11174 /// `code` and `display_name` should be very stable. But new codes and
11175 /// display names may appear over time, which may cause a given (invalid)
11176 /// request to yield a different (`code`, `display_name`) pair because the new
11177 /// error hid the old one (see "MULTIPLE ERRORS").
11178 ///
11179 /// *REFERENCE*: A list of all (code, name) pairs:
11180 ///
11181 /// * UNSPECIFIED = 0;
11182 ///
11183 /// * VALIDATION_TIMEOUT_ERROR = 10; Validation couldn't be completed within
11184 /// the deadline.
11185 ///
11186 /// * REQUEST_OPTIONS_ERROR = 12;
11187 ///
11188 /// * REQUEST_OPTIONS_INVALID_SOLVING_MODE = 1201;
11189 /// * REQUEST_OPTIONS_INVALID_MAX_VALIDATION_ERRORS = 1203;
11190 /// * REQUEST_OPTIONS_INVALID_GEODESIC_METERS_PER_SECOND = 1204;
11191 /// * REQUEST_OPTIONS_GEODESIC_METERS_PER_SECOND_TOO_SMALL = 1205;
11192 /// * REQUEST_OPTIONS_MISSING_GEODESIC_METERS_PER_SECOND = 1206;
11193 /// * REQUEST_OPTIONS_POPULATE_PATHFINDER_TRIPS_AND_GEODESIC_DISTANCE
11194 /// = 1207;
11195 /// * REQUEST_OPTIONS_COST_MODEL_OPTIONS_AND_GEODESIC_DISTANCE = 1208;
11196 /// * REQUEST_OPTIONS_TRAVEL_MODE_INCOMPATIBLE_WITH_TRAFFIC = 1211;
11197 /// * REQUEST_OPTIONS_MULTIPLE_TRAFFIC_FLAVORS = 1212;
11198 /// * REQUEST_OPTIONS_INVALID_TRAFFIC_FLAVOR = 1213;
11199 /// * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITHOUT_GLOBAL_START_TIME = 1214;
11200 /// * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITH_PRECEDENCES = 1215;
11201 /// * REQUEST_OPTIONS_TRAFFIC_PREFILL_MODE_INVALID = 1216;
11202 /// * REQUEST_OPTIONS_TRAFFIC_PREFILL_ENABLED_WITHOUT_TRAFFIC = 1217;
11203 /// * INJECTED_SOLUTION_ERROR = 20;
11204 ///
11205 /// * INJECTED_SOLUTION_MISSING_LABEL = 2000;
11206 /// * INJECTED_SOLUTION_DUPLICATE_LABEL = 2001;
11207 /// * INJECTED_SOLUTION_AMBIGUOUS_INDEX = 2002;
11208 /// * INJECTED_SOLUTION_INFEASIBLE_AFTER_GETTING_TRAVEL_TIMES = 2003;
11209 /// * INJECTED_SOLUTION_TRANSITION_INCONSISTENT_WITH_ACTUAL_TRAVEL = 2004;
11210 /// * INJECTED_SOLUTION_CONCURRENT_SOLUTION_TYPES = 2005;
11211 /// * INJECTED_SOLUTION_MORE_THAN_ONE_PER_TYPE = 2006;
11212 /// * INJECTED_SOLUTION_REFRESH_WITHOUT_POPULATE = 2008;
11213 /// * INJECTED_SOLUTION_CONSTRAINED_ROUTE_PORTION_INFEASIBLE = 2010;
11214 /// * SHIPMENT_MODEL_ERROR = 22;
11215 ///
11216 /// * SHIPMENT_MODEL_TOO_LARGE = 2200;
11217 /// * SHIPMENT_MODEL_TOO_MANY_CAPACITY_TYPES = 2201;
11218 /// * SHIPMENT_MODEL_GLOBAL_START_TIME_NEGATIVE_OR_NAN = 2202;
11219 /// * SHIPMENT_MODEL_GLOBAL_END_TIME_TOO_LARGE_OR_NAN = 2203;
11220 /// * SHIPMENT_MODEL_GLOBAL_START_TIME_AFTER_GLOBAL_END_TIME = 2204;
11221 /// * SHIPMENT_MODEL_GLOBAL_DURATION_TOO_LONG = 2205;
11222 /// * SHIPMENT_MODEL_MAX_ACTIVE_VEHICLES_NOT_POSITIVE = 2206;
11223 /// * SHIPMENT_MODEL_DURATION_MATRIX_TOO_LARGE = 2207;
11224 /// * INDEX_ERROR = 24;
11225 ///
11226 /// * TAG_ERROR = 26;
11227 ///
11228 /// * TIME_WINDOW_ERROR = 28;
11229 ///
11230 /// * TIME_WINDOW_INVALID_START_TIME = 2800;
11231 /// * TIME_WINDOW_INVALID_END_TIME = 2801;
11232 /// * TIME_WINDOW_INVALID_SOFT_START_TIME = 2802;
11233 /// * TIME_WINDOW_INVALID_SOFT_END_TIME = 2803;
11234 /// * TIME_WINDOW_OUTSIDE_GLOBAL_TIME_WINDOW = 2804;
11235 /// * TIME_WINDOW_START_TIME_AFTER_END_TIME = 2805;
11236 /// * TIME_WINDOW_INVALID_COST_PER_HOUR_BEFORE_SOFT_START_TIME = 2806;
11237 /// * TIME_WINDOW_INVALID_COST_PER_HOUR_AFTER_SOFT_END_TIME = 2807;
11238 /// * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_WITHOUT_SOFT_START_TIME
11239 /// = 2808;
11240 /// * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_WITHOUT_SOFT_END_TIME = 2809;
11241 /// * TIME_WINDOW_SOFT_START_TIME_WITHOUT_COST_BEFORE_SOFT_START_TIME
11242 /// = 2810;
11243 /// * TIME_WINDOW_SOFT_END_TIME_WITHOUT_COST_AFTER_SOFT_END_TIME = 2811;
11244 /// * TIME_WINDOW_OVERLAPPING_ADJACENT_OR_EARLIER_THAN_PREVIOUS = 2812;
11245 /// * TIME_WINDOW_START_TIME_AFTER_SOFT_START_TIME = 2813;
11246 /// * TIME_WINDOW_SOFT_START_TIME_AFTER_END_TIME = 2814;
11247 /// * TIME_WINDOW_START_TIME_AFTER_SOFT_END_TIME = 2815;
11248 /// * TIME_WINDOW_SOFT_END_TIME_AFTER_END_TIME = 2816;
11249 /// * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_SET_AND_MULTIPLE_WINDOWS
11250 /// = 2817;
11251 /// * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_SET_AND_MULTIPLE_WINDOWS = 2818;
11252 /// * TRANSITION_ATTRIBUTES_ERROR = 30;
11253 /// * TRANSITION_ATTRIBUTES_INVALID_COST = 3000;
11254 /// * TRANSITION_ATTRIBUTES_INVALID_COST_PER_KILOMETER = 3001;
11255 /// * TRANSITION_ATTRIBUTES_DUPLICATE_TAG_PAIR = 3002;
11256 /// * TRANSITION_ATTRIBUTES_DISTANCE_LIMIT_MAX_METERS_UNSUPPORTED = 3003;
11257 /// * TRANSITION_ATTRIBUTES_UNSPECIFIED_SOURCE_TAGS = 3004;
11258 /// * TRANSITION_ATTRIBUTES_CONFLICTING_SOURCE_TAGS_FIELDS = 3005;
11259 /// * TRANSITION_ATTRIBUTES_UNSPECIFIED_DESTINATION_TAGS = 3006;
11260 /// * TRANSITION_ATTRIBUTES_CONFLICTING_DESTINATION_TAGS_FIELDS = 3007;
11261 /// * TRANSITION_ATTRIBUTES_DELAY_DURATION_NEGATIVE_OR_NAN = 3008;
11262 /// * TRANSITION_ATTRIBUTES_DELAY_DURATION_EXCEEDS_GLOBAL_DURATION = 3009;
11263 /// * AMOUNT_ERROR = 31;
11264 ///
11265 /// * AMOUNT_NEGATIVE_VALUE = 3100;
11266 /// * LOAD_LIMIT_ERROR = 33;
11267 ///
11268 /// * LOAD_LIMIT_INVALID_COST_ABOVE_SOFT_MAX = 3303;
11269 /// * LOAD_LIMIT_SOFT_MAX_WITHOUT_COST_ABOVE_SOFT_MAX = 3304;
11270 /// * LOAD_LIMIT_COST_ABOVE_SOFT_MAX_WITHOUT_SOFT_MAX = 3305;
11271 /// * LOAD_LIMIT_NEGATIVE_SOFT_MAX = 3306;
11272 /// * LOAD_LIMIT_MIXED_DEMAND_TYPE = 3307;
11273 /// * LOAD_LIMIT_MAX_LOAD_NEGATIVE_VALUE = 3308;
11274 /// * LOAD_LIMIT_SOFT_MAX_ABOVE_MAX = 3309;
11275 /// * INTERVAL_ERROR = 34;
11276 ///
11277 /// * INTERVAL_MIN_EXCEEDS_MAX = 3401;
11278 /// * INTERVAL_NEGATIVE_MIN = 3402;
11279 /// * INTERVAL_NEGATIVE_MAX = 3403;
11280 /// * INTERVAL_MIN_EXCEEDS_CAPACITY = 3404;
11281 /// * INTERVAL_MAX_EXCEEDS_CAPACITY = 3405;
11282 /// * DISTANCE_LIMIT_ERROR = 36;
11283 ///
11284 /// * DISTANCE_LIMIT_INVALID_COST_AFTER_SOFT_MAX = 3601;
11285 /// * DISTANCE_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3602;
11286 /// * DISTANCE_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3603;
11287 /// * DISTANCE_LIMIT_NEGATIVE_MAX = 3604;
11288 /// * DISTANCE_LIMIT_NEGATIVE_SOFT_MAX = 3605;
11289 /// * DISTANCE_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3606;
11290 /// * DURATION_LIMIT_ERROR = 38;
11291 ///
11292 /// * DURATION_LIMIT_MAX_DURATION_NEGATIVE_OR_NAN = 3800;
11293 /// * DURATION_LIMIT_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3801;
11294 /// * DURATION_LIMIT_INVALID_COST_PER_HOUR_AFTER_SOFT_MAX = 3802;
11295 /// * DURATION_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3803;
11296 /// * DURATION_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3804;
11297 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3805;
11298 /// * DURATION_LIMIT_INVALID_COST_AFTER_QUADRATIC_SOFT_MAX = 3806;
11299 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_COST_PER_SQUARE_HOUR
11300 /// = 3807;
11301 /// * DURATION_LIMIT_COST_PER_SQUARE_HOUR_WITHOUT_QUADRATIC_SOFT_MAX
11302 /// = 3808;
11303 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_MAX = 3809;
11304 /// * DURATION_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3810;
11305 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_LARGER_THAN_MAX = 3811;
11306 /// * DURATION_LIMIT_DIFF_BETWEEN_MAX_AND_QUADRATIC_SOFT_MAX_TOO_LARGE
11307 /// = 3812;
11308 /// * DURATION_LIMIT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3813;
11309 /// * DURATION_LIMIT_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3814;
11310 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION
11311 /// = 3815;
11312 /// * SHIPMENT_ERROR = 40;
11313 ///
11314 /// * SHIPMENT_PD_LIMIT_WITHOUT_PICKUP_AND_DELIVERY = 4014;
11315 /// * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_NEGATIVE_OR_NAN = 4000;
11316 /// * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION
11317 /// = 4001;
11318 /// * SHIPMENT_PD_RELATIVE_DETOUR_LIMIT_INVALID = 4015;
11319 /// * SHIPMENT_PD_DETOUR_LIMIT_AND_EXTRA_VISIT_DURATION = 4016;
11320 /// * SHIPMENT_PD_TIME_LIMIT_DURATION_NEGATIVE_OR_NAN = 4002;
11321 /// * SHIPMENT_PD_TIME_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4003;
11322 /// * SHIPMENT_EMPTY_SHIPMENT_TYPE = 4004;
11323 /// * SHIPMENT_NO_PICKUP_NO_DELIVERY = 4005;
11324 /// * SHIPMENT_INVALID_PENALTY_COST = 4006;
11325 /// * SHIPMENT_ALLOWED_VEHICLE_INDEX_OUT_OF_BOUNDS = 4007;
11326 /// * SHIPMENT_DUPLICATE_ALLOWED_VEHICLE_INDEX = 4008;
11327 /// * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITHOUT_INDEX = 4009;
11328 /// * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITH_INDEX = 4010;
11329 /// * SHIPMENT_INVALID_COST_FOR_VEHICLE = 4011;
11330 /// * SHIPMENT_COST_FOR_VEHICLE_INDEX_OUT_OF_BOUNDS = 4012;
11331 /// * SHIPMENT_DUPLICATE_COST_FOR_VEHICLE_INDEX = 4013;
11332 /// * VEHICLE_ERROR = 42;
11333 ///
11334 /// * VEHICLE_EMPTY_REQUIRED_OPERATOR_TYPE = 4200;
11335 /// * VEHICLE_DUPLICATE_REQUIRED_OPERATOR_TYPE = 4201;
11336 /// * VEHICLE_NO_OPERATOR_WITH_REQUIRED_OPERATOR_TYPE = 4202;
11337 /// * VEHICLE_EMPTY_START_TAG = 4203;
11338 /// * VEHICLE_DUPLICATE_START_TAG = 4204;
11339 /// * VEHICLE_EMPTY_END_TAG = 4205;
11340 /// * VEHICLE_DUPLICATE_END_TAG = 4206;
11341 /// * VEHICLE_EXTRA_VISIT_DURATION_NEGATIVE_OR_NAN = 4207;
11342 /// * VEHICLE_EXTRA_VISIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4208;
11343 /// * VEHICLE_EXTRA_VISIT_DURATION_EMPTY_KEY = 4209;
11344 /// * VEHICLE_FIRST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4210;
11345 /// * VEHICLE_FIRST_SHIPMENT_IGNORED = 4211;
11346 /// * VEHICLE_FIRST_SHIPMENT_NOT_BOUND = 4212;
11347 /// * VEHICLE_LAST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4213;
11348 /// * VEHICLE_LAST_SHIPMENT_IGNORED = 4214;
11349 /// * VEHICLE_LAST_SHIPMENT_NOT_BOUND = 4215;
11350 /// * VEHICLE_IGNORED_WITH_USED_IF_ROUTE_IS_EMPTY = 4216;
11351 /// * VEHICLE_INVALID_COST_PER_KILOMETER = 4217;
11352 /// * VEHICLE_INVALID_COST_PER_HOUR = 4218;
11353 /// * VEHICLE_INVALID_COST_PER_TRAVELED_HOUR = 4219;
11354 /// * VEHICLE_INVALID_FIXED_COST = 4220;
11355 /// * VEHICLE_INVALID_TRAVEL_DURATION_MULTIPLE = 4221;
11356 /// * VEHICLE_TRAVEL_DURATION_MULTIPLE_WITH_SHIPMENT_PD_DETOUR_LIMITS
11357 /// = 4223;
11358 /// * VEHICLE_MATRIX_INDEX_WITH_SHIPMENT_PD_DETOUR_LIMITS = 4224;
11359 /// * VEHICLE_MINIMUM_DURATION_LONGER_THAN_DURATION_LIMIT = 4222;
11360 /// * VISIT_REQUEST_ERROR = 44;
11361 ///
11362 /// * VISIT_REQUEST_EMPTY_TAG = 4400;
11363 /// * VISIT_REQUEST_DUPLICATE_TAG = 4401;
11364 /// * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404;
11365 /// * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405;
11366 /// * PRECEDENCE_ERROR = 46;
11367 ///
11368 /// * PRECEDENCE_RULE_MISSING_FIRST_INDEX = 4600;
11369 /// * PRECEDENCE_RULE_MISSING_SECOND_INDEX = 4601;
11370 /// * PRECEDENCE_RULE_FIRST_INDEX_OUT_OF_BOUNDS = 4602;
11371 /// * PRECEDENCE_RULE_SECOND_INDEX_OUT_OF_BOUNDS = 4603;
11372 /// * PRECEDENCE_RULE_DUPLICATE_INDEX = 4604;
11373 /// * PRECEDENCE_RULE_INEXISTENT_FIRST_VISIT_REQUEST = 4605;
11374 /// * PRECEDENCE_RULE_INEXISTENT_SECOND_VISIT_REQUEST = 4606;
11375 /// * BREAK_ERROR = 48;
11376 ///
11377 /// * BREAK_RULE_EMPTY = 4800;
11378 /// * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801;
11379 /// * BREAK_REQUEST_UNSPECIFIED_EARLIEST_START_TIME = 4802;
11380 /// * BREAK_REQUEST_UNSPECIFIED_LATEST_START_TIME = 4803;
11381 /// * BREAK_REQUEST_DURATION_NEGATIVE_OR_NAN = 4804; = 4804;
11382 /// * BREAK_REQUEST_LATEST_START_TIME_BEFORE_EARLIEST_START_TIME = 4805;
11383 /// * BREAK_REQUEST_EARLIEST_START_TIME_BEFORE_GLOBAL_START_TIME = 4806;
11384 /// * BREAK_REQUEST_LATEST_END_TIME_AFTER_GLOBAL_END_TIME = 4807;
11385 /// * BREAK_REQUEST_NON_SCHEDULABLE = 4808;
11386 /// * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_NEGATIVE_OR_NAN = 4809;
11387 /// * BREAK_FREQUENCY_MIN_BREAK_DURATION_NEGATIVE_OR_NAN = 4810;
11388 /// * BREAK_FREQUENCY_MIN_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION = 4811;
11389 /// * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION
11390 /// = 4812;
11391 /// * BREAK_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4813;
11392 /// * BREAK_FREQUENCY_MISSING_MAX_INTER_BREAK_DURATION = 4814;
11393 /// * BREAK_FREQUENCY_MISSING_MIN_BREAK_DURATION = 4815;
11394 /// * SHIPMENT_TYPE_INCOMPATIBILITY_ERROR = 50;
11395 ///
11396 /// * SHIPMENT_TYPE_INCOMPATIBILITY_EMPTY_TYPE = 5001;
11397 /// * SHIPMENT_TYPE_INCOMPATIBILITY_LESS_THAN_TWO_TYPES = 5002;
11398 /// * SHIPMENT_TYPE_INCOMPATIBILITY_DUPLICATE_TYPE = 5003;
11399 /// * SHIPMENT_TYPE_INCOMPATIBILITY_INVALID_INCOMPATIBILITY_MODE = 5004;
11400 /// * SHIPMENT_TYPE_INCOMPATIBILITY_TOO_MANY_INCOMPATIBILITIES = 5005;
11401 /// * SHIPMENT_TYPE_REQUIREMENT_ERROR = 52;
11402 ///
11403 /// * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE = 52001;
11404 /// * SHIPMENT_TYPE_REQUIREMENT_NO_DEPENDENT_TYPE = 52002;
11405 /// * SHIPMENT_TYPE_REQUIREMENT_INVALID_REQUIREMENT_MODE = 52003;
11406 /// * SHIPMENT_TYPE_REQUIREMENT_TOO_MANY_REQUIREMENTS = 52004;
11407 /// * SHIPMENT_TYPE_REQUIREMENT_EMPTY_REQUIRED_TYPE = 52005;
11408 /// * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_REQUIRED_TYPE = 52006;
11409 /// * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE_FOUND = 52007;
11410 /// * SHIPMENT_TYPE_REQUIREMENT_EMPTY_DEPENDENT_TYPE = 52008;
11411 /// * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_DEPENDENT_TYPE = 52009;
11412 /// * SHIPMENT_TYPE_REQUIREMENT_SELF_DEPENDENT_TYPE = 52010;
11413 /// * SHIPMENT_TYPE_REQUIREMENT_GRAPH_HAS_CYCLES = 52011;
11414 /// * VEHICLE_OPERATOR_ERROR = 54;
11415 ///
11416 /// * VEHICLE_OPERATOR_EMPTY_TYPE = 5400;
11417 /// * VEHICLE_OPERATOR_MULTIPLE_START_TIME_WINDOWS = 5401;
11418 /// * VEHICLE_OPERATOR_SOFT_START_TIME_WINDOW = 5402;
11419 /// * VEHICLE_OPERATOR_MULTIPLE_END_TIME_WINDOWS = 5403;
11420 /// * VEHICLE_OPERATOR_SOFT_END_TIME_WINDOW = 5404;
11421 /// * DURATION_SECONDS_MATRIX_ERROR = 56;
11422 ///
11423 /// * DURATION_SECONDS_MATRIX_DURATION_NEGATIVE_OR_NAN = 5600;
11424 /// * DURATION_SECONDS_MATRIX_DURATION_EXCEEDS_GLOBAL_DURATION = 5601;
11425 pub code: i32,
11426
11427 /// The error display name.
11428 pub display_name: std::string::String,
11429
11430 /// An error context may involve 0, 1 (most of the time) or more fields. For
11431 /// example, referring to vehicle #4 and shipment #2's first pickup can be
11432 /// done as follows:
11433 ///
11434 /// ```norust
11435 /// fields { name: "vehicles" index: 4}
11436 /// fields { name: "shipments" index: 2 sub_field {name: "pickups" index: 0} }
11437 /// ```
11438 ///
11439 /// Note, however, that the cardinality of `fields` should not change for a
11440 /// given error code.
11441 pub fields: std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>,
11442
11443 /// Human-readable string describing the error. There is a 1:1 mapping
11444 /// between `code` and `error_message` (when code != "UNSPECIFIED").
11445 ///
11446 /// *STABILITY*: Not stable: the error message associated to a given `code` may
11447 /// change (hopefully to clarify it) over time. Please rely on the
11448 /// `display_name` and `code` instead.
11449 pub error_message: std::string::String,
11450
11451 /// May contain the value(s) of the field(s). This is not always available. You
11452 /// should absolutely not rely on it and use it only for manual model
11453 /// debugging.
11454 pub offending_values: std::string::String,
11455
11456 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11457}
11458
11459impl OptimizeToursValidationError {
11460 /// Creates a new default instance.
11461 pub fn new() -> Self {
11462 std::default::Default::default()
11463 }
11464
11465 /// Sets the value of [code][crate::model::OptimizeToursValidationError::code].
11466 ///
11467 /// # Example
11468 /// ```ignore,no_run
11469 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11470 /// let x = OptimizeToursValidationError::new().set_code(42);
11471 /// ```
11472 pub fn set_code<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
11473 self.code = v.into();
11474 self
11475 }
11476
11477 /// Sets the value of [display_name][crate::model::OptimizeToursValidationError::display_name].
11478 ///
11479 /// # Example
11480 /// ```ignore,no_run
11481 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11482 /// let x = OptimizeToursValidationError::new().set_display_name("example");
11483 /// ```
11484 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11485 self.display_name = v.into();
11486 self
11487 }
11488
11489 /// Sets the value of [fields][crate::model::OptimizeToursValidationError::fields].
11490 ///
11491 /// # Example
11492 /// ```ignore,no_run
11493 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11494 /// use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11495 /// let x = OptimizeToursValidationError::new()
11496 /// .set_fields([
11497 /// FieldReference::default()/* use setters */,
11498 /// FieldReference::default()/* use (different) setters */,
11499 /// ]);
11500 /// ```
11501 pub fn set_fields<T, V>(mut self, v: T) -> Self
11502 where
11503 T: std::iter::IntoIterator<Item = V>,
11504 V: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11505 {
11506 use std::iter::Iterator;
11507 self.fields = v.into_iter().map(|i| i.into()).collect();
11508 self
11509 }
11510
11511 /// Sets the value of [error_message][crate::model::OptimizeToursValidationError::error_message].
11512 ///
11513 /// # Example
11514 /// ```ignore,no_run
11515 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11516 /// let x = OptimizeToursValidationError::new().set_error_message("example");
11517 /// ```
11518 pub fn set_error_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11519 self.error_message = v.into();
11520 self
11521 }
11522
11523 /// Sets the value of [offending_values][crate::model::OptimizeToursValidationError::offending_values].
11524 ///
11525 /// # Example
11526 /// ```ignore,no_run
11527 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11528 /// let x = OptimizeToursValidationError::new().set_offending_values("example");
11529 /// ```
11530 pub fn set_offending_values<T: std::convert::Into<std::string::String>>(
11531 mut self,
11532 v: T,
11533 ) -> Self {
11534 self.offending_values = v.into();
11535 self
11536 }
11537}
11538
11539impl wkt::message::Message for OptimizeToursValidationError {
11540 fn typename() -> &'static str {
11541 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError"
11542 }
11543}
11544
11545/// Defines additional types related to [OptimizeToursValidationError].
11546pub mod optimize_tours_validation_error {
11547 #[allow(unused_imports)]
11548 use super::*;
11549
11550 /// Specifies a context for the validation error. A `FieldReference` always
11551 /// refers to a given field in this file and follows the same hierarchical
11552 /// structure. For example, we may specify element #2 of `start_time_windows`
11553 /// of vehicle #5 using:
11554 ///
11555 /// ```norust
11556 /// name: "vehicles" index: 5 sub_field { name: "end_time_windows" index: 2 }
11557 /// ```
11558 ///
11559 /// We however omit top-level entities such as `OptimizeToursRequest` or
11560 /// `ShipmentModel` to avoid crowding the message.
11561 #[derive(Clone, Default, PartialEq)]
11562 #[non_exhaustive]
11563 pub struct FieldReference {
11564 /// Name of the field, e.g., "vehicles".
11565 pub name: std::string::String,
11566
11567 /// Recursively nested sub-field, if needed.
11568 pub sub_field: std::option::Option<
11569 std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>,
11570 >,
11571
11572 #[allow(missing_docs)]
11573 pub index_or_key: std::option::Option<
11574 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
11575 >,
11576
11577 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11578 }
11579
11580 impl FieldReference {
11581 /// Creates a new default instance.
11582 pub fn new() -> Self {
11583 std::default::Default::default()
11584 }
11585
11586 /// Sets the value of [name][crate::model::optimize_tours_validation_error::FieldReference::name].
11587 ///
11588 /// # Example
11589 /// ```ignore,no_run
11590 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11591 /// let x = FieldReference::new().set_name("example");
11592 /// ```
11593 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11594 self.name = v.into();
11595 self
11596 }
11597
11598 /// Sets the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
11599 ///
11600 /// # Example
11601 /// ```ignore,no_run
11602 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11603 /// let x = FieldReference::new().set_sub_field(FieldReference::default()/* use setters */);
11604 /// ```
11605 pub fn set_sub_field<T>(mut self, v: T) -> Self
11606 where
11607 T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11608 {
11609 self.sub_field = std::option::Option::Some(std::boxed::Box::new(v.into()));
11610 self
11611 }
11612
11613 /// Sets or clears the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
11614 ///
11615 /// # Example
11616 /// ```ignore,no_run
11617 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11618 /// let x = FieldReference::new().set_or_clear_sub_field(Some(FieldReference::default()/* use setters */));
11619 /// let x = FieldReference::new().set_or_clear_sub_field(None::<FieldReference>);
11620 /// ```
11621 pub fn set_or_clear_sub_field<T>(mut self, v: std::option::Option<T>) -> Self
11622 where
11623 T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11624 {
11625 self.sub_field = v.map(|x| std::boxed::Box::new(x.into()));
11626 self
11627 }
11628
11629 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key].
11630 ///
11631 /// Note that all the setters affecting `index_or_key` are mutually
11632 /// exclusive.
11633 ///
11634 /// # Example
11635 /// ```ignore,no_run
11636 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11637 /// use google_cloud_optimization_v1::model::optimize_tours_validation_error::field_reference::IndexOrKey;
11638 /// let x = FieldReference::new().set_index_or_key(Some(IndexOrKey::Index(42)));
11639 /// ```
11640 pub fn set_index_or_key<
11641 T: std::convert::Into<
11642 std::option::Option<
11643 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
11644 >,
11645 >,
11646 >(
11647 mut self,
11648 v: T,
11649 ) -> Self {
11650 self.index_or_key = v.into();
11651 self
11652 }
11653
11654 /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11655 /// if it holds a `Index`, `None` if the field is not set or
11656 /// holds a different branch.
11657 pub fn index(&self) -> std::option::Option<&i32> {
11658 #[allow(unreachable_patterns)]
11659 self.index_or_key.as_ref().and_then(|v| match v {
11660 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(v) => std::option::Option::Some(v),
11661 _ => std::option::Option::None,
11662 })
11663 }
11664
11665 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11666 /// to hold a `Index`.
11667 ///
11668 /// Note that all the setters affecting `index_or_key` are
11669 /// mutually exclusive.
11670 ///
11671 /// # Example
11672 /// ```ignore,no_run
11673 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11674 /// let x = FieldReference::new().set_index(42);
11675 /// assert!(x.index().is_some());
11676 /// assert!(x.key().is_none());
11677 /// ```
11678 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
11679 self.index_or_key = std::option::Option::Some(
11680 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
11681 v.into(),
11682 ),
11683 );
11684 self
11685 }
11686
11687 /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11688 /// if it holds a `Key`, `None` if the field is not set or
11689 /// holds a different branch.
11690 pub fn key(&self) -> std::option::Option<&std::string::String> {
11691 #[allow(unreachable_patterns)]
11692 self.index_or_key.as_ref().and_then(|v| match v {
11693 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
11694 v,
11695 ) => std::option::Option::Some(v),
11696 _ => std::option::Option::None,
11697 })
11698 }
11699
11700 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11701 /// to hold a `Key`.
11702 ///
11703 /// Note that all the setters affecting `index_or_key` are
11704 /// mutually exclusive.
11705 ///
11706 /// # Example
11707 /// ```ignore,no_run
11708 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11709 /// let x = FieldReference::new().set_key("example");
11710 /// assert!(x.key().is_some());
11711 /// assert!(x.index().is_none());
11712 /// ```
11713 pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11714 self.index_or_key = std::option::Option::Some(
11715 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
11716 v.into(),
11717 ),
11718 );
11719 self
11720 }
11721 }
11722
11723 impl wkt::message::Message for FieldReference {
11724 fn typename() -> &'static str {
11725 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference"
11726 }
11727 }
11728
11729 /// Defines additional types related to [FieldReference].
11730 pub mod field_reference {
11731 #[allow(unused_imports)]
11732 use super::*;
11733
11734 #[allow(missing_docs)]
11735 #[derive(Clone, Debug, PartialEq)]
11736 #[non_exhaustive]
11737 pub enum IndexOrKey {
11738 /// Index of the field if repeated.
11739 Index(i32),
11740 /// Key if the field is a map.
11741 Key(std::string::String),
11742 }
11743 }
11744}
11745
11746/// Data formats for input and output files.
11747///
11748/// # Working with unknown values
11749///
11750/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
11751/// additional enum variants at any time. Adding new variants is not considered
11752/// a breaking change. Applications should write their code in anticipation of:
11753///
11754/// - New values appearing in future releases of the client library, **and**
11755/// - New values received dynamically, without application changes.
11756///
11757/// Please consult the [Working with enums] section in the user guide for some
11758/// guidelines.
11759///
11760/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
11761#[derive(Clone, Debug, PartialEq)]
11762#[non_exhaustive]
11763pub enum DataFormat {
11764 /// Default value.
11765 Unspecified,
11766 /// Input data in json format.
11767 Json,
11768 /// Input data in string format.
11769 String,
11770 /// If set, the enum was initialized with an unknown value.
11771 ///
11772 /// Applications can examine the value using [DataFormat::value] or
11773 /// [DataFormat::name].
11774 UnknownValue(data_format::UnknownValue),
11775}
11776
11777#[doc(hidden)]
11778pub mod data_format {
11779 #[allow(unused_imports)]
11780 use super::*;
11781 #[derive(Clone, Debug, PartialEq)]
11782 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11783}
11784
11785impl DataFormat {
11786 /// Gets the enum value.
11787 ///
11788 /// Returns `None` if the enum contains an unknown value deserialized from
11789 /// the string representation of enums.
11790 pub fn value(&self) -> std::option::Option<i32> {
11791 match self {
11792 Self::Unspecified => std::option::Option::Some(0),
11793 Self::Json => std::option::Option::Some(1),
11794 Self::String => std::option::Option::Some(2),
11795 Self::UnknownValue(u) => u.0.value(),
11796 }
11797 }
11798
11799 /// Gets the enum value as a string.
11800 ///
11801 /// Returns `None` if the enum contains an unknown value deserialized from
11802 /// the integer representation of enums.
11803 pub fn name(&self) -> std::option::Option<&str> {
11804 match self {
11805 Self::Unspecified => std::option::Option::Some("DATA_FORMAT_UNSPECIFIED"),
11806 Self::Json => std::option::Option::Some("JSON"),
11807 Self::String => std::option::Option::Some("STRING"),
11808 Self::UnknownValue(u) => u.0.name(),
11809 }
11810 }
11811}
11812
11813impl std::default::Default for DataFormat {
11814 fn default() -> Self {
11815 use std::convert::From;
11816 Self::from(0)
11817 }
11818}
11819
11820impl std::fmt::Display for DataFormat {
11821 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11822 wkt::internal::display_enum(f, self.name(), self.value())
11823 }
11824}
11825
11826impl std::convert::From<i32> for DataFormat {
11827 fn from(value: i32) -> Self {
11828 match value {
11829 0 => Self::Unspecified,
11830 1 => Self::Json,
11831 2 => Self::String,
11832 _ => Self::UnknownValue(data_format::UnknownValue(
11833 wkt::internal::UnknownEnumValue::Integer(value),
11834 )),
11835 }
11836 }
11837}
11838
11839impl std::convert::From<&str> for DataFormat {
11840 fn from(value: &str) -> Self {
11841 use std::string::ToString;
11842 match value {
11843 "DATA_FORMAT_UNSPECIFIED" => Self::Unspecified,
11844 "JSON" => Self::Json,
11845 "STRING" => Self::String,
11846 _ => Self::UnknownValue(data_format::UnknownValue(
11847 wkt::internal::UnknownEnumValue::String(value.to_string()),
11848 )),
11849 }
11850 }
11851}
11852
11853impl serde::ser::Serialize for DataFormat {
11854 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11855 where
11856 S: serde::Serializer,
11857 {
11858 match self {
11859 Self::Unspecified => serializer.serialize_i32(0),
11860 Self::Json => serializer.serialize_i32(1),
11861 Self::String => serializer.serialize_i32(2),
11862 Self::UnknownValue(u) => u.0.serialize(serializer),
11863 }
11864 }
11865}
11866
11867impl<'de> serde::de::Deserialize<'de> for DataFormat {
11868 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11869 where
11870 D: serde::Deserializer<'de>,
11871 {
11872 deserializer.deserialize_any(wkt::internal::EnumVisitor::<DataFormat>::new(
11873 ".google.cloud.optimization.v1.DataFormat",
11874 ))
11875 }
11876}