A service for optimizing vehicle tours.
Validity of certain types of fields:
* google.protobuf.Timestamp
* Times are in Unix time: seconds since 1970-01-01T00:00:00+00:00. * seconds must be in [0, 253402300799], i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. * nanos must be unset or set to 0. * google.protobuf.Duration
* seconds must be in [0, 253402300799], i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. * nanos must be unset or set to 0. * google.type.LatLng
* latitude must be in [-90.0, 90.0]. * longitude must be in [-180.0, 180.0]. * at least one of latitude and longitude must be non-zero.
v1
Package
@googlemaps/routeoptimizationConstructors
(constructor)(opts, gaxInstance)
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
Construct an instance of RouteOptimizationClient.
Parameters | |
---|---|
Name | Description |
opts |
ClientOptions
|
gaxInstance |
typeof gax | typeof fallback
: loaded instance of |
Properties
apiEndpoint
get apiEndpoint(): string;
The DNS address for this API service.
apiEndpoint
static get apiEndpoint(): string;
The DNS address for this API service - same as servicePath.
auth
auth: gax.GoogleAuth;
descriptors
descriptors: Descriptors;
innerApiCalls
innerApiCalls: {
[name: string]: Function;
};
operationsClient
operationsClient: gax.OperationsClient;
port
static get port(): number;
The port for this API service.
routeOptimizationStub
routeOptimizationStub?: Promise<{
[name: string]: Function;
}>;
scopes
static get scopes(): string[];
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
static get servicePath(): string;
The DNS address for this API service.
universeDomain
get universeDomain(): string;
warn
warn: (code: string, message: string, warnType?: string) => void;
Methods
batchOptimizeTours(request, options)
batchOptimizeTours(request?: protos.google.maps.routeoptimization.v1.IBatchOptimizeToursRequest, options?: CallOptions): Promise<[
LROperation<protos.google.maps.routeoptimization.v1.IBatchOptimizeToursResponse, protos.google.maps.routeoptimization.v1.IBatchOptimizeToursMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
Optimizes vehicle tours for one or more OptimizeToursRequest
messages as a batch.
This method is a Long Running Operation (LRO). The inputs for optimization (OptimizeToursRequest
messages) and outputs (OptimizeToursResponse
messages) are read from and written to Cloud Storage in user-specified format. Like the OptimizeTours
method, each OptimizeToursRequest
contains a ShipmentModel
and returns an OptimizeToursResponse
containing ShipmentRoute
fields, which are a set of routes to be performed by vehicles minimizing the overall cost.
The user can poll operations.get
to check the status of the LRO:
If the LRO done
field is false, then at least one request is still being processed. Other requests may have completed successfully and their results are available in Cloud Storage.
If the LRO's done
field is true, then all requests have been processed. Any successfully processed requests will have their results available in Cloud Storage. Any requests that failed will not have their results available in Cloud Storage. If the LRO's error
field is set, then it contains the error from one of the failed requests.
Parameters | |
---|---|
Name | Description |
request |
IBatchOptimizeToursRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
LROperation<protos.google.maps.routeoptimization.v1.IBatchOptimizeToursResponse, protos.google.maps.routeoptimization.v1.IBatchOptimizeToursMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]> |
{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Target project and location to make a call.
* Format:
* * `projects/{project-id}`
* * `projects/{project-id}/locations/{location-id}`
* If no location is specified, a region will be chosen automatically.
*/
// const parent = 'abc123'
/**
* Required. Input/Output information each purchase model, such as file paths
* and data formats.
*/
// const modelConfigs = [1,2,3,4]
// Imports the Routeoptimization library
const {RouteOptimizationClient} = require('@googlemaps/routeoptimization').v1;
// Instantiates a client
const routeoptimizationClient = new RouteOptimizationClient();
async function callBatchOptimizeTours() {
// Construct request
const request = {
parent,
modelConfigs,
};
// Run request
const [operation] = await routeoptimizationClient.batchOptimizeTours(request);
const [response] = await operation.promise();
console.log(response);
}
callBatchOptimizeTours();
batchOptimizeTours(request, options, callback)
batchOptimizeTours(request: protos.google.maps.routeoptimization.v1.IBatchOptimizeToursRequest, options: CallOptions, callback: Callback<LROperation<protos.google.maps.routeoptimization.v1.IBatchOptimizeToursResponse, protos.google.maps.routeoptimization.v1.IBatchOptimizeToursMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IBatchOptimizeToursRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.maps.routeoptimization.v1.IBatchOptimizeToursResponse, protos.google.maps.routeoptimization.v1.IBatchOptimizeToursMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
batchOptimizeTours(request, callback)
batchOptimizeTours(request: protos.google.maps.routeoptimization.v1.IBatchOptimizeToursRequest, callback: Callback<LROperation<protos.google.maps.routeoptimization.v1.IBatchOptimizeToursResponse, protos.google.maps.routeoptimization.v1.IBatchOptimizeToursMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IBatchOptimizeToursRequest
|
callback |
Callback<LROperation<protos.google.maps.routeoptimization.v1.IBatchOptimizeToursResponse, protos.google.maps.routeoptimization.v1.IBatchOptimizeToursMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
cancelOperation(request, options, callback)
cancelOperation(request: protos.google.longrunning.CancelOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>, callback?: Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>): Promise<protos.google.protobuf.Empty>;
Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED
. Clients can use or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an value with a of 1, corresponding to Code.CANCELLED
.
Parameters | |
---|---|
Name | Description |
request |
CancelOperationRequest
The request object that will be sent. |
options |
CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
callback |
Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>
The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call. |
Returns | |
---|---|
Type | Description |
Promise<protos.google.protobuf.Empty> |
const client = longrunning.operationsClient();
await client.cancelOperation({name: ''});
checkBatchOptimizeToursProgress(name)
checkBatchOptimizeToursProgress(name: string): Promise<LROperation<protos.google.maps.routeoptimization.v1.BatchOptimizeToursResponse, protos.google.maps.routeoptimization.v1.BatchOptimizeToursMetadata>>;
Check the status of the long running operation returned by batchOptimizeTours()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.maps.routeoptimization.v1.BatchOptimizeToursResponse, protos.google.maps.routeoptimization.v1.BatchOptimizeToursMetadata>> |
{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Target project and location to make a call.
* Format:
* * `projects/{project-id}`
* * `projects/{project-id}/locations/{location-id}`
* If no location is specified, a region will be chosen automatically.
*/
// const parent = 'abc123'
/**
* Required. Input/Output information each purchase model, such as file paths
* and data formats.
*/
// const modelConfigs = [1,2,3,4]
// Imports the Routeoptimization library
const {RouteOptimizationClient} = require('@googlemaps/routeoptimization').v1;
// Instantiates a client
const routeoptimizationClient = new RouteOptimizationClient();
async function callBatchOptimizeTours() {
// Construct request
const request = {
parent,
modelConfigs,
};
// Run request
const [operation] = await routeoptimizationClient.batchOptimizeTours(request);
const [response] = await operation.promise();
console.log(response);
}
callBatchOptimizeTours();
close()
close(): Promise<void>;
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Returns | |
---|---|
Type | Description |
Promise<void> |
{Promise} A promise that resolves when the client is closed. |
deleteOperation(request, options, callback)
deleteOperation(request: protos.google.longrunning.DeleteOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>): Promise<protos.google.protobuf.Empty>;
Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED
.
Parameters | |
---|---|
Name | Description |
request |
DeleteOperationRequest
The request object that will be sent. |
options |
CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
callback |
Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>
The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call. |
Returns | |
---|---|
Type | Description |
Promise<protos.google.protobuf.Empty> |
const client = longrunning.operationsClient();
await client.deleteOperation({name: ''});
getOperation(request, options, callback)
getOperation(request: protos.google.longrunning.GetOperationRequest, options?: gax.CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>): Promise<[protos.google.longrunning.Operation]>;
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
Parameters | |
---|---|
Name | Description |
request |
GetOperationRequest
The request object that will be sent. |
options |
CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
callback |
Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>
The function which will be called with the result of the API call. The second parameter to the callback is an object representing . {Promise} - The promise which resolves to an array. The first element of the array is an object representing . The promise has a method named "cancel" which cancels the ongoing API call. |
Returns | |
---|---|
Type | Description |
Promise<[protos.google.longrunning.Operation]> |
const client = longrunning.operationsClient();
const name = '';
const [response] = await client.getOperation({name});
// doThingsWith(response)
getProjectId()
getProjectId(): Promise<string>;
Returns | |
---|---|
Type | Description |
Promise<string> |
getProjectId(callback)
getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter | |
---|---|
Name | Description |
callback |
Callback<string, undefined, undefined>
|
Returns | |
---|---|
Type | Description |
void |
initialize()
initialize(): Promise<{
[name: string]: Function;
}>;
Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.
You can await on this method if you want to make sure the client is initialized.
Returns | |
---|---|
Type | Description |
Promise<{
[name: string]: Function;
}> |
{Promise} A promise that resolves to an authenticated service stub. |
listOperationsAsync(request, options)
listOperationsAsync(request: protos.google.longrunning.ListOperationsRequest, options?: gax.CallOptions): AsyncIterable<protos.google.longrunning.ListOperationsResponse>;
Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED
. Returns an iterable object.
For-await-of syntax is used with the iterable to recursively get response element on-demand.
Parameters | |
---|---|
Name | Description |
request |
ListOperationsRequest
The request object that will be sent. |
options |
CallOptions
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
Returns | |
---|---|
Type | Description |
AsyncIterable<protos.google.longrunning.ListOperationsResponse> |
{Object} An iterable Object that conforms to iteration protocols. |
const client = longrunning.operationsClient();
for await (const response of client.listOperationsAsync(request));
// doThingsWith(response)
optimizeTours(request, options)
optimizeTours(request?: protos.google.maps.routeoptimization.v1.IOptimizeToursRequest, options?: CallOptions): Promise<[
protos.google.maps.routeoptimization.v1.IOptimizeToursResponse,
protos.google.maps.routeoptimization.v1.IOptimizeToursRequest | undefined,
{} | undefined
]>;
Sends an OptimizeToursRequest
containing a ShipmentModel
and returns an OptimizeToursResponse
containing ShipmentRoute
s, which are a set of routes to be performed by vehicles minimizing the overall cost.
A ShipmentModel
model consists mainly of Shipment
s that need to be carried out and Vehicle
s that can be used to transport the Shipment
s. The ShipmentRoute
s assign Shipment
s to Vehicle
s. More specifically, they assign a series of Visit
s to each vehicle, where a Visit
corresponds to a VisitRequest
, which is a pickup or delivery for a Shipment
.
The goal is to provide an assignment of ShipmentRoute
s to Vehicle
s that minimizes the total cost where cost has many components defined in the ShipmentModel
.
Parameters | |
---|---|
Name | Description |
request |
IOptimizeToursRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.maps.routeoptimization.v1.IOptimizeToursResponse,
protos.google.maps.routeoptimization.v1.IOptimizeToursRequest | undefined,
{} | undefined
]> |
{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Target project or location to make a call.
* Format:
* * `projects/{project-id}`
* * `projects/{project-id}/locations/{location-id}`
* If no location is specified, a region will be chosen automatically.
*/
// const parent = 'abc123'
/**
* If this timeout is set, the server returns a response before the timeout
* period has elapsed or the server deadline for synchronous requests is
* reached, whichever is sooner.
* For asynchronous requests, the server will generate a solution (if
* possible) before the timeout has elapsed.
*/
// const timeout = {}
/**
* Shipment model to solve.
*/
// const model = {}
/**
* By default, the solving mode is `DEFAULT_SOLVE` (0).
*/
// const solvingMode = {}
/**
* Search mode used to solve the request.
*/
// const searchMode = {}
/**
* Guide the optimization algorithm in finding a first solution that is
* similar to a previous solution.
* The model is constrained when the first solution is built.
* Any shipments not performed on a route are implicitly skipped in the first
* solution, but they may be performed in successive solutions.
* The solution must satisfy some basic validity assumptions:
* * for all routes, `vehicle_index` must be in range and not be duplicated.
* * for all visits, `shipment_index` and `visit_request_index` must be
* in range.
* * a shipment may only be referenced on one route.
* * the pickup of a pickup-delivery shipment must be performed before
* the delivery.
* * no more than one pickup alternative or delivery alternative of
* a shipment may be performed.
* * for all routes, times are increasing (i.e., `vehicle_start_time
* <= visits0.start_time=""><= visits1.start_time="" ...="" *=""><= vehicle_end_time`).="" *="" *="" a="" shipment="" may="" only="" be="" performed="" on="" a="" vehicle="" that="" is="" allowed.="" a="" *="" vehicle="" is="" allowed="" if="" *="" shipment.allowed_vehicle_indices="" google.maps.routeoptimization.v1.shipment.allowed_vehicle_indices="" *="" is="" empty="" or="" its="" `vehicle_index`="" is="" included="" in="" *="" shipment.allowed_vehicle_indices="" google.maps.routeoptimization.v1.shipment.allowed_vehicle_indices.="" *="" if="" the="" injected="" solution="" is="" not="" feasible,="" a="" validation="" error="" is="" not="" *="" necessarily="" returned="" and="" an="" error="" indicating="" infeasibility="" may="" be="" returned="" *="" instead.="" */="" const="" injectedfirstsolutionroutes="[1,2,3,4]" *="" *="" constrain="" the="" optimization="" algorithm="" to="" find="" a="" final="" solution="" that="" is="" *="" similar="" to="" a="" previous="" solution.="" for="" example,="" this="" may="" be="" used="" to="" freeze="" *="" portions="" of="" routes="" which="" have="" already="" been="" completed="" or="" which="" are="" to="" be="" *="" completed="" but="" must="" not="" be="" modified.="" *="" if="" the="" injected="" solution="" is="" not="" feasible,="" a="" validation="" error="" is="" not="" *="" necessarily="" returned="" and="" an="" error="" indicating="" infeasibility="" may="" be="" returned="" *="" instead.="" */="" const="" injectedsolutionconstraint="{}" *="" *="" if="" non-empty,="" the="" given="" routes="" will="" be="" refreshed,="" without="" modifying="" their="" *="" underlying="" sequence="" of="" visits="" or="" travel="" times:="" only="" other="" details="" will="" be="" *="" updated.="" this="" does="" not="" solve="" the="" model.="" *="" as="" of="" 2020/11,="" this="" only="" populates="" the="" polylines="" of="" non-empty="" routes="" and="" *="" requires="" that="" `populate_polylines`="" is="" true.="" *="" the="" `route_polyline`="" fields="" of="" the="" passed-in="" routes="" may="" be="" inconsistent="" *="" with="" route="" `transitions`.="" *="" this="" field="" must="" not="" be="" used="" together="" with="" `injected_first_solution_routes`="" *="" or="" `injected_solution_constraint`.="" *="" `shipment.ignore`="" and="" `vehicle.ignore`="" have="" no="" effect="" on="" the="" behavior.="" *="" polylines="" are="" still="" populated="" between="" all="" visits="" in="" all="" non-empty="" routes="" *="" regardless="" of="" whether="" the="" related="" shipments="" or="" vehicles="" are="" ignored.="" */="" const="" refreshdetailsroutes="[1,2,3,4]" *="" *="" if="" true:="" *="" *="" uses="" *="" shipmentroute.vehicle_label="" google.maps.routeoptimization.v1.shipmentroute.vehicle_label="" *="" instead="" of="" `vehicle_index`="" to="" *="" match="" routes="" in="" an="" injected="" solution="" with="" vehicles="" in="" the="" request;="" *="" reuses="" the="" mapping="" of="" original="" *="" shipmentroute.vehicle_index="" google.maps.routeoptimization.v1.shipmentroute.vehicle_index="" *="" to="" new="" *="" shipmentroute.vehicle_index="" google.maps.routeoptimization.v1.shipmentroute.vehicle_index="" *="" to="" update="" *="" constraintrelaxation.vehicle_indices="" google.maps.routeoptimization.v1.injectedsolutionconstraint.constraintrelaxation.vehicle_indices="" *="" if="" non-empty,="" but="" the="" mapping="" must="" be="" unambiguous="" (i.e.,="" multiple="" *="" `shipmentroute`s="" must="" not="" share="" the="" same="" original="" `vehicle_index`).="" *="" *="" uses="" *="" shipmentroute.visit.shipment_label="" google.maps.routeoptimization.v1.shipmentroute.visit.shipment_label="" *="" instead="" of="" `shipment_index`="" *="" to="" match="" visits="" in="" an="" injected="" solution="" with="" shipments="" in="" the="" request;="" *="" *="" uses="" *="" skippedshipment.label="" google.maps.routeoptimization.v1.skippedshipment.label="" *="" instead="" of="" *="" skippedshipment.index="" google.maps.routeoptimization.v1.skippedshipment.index="" *="" to="" *="" match="" skipped="" shipments="" in="" the="" injected="" solution="" with="" request="" *="" shipments.="" *="" this="" interpretation="" applies="" to="" the="" `injected_first_solution_routes`,="" *="" `injected_solution_constraint`,="" and="" `refresh_details_routes`="" fields.="" *="" it="" can="" be="" used="" when="" shipment="" or="" vehicle="" indices="" in="" the="" request="" have="" *="" changed="" since="" the="" solution="" was="" created,="" perhaps="" because="" shipments="" or="" *="" vehicles="" have="" been="" removed="" from="" or="" added="" to="" the="" request.="" *="" if="" true,="" labels="" in="" the="" following="" categories="" must="" appear="" at="" most="" once="" in="" *="" their="" category:="" *="" *="" vehicle.label="" google.maps.routeoptimization.v1.vehicle.label="" in="" the="" *="" request;="" *="" *="" shipment.label="" google.maps.routeoptimization.v1.shipment.label="" in="" *="" the="" request;="" *="" *="" shipmentroute.vehicle_label="" google.maps.routeoptimization.v1.shipmentroute.vehicle_label="" in="" the="" injected="" solution;="" *="" *="" skippedshipment.label="" google.maps.routeoptimization.v1.skippedshipment.label="" and="" shipmentroute.visit.shipment_label="" google.maps.routeoptimization.v1.shipmentroute.visit.shipment_label="" in="" *="" the="" injected="" solution="" (except="" pickup/delivery="" visit="" pairs,="" whose="" *="" `shipment_label`="" must="" appear="" twice).="" *="" if="" a="" `vehicle_label`="" in="" the="" injected="" solution="" does="" not="" correspond="" to="" a="" *="" request="" vehicle,="" the="" corresponding="" route="" is="" removed="" from="" the="" solution="" *="" along="" with="" its="" visits.="" if="" a="" `shipment_label`="" in="" the="" injected="" solution="" does="" *="" not="" correspond="" to="" a="" request="" shipment,="" the="" corresponding="" visit="" is="" removed="" *="" from="" the="" solution.="" if="" a="" *="" skippedshipment.label="" google.maps.routeoptimization.v1.skippedshipment.label="" *="" in="" the="" injected="" solution="" does="" not="" correspond="" to="" a="" request="" shipment,="" the="" *="" `skippedshipment`="" is="" removed="" from="" the="" solution.="" *="" removing="" route="" visits="" or="" entire="" routes="" from="" an="" injected="" solution="" may="" *="" have="" an="" effect="" on="" the="" implied="" constraints,="" which="" may="" lead="" to="" change="" in="" *="" solution,="" validation="" errors,="" or="" infeasibility.="" *="" note:="" the="" caller="" must="" ensure="" that="" each="" *="" vehicle.label="" google.maps.routeoptimization.v1.vehicle.label="" (resp.="" *="" shipment.label="" google.maps.routeoptimization.v1.shipment.label)="" uniquely="" *="" identifies="" a="" vehicle="" (resp.="" shipment)="" entity="" used="" across="" the="" two="" relevant="" *="" requests:="" the="" past="" request="" that="" produced="" the="" `optimizetoursresponse`="" used="" *="" in="" the="" injected="" solution="" and="" the="" current="" request="" that="" includes="" the="" injected="" *="" solution.="" the="" uniqueness="" checks="" described="" above="" are="" not="" enough="" to="" guarantee="" *="" this="" requirement.="" */="" const="" interpretinjectedsolutionsusinglabels="true" *="" *="" consider="" traffic="" estimation="" in="" calculating="" `shipmentroute`="" fields="" *="" transition.travel_duration="" google.maps.routeoptimization.v1.shipmentroute.transition.travel_duration,="" *="" visit.start_time="" google.maps.routeoptimization.v1.shipmentroute.visit.start_time,="" *="" and="" `vehicle_end_time`;="" in="" setting="" the="" *="" shipmentroute.has_traffic_infeasibilities="" google.maps.routeoptimization.v1.shipmentroute.has_traffic_infeasibilities="" *="" field,="" and="" in="" calculating="" the="" *="" optimizetoursresponse.total_cost="" google.maps.routeoptimization.v1.optimizetoursresponse.total_cost="" *="" field.="" */="" const="" considerroadtraffic="true" *="" *="" if="" true,="" polylines="" will="" be="" populated="" in="" response="" `shipmentroute`s.="" */="" const="" populatepolylines="true" *="" *="" if="" true,="" polylines="" and="" route="" tokens="" will="" be="" populated="" in="" response="" *="" shipmentroute.transitions="" google.maps.routeoptimization.v1.shipmentroute.transitions.="" */="" const="" populatetransitionpolylines="true" *="" *="" if="" this="" is="" set,="" then="" the="" request="" can="" have="" a="" deadline="" *="" (see="" https://grpc.io/blog/deadlines)="" of="" up="" to="" 60="" minutes.="" *="" otherwise,="" the="" maximum="" deadline="" is="" only="" 30="" minutes.="" *="" note="" that="" long-lived="" requests="" have="" a="" significantly="" larger="" (but="" still="" small)="" *="" risk="" of="" interruption.="" */="" const="" allowlargedeadlinedespiteinterruptionrisk="true" *="" *="" if="" true,="" travel="" distances="" will="" be="" computed="" using="" geodesic="" distances="" instead="" *="" of="" google="" maps="" distances,="" and="" travel="" times="" will="" be="" computed="" using="" geodesic="" *="" distances="" with="" a="" speed="" defined="" by="" `geodesic_meters_per_second`.="" */="" const="" usegeodesicdistances="true" *="" *="" when="" `use_geodesic_distances`="" is="" true,="" this="" field="" must="" be="" set="" and="" defines="" *="" the="" speed="" applied="" to="" compute="" travel="" times.="" its="" value="" must="" be="" at="" least="" 1.0="" *="" meters/seconds.="" */="" const="" geodesicmeterspersecond="1234" *="" *="" truncates="" the="" number="" of="" validation="" errors="" returned.="" these="" errors="" are="" *="" typically="" attached="" to="" an="" invalid_argument="" error="" payload="" as="" a="" badrequest="" *="" error="" detail="" (https://cloud.google.com/apis/design/errors#error_details),="" *="" unless="" solving_mode="VALIDATE_ONLY:" see="" the="" *="" optimizetoursresponse.validation_errors="" google.maps.routeoptimization.v1.optimizetoursresponse.validation_errors="" *="" field.="" *="" this="" defaults="" to="" 100="" and="" is="" capped="" at="" 10,000.="" */="" const="" maxvalidationerrors="1234" *="" *="" label="" that="" may="" be="" used="" to="" identify="" this="" request,="" reported="" back="" in="" the="" *="" optimizetoursresponse.request_label="" google.maps.routeoptimization.v1.optimizetoursresponse.request_label.="" */="" const="" label='abc123' imports="" the="" routeoptimization="" library="" const="" {routeoptimizationclient}="require('@googlemaps/routeoptimization').v1;" instantiates="" a="" client="" const="" routeoptimizationclient="new" routeoptimizationclient();="" async="" function="" calloptimizetours()="" {="" construct="" request="" const="" request="{" parent,="" };="" run="" request="" const="" response="await" routeoptimizationclient.optimizetours(request);="" console.log(response);="" }="" calloptimizetours();="">
optimizeTours(request, options, callback)
optimizeTours(request: protos.google.maps.routeoptimization.v1.IOptimizeToursRequest, options: CallOptions, callback: Callback<protos.google.maps.routeoptimization.v1.IOptimizeToursResponse, protos.google.maps.routeoptimization.v1.IOptimizeToursRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IOptimizeToursRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.maps.routeoptimization.v1.IOptimizeToursResponse, protos.google.maps.routeoptimization.v1.IOptimizeToursRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
optimizeTours(request, callback)
optimizeTours(request: protos.google.maps.routeoptimization.v1.IOptimizeToursRequest, callback: Callback<protos.google.maps.routeoptimization.v1.IOptimizeToursResponse, protos.google.maps.routeoptimization.v1.IOptimizeToursRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IOptimizeToursRequest
|
callback |
Callback<protos.google.maps.routeoptimization.v1.IOptimizeToursResponse, protos.google.maps.routeoptimization.v1.IOptimizeToursRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |