# Cloud Optimization v1 API - Class Vehicle.Types.DurationLimit (2.7.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.7.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.Vehicle.Types.DurationLimit)
- [2.6.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.6.0/Google.Cloud.Optimization.V1.Vehicle.Types.DurationLimit)
- [2.5.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.5.0/Google.Cloud.Optimization.V1.Vehicle.Types.DurationLimit)
- [2.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.4.0/Google.Cloud.Optimization.V1.Vehicle.Types.DurationLimit)
- [2.3.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.3.0/Google.Cloud.Optimization.V1.Vehicle.Types.DurationLimit)
- [2.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.2.0/Google.Cloud.Optimization.V1.Vehicle.Types.DurationLimit)
- [2.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.1.0/Google.Cloud.Optimization.V1.Vehicle.Types.DurationLimit)
- [2.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.0.0/Google.Cloud.Optimization.V1.Vehicle.Types.DurationLimit)
- [1.0.0-beta01](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/1.0.0-beta01/Google.Cloud.Optimization.V1.Vehicle.Types.DurationLimit)

    public sealed class Vehicle.Types.DurationLimit : IMessage<Vehicle.Types.DurationLimit>, IEquatable<Vehicle.Types.DurationLimit>, IDeepCloneable<Vehicle.Types.DurationLimit>, IBufferMessage, IMessage

Reference documentation and code samples for the Cloud Optimization v1 API class Vehicle.Types.DurationLimit.

A limit defining a maximum duration of the route of a vehicle. It can be
either hard or soft.

When a soft limit field is defined, both the soft max threshold and its
associated cost must be defined together.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> Vehicle.Types.DurationLimit

## Implements

[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[Vehicle](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.Vehicle)[Types](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.Vehicle.Types)[DurationLimit](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.Vehicle.Types.DurationLimit), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[Vehicle](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.Vehicle)[Types](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.Vehicle.Types)[DurationLimit](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.Vehicle.Types.DurationLimit), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[Vehicle](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.Vehicle)[Types](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.Vehicle.Types)[DurationLimit](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.Vehicle.Types.DurationLimit), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html)

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Cloud.Optimization.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1)

## Assembly

Google.Cloud.Optimization.V1.dll

## Constructors

### DurationLimit()

    public DurationLimit()

### DurationLimit(DurationLimit)

    public DurationLimit(Vehicle.Types.DurationLimit other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.Vehiclehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.Vehicle.Typeshttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.Vehicle.Types.DurationLimit` |

## Properties

### CostPerHourAfterSoftMax

    public double CostPerHourAfterSoftMax { get; set; }

Cost per hour incurred if the `soft_max_duration` threshold is violated.
The additional cost is 0 if the duration is under the threshold,
otherwise the cost depends on the duration as follows:

      cost_per_hour_after_soft_max * (duration - soft_max_duration)

The cost must be nonnegative.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.double` |   |

### CostPerSquareHourAfterQuadraticSoftMax

    public double CostPerSquareHourAfterQuadraticSoftMax { get; set; }

Cost per square hour incurred if the
`quadratic_soft_max_duration` threshold is violated.

The additional cost is 0 if the duration is under the threshold,
otherwise the cost depends on the duration as follows:

      cost_per_square_hour_after_quadratic_soft_max *
      (duration - quadratic_soft_max_duration)^2

The cost must be nonnegative.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.double` |   |

### HasCostPerHourAfterSoftMax

    public bool HasCostPerHourAfterSoftMax { get; }

Gets whether the "cost_per_hour_after_soft_max" field is set

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` |   |

### HasCostPerSquareHourAfterQuadraticSoftMax

    public bool HasCostPerSquareHourAfterQuadraticSoftMax { get; }

Gets whether the "cost_per_square_hour_after_quadratic_soft_max" field is set

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` |   |

### MaxDuration

    public Duration MaxDuration { get; set; }

A hard limit constraining the duration to be at most max_duration.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Duration.html` |   |

### QuadraticSoftMaxDuration

    public Duration QuadraticSoftMaxDuration { get; set; }

A soft limit not enforcing a maximum duration limit, but when violated
makes the route incur a cost, quadratic in the duration. This cost adds
up to other costs defined in the model, with the same unit.

If defined, `quadratic_soft_max_duration` must be nonnegative. If
`max_duration` is also defined, `quadratic_soft_max_duration` must be
less than `max_duration`, and the difference must be no larger than one
day:

`max_duration - quadratic_soft_max_duration <= 86400 seconds`

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Duration.html` |   |

### SoftMaxDuration

    public Duration SoftMaxDuration { get; set; }

A soft limit not enforcing a maximum duration limit, but when violated
makes the route incur a cost. This cost adds up to other costs defined in
the model, with the same unit.

If defined, `soft_max_duration` must be nonnegative. If max_duration is
also defined, `soft_max_duration` must be less than max_duration.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Duration.html` |   |