Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.

Commit 4095c0c

Browse files
feat: added support for walking mode and cost_per_kilometer_below_soft_max (#151)
* feat: added support for walking mode and cost_per_kilometer_below_soft_max Clients can now use walking as the travel mode. And clients can set a cost per kilometer bounded by the soft max. PiperOrigin-RevId: 563199524 Source-Link: googleapis/googleapis@7578999 Source-Link: https://github.com/googleapis/googleapis-gen/commit/ba24bb374d50f1333eba36cf29988a054ba4ffff Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYmEyNGJiMzc0ZDUwZjEzMzNlYmEzNmNmMjk5ODhhMDU0YmE0ZmZmZiJ9 * 🦉 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 946f557 commit 4095c0c

File tree

2 files changed

+51
-20
lines changed

2 files changed

+51
-20
lines changed

google/cloud/optimization_v1/types/fleet_routing.py

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,6 @@ class OptimizeToursRequest(proto.Message):
8383
Shipment model to solve.
8484
solving_mode (google.cloud.optimization_v1.types.OptimizeToursRequest.SolvingMode):
8585
By default, the solving mode is ``DEFAULT_SOLVE`` (0).
86-
max_validation_errors (int):
87-
Truncates the number of validation errors returned. These
88-
errors are typically attached to an INVALID_ARGUMENT error
89-
payload as a BadRequest error detail
90-
(https://cloud.google.com/apis/design/errors#error_details),
91-
unless solving_mode=VALIDATE_ONLY: see the
92-
[OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
93-
field. This defaults to 100 and is capped at 10,000.
94-
95-
This field is a member of `oneof`_ ``_max_validation_errors``.
9686
search_mode (google.cloud.optimization_v1.types.OptimizeToursRequest.SearchMode):
9787
Search mode used to solve the request.
9888
injected_first_solution_routes (MutableSequence[google.cloud.optimization_v1.types.ShipmentRoute]):
@@ -271,6 +261,16 @@ class OptimizeToursRequest(proto.Message):
271261
Its value must be at least 1.0 meters/seconds.
272262
273263
This field is a member of `oneof`_ ``_geodesic_meters_per_second``.
264+
max_validation_errors (int):
265+
Truncates the number of validation errors returned. These
266+
errors are typically attached to an INVALID_ARGUMENT error
267+
payload as a BadRequest error detail
268+
(https://cloud.google.com/apis/design/errors#error_details),
269+
unless solving_mode=VALIDATE_ONLY: see the
270+
[OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
271+
field. This defaults to 100 and is capped at 10,000.
272+
273+
This field is a member of `oneof`_ ``_max_validation_errors``.
274274
label (str):
275275
Label that may be used to identify this request, reported
276276
back in the
@@ -301,12 +301,20 @@ class SolvingMode(proto.Enum):
301301
as possible.
302302
DETECT_SOME_INFEASIBLE_SHIPMENTS (2):
303303
Only populates
304+
[OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
305+
or
304306
[OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments],
305307
and doesn't actually solve the rest of the request
306-
(``status`` and ``routes`` are unset in the response).
308+
(``status`` and ``routes`` are unset in the response). If
309+
infeasibilities in ``injected_solution_constraint`` routes
310+
are detected they are populated in the
311+
[OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
312+
field and
313+
[OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]
314+
is left empty.
307315
308316
*IMPORTANT*: not all infeasible shipments are returned here,
309-
but only the ones that are detected as infeasible as a
317+
but only the ones that are detected as infeasible during
310318
preprocessing.
311319
"""
312320
DEFAULT_SOLVE = 0
@@ -351,11 +359,6 @@ class SearchMode(proto.Enum):
351359
number=4,
352360
enum=SolvingMode,
353361
)
354-
max_validation_errors: int = proto.Field(
355-
proto.INT32,
356-
number=5,
357-
optional=True,
358-
)
359362
search_mode: SearchMode = proto.Field(
360363
proto.ENUM,
361364
number=6,
@@ -407,6 +410,11 @@ class SearchMode(proto.Enum):
407410
number=16,
408411
optional=True,
409412
)
413+
max_validation_errors: int = proto.Field(
414+
proto.INT32,
415+
number=5,
416+
optional=True,
417+
)
410418
label: str = proto.Field(
411419
proto.STRING,
412420
number=17,
@@ -1915,9 +1923,13 @@ class TravelMode(proto.Enum):
19151923
DRIVING (1):
19161924
Travel mode corresponding to driving
19171925
directions (car, ...).
1926+
WALKING (2):
1927+
Travel mode corresponding to walking
1928+
directions.
19181929
"""
19191930
TRAVEL_MODE_UNSPECIFIED = 0
19201931
DRIVING = 1
1932+
WALKING = 2
19211933

19221934
class UnloadingPolicy(proto.Enum):
19231935
r"""Policy on how a vehicle can be unloaded. Applies only to shipments
@@ -2450,6 +2462,18 @@ class DistanceLimit(proto.Message):
24502462
must be nonnegative.
24512463
24522464
This field is a member of `oneof`_ ``_soft_max_meters``.
2465+
cost_per_kilometer_below_soft_max (float):
2466+
Cost per kilometer incurred, increasing up to
2467+
``soft_max_meters``, with formula:
2468+
2469+
::
2470+
2471+
min(distance_meters, soft_max_meters) / 1000.0 *
2472+
cost_per_kilometer_below_soft_max.
2473+
2474+
This cost is not supported in ``route_distance_limit``.
2475+
2476+
This field is a member of `oneof`_ ``_cost_per_kilometer_below_soft_max``.
24532477
cost_per_kilometer_above_soft_max (float):
24542478
Cost per kilometer incurred if distance is above
24552479
``soft_max_meters`` limit. The additional cost is 0 if the
@@ -2476,6 +2500,11 @@ class DistanceLimit(proto.Message):
24762500
number=2,
24772501
optional=True,
24782502
)
2503+
cost_per_kilometer_below_soft_max: float = proto.Field(
2504+
proto.DOUBLE,
2505+
number=4,
2506+
optional=True,
2507+
)
24792508
cost_per_kilometer_above_soft_max: float = proto.Field(
24802509
proto.DOUBLE,
24812510
number=3,
@@ -3858,8 +3887,8 @@ class Level(proto.Enum):
38583887
or before them.
38593888
RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD (2):
38603889
Same as ``RELAX_VISIT_TIMES_AFTER_THRESHOLD``, but the visit
3861-
sequence is also relaxed: visits remain simply bound to
3862-
their vehicle.
3890+
sequence is also relaxed: visits can only be performed by
3891+
this vehicle, but can potentially become unperformed.
38633892
RELAX_ALL_AFTER_THRESHOLD (3):
38643893
Same as ``RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD``,
38653894
but the vehicle is also relaxed: visits are completely free
@@ -3985,6 +4014,8 @@ class OptimizeToursValidationError(proto.Message):
39854014
- INJECTED_SOLUTION_CONCURRENT_SOLUTION_TYPES = 2005;
39864015
- INJECTED_SOLUTION_MORE_THAN_ONE_PER_TYPE = 2006;
39874016
- INJECTED_SOLUTION_REFRESH_WITHOUT_POPULATE = 2008;
4017+
- INJECTED_SOLUTION_CONSTRAINED_ROUTE_PORTION_INFEASIBLE
4018+
= 2010;
39884019
39894020
- SHIPMENT_MODEL_ERROR = 22;
39904021

scripts/fixup_optimization_v1_keywords.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class optimizationCallTransformer(cst.CSTTransformer):
4040
CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
4141
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
4242
'batch_optimize_tours': ('parent', 'model_configs', ),
43-
'optimize_tours': ('parent', 'timeout', 'model', 'solving_mode', 'max_validation_errors', 'search_mode', 'injected_first_solution_routes', 'injected_solution_constraint', 'refresh_details_routes', 'interpret_injected_solutions_using_labels', 'consider_road_traffic', 'populate_polylines', 'populate_transition_polylines', 'allow_large_deadline_despite_interruption_risk', 'use_geodesic_distances', 'geodesic_meters_per_second', 'label', 'populate_travel_step_polylines', ),
43+
'optimize_tours': ('parent', 'timeout', 'model', 'solving_mode', 'search_mode', 'injected_first_solution_routes', 'injected_solution_constraint', 'refresh_details_routes', 'interpret_injected_solutions_using_labels', 'consider_road_traffic', 'populate_polylines', 'populate_transition_polylines', 'allow_large_deadline_despite_interruption_risk', 'use_geodesic_distances', 'geodesic_meters_per_second', 'max_validation_errors', 'label', 'populate_travel_step_polylines', ),
4444
}
4545

4646
def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:

0 commit comments

Comments
 (0)