google-cloud-optimization-v1 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/google/cloud/optimization/v1/fleet_routing/client.rb +4 -4
- data/lib/google/cloud/optimization/v1/fleet_routing/operations.rb +12 -14
- data/lib/google/cloud/optimization/v1/fleet_routing/rest/client.rb +667 -0
- data/lib/google/cloud/optimization/v1/fleet_routing/rest/operations.rb +800 -0
- data/lib/google/cloud/optimization/v1/fleet_routing/rest/service_stub.rb +184 -0
- data/lib/google/cloud/optimization/v1/fleet_routing/rest.rb +68 -0
- data/lib/google/cloud/optimization/v1/fleet_routing.rb +6 -0
- data/lib/google/cloud/optimization/v1/rest.rb +37 -0
- data/lib/google/cloud/optimization/v1/version.rb +1 -1
- data/lib/google/cloud/optimization/v1.rb +5 -0
- metadata +13 -7
@@ -0,0 +1,667 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2023 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "google/cloud/errors"
|
20
|
+
require "google/cloud/optimization/v1/fleet_routing_pb"
|
21
|
+
require "google/cloud/optimization/v1/fleet_routing/rest/service_stub"
|
22
|
+
|
23
|
+
module Google
|
24
|
+
module Cloud
|
25
|
+
module Optimization
|
26
|
+
module V1
|
27
|
+
module FleetRouting
|
28
|
+
module Rest
|
29
|
+
##
|
30
|
+
# REST client for the FleetRouting service.
|
31
|
+
#
|
32
|
+
# A service for optimizing vehicle tours.
|
33
|
+
#
|
34
|
+
# Validity of certain types of fields:
|
35
|
+
#
|
36
|
+
# * `google.protobuf.Timestamp`
|
37
|
+
# * Times are in Unix time: seconds since 1970-01-01T00:00:00+00:00.
|
38
|
+
# * seconds must be in [0, 253402300799],
|
39
|
+
# i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00].
|
40
|
+
# * nanos must be unset or set to 0.
|
41
|
+
# * `google.protobuf.Duration`
|
42
|
+
# * seconds must be in [0, 253402300799],
|
43
|
+
# i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00].
|
44
|
+
# * nanos must be unset or set to 0.
|
45
|
+
# * `google.type.LatLng`
|
46
|
+
# * latitude must be in [-90.0, 90.0].
|
47
|
+
# * longitude must be in [-180.0, 180.0].
|
48
|
+
# * at least one of latitude and longitude must be non-zero.
|
49
|
+
#
|
50
|
+
class Client
|
51
|
+
# @private
|
52
|
+
attr_reader :fleet_routing_stub
|
53
|
+
|
54
|
+
##
|
55
|
+
# Configure the FleetRouting Client class.
|
56
|
+
#
|
57
|
+
# See {::Google::Cloud::Optimization::V1::FleetRouting::Rest::Client::Configuration}
|
58
|
+
# for a description of the configuration fields.
|
59
|
+
#
|
60
|
+
# @example
|
61
|
+
#
|
62
|
+
# # Modify the configuration for all FleetRouting clients
|
63
|
+
# ::Google::Cloud::Optimization::V1::FleetRouting::Rest::Client.configure do |config|
|
64
|
+
# config.timeout = 10.0
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# @yield [config] Configure the Client client.
|
68
|
+
# @yieldparam config [Client::Configuration]
|
69
|
+
#
|
70
|
+
# @return [Client::Configuration]
|
71
|
+
#
|
72
|
+
def self.configure
|
73
|
+
@configure ||= begin
|
74
|
+
namespace = ["Google", "Cloud", "Optimization", "V1"]
|
75
|
+
parent_config = while namespace.any?
|
76
|
+
parent_name = namespace.join "::"
|
77
|
+
parent_const = const_get parent_name
|
78
|
+
break parent_const.configure if parent_const.respond_to? :configure
|
79
|
+
namespace.pop
|
80
|
+
end
|
81
|
+
default_config = Client::Configuration.new parent_config
|
82
|
+
|
83
|
+
default_config.rpcs.optimize_tours.timeout = 3600.0
|
84
|
+
default_config.rpcs.optimize_tours.retry_policy = {
|
85
|
+
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
|
86
|
+
}
|
87
|
+
|
88
|
+
default_config.rpcs.batch_optimize_tours.timeout = 60.0
|
89
|
+
default_config.rpcs.batch_optimize_tours.retry_policy = {
|
90
|
+
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
|
91
|
+
}
|
92
|
+
|
93
|
+
default_config
|
94
|
+
end
|
95
|
+
yield @configure if block_given?
|
96
|
+
@configure
|
97
|
+
end
|
98
|
+
|
99
|
+
##
|
100
|
+
# Configure the FleetRouting Client instance.
|
101
|
+
#
|
102
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
103
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
104
|
+
# should be made on {Client.configure}.
|
105
|
+
#
|
106
|
+
# See {::Google::Cloud::Optimization::V1::FleetRouting::Rest::Client::Configuration}
|
107
|
+
# for a description of the configuration fields.
|
108
|
+
#
|
109
|
+
# @yield [config] Configure the Client client.
|
110
|
+
# @yieldparam config [Client::Configuration]
|
111
|
+
#
|
112
|
+
# @return [Client::Configuration]
|
113
|
+
#
|
114
|
+
def configure
|
115
|
+
yield @config if block_given?
|
116
|
+
@config
|
117
|
+
end
|
118
|
+
|
119
|
+
##
|
120
|
+
# Create a new FleetRouting REST client object.
|
121
|
+
#
|
122
|
+
# @example
|
123
|
+
#
|
124
|
+
# # Create a client using the default configuration
|
125
|
+
# client = ::Google::Cloud::Optimization::V1::FleetRouting::Rest::Client.new
|
126
|
+
#
|
127
|
+
# # Create a client using a custom configuration
|
128
|
+
# client = ::Google::Cloud::Optimization::V1::FleetRouting::Rest::Client.new do |config|
|
129
|
+
# config.timeout = 10.0
|
130
|
+
# end
|
131
|
+
#
|
132
|
+
# @yield [config] Configure the FleetRouting client.
|
133
|
+
# @yieldparam config [Client::Configuration]
|
134
|
+
#
|
135
|
+
def initialize
|
136
|
+
# Create the configuration object
|
137
|
+
@config = Configuration.new Client.configure
|
138
|
+
|
139
|
+
# Yield the configuration if needed
|
140
|
+
yield @config if block_given?
|
141
|
+
|
142
|
+
# Create credentials
|
143
|
+
credentials = @config.credentials
|
144
|
+
# Use self-signed JWT if the endpoint is unchanged from default,
|
145
|
+
# but only if the default endpoint does not have a region prefix.
|
146
|
+
enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
|
147
|
+
!@config.endpoint.split(".").first.include?("-")
|
148
|
+
credentials ||= Credentials.default scope: @config.scope,
|
149
|
+
enable_self_signed_jwt: enable_self_signed_jwt
|
150
|
+
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
|
151
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
152
|
+
end
|
153
|
+
|
154
|
+
@quota_project_id = @config.quota_project
|
155
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
156
|
+
|
157
|
+
@operations_client = ::Google::Cloud::Optimization::V1::FleetRouting::Rest::Operations.new do |config|
|
158
|
+
config.credentials = credentials
|
159
|
+
config.quota_project = @quota_project_id
|
160
|
+
config.endpoint = @config.endpoint
|
161
|
+
end
|
162
|
+
|
163
|
+
@fleet_routing_stub = ::Google::Cloud::Optimization::V1::FleetRouting::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
|
164
|
+
end
|
165
|
+
|
166
|
+
##
|
167
|
+
# Get the associated client for long-running operations.
|
168
|
+
#
|
169
|
+
# @return [::Google::Cloud::Optimization::V1::FleetRouting::Rest::Operations]
|
170
|
+
#
|
171
|
+
attr_reader :operations_client
|
172
|
+
|
173
|
+
# Service calls
|
174
|
+
|
175
|
+
##
|
176
|
+
# Sends an `OptimizeToursRequest` containing a `ShipmentModel` and returns an
|
177
|
+
# `OptimizeToursResponse` containing `ShipmentRoute`s, which are a set of
|
178
|
+
# routes to be performed by vehicles minimizing the overall cost.
|
179
|
+
#
|
180
|
+
# A `ShipmentModel` model consists mainly of `Shipment`s that need to be
|
181
|
+
# carried out and `Vehicle`s that can be used to transport the `Shipment`s.
|
182
|
+
# The `ShipmentRoute`s assign `Shipment`s to `Vehicle`s. More specifically,
|
183
|
+
# they assign a series of `Visit`s to each vehicle, where a `Visit`
|
184
|
+
# corresponds to a `VisitRequest`, which is a pickup or delivery for a
|
185
|
+
# `Shipment`.
|
186
|
+
#
|
187
|
+
# The goal is to provide an assignment of `ShipmentRoute`s to `Vehicle`s that
|
188
|
+
# minimizes the total cost where cost has many components defined in the
|
189
|
+
# `ShipmentModel`.
|
190
|
+
#
|
191
|
+
# @overload optimize_tours(request, options = nil)
|
192
|
+
# Pass arguments to `optimize_tours` via a request object, either of type
|
193
|
+
# {::Google::Cloud::Optimization::V1::OptimizeToursRequest} or an equivalent Hash.
|
194
|
+
#
|
195
|
+
# @param request [::Google::Cloud::Optimization::V1::OptimizeToursRequest, ::Hash]
|
196
|
+
# A request object representing the call parameters. Required. To specify no
|
197
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
198
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
199
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
200
|
+
#
|
201
|
+
# @overload optimize_tours(parent: nil, timeout: nil, model: nil, solving_mode: nil, max_validation_errors: nil, search_mode: nil, injected_first_solution_routes: nil, injected_solution_constraint: nil, refresh_details_routes: nil, interpret_injected_solutions_using_labels: nil, consider_road_traffic: nil, populate_polylines: nil, populate_transition_polylines: nil, allow_large_deadline_despite_interruption_risk: nil, use_geodesic_distances: nil, geodesic_meters_per_second: nil, label: nil, populate_travel_step_polylines: nil)
|
202
|
+
# Pass arguments to `optimize_tours` via keyword arguments. Note that at
|
203
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
204
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
205
|
+
#
|
206
|
+
# @param parent [::String]
|
207
|
+
# Required. Target project and location to make a call.
|
208
|
+
#
|
209
|
+
# Format: `projects/{project-id}/locations/{location-id}`.
|
210
|
+
#
|
211
|
+
# If no location is specified, a region will be chosen automatically.
|
212
|
+
# @param timeout [::Google::Protobuf::Duration, ::Hash]
|
213
|
+
# If this timeout is set, the server returns a response before the timeout
|
214
|
+
# period has elapsed or the server deadline for synchronous requests is
|
215
|
+
# reached, whichever is sooner.
|
216
|
+
#
|
217
|
+
# For asynchronous requests, the server will generate a solution (if
|
218
|
+
# possible) before the timeout has elapsed.
|
219
|
+
# @param model [::Google::Cloud::Optimization::V1::ShipmentModel, ::Hash]
|
220
|
+
# Shipment model to solve.
|
221
|
+
# @param solving_mode [::Google::Cloud::Optimization::V1::OptimizeToursRequest::SolvingMode]
|
222
|
+
# By default, the solving mode is `DEFAULT_SOLVE` (0).
|
223
|
+
# @param max_validation_errors [::Integer]
|
224
|
+
# Truncates the number of validation errors returned. These errors are
|
225
|
+
# typically attached to an INVALID_ARGUMENT error payload as a BadRequest
|
226
|
+
# error detail (https://cloud.google.com/apis/design/errors#error_details),
|
227
|
+
# unless solving_mode=VALIDATE_ONLY: see the
|
228
|
+
# {::Google::Cloud::Optimization::V1::OptimizeToursResponse#validation_errors OptimizeToursResponse.validation_errors}
|
229
|
+
# field.
|
230
|
+
# This defaults to 100 and is capped at 10,000.
|
231
|
+
# @param search_mode [::Google::Cloud::Optimization::V1::OptimizeToursRequest::SearchMode]
|
232
|
+
# Search mode used to solve the request.
|
233
|
+
# @param injected_first_solution_routes [::Array<::Google::Cloud::Optimization::V1::ShipmentRoute, ::Hash>]
|
234
|
+
# Guide the optimization algorithm in finding a first solution that is
|
235
|
+
# similar to a previous solution.
|
236
|
+
#
|
237
|
+
# The model is constrained when the first solution is built.
|
238
|
+
# Any shipments not performed on a route are implicitly skipped in the first
|
239
|
+
# solution, but they may be performed in successive solutions.
|
240
|
+
#
|
241
|
+
# The solution must satisfy some basic validity assumptions:
|
242
|
+
#
|
243
|
+
# * for all routes, `vehicle_index` must be in range and not be duplicated.
|
244
|
+
# * for all visits, `shipment_index` and `visit_request_index` must be
|
245
|
+
# in range.
|
246
|
+
# * a shipment may only be referenced on one route.
|
247
|
+
# * the pickup of a pickup-delivery shipment must be performed before
|
248
|
+
# the delivery.
|
249
|
+
# * no more than one pickup alternative or delivery alternative of
|
250
|
+
# a shipment may be performed.
|
251
|
+
# * for all routes, times are increasing (i.e., `vehicle_start_time
|
252
|
+
# <= visits[0].start_time <= visits[1].start_time ...
|
253
|
+
# <= vehicle_end_time`).
|
254
|
+
# * a shipment may only be performed on a vehicle that is allowed. A
|
255
|
+
# vehicle is allowed if
|
256
|
+
# {::Google::Cloud::Optimization::V1::Shipment#allowed_vehicle_indices Shipment.allowed_vehicle_indices}
|
257
|
+
# is empty or its `vehicle_index` is included in
|
258
|
+
# {::Google::Cloud::Optimization::V1::Shipment#allowed_vehicle_indices Shipment.allowed_vehicle_indices}.
|
259
|
+
#
|
260
|
+
# If the injected solution is not feasible, a validation error is not
|
261
|
+
# necessarily returned and an error indicating infeasibility may be returned
|
262
|
+
# instead.
|
263
|
+
# @param injected_solution_constraint [::Google::Cloud::Optimization::V1::InjectedSolutionConstraint, ::Hash]
|
264
|
+
# Constrain the optimization algorithm to find a final solution that is
|
265
|
+
# similar to a previous solution. For example, this may be used to freeze
|
266
|
+
# portions of routes which have already been completed or which are to be
|
267
|
+
# completed but must not be modified.
|
268
|
+
#
|
269
|
+
# If the injected solution is not feasible, a validation error is not
|
270
|
+
# necessarily returned and an error indicating infeasibility may be returned
|
271
|
+
# instead.
|
272
|
+
# @param refresh_details_routes [::Array<::Google::Cloud::Optimization::V1::ShipmentRoute, ::Hash>]
|
273
|
+
# If non-empty, the given routes will be refreshed, without modifying their
|
274
|
+
# underlying sequence of visits or travel times: only other details will be
|
275
|
+
# updated. This does not solve the model.
|
276
|
+
#
|
277
|
+
# As of 2020/11, this only populates the polylines of non-empty routes and
|
278
|
+
# requires that `populate_polylines` is true.
|
279
|
+
#
|
280
|
+
# The `route_polyline` fields of the passed-in routes may be inconsistent
|
281
|
+
# with route `transitions`.
|
282
|
+
#
|
283
|
+
# This field must not be used together with `injected_first_solution_routes`
|
284
|
+
# or `injected_solution_constraint`.
|
285
|
+
#
|
286
|
+
# `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
|
287
|
+
# Polylines are still populated between all visits in all non-empty routes
|
288
|
+
# regardless of whether the related shipments or vehicles are ignored.
|
289
|
+
# @param interpret_injected_solutions_using_labels [::Boolean]
|
290
|
+
# If true:
|
291
|
+
#
|
292
|
+
# * uses
|
293
|
+
# {::Google::Cloud::Optimization::V1::ShipmentRoute#vehicle_label ShipmentRoute.vehicle_label}
|
294
|
+
# instead of `vehicle_index` to
|
295
|
+
# match routes in an injected solution with vehicles in the request;
|
296
|
+
# reuses the mapping of original
|
297
|
+
# {::Google::Cloud::Optimization::V1::ShipmentRoute#vehicle_index ShipmentRoute.vehicle_index}
|
298
|
+
# to new
|
299
|
+
# {::Google::Cloud::Optimization::V1::ShipmentRoute#vehicle_index ShipmentRoute.vehicle_index}
|
300
|
+
# to update
|
301
|
+
# {::Google::Cloud::Optimization::V1::InjectedSolutionConstraint::ConstraintRelaxation#vehicle_indices ConstraintRelaxation.vehicle_indices}
|
302
|
+
# if non-empty, but the mapping must be unambiguous (i.e., multiple
|
303
|
+
# `ShipmentRoute`s must not share the same original `vehicle_index`).
|
304
|
+
# * uses
|
305
|
+
# {::Google::Cloud::Optimization::V1::ShipmentRoute::Visit#shipment_label ShipmentRoute.Visit.shipment_label}
|
306
|
+
# instead of `shipment_index`
|
307
|
+
# to match visits in an injected solution with shipments in the request;
|
308
|
+
# * uses
|
309
|
+
# {::Google::Cloud::Optimization::V1::SkippedShipment#label SkippedShipment.label}
|
310
|
+
# instead of
|
311
|
+
# {::Google::Cloud::Optimization::V1::SkippedShipment#index SkippedShipment.index}
|
312
|
+
# to
|
313
|
+
# match skipped shipments in the injected solution with request
|
314
|
+
# shipments.
|
315
|
+
#
|
316
|
+
# This interpretation applies to the `injected_first_solution_routes`,
|
317
|
+
# `injected_solution_constraint`, and `refresh_details_routes` fields.
|
318
|
+
# It can be used when shipment or vehicle indices in the request have
|
319
|
+
# changed since the solution was created, perhaps because shipments or
|
320
|
+
# vehicles have been removed from or added to the request.
|
321
|
+
#
|
322
|
+
# If true, labels in the following categories must appear at most once in
|
323
|
+
# their category:
|
324
|
+
#
|
325
|
+
# * {::Google::Cloud::Optimization::V1::Vehicle#label Vehicle.label} in the
|
326
|
+
# request;
|
327
|
+
# * {::Google::Cloud::Optimization::V1::Shipment#label Shipment.label} in the
|
328
|
+
# request;
|
329
|
+
# * {::Google::Cloud::Optimization::V1::ShipmentRoute#vehicle_label ShipmentRoute.vehicle_label} in the injected solution;
|
330
|
+
# * {::Google::Cloud::Optimization::V1::SkippedShipment#label SkippedShipment.label} and {::Google::Cloud::Optimization::V1::ShipmentRoute::Visit#shipment_label ShipmentRoute.Visit.shipment_label} in
|
331
|
+
# the injected solution (except pickup/delivery visit pairs, whose
|
332
|
+
# `shipment_label` must appear twice).
|
333
|
+
#
|
334
|
+
# If a `vehicle_label` in the injected solution does not correspond to a
|
335
|
+
# request vehicle, the corresponding route is removed from the solution
|
336
|
+
# along with its visits. If a `shipment_label` in the injected solution does
|
337
|
+
# not correspond to a request shipment, the corresponding visit is removed
|
338
|
+
# from the solution. If a
|
339
|
+
# {::Google::Cloud::Optimization::V1::SkippedShipment#label SkippedShipment.label}
|
340
|
+
# in the injected solution does not correspond to a request shipment, the
|
341
|
+
# `SkippedShipment` is removed from the solution.
|
342
|
+
#
|
343
|
+
# Removing route visits or entire routes from an injected solution may
|
344
|
+
# have an effect on the implied constraints, which may lead to change in
|
345
|
+
# solution, validation errors, or infeasibility.
|
346
|
+
#
|
347
|
+
# NOTE: The caller must ensure that each
|
348
|
+
# {::Google::Cloud::Optimization::V1::Vehicle#label Vehicle.label} (resp.
|
349
|
+
# {::Google::Cloud::Optimization::V1::Shipment#label Shipment.label}) uniquely
|
350
|
+
# identifies a vehicle (resp. shipment) entity used across the two relevant
|
351
|
+
# requests: the past request that produced the `OptimizeToursResponse` used
|
352
|
+
# in the injected solution and the current request that includes the injected
|
353
|
+
# solution. The uniqueness checks described above are not enough to guarantee
|
354
|
+
# this requirement.
|
355
|
+
# @param consider_road_traffic [::Boolean]
|
356
|
+
# Consider traffic estimation in calculating `ShipmentRoute` fields
|
357
|
+
# {::Google::Cloud::Optimization::V1::ShipmentRoute::Transition#travel_duration Transition.travel_duration},
|
358
|
+
# {::Google::Cloud::Optimization::V1::ShipmentRoute::Visit#start_time Visit.start_time},
|
359
|
+
# and `vehicle_end_time`; in setting the
|
360
|
+
# {::Google::Cloud::Optimization::V1::ShipmentRoute#has_traffic_infeasibilities ShipmentRoute.has_traffic_infeasibilities}
|
361
|
+
# field, and in calculating the
|
362
|
+
# {::Google::Cloud::Optimization::V1::OptimizeToursResponse#total_cost OptimizeToursResponse.total_cost}
|
363
|
+
# field.
|
364
|
+
# @param populate_polylines [::Boolean]
|
365
|
+
# If true, polylines will be populated in response `ShipmentRoute`s.
|
366
|
+
# @param populate_transition_polylines [::Boolean]
|
367
|
+
# If true, polylines will be populated in response
|
368
|
+
# {::Google::Cloud::Optimization::V1::ShipmentRoute#transitions ShipmentRoute.transitions}.
|
369
|
+
# Note that in this case, the polylines will also be populated in the
|
370
|
+
# deprecated `travel_steps`.
|
371
|
+
# @param allow_large_deadline_despite_interruption_risk [::Boolean]
|
372
|
+
# If this is set, then the request can have a deadline
|
373
|
+
# (see https://grpc.io/blog/deadlines) of up to 60 minutes.
|
374
|
+
# Otherwise, the maximum deadline is only 30 minutes.
|
375
|
+
# Note that long-lived requests have a significantly larger (but still small)
|
376
|
+
# risk of interruption.
|
377
|
+
# @param use_geodesic_distances [::Boolean]
|
378
|
+
# If true, travel distances will be computed using geodesic distances instead
|
379
|
+
# of Google Maps distances, and travel times will be computed using geodesic
|
380
|
+
# distances with a speed defined by `geodesic_meters_per_second`.
|
381
|
+
# @param geodesic_meters_per_second [::Float]
|
382
|
+
# When `use_geodesic_distances` is true, this field must be set and defines
|
383
|
+
# the speed applied to compute travel times. Its value must be at least 1.0
|
384
|
+
# meters/seconds.
|
385
|
+
# @param label [::String]
|
386
|
+
# Label that may be used to identify this request, reported back in the
|
387
|
+
# {::Google::Cloud::Optimization::V1::OptimizeToursResponse#request_label OptimizeToursResponse.request_label}.
|
388
|
+
# @param populate_travel_step_polylines [::Boolean]
|
389
|
+
# Deprecated: Use
|
390
|
+
# {::Google::Cloud::Optimization::V1::OptimizeToursRequest#populate_transition_polylines OptimizeToursRequest.populate_transition_polylines}
|
391
|
+
# instead. If true, polylines will be populated in response
|
392
|
+
# {::Google::Cloud::Optimization::V1::ShipmentRoute#transitions ShipmentRoute.transitions}.
|
393
|
+
# Note that in this case, the polylines will also be populated in the
|
394
|
+
# deprecated `travel_steps`.
|
395
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
396
|
+
# @yieldparam result [::Google::Cloud::Optimization::V1::OptimizeToursResponse]
|
397
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
398
|
+
#
|
399
|
+
# @return [::Google::Cloud::Optimization::V1::OptimizeToursResponse]
|
400
|
+
#
|
401
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
402
|
+
def optimize_tours request, options = nil
|
403
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
404
|
+
|
405
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Optimization::V1::OptimizeToursRequest
|
406
|
+
|
407
|
+
# Converts hash and nil to an options object
|
408
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
409
|
+
|
410
|
+
# Customize the options with defaults
|
411
|
+
call_metadata = @config.rpcs.optimize_tours.metadata.to_h
|
412
|
+
|
413
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
414
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
415
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
416
|
+
gapic_version: ::Google::Cloud::Optimization::V1::VERSION,
|
417
|
+
transports_version_send: [:rest]
|
418
|
+
|
419
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
420
|
+
|
421
|
+
options.apply_defaults timeout: @config.rpcs.optimize_tours.timeout,
|
422
|
+
metadata: call_metadata,
|
423
|
+
retry_policy: @config.rpcs.optimize_tours.retry_policy
|
424
|
+
|
425
|
+
options.apply_defaults timeout: @config.timeout,
|
426
|
+
metadata: @config.metadata,
|
427
|
+
retry_policy: @config.retry_policy
|
428
|
+
|
429
|
+
@fleet_routing_stub.optimize_tours request, options do |result, operation|
|
430
|
+
yield result, operation if block_given?
|
431
|
+
return result
|
432
|
+
end
|
433
|
+
rescue ::Gapic::Rest::Error => e
|
434
|
+
raise ::Google::Cloud::Error.from_error(e)
|
435
|
+
end
|
436
|
+
|
437
|
+
##
|
438
|
+
# Optimizes vehicle tours for one or more `OptimizeToursRequest`
|
439
|
+
# messages as a batch.
|
440
|
+
#
|
441
|
+
# This method is a Long Running Operation (LRO). The inputs for optimization
|
442
|
+
# (`OptimizeToursRequest` messages) and outputs (`OptimizeToursResponse`
|
443
|
+
# messages) are read/written from/to Cloud Storage in user-specified
|
444
|
+
# format. Like the `OptimizeTours` method, each `OptimizeToursRequest`
|
445
|
+
# contains a `ShipmentModel` and returns an `OptimizeToursResponse`
|
446
|
+
# containing `ShipmentRoute`s, which are a set of routes to be performed by
|
447
|
+
# vehicles minimizing the overall cost.
|
448
|
+
#
|
449
|
+
# @overload batch_optimize_tours(request, options = nil)
|
450
|
+
# Pass arguments to `batch_optimize_tours` via a request object, either of type
|
451
|
+
# {::Google::Cloud::Optimization::V1::BatchOptimizeToursRequest} or an equivalent Hash.
|
452
|
+
#
|
453
|
+
# @param request [::Google::Cloud::Optimization::V1::BatchOptimizeToursRequest, ::Hash]
|
454
|
+
# A request object representing the call parameters. Required. To specify no
|
455
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
456
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
457
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
458
|
+
#
|
459
|
+
# @overload batch_optimize_tours(parent: nil, model_configs: nil)
|
460
|
+
# Pass arguments to `batch_optimize_tours` via keyword arguments. Note that at
|
461
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
462
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
463
|
+
#
|
464
|
+
# @param parent [::String]
|
465
|
+
# Required. Target project and location to make a call.
|
466
|
+
#
|
467
|
+
# Format: `projects/{project-id}/locations/{location-id}`.
|
468
|
+
#
|
469
|
+
# If no location is specified, a region will be chosen automatically.
|
470
|
+
# @param model_configs [::Array<::Google::Cloud::Optimization::V1::BatchOptimizeToursRequest::AsyncModelConfig, ::Hash>]
|
471
|
+
# Required. Input/Output information each purchase model, such as file paths
|
472
|
+
# and data formats.
|
473
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
474
|
+
# @yieldparam result [::Gapic::Operation]
|
475
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
476
|
+
#
|
477
|
+
# @return [::Gapic::Operation]
|
478
|
+
#
|
479
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
480
|
+
def batch_optimize_tours request, options = nil
|
481
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
482
|
+
|
483
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Optimization::V1::BatchOptimizeToursRequest
|
484
|
+
|
485
|
+
# Converts hash and nil to an options object
|
486
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
487
|
+
|
488
|
+
# Customize the options with defaults
|
489
|
+
call_metadata = @config.rpcs.batch_optimize_tours.metadata.to_h
|
490
|
+
|
491
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
492
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
493
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
494
|
+
gapic_version: ::Google::Cloud::Optimization::V1::VERSION,
|
495
|
+
transports_version_send: [:rest]
|
496
|
+
|
497
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
498
|
+
|
499
|
+
options.apply_defaults timeout: @config.rpcs.batch_optimize_tours.timeout,
|
500
|
+
metadata: call_metadata,
|
501
|
+
retry_policy: @config.rpcs.batch_optimize_tours.retry_policy
|
502
|
+
|
503
|
+
options.apply_defaults timeout: @config.timeout,
|
504
|
+
metadata: @config.metadata,
|
505
|
+
retry_policy: @config.retry_policy
|
506
|
+
|
507
|
+
@fleet_routing_stub.batch_optimize_tours request, options do |result, operation|
|
508
|
+
result = ::Gapic::Operation.new result, @operations_client, options: options
|
509
|
+
yield result, operation if block_given?
|
510
|
+
return result
|
511
|
+
end
|
512
|
+
rescue ::Gapic::Rest::Error => e
|
513
|
+
raise ::Google::Cloud::Error.from_error(e)
|
514
|
+
end
|
515
|
+
|
516
|
+
##
|
517
|
+
# Configuration class for the FleetRouting REST API.
|
518
|
+
#
|
519
|
+
# This class represents the configuration for FleetRouting REST,
|
520
|
+
# providing control over timeouts, retry behavior, logging, transport
|
521
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
522
|
+
# applied individually to specific RPCs. See
|
523
|
+
# {::Google::Cloud::Optimization::V1::FleetRouting::Rest::Client::Configuration::Rpcs}
|
524
|
+
# for a list of RPCs that can be configured independently.
|
525
|
+
#
|
526
|
+
# Configuration can be applied globally to all clients, or to a single client
|
527
|
+
# on construction.
|
528
|
+
#
|
529
|
+
# @example
|
530
|
+
#
|
531
|
+
# # Modify the global config, setting the timeout for
|
532
|
+
# # optimize_tours to 20 seconds,
|
533
|
+
# # and all remaining timeouts to 10 seconds.
|
534
|
+
# ::Google::Cloud::Optimization::V1::FleetRouting::Rest::Client.configure do |config|
|
535
|
+
# config.timeout = 10.0
|
536
|
+
# config.rpcs.optimize_tours.timeout = 20.0
|
537
|
+
# end
|
538
|
+
#
|
539
|
+
# # Apply the above configuration only to a new client.
|
540
|
+
# client = ::Google::Cloud::Optimization::V1::FleetRouting::Rest::Client.new do |config|
|
541
|
+
# config.timeout = 10.0
|
542
|
+
# config.rpcs.optimize_tours.timeout = 20.0
|
543
|
+
# end
|
544
|
+
#
|
545
|
+
# @!attribute [rw] endpoint
|
546
|
+
# The hostname or hostname:port of the service endpoint.
|
547
|
+
# Defaults to `"cloudoptimization.googleapis.com"`.
|
548
|
+
# @return [::String]
|
549
|
+
# @!attribute [rw] credentials
|
550
|
+
# Credentials to send with calls. You may provide any of the following types:
|
551
|
+
# * (`String`) The path to a service account key file in JSON format
|
552
|
+
# * (`Hash`) A service account key as a Hash
|
553
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
554
|
+
# (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
|
555
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
556
|
+
# (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
|
557
|
+
# * (`nil`) indicating no credentials
|
558
|
+
# @return [::Object]
|
559
|
+
# @!attribute [rw] scope
|
560
|
+
# The OAuth scopes
|
561
|
+
# @return [::Array<::String>]
|
562
|
+
# @!attribute [rw] lib_name
|
563
|
+
# The library name as recorded in instrumentation and logging
|
564
|
+
# @return [::String]
|
565
|
+
# @!attribute [rw] lib_version
|
566
|
+
# The library version as recorded in instrumentation and logging
|
567
|
+
# @return [::String]
|
568
|
+
# @!attribute [rw] timeout
|
569
|
+
# The call timeout in seconds.
|
570
|
+
# @return [::Numeric]
|
571
|
+
# @!attribute [rw] metadata
|
572
|
+
# Additional headers to be sent with the call.
|
573
|
+
# @return [::Hash{::Symbol=>::String}]
|
574
|
+
# @!attribute [rw] retry_policy
|
575
|
+
# The retry policy. The value is a hash with the following keys:
|
576
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
577
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
578
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
579
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
580
|
+
# trigger a retry.
|
581
|
+
# @return [::Hash]
|
582
|
+
# @!attribute [rw] quota_project
|
583
|
+
# A separate project against which to charge quota.
|
584
|
+
# @return [::String]
|
585
|
+
#
|
586
|
+
class Configuration
|
587
|
+
extend ::Gapic::Config
|
588
|
+
|
589
|
+
config_attr :endpoint, "cloudoptimization.googleapis.com", ::String
|
590
|
+
config_attr :credentials, nil do |value|
|
591
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
592
|
+
allowed.any? { |klass| klass === value }
|
593
|
+
end
|
594
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
595
|
+
config_attr :lib_name, nil, ::String, nil
|
596
|
+
config_attr :lib_version, nil, ::String, nil
|
597
|
+
config_attr :timeout, nil, ::Numeric, nil
|
598
|
+
config_attr :metadata, nil, ::Hash, nil
|
599
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
600
|
+
config_attr :quota_project, nil, ::String, nil
|
601
|
+
|
602
|
+
# @private
|
603
|
+
def initialize parent_config = nil
|
604
|
+
@parent_config = parent_config unless parent_config.nil?
|
605
|
+
|
606
|
+
yield self if block_given?
|
607
|
+
end
|
608
|
+
|
609
|
+
##
|
610
|
+
# Configurations for individual RPCs
|
611
|
+
# @return [Rpcs]
|
612
|
+
#
|
613
|
+
def rpcs
|
614
|
+
@rpcs ||= begin
|
615
|
+
parent_rpcs = nil
|
616
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
|
617
|
+
Rpcs.new parent_rpcs
|
618
|
+
end
|
619
|
+
end
|
620
|
+
|
621
|
+
##
|
622
|
+
# Configuration RPC class for the FleetRouting API.
|
623
|
+
#
|
624
|
+
# Includes fields providing the configuration for each RPC in this service.
|
625
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
626
|
+
# the following configuration fields:
|
627
|
+
#
|
628
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in seconds
|
629
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
|
630
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
631
|
+
# include the following keys:
|
632
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
633
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
634
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
635
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
636
|
+
# trigger a retry.
|
637
|
+
#
|
638
|
+
class Rpcs
|
639
|
+
##
|
640
|
+
# RPC-specific configuration for `optimize_tours`
|
641
|
+
# @return [::Gapic::Config::Method]
|
642
|
+
#
|
643
|
+
attr_reader :optimize_tours
|
644
|
+
##
|
645
|
+
# RPC-specific configuration for `batch_optimize_tours`
|
646
|
+
# @return [::Gapic::Config::Method]
|
647
|
+
#
|
648
|
+
attr_reader :batch_optimize_tours
|
649
|
+
|
650
|
+
# @private
|
651
|
+
def initialize parent_rpcs = nil
|
652
|
+
optimize_tours_config = parent_rpcs.optimize_tours if parent_rpcs.respond_to? :optimize_tours
|
653
|
+
@optimize_tours = ::Gapic::Config::Method.new optimize_tours_config
|
654
|
+
batch_optimize_tours_config = parent_rpcs.batch_optimize_tours if parent_rpcs.respond_to? :batch_optimize_tours
|
655
|
+
@batch_optimize_tours = ::Gapic::Config::Method.new batch_optimize_tours_config
|
656
|
+
|
657
|
+
yield self if block_given?
|
658
|
+
end
|
659
|
+
end
|
660
|
+
end
|
661
|
+
end
|
662
|
+
end
|
663
|
+
end
|
664
|
+
end
|
665
|
+
end
|
666
|
+
end
|
667
|
+
end
|