Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from collections import OrderedDict
import functools
import re
from typing import Dict, Optional, Sequence, Tuple, Type, Union
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
import pkg_resources

from google.api_core.client_options import ClientOptions
Expand Down Expand Up @@ -246,7 +246,6 @@ async def optimize_tours(
``Vehicle``\ s that minimizes the total cost where cost has many
components defined in the ``ShipmentModel``.


.. code-block:: python

from google.cloud import optimization_v1
Expand Down Expand Up @@ -343,7 +342,6 @@ async def batch_optimize_tours(
containing ``ShipmentRoute``\ s, which are a set of routes to be
performed by vehicles minimizing the overall cost.


.. code-block:: python

from google.cloud import optimization_v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from collections import OrderedDict
import os
import re
from typing import Dict, Optional, Sequence, Tuple, Type, Union
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
import pkg_resources

from google.api_core import client_options as client_options_lib
Expand Down Expand Up @@ -452,7 +452,6 @@ def optimize_tours(
``Vehicle``\ s that minimizes the total cost where cost has many
components defined in the ``ShipmentModel``.


.. code-block:: python

from google.cloud import optimization_v1
Expand Down Expand Up @@ -541,7 +540,6 @@ def batch_optimize_tours(
containing ``ShipmentRoute``\ s, which are a set of routes to be
performed by vehicles minimizing the overall cost.


.. code-block:: python

from google.cloud import optimization_v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def __init__(
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
be used for service account credentials.
"""

# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
host += ":443"
Expand Down Expand Up @@ -187,5 +188,9 @@ def batch_optimize_tours(
]:
raise NotImplementedError()

@property
def kind(self) -> str:
raise NotImplementedError()


__all__ = ("FleetRoutingTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -348,5 +348,9 @@ def batch_optimize_tours(
def close(self):
self.grpc_channel.close()

@property
def kind(self) -> str:
return "grpc"


__all__ = ("FleetRoutingGrpcTransport",)
20 changes: 10 additions & 10 deletions google/cloud/optimization_v1/types/fleet_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class Metrics(proto.Message):
The latest end time for a used vehicle, computed as the
maximum over all used vehicles of
[ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time].
costs (Sequence[google.cloud.optimization_v1.types.OptimizeToursResponse.Metrics.CostsEntry]):
costs (Mapping[str, float]):
Cost of the solution, broken down by cost-related request
fields. The keys are proto paths, relative to the input
OptimizeToursRequest, e.g. "model.shipments.pickups.cost",
Expand Down Expand Up @@ -1130,7 +1130,7 @@ class Shipment(proto.Message):
the shipment. If not specified, the vehicle only
needs to visit a location corresponding to the
pickups.
load_demands (Sequence[google.cloud.optimization_v1.types.Shipment.LoadDemandsEntry]):
load_demands (Mapping[str, google.cloud.optimization_v1.types.Shipment.Load]):
Load demands of the shipment (for example weight, volume,
number of pallets etc). The keys in the map should be
identifiers describing the type of the corresponding load,
Expand Down Expand Up @@ -1322,7 +1322,7 @@ class VisitRequest(proto.Message):
pickup or delivery of a shipment. This cost must be in the
same unit as ``Shipment.penalty_cost`` and must not be
negative.
load_demands (Sequence[google.cloud.optimization_v1.types.Shipment.VisitRequest.LoadDemandsEntry]):
load_demands (Mapping[str, google.cloud.optimization_v1.types.Shipment.Load]):
Load demands of this visit request. This is just like
[Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
field, except that it only applies to this
Expand Down Expand Up @@ -1665,7 +1665,7 @@ class Vehicle(proto.Message):
This field is a member of `oneof`_ ``_travel_duration_multiple``.
unloading_policy (google.cloud.optimization_v1.types.Vehicle.UnloadingPolicy):
Unloading policy enforced on the vehicle.
load_limits (Sequence[google.cloud.optimization_v1.types.Vehicle.LoadLimitsEntry]):
load_limits (Mapping[str, google.cloud.optimization_v1.types.Vehicle.LoadLimit]):
Capacities of the vehicle (weight, volume, # of pallets for
example). The keys in the map are the identifiers of the
type of load, consistent with the keys of the
Expand Down Expand Up @@ -1728,7 +1728,7 @@ class Vehicle(proto.Message):
In a given ``OptimizeToursResponse``, the route distance is
the sum of all its
[transitions.travel_distance_meters][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters].
extra_visit_duration_for_visit_type (Sequence[google.cloud.optimization_v1.types.Vehicle.ExtraVisitDurationForVisitTypeEntry]):
extra_visit_duration_for_visit_type (Mapping[str, google.protobuf.duration_pb2.Duration]):
Specifies a map from visit_types strings to durations. The
duration is time in addition to
[VisitRequest.duration][google.cloud.optimization.v1.Shipment.VisitRequest.duration]
Expand Down Expand Up @@ -2774,7 +2774,7 @@ class ShipmentRoute(proto.Message):
or
[ShipmentRoute.visits][google.cloud.optimization.v1.ShipmentRoute.visits],
depending on the context.
route_costs (Sequence[google.cloud.optimization_v1.types.ShipmentRoute.RouteCostsEntry]):
route_costs (Mapping[str, float]):
Cost of the route, broken down by cost-related request
fields. The keys are proto paths, relative to the input
OptimizeToursRequest, e.g. "model.shipments.pickups.cost",
Expand Down Expand Up @@ -2857,7 +2857,7 @@ class Visit(proto.Message):
Time at which the visit starts. Note that the vehicle may
arrive earlier than this at the visit location. Times are
consistent with the ``ShipmentModel``.
load_demands (Sequence[google.cloud.optimization_v1.types.ShipmentRoute.Visit.LoadDemandsEntry]):
load_demands (Mapping[str, google.cloud.optimization_v1.types.Shipment.Load]):
Total visit load demand as the sum of the shipment and the
visit request ``load_demands``. The values are negative if
the visit is a delivery. Demands are reported for the same
Expand Down Expand Up @@ -3017,7 +3017,7 @@ class Transition(proto.Message):
[populate_transition_polylines]
[google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
is set to true.
vehicle_loads (Sequence[google.cloud.optimization_v1.types.ShipmentRoute.Transition.VehicleLoadsEntry]):
vehicle_loads (Mapping[str, google.cloud.optimization_v1.types.ShipmentRoute.VehicleLoad]):
Vehicle loads during this transition, for each type that
either appears in this vehicle's
[Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits],
Expand Down Expand Up @@ -3425,14 +3425,14 @@ class AggregatedMetrics(proto.Message):
travel_distance_meters (float):
Total travel distance for a route or a
solution.
max_loads (Sequence[google.cloud.optimization_v1.types.AggregatedMetrics.MaxLoadsEntry]):
max_loads (Mapping[str, google.cloud.optimization_v1.types.ShipmentRoute.VehicleLoad]):
Maximum load achieved over the entire route (resp.
solution), for each of the quantities on this route (resp.
solution), computed as the maximum over all
[Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
(resp.
[ShipmentRoute.metrics.max_loads][google.cloud.optimization.v1.AggregatedMetrics.max_loads].
costs (Sequence[google.cloud.optimization_v1.types.AggregatedMetrics.CostsEntry]):
costs (Mapping[str, float]):
Deprecated: Use [ShipmentRoute.route_costs][] and
[OptimizeToursResponse.Metrics.costs][] instead.
total_cost (float):
Expand Down
154 changes: 146 additions & 8 deletions samples/generated_samples/snippet_metadata_optimization_v1.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,57 @@
{
"clientLibrary": {
"apis": [
{
"id": "google.cloud.optimization.v1",
"version": "v1"
}
],
"language": "PYTHON",
"name": "google-cloud-optimization"
},
"snippets": [
{
"canonical": true,
"clientMethod": {
"async": true,
"client": {
"fullName": "google.cloud.optimization_v1.FleetRoutingAsyncClient",
"shortName": "FleetRoutingAsyncClient"
},
"fullName": "google.cloud.optimization_v1.FleetRoutingAsyncClient.batch_optimize_tours",
"method": {
"fullName": "google.cloud.optimization.v1.FleetRouting.BatchOptimizeTours",
"service": {
"fullName": "google.cloud.optimization.v1.FleetRouting",
"shortName": "FleetRouting"
},
"shortName": "BatchOptimizeTours"
}
},
"parameters": [
{
"name": "request",
"type": "google.cloud.optimization_v1.types.BatchOptimizeToursRequest"
},
{
"name": "retry",
"type": "google.api_core.retry.Retry"
},
{
"name": "timeout",
"type": "float"
},
{
"name": "metadata",
"type": "Sequence[Tuple[str, str]"
}
],
"resultType": "google.api_core.operation_async.AsyncOperation",
"shortName": "batch_optimize_tours"
},
"description": "Sample for BatchOptimizeTours",
"file": "cloudoptimization_v1_generated_fleet_routing_batch_optimize_tours_async.py",
"language": "PYTHON",
"origin": "API_DEFINITION",
"regionTag": "cloudoptimization_v1_generated_FleetRouting_BatchOptimizeTours_async",
"segments": [
{
Expand Down Expand Up @@ -43,18 +84,50 @@
"start": 51,
"type": "RESPONSE_HANDLING"
}
]
],
"title": "cloudoptimization_v1_generated_fleet_routing_batch_optimize_tours_async.py"
},
{
"canonical": true,
"clientMethod": {
"client": {
"fullName": "google.cloud.optimization_v1.FleetRoutingClient",
"shortName": "FleetRoutingClient"
},
"fullName": "google.cloud.optimization_v1.FleetRoutingClient.batch_optimize_tours",
"method": {
"fullName": "google.cloud.optimization.v1.FleetRouting.BatchOptimizeTours",
"service": {
"fullName": "google.cloud.optimization.v1.FleetRouting",
"shortName": "FleetRouting"
},
"shortName": "BatchOptimizeTours"
}
},
"parameters": [
{
"name": "request",
"type": "google.cloud.optimization_v1.types.BatchOptimizeToursRequest"
},
{
"name": "retry",
"type": "google.api_core.retry.Retry"
},
{
"name": "timeout",
"type": "float"
},
{
"name": "metadata",
"type": "Sequence[Tuple[str, str]"
}
],
"resultType": "google.api_core.operation.Operation",
"shortName": "batch_optimize_tours"
},
"description": "Sample for BatchOptimizeTours",
"file": "cloudoptimization_v1_generated_fleet_routing_batch_optimize_tours_sync.py",
"language": "PYTHON",
"origin": "API_DEFINITION",
"regionTag": "cloudoptimization_v1_generated_FleetRouting_BatchOptimizeTours_sync",
"segments": [
{
Expand Down Expand Up @@ -87,19 +160,51 @@
"start": 51,
"type": "RESPONSE_HANDLING"
}
]
],
"title": "cloudoptimization_v1_generated_fleet_routing_batch_optimize_tours_sync.py"
},
{
"canonical": true,
"clientMethod": {
"async": true,
"client": {
"fullName": "google.cloud.optimization_v1.FleetRoutingAsyncClient",
"shortName": "FleetRoutingAsyncClient"
},
"fullName": "google.cloud.optimization_v1.FleetRoutingAsyncClient.optimize_tours",
"method": {
"fullName": "google.cloud.optimization.v1.FleetRouting.OptimizeTours",
"service": {
"fullName": "google.cloud.optimization.v1.FleetRouting",
"shortName": "FleetRouting"
},
"shortName": "OptimizeTours"
}
},
"parameters": [
{
"name": "request",
"type": "google.cloud.optimization_v1.types.OptimizeToursRequest"
},
{
"name": "retry",
"type": "google.api_core.retry.Retry"
},
{
"name": "timeout",
"type": "float"
},
{
"name": "metadata",
"type": "Sequence[Tuple[str, str]"
}
],
"resultType": "google.cloud.optimization_v1.types.OptimizeToursResponse",
"shortName": "optimize_tours"
},
"description": "Sample for OptimizeTours",
"file": "cloudoptimization_v1_generated_fleet_routing_optimize_tours_async.py",
"language": "PYTHON",
"origin": "API_DEFINITION",
"regionTag": "cloudoptimization_v1_generated_FleetRouting_OptimizeTours_async",
"segments": [
{
Expand Down Expand Up @@ -132,18 +237,50 @@
"start": 42,
"type": "RESPONSE_HANDLING"
}
]
],
"title": "cloudoptimization_v1_generated_fleet_routing_optimize_tours_async.py"
},
{
"canonical": true,
"clientMethod": {
"client": {
"fullName": "google.cloud.optimization_v1.FleetRoutingClient",
"shortName": "FleetRoutingClient"
},
"fullName": "google.cloud.optimization_v1.FleetRoutingClient.optimize_tours",
"method": {
"fullName": "google.cloud.optimization.v1.FleetRouting.OptimizeTours",
"service": {
"fullName": "google.cloud.optimization.v1.FleetRouting",
"shortName": "FleetRouting"
},
"shortName": "OptimizeTours"
}
},
"parameters": [
{
"name": "request",
"type": "google.cloud.optimization_v1.types.OptimizeToursRequest"
},
{
"name": "retry",
"type": "google.api_core.retry.Retry"
},
{
"name": "timeout",
"type": "float"
},
{
"name": "metadata",
"type": "Sequence[Tuple[str, str]"
}
],
"resultType": "google.cloud.optimization_v1.types.OptimizeToursResponse",
"shortName": "optimize_tours"
},
"description": "Sample for OptimizeTours",
"file": "cloudoptimization_v1_generated_fleet_routing_optimize_tours_sync.py",
"language": "PYTHON",
"origin": "API_DEFINITION",
"regionTag": "cloudoptimization_v1_generated_FleetRouting_OptimizeTours_sync",
"segments": [
{
Expand Down Expand Up @@ -176,7 +313,8 @@
"start": 42,
"type": "RESPONSE_HANDLING"
}
]
],
"title": "cloudoptimization_v1_generated_fleet_routing_optimize_tours_sync.py"
}
]
}
Loading