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