int
A hard limit constraining the distance to be at most
max_meters. The limit must be nonnegative.
This field is a member of oneof_ _max_meters.
soft_max_meters
int
A soft limit not enforcing a maximum distance limit, but
when violated results in a cost which adds up to other costs
defined in the model, with the same unit.
If defined soft_max_meters must be less than max_meters and
must be nonnegative.
This field is a member of oneof_ _soft_max_meters.
cost_per_kilometer_below_soft_max
float
Cost per kilometer incurred, increasing up to
soft_max_meters, with formula:
::
min(distance_meters, soft_max_meters) / 1000.0 *
cost_per_kilometer_below_soft_max.
This cost is not supported in route_distance_limit.
This field is a member of oneof_ _cost_per_kilometer_below_soft_max.
cost_per_kilometer_above_soft_max
float
Cost per kilometer incurred if distance is above
soft_max_meters limit. The additional cost is 0 if the
distance is under the limit, otherwise the formula used to
compute the cost is the following:
::
(distance_meters - soft_max_meters) / 1000.0 *
cost_per_kilometer_above_soft_max.
The cost must be nonnegative.
This field is a member of oneof_ _cost_per_kilometer_above_soft_max.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[],null,["# Class DistanceLimit (1.11.2)\n\nVersion latestkeyboard_arrow_down\n\n- [1.11.2 (latest)](/python/docs/reference/optimization/latest/google.cloud.optimization_v1.types.DistanceLimit)\n- [1.11.0](/python/docs/reference/optimization/1.11.0/google.cloud.optimization_v1.types.DistanceLimit)\n- [1.10.0](/python/docs/reference/optimization/1.10.0/google.cloud.optimization_v1.types.DistanceLimit)\n- [1.9.1](/python/docs/reference/optimization/1.9.1/google.cloud.optimization_v1.types.DistanceLimit)\n- [1.8.5](/python/docs/reference/optimization/1.8.5/google.cloud.optimization_v1.types.DistanceLimit)\n- [1.7.0](/python/docs/reference/optimization/1.7.0/google.cloud.optimization_v1.types.DistanceLimit)\n- [1.6.0](/python/docs/reference/optimization/1.6.0/google.cloud.optimization_v1.types.DistanceLimit)\n- [1.5.0](/python/docs/reference/optimization/1.5.0/google.cloud.optimization_v1.types.DistanceLimit)\n- [1.4.3](/python/docs/reference/optimization/1.4.3/google.cloud.optimization_v1.types.DistanceLimit)\n- [1.3.2](/python/docs/reference/optimization/1.3.2/google.cloud.optimization_v1.types.DistanceLimit)\n- [1.2.0](/python/docs/reference/optimization/1.2.0/google.cloud.optimization_v1.types.DistanceLimit)\n- [1.1.3](/python/docs/reference/optimization/1.1.3/google.cloud.optimization_v1.types.DistanceLimit)\n- [1.0.1](/python/docs/reference/optimization/1.0.1/google.cloud.optimization_v1.types.DistanceLimit)\n- [0.1.1](/python/docs/reference/optimization/0.1.1/google.cloud.optimization_v1.types.DistanceLimit) \n\n DistanceLimit(mapping=None, *, ignore_unknown_fields=False, **kwargs)\n\nA limit defining a maximum distance which can be traveled. It can be\neither hard or soft.\n\nIf a soft limit is defined, both `soft_max_meters` and\n`cost_per_kilometer_above_soft_max` must be defined and be\nnonnegative.\n\n.. _oneof: \u003chttps://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields\u003e"]]