# Cloud Optimization V1 API - Class Google::Cloud::Optimization::V1::DistanceLimit (v0.16.0)

0.16.0 (latest) 0.15.0 0.14.1 0.13.0 0.12.0 0.11.1 0.10.0 0.9.2 0.8.2 0.7.0 0.6.0 0.5.0 0.4.1 0.3.0 0.2.1 0.1.1 Reference documentation and code samples for the Cloud Optimization V1 API class Google::Cloud::Optimization::V1::DistanceLimit.

A limit defining a maximum distance which can be traveled. It can be either
hard or soft.


<br />

If a soft limit is defined, both `soft_max_meters` and
`cost_per_kilometer_above_soft_max` must be defined and be nonnegative.

## Inherits

- Object

## Extended By

- Google::Protobuf::MessageExts::ClassMethods

## Includes

- Google::Protobuf::MessageExts

## Methods

### #cost_per_kilometer_above_soft_max

    def cost_per_kilometer_above_soft_max() -> ::Float

**Returns**

- (::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.

### #cost_per_kilometer_above_soft_max=

    def cost_per_kilometer_above_soft_max=(value) -> ::Float

**Parameter**

- **value** (::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.
**Returns**

- (::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.

### #cost_per_kilometer_below_soft_max

    def cost_per_kilometer_below_soft_max() -> ::Float

**Returns**

- (::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`.

### #cost_per_kilometer_below_soft_max=

    def cost_per_kilometer_below_soft_max=(value) -> ::Float

**Parameter**

- **value** (::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`.
**Returns**

- (::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`.

### #max_meters

    def max_meters() -> ::Integer

**Returns**

- (::Integer) --- A hard limit constraining the distance to be at most max_meters. The limit must be nonnegative.

### #max_meters=

    def max_meters=(value) -> ::Integer

**Parameter**

- **value** (::Integer) --- A hard limit constraining the distance to be at most max_meters. The limit must be nonnegative.
**Returns**

- (::Integer) --- A hard limit constraining the distance to be at most max_meters. The limit must be nonnegative.

### #soft_max_meters

    def soft_max_meters() -> ::Integer

**Returns**

- (::Integer) --- 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.

### #soft_max_meters=

    def soft_max_meters=(value) -> ::Integer

**Parameter**

- **value** (::Integer) --- 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.
**Returns**

- (::Integer) --- 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.