Show / Hide Table of Contents

Class RouteOptimizationClient

RouteOptimization client wrapper, for convenient use.

Inheritance
object
RouteOptimizationClient
RouteOptimizationClientImpl
Inherited Members
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ToString()
Namespace: Google.Maps.RouteOptimization.V1
Assembly: Google.Maps.RouteOptimization.V1.dll
Syntax
public abstract class RouteOptimizationClient
Remarks

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.

Properties

BatchOptimizeToursOperationsClient

The long-running operations client for BatchOptimizeTours.

Declaration
public virtual OperationsClient BatchOptimizeToursOperationsClient { get; }
Property Value
Type Description
OperationsClient

DefaultEndpoint

The default endpoint for the RouteOptimization service, which is a host of "routeoptimization.googleapis.com" and a port of 443.

Declaration
public static string DefaultEndpoint { get; }
Property Value
Type Description
string

DefaultScopes

The default RouteOptimization scopes.

Declaration
public static IReadOnlyList<string> DefaultScopes { get; }
Property Value
Type Description
IReadOnlyList<string>
Remarks

The default RouteOptimization scopes are:

  • https://www.googleapis.com/auth/cloud-platform

GrpcClient

The underlying gRPC RouteOptimization client

Declaration
public virtual RouteOptimization.RouteOptimizationClient GrpcClient { get; }
Property Value
Type Description
RouteOptimization.RouteOptimizationClient

ServiceMetadata

The service metadata associated with this client type.

Declaration
public static ServiceMetadata ServiceMetadata { get; }
Property Value
Type Description
ServiceMetadata

Methods

BatchOptimizeTours(BatchOptimizeToursRequest, CallSettings)

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.

Declaration
public virtual Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata> BatchOptimizeTours(BatchOptimizeToursRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
BatchOptimizeToursRequest request

The request object containing all of the parameters for the API call.

CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata>

The RPC response.

Sample code
// Create client
RouteOptimizationClient routeOptimizationClient = RouteOptimizationClient.Create();
// Initialize request argument(s)
BatchOptimizeToursRequest request = new BatchOptimizeToursRequest
{
    Parent = "",
    ModelConfigs =
    {
        new BatchOptimizeToursRequest.Types.AsyncModelConfig(),
    },
};
// Make the request
Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata> response = routeOptimizationClient.BatchOptimizeTours(request);

// Poll until the returned long-running operation is complete
Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
BatchOptimizeToursResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata> retrievedResponse = routeOptimizationClient.PollOnceBatchOptimizeTours(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchOptimizeToursResponse retrievedResult = retrievedResponse.Result;
}

BatchOptimizeToursAsync(BatchOptimizeToursRequest, CallSettings)

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.

Declaration
public virtual Task<Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata>> BatchOptimizeToursAsync(BatchOptimizeToursRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
BatchOptimizeToursRequest request

The request object containing all of the parameters for the API call.

CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task<Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata>>

A Task containing the RPC response.

Sample code
// Create client
RouteOptimizationClient routeOptimizationClient = await RouteOptimizationClient.CreateAsync();
// Initialize request argument(s)
BatchOptimizeToursRequest request = new BatchOptimizeToursRequest
{
    Parent = "",
    ModelConfigs =
    {
        new BatchOptimizeToursRequest.Types.AsyncModelConfig(),
    },
};
// Make the request
Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata> response = await routeOptimizationClient.BatchOptimizeToursAsync(request);

// Poll until the returned long-running operation is complete
Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
BatchOptimizeToursResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata> retrievedResponse = await routeOptimizationClient.PollOnceBatchOptimizeToursAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchOptimizeToursResponse retrievedResult = retrievedResponse.Result;
}

BatchOptimizeToursAsync(BatchOptimizeToursRequest, CancellationToken)

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.

Declaration
public virtual Task<Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata>> BatchOptimizeToursAsync(BatchOptimizeToursRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
BatchOptimizeToursRequest request

The request object containing all of the parameters for the API call.

CancellationToken cancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task<Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata>>

A Task containing the RPC response.

Sample code
// Create client
RouteOptimizationClient routeOptimizationClient = await RouteOptimizationClient.CreateAsync();
// Initialize request argument(s)
BatchOptimizeToursRequest request = new BatchOptimizeToursRequest
{
    Parent = "",
    ModelConfigs =
    {
        new BatchOptimizeToursRequest.Types.AsyncModelConfig(),
    },
};
// Make the request
Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata> response = await routeOptimizationClient.BatchOptimizeToursAsync(request);

// Poll until the returned long-running operation is complete
Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
BatchOptimizeToursResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata> retrievedResponse = await routeOptimizationClient.PollOnceBatchOptimizeToursAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchOptimizeToursResponse retrievedResult = retrievedResponse.Result;
}

Create()

Synchronously creates a RouteOptimizationClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use RouteOptimizationClientBuilder.

Declaration
public static RouteOptimizationClient Create()
Returns
Type Description
RouteOptimizationClient

The created RouteOptimizationClient.

CreateAsync(CancellationToken)

Asynchronously creates a RouteOptimizationClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use RouteOptimizationClientBuilder.

Declaration
public static Task<RouteOptimizationClient> CreateAsync(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

The CancellationToken to use while creating the client.

Returns
Type Description
Task<RouteOptimizationClient>

The task representing the created RouteOptimizationClient.

OptimizeTours(OptimizeToursRequest, CallSettings)

Sends an OptimizeToursRequest containing a ShipmentModel and returns an OptimizeToursResponse containing ShipmentRoutes, which are a set of routes to be performed by vehicles minimizing the overall cost.

A ShipmentModel model consists mainly of Shipments that need to be carried out and Vehicles that can be used to transport the Shipments. The ShipmentRoutes assign Shipments to Vehicles. More specifically, they assign a series of Visits 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 ShipmentRoutes to Vehicles that minimizes the total cost where cost has many components defined in the ShipmentModel.

Declaration
public virtual OptimizeToursResponse OptimizeTours(OptimizeToursRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
OptimizeToursRequest request

The request object containing all of the parameters for the API call.

CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OptimizeToursResponse

The RPC response.

Sample code
// Create client
RouteOptimizationClient routeOptimizationClient = RouteOptimizationClient.Create();
// Initialize request argument(s)
OptimizeToursRequest request = new OptimizeToursRequest
{
    Parent = "",
    Timeout = new Duration(),
    Model = new ShipmentModel(),
    SolvingMode = OptimizeToursRequest.Types.SolvingMode.DefaultSolve,
    MaxValidationErrors = 0,
    SearchMode = OptimizeToursRequest.Types.SearchMode.Unspecified,
    InjectedFirstSolutionRoutes =
    {
        new ShipmentRoute(),
    },
    InjectedSolutionConstraint = new InjectedSolutionConstraint(),
    RefreshDetailsRoutes =
    {
        new ShipmentRoute(),
    },
    InterpretInjectedSolutionsUsingLabels = false,
    ConsiderRoadTraffic = false,
    PopulatePolylines = false,
    PopulateTransitionPolylines = false,
    AllowLargeDeadlineDespiteInterruptionRisk = false,
    UseGeodesicDistances = false,
    GeodesicMetersPerSecond = 0,
    Label = "",
};
// Make the request
OptimizeToursResponse response = routeOptimizationClient.OptimizeTours(request);

OptimizeToursAsync(OptimizeToursRequest, CallSettings)

Sends an OptimizeToursRequest containing a ShipmentModel and returns an OptimizeToursResponse containing ShipmentRoutes, which are a set of routes to be performed by vehicles minimizing the overall cost.

A ShipmentModel model consists mainly of Shipments that need to be carried out and Vehicles that can be used to transport the Shipments. The ShipmentRoutes assign Shipments to Vehicles. More specifically, they assign a series of Visits 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 ShipmentRoutes to Vehicles that minimizes the total cost where cost has many components defined in the ShipmentModel.

Declaration
public virtual Task<OptimizeToursResponse> OptimizeToursAsync(OptimizeToursRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
OptimizeToursRequest request

The request object containing all of the parameters for the API call.

CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task<OptimizeToursResponse>

A Task containing the RPC response.

Sample code
// Create client
RouteOptimizationClient routeOptimizationClient = await RouteOptimizationClient.CreateAsync();
// Initialize request argument(s)
OptimizeToursRequest request = new OptimizeToursRequest
{
    Parent = "",
    Timeout = new Duration(),
    Model = new ShipmentModel(),
    SolvingMode = OptimizeToursRequest.Types.SolvingMode.DefaultSolve,
    MaxValidationErrors = 0,
    SearchMode = OptimizeToursRequest.Types.SearchMode.Unspecified,
    InjectedFirstSolutionRoutes =
    {
        new ShipmentRoute(),
    },
    InjectedSolutionConstraint = new InjectedSolutionConstraint(),
    RefreshDetailsRoutes =
    {
        new ShipmentRoute(),
    },
    InterpretInjectedSolutionsUsingLabels = false,
    ConsiderRoadTraffic = false,
    PopulatePolylines = false,
    PopulateTransitionPolylines = false,
    AllowLargeDeadlineDespiteInterruptionRisk = false,
    UseGeodesicDistances = false,
    GeodesicMetersPerSecond = 0,
    Label = "",
};
// Make the request
OptimizeToursResponse response = await routeOptimizationClient.OptimizeToursAsync(request);

OptimizeToursAsync(OptimizeToursRequest, CancellationToken)

Sends an OptimizeToursRequest containing a ShipmentModel and returns an OptimizeToursResponse containing ShipmentRoutes, which are a set of routes to be performed by vehicles minimizing the overall cost.

A ShipmentModel model consists mainly of Shipments that need to be carried out and Vehicles that can be used to transport the Shipments. The ShipmentRoutes assign Shipments to Vehicles. More specifically, they assign a series of Visits 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 ShipmentRoutes to Vehicles that minimizes the total cost where cost has many components defined in the ShipmentModel.

Declaration
public virtual Task<OptimizeToursResponse> OptimizeToursAsync(OptimizeToursRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
OptimizeToursRequest request

The request object containing all of the parameters for the API call.

CancellationToken cancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task<OptimizeToursResponse>

A Task containing the RPC response.

Sample code
// Create client
RouteOptimizationClient routeOptimizationClient = await RouteOptimizationClient.CreateAsync();
// Initialize request argument(s)
OptimizeToursRequest request = new OptimizeToursRequest
{
    Parent = "",
    Timeout = new Duration(),
    Model = new ShipmentModel(),
    SolvingMode = OptimizeToursRequest.Types.SolvingMode.DefaultSolve,
    MaxValidationErrors = 0,
    SearchMode = OptimizeToursRequest.Types.SearchMode.Unspecified,
    InjectedFirstSolutionRoutes =
    {
        new ShipmentRoute(),
    },
    InjectedSolutionConstraint = new InjectedSolutionConstraint(),
    RefreshDetailsRoutes =
    {
        new ShipmentRoute(),
    },
    InterpretInjectedSolutionsUsingLabels = false,
    ConsiderRoadTraffic = false,
    PopulatePolylines = false,
    PopulateTransitionPolylines = false,
    AllowLargeDeadlineDespiteInterruptionRisk = false,
    UseGeodesicDistances = false,
    GeodesicMetersPerSecond = 0,
    Label = "",
};
// Make the request
OptimizeToursResponse response = await routeOptimizationClient.OptimizeToursAsync(request);

PollOnceBatchOptimizeTours(string, CallSettings)

Poll an operation once, using an operationName from a previous invocation of BatchOptimizeTours .

Declaration
public virtual Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata> PollOnceBatchOptimizeTours(string operationName, CallSettings callSettings = null)
Parameters
Type Name Description
string operationName

The name of a previously invoked operation. Must not be null or empty.

CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata>

The result of polling the operation.

PollOnceBatchOptimizeToursAsync(string, CallSettings)

Asynchronously poll an operation once, using an operationName from a previous invocation of BatchOptimizeTours.

Declaration
public virtual Task<Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata>> PollOnceBatchOptimizeToursAsync(string operationName, CallSettings callSettings = null)
Parameters
Type Name Description
string operationName

The name of a previously invoked operation. Must not be null or empty.

CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task<Operation<BatchOptimizeToursResponse, BatchOptimizeToursMetadata>>

A task representing the result of polling the operation.

ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Declaration
public static Task ShutdownDefaultChannelsAsync()
Returns
Type Description
Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.

In this article
Back to top Generated by DocFX