Skip to content

Commit 68fd63c

Browse files
feat: [routeoptimization] add experimental Load Costs feature (#6819)
* feat: add experimental Load Costs feature feat: add experimental U-turn Avoidance feature feat: add OptimizeToursLongRunning method feat: add OptimizeToursUri method docs: A comment for field `duration_distance_matrices` in message `.google.maps.routeoptimization.v1.ShipmentModel` is changed docs: A comment for field `precedence_rules` in message `.google.maps.routeoptimization.v1.ShipmentModel` is changed docs: A comment for enum `TravelMode` is changed docs: A comment for field `place_id` in message `.google.maps.routeoptimization.v1.Waypoint` is changed PiperOrigin-RevId: 819788002 Source-Link: googleapis/googleapis@4c5d582 Source-Link: googleapis/googleapis-gen@f3bff08 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLW1hcHMtcm91dGVvcHRpbWl6YXRpb24vLk93bEJvdC55YW1sIiwiaCI6ImYzYmZmMDg4ZjM1OWVhZDRlNThhNzY1OTkyNzQyZmNhNGE1ZmVmZjkifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent d2f5ca8 commit 68fd63c

12 files changed

Lines changed: 8516 additions & 2791 deletions

packages/google-maps-routeoptimization/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ Samples are in the [`samples/`][homepage_samples] directory. Each sample's `READ
7979
| --------------------------- | --------------------------------- |
8080
| batch optimize tours | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-maps-routeoptimization/samples/generated/v1/route_optimization.batch_optimize_tours.js) |
8181
| optimize tours | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-maps-routeoptimization/samples/generated/v1/route_optimization.optimize_tours.js) |
82+
| optimize tours long running | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-maps-routeoptimization/samples/generated/v1/route_optimization.optimize_tours_long_running.js) |
83+
| optimize tours uri | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-maps-routeoptimization/samples/generated/v1/route_optimization.optimize_tours_uri.js) |
8284
| maps | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-maps-routeoptimization/samples/generated/v1/snippet_metadata_google.maps.routeoptimization.v1.json) |
8385

8486

packages/google-maps-routeoptimization/protos/google/maps/routeoptimization/v1/route_optimization_service.proto

Lines changed: 497 additions & 13 deletions
Large diffs are not rendered by default.

packages/google-maps-routeoptimization/protos/protos.d.ts

Lines changed: 983 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/google-maps-routeoptimization/protos/protos.js

Lines changed: 5338 additions & 2753 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/google-maps-routeoptimization/protos/protos.json

Lines changed: 405 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
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+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
18+
19+
20+
21+
'use strict';
22+
23+
function main(parent) {
24+
// [START routeoptimization_v1_generated_RouteOptimization_OptimizeToursLongRunning_async]
25+
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
29+
* TODO(developer): Uncomment these variables before running the sample.
30+
*/
31+
/**
32+
* Required. Target project or location to make a call.
33+
* Format:
34+
* * `projects/{project-id}`
35+
* * `projects/{project-id}/locations/{location-id}`
36+
* If no location is specified, a region will be chosen automatically.
37+
*/
38+
// const parent = 'abc123'
39+
/**
40+
* If this timeout is set, the server returns a response before the timeout
41+
* period has elapsed or the server deadline for synchronous requests is
42+
* reached, whichever is sooner.
43+
* For asynchronous requests, the server will generate a solution (if
44+
* possible) before the timeout has elapsed.
45+
*/
46+
// const timeout = {}
47+
/**
48+
* Shipment model to solve.
49+
*/
50+
// const model = {}
51+
/**
52+
* By default, the solving mode is `DEFAULT_SOLVE` (0).
53+
*/
54+
// const solvingMode = {}
55+
/**
56+
* Search mode used to solve the request.
57+
*/
58+
// const searchMode = {}
59+
/**
60+
* Guide the optimization algorithm in finding a first solution that is
61+
* similar to a previous solution.
62+
* The model is constrained when the first solution is built.
63+
* Any shipments not performed on a route are implicitly skipped in the first
64+
* solution, but they may be performed in successive solutions.
65+
* The solution must satisfy some basic validity assumptions:
66+
* * for all routes, `vehicle_index` must be in range and not be duplicated.
67+
* * for all visits, `shipment_index` and `visit_request_index` must be
68+
* in range.
69+
* * a shipment may only be referenced on one route.
70+
* * the pickup of a pickup-delivery shipment must be performed before
71+
* the delivery.
72+
* * no more than one pickup alternative or delivery alternative of
73+
* a shipment may be performed.
74+
* * for all routes, times are increasing (i.e., `vehicle_start_time
75+
* <= visits0.start_time <= visits1.start_time ...
76+
* <= vehicle_end_time`).
77+
* * a shipment may only be performed on a vehicle that is allowed. A
78+
* vehicle is allowed if
79+
* Shipment.allowed_vehicle_indices google.maps.routeoptimization.v1.Shipment.allowed_vehicle_indices
80+
* is empty or its `vehicle_index` is included in
81+
* Shipment.allowed_vehicle_indices google.maps.routeoptimization.v1.Shipment.allowed_vehicle_indices.
82+
* If the injected solution is not feasible, a validation error is not
83+
* necessarily returned and an error indicating infeasibility may be returned
84+
* instead.
85+
*/
86+
// const injectedFirstSolutionRoutes = [1,2,3,4]
87+
/**
88+
* Constrain the optimization algorithm to find a final solution that is
89+
* similar to a previous solution. For example, this may be used to freeze
90+
* portions of routes which have already been completed or which are to be
91+
* completed but must not be modified.
92+
* If the injected solution is not feasible, a validation error is not
93+
* necessarily returned and an error indicating infeasibility may be returned
94+
* instead.
95+
*/
96+
// const injectedSolutionConstraint = {}
97+
/**
98+
* If non-empty, the given routes will be refreshed, without modifying their
99+
* underlying sequence of visits or travel times: only other details will be
100+
* updated. This does not solve the model.
101+
* As of 2020/11, this only populates the polylines of non-empty routes and
102+
* requires that `populate_polylines` is true.
103+
* The `route_polyline` fields of the passed-in routes may be inconsistent
104+
* with route `transitions`.
105+
* This field must not be used together with `injected_first_solution_routes`
106+
* or `injected_solution_constraint`.
107+
* `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
108+
* Polylines are still populated between all visits in all non-empty routes
109+
* regardless of whether the related shipments or vehicles are ignored.
110+
*/
111+
// const refreshDetailsRoutes = [1,2,3,4]
112+
/**
113+
* If true:
114+
* * uses
115+
* ShipmentRoute.vehicle_label google.maps.routeoptimization.v1.ShipmentRoute.vehicle_label
116+
* instead of `vehicle_index` to
117+
* match routes in an injected solution with vehicles in the request;
118+
* reuses the mapping of original
119+
* ShipmentRoute.vehicle_index google.maps.routeoptimization.v1.ShipmentRoute.vehicle_index
120+
* to new
121+
* ShipmentRoute.vehicle_index google.maps.routeoptimization.v1.ShipmentRoute.vehicle_index
122+
* to update
123+
* ConstraintRelaxation.vehicle_indices google.maps.routeoptimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices
124+
* if non-empty, but the mapping must be unambiguous (i.e., multiple
125+
* `ShipmentRoute`s must not share the same original `vehicle_index`).
126+
* * uses
127+
* ShipmentRoute.Visit.shipment_label google.maps.routeoptimization.v1.ShipmentRoute.Visit.shipment_label
128+
* instead of `shipment_index`
129+
* to match visits in an injected solution with shipments in the request;
130+
* * uses
131+
* SkippedShipment.label google.maps.routeoptimization.v1.SkippedShipment.label
132+
* instead of
133+
* SkippedShipment.index google.maps.routeoptimization.v1.SkippedShipment.index
134+
* to
135+
* match skipped shipments in the injected solution with request
136+
* shipments.
137+
* This interpretation applies to the `injected_first_solution_routes`,
138+
* `injected_solution_constraint`, and `refresh_details_routes` fields.
139+
* It can be used when shipment or vehicle indices in the request have
140+
* changed since the solution was created, perhaps because shipments or
141+
* vehicles have been removed from or added to the request.
142+
* If true, labels in the following categories must appear at most once in
143+
* their category:
144+
* * Vehicle.label google.maps.routeoptimization.v1.Vehicle.label in the
145+
* request;
146+
* * Shipment.label google.maps.routeoptimization.v1.Shipment.label in
147+
* the request;
148+
* * ShipmentRoute.vehicle_label google.maps.routeoptimization.v1.ShipmentRoute.vehicle_label in the injected solution;
149+
* * SkippedShipment.label google.maps.routeoptimization.v1.SkippedShipment.label and ShipmentRoute.Visit.shipment_label google.maps.routeoptimization.v1.ShipmentRoute.Visit.shipment_label in
150+
* the injected solution (except pickup/delivery visit pairs, whose
151+
* `shipment_label` must appear twice).
152+
* If a `vehicle_label` in the injected solution does not correspond to a
153+
* request vehicle, the corresponding route is removed from the solution
154+
* along with its visits. If a `shipment_label` in the injected solution does
155+
* not correspond to a request shipment, the corresponding visit is removed
156+
* from the solution. If a
157+
* SkippedShipment.label google.maps.routeoptimization.v1.SkippedShipment.label
158+
* in the injected solution does not correspond to a request shipment, the
159+
* `SkippedShipment` is removed from the solution.
160+
* Removing route visits or entire routes from an injected solution may
161+
* have an effect on the implied constraints, which may lead to change in
162+
* solution, validation errors, or infeasibility.
163+
* NOTE: The caller must ensure that each
164+
* Vehicle.label google.maps.routeoptimization.v1.Vehicle.label (resp.
165+
* Shipment.label google.maps.routeoptimization.v1.Shipment.label) uniquely
166+
* identifies a vehicle (resp. shipment) entity used across the two relevant
167+
* requests: the past request that produced the `OptimizeToursResponse` used
168+
* in the injected solution and the current request that includes the injected
169+
* solution. The uniqueness checks described above are not enough to guarantee
170+
* this requirement.
171+
*/
172+
// const interpretInjectedSolutionsUsingLabels = true
173+
/**
174+
* Consider traffic estimation in calculating `ShipmentRoute` fields
175+
* Transition.travel_duration google.maps.routeoptimization.v1.ShipmentRoute.Transition.travel_duration,
176+
* Visit.start_time google.maps.routeoptimization.v1.ShipmentRoute.Visit.start_time,
177+
* and `vehicle_end_time`; in setting the
178+
* ShipmentRoute.has_traffic_infeasibilities google.maps.routeoptimization.v1.ShipmentRoute.has_traffic_infeasibilities
179+
* field, and in calculating the
180+
* OptimizeToursResponse.total_cost google.maps.routeoptimization.v1.OptimizeToursResponse.total_cost
181+
* field.
182+
*/
183+
// const considerRoadTraffic = true
184+
/**
185+
* If true, polylines will be populated in response `ShipmentRoute`s.
186+
*/
187+
// const populatePolylines = true
188+
/**
189+
* If true, polylines and route tokens will be populated in response
190+
* ShipmentRoute.transitions google.maps.routeoptimization.v1.ShipmentRoute.transitions.
191+
*/
192+
// const populateTransitionPolylines = true
193+
/**
194+
* If this is set, then the request can have a deadline
195+
* (see https://grpc.io/blog/deadlines) of up to 60 minutes.
196+
* Otherwise, the maximum deadline is only 30 minutes.
197+
* Note that long-lived requests have a significantly larger (but still small)
198+
* risk of interruption.
199+
*/
200+
// const allowLargeDeadlineDespiteInterruptionRisk = true
201+
/**
202+
* If true, travel distances will be computed using geodesic distances instead
203+
* of Google Maps distances, and travel times will be computed using geodesic
204+
* distances with a speed defined by `geodesic_meters_per_second`.
205+
*/
206+
// const useGeodesicDistances = true
207+
/**
208+
* When `use_geodesic_distances` is true, this field must be set and defines
209+
* the speed applied to compute travel times. Its value must be at least 1.0
210+
* meters/seconds.
211+
*/
212+
// const geodesicMetersPerSecond = 1234
213+
/**
214+
* Truncates the number of validation errors returned. These errors are
215+
* typically attached to an INVALID_ARGUMENT error payload as a BadRequest
216+
* error detail (https://cloud.google.com/apis/design/errors#error_details),
217+
* unless solving_mode=VALIDATE_ONLY: see the
218+
* OptimizeToursResponse.validation_errors google.maps.routeoptimization.v1.OptimizeToursResponse.validation_errors
219+
* field.
220+
* This defaults to 100 and is capped at 10,000.
221+
*/
222+
// const maxValidationErrors = 1234
223+
/**
224+
* Label that may be used to identify this request, reported back in the
225+
* OptimizeToursResponse.request_label google.maps.routeoptimization.v1.OptimizeToursResponse.request_label.
226+
*/
227+
// const label = 'abc123'
228+
229+
// Imports the Routeoptimization library
230+
const {RouteOptimizationClient} = require('@googlemaps/routeoptimization').v1;
231+
232+
// Instantiates a client
233+
const routeoptimizationClient = new RouteOptimizationClient();
234+
235+
async function callOptimizeToursLongRunning() {
236+
// Construct request
237+
const request = {
238+
parent,
239+
};
240+
241+
// Run request
242+
const [operation] = await routeoptimizationClient.optimizeToursLongRunning(request);
243+
const [response] = await operation.promise();
244+
console.log(response);
245+
}
246+
247+
callOptimizeToursLongRunning();
248+
// [END routeoptimization_v1_generated_RouteOptimization_OptimizeToursLongRunning_async]
249+
}
250+
251+
process.on('unhandledRejection', err => {
252+
console.error(err.message);
253+
process.exitCode = 1;
254+
});
255+
main(...process.argv.slice(2));
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
18+
19+
20+
21+
'use strict';
22+
23+
function main(parent, input, output) {
24+
// [START routeoptimization_v1_generated_RouteOptimization_OptimizeToursUri_async]
25+
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
29+
* TODO(developer): Uncomment these variables before running the sample.
30+
*/
31+
/**
32+
* Required. Target project or location to make a call.
33+
* Format:
34+
* * `projects/{project-id}`
35+
* * `projects/{project-id}/locations/{location-id}`
36+
* If no location is specified, a region will be chosen automatically.
37+
*/
38+
// const parent = 'abc123'
39+
/**
40+
* Required. The URI of the Cloud Storage object containing the
41+
* `OptimizeToursRequest`.
42+
*/
43+
// const input = {}
44+
/**
45+
* Required. The URI of the Cloud Storage object that will contain the
46+
* `OptimizeToursResponse`.
47+
*/
48+
// const output = {}
49+
50+
// Imports the Routeoptimization library
51+
const {RouteOptimizationClient} = require('@googlemaps/routeoptimization').v1;
52+
53+
// Instantiates a client
54+
const routeoptimizationClient = new RouteOptimizationClient();
55+
56+
async function callOptimizeToursUri() {
57+
// Construct request
58+
const request = {
59+
parent,
60+
input,
61+
output,
62+
};
63+
64+
// Run request
65+
const [operation] = await routeoptimizationClient.optimizeToursUri(request);
66+
const [response] = await operation.promise();
67+
console.log(response);
68+
}
69+
70+
callOptimizeToursUri();
71+
// [END routeoptimization_v1_generated_RouteOptimization_OptimizeToursUri_async]
72+
}
73+
74+
process.on('unhandledRejection', err => {
75+
console.error(err.message);
76+
process.exitCode = 1;
77+
});
78+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)