# Cloud Optimization V1 API - Class Google::Cloud::Optimization::V1::TimeWindow (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::TimeWindow.

Time windows constrain the time of an event, such as the arrival time at a
visit, or the start and end time of a vehicle.


<br />

Hard time window bounds, `start_time` and `end_time`, enforce the earliest
and latest time of the event, such that `start_time <= event_time <=
end_time`. The soft time window lower bound, `soft_start_time`, expresses a
preference for the event to happen at or after `soft_start_time` by incurring
a cost proportional to how long before soft_start_time the event occurs. The
soft time window upper bound, `soft_end_time`, expresses a preference for the
event to happen at or before `soft_end_time` by incurring a cost proportional
to how long after `soft_end_time` the event occurs. `start_time`, `end_time`,
`soft_start_time` and `soft_end_time` should be within the global time limits
(see
[ShipmentModel.global_start_time](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Cloud-Optimization-V1-ShipmentModel#Google__Cloud__Optimization__V1__ShipmentModel_global_start_time_instance_ "Google::Cloud::Optimization::V1::ShipmentModel#global_start_time (method)")
and
[ShipmentModel.global_end_time](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Cloud-Optimization-V1-ShipmentModel#Google__Cloud__Optimization__V1__ShipmentModel_global_end_time_instance_ "Google::Cloud::Optimization::V1::ShipmentModel#global_end_time (method)"))
and should respect:
``
0 <= `start_time` <= `soft_start_time` <= `end_time` and
0 <= `start_time` <= `soft_end_time` <= `end_time`.
``

## Inherits

- Object

## Extended By

- Google::Protobuf::MessageExts::ClassMethods

## Includes

- Google::Protobuf::MessageExts

## Methods

### #cost_per_hour_after_soft_end_time

    def cost_per_hour_after_soft_end_time() -> ::Float

**Returns**

- (::Float) --- A cost per hour added to other costs in the model if the event occurs after `soft_end_time`, computed as:


  `
  max(0, t.seconds - soft_end_time.seconds)
  * cost_per_hour_after_soft_end_time / 3600,
  t being the time of the event.
  `

  This cost must be positive, and the field can only be set if
  `soft_end_time` has been set.

### #cost_per_hour_after_soft_end_time=

    def cost_per_hour_after_soft_end_time=(value) -> ::Float

**Parameter**

- **value** (::Float) --- A cost per hour added to other costs in the model if the event occurs after `soft_end_time`, computed as:


  `
  max(0, t.seconds - soft_end_time.seconds)
  * cost_per_hour_after_soft_end_time / 3600,
  t being the time of the event.
  `

  This cost must be positive, and the field can only be set if
  `soft_end_time` has been set.
**Returns**

- (::Float) --- A cost per hour added to other costs in the model if the event occurs after `soft_end_time`, computed as:


  `
  max(0, t.seconds - soft_end_time.seconds)
  * cost_per_hour_after_soft_end_time / 3600,
  t being the time of the event.
  `

  This cost must be positive, and the field can only be set if
  `soft_end_time` has been set.

### #cost_per_hour_before_soft_start_time

    def cost_per_hour_before_soft_start_time() -> ::Float

**Returns**

- (::Float) --- A cost per hour added to other costs in the model if the event occurs before soft_start_time, computed as:

  `
  max(0, soft_start_time - t.seconds)
  * cost_per_hour_before_soft_start_time / 3600,
  t being the time of the event.
  `

  This cost must be positive, and the field can only be set if
  soft_start_time has been set.

### #cost_per_hour_before_soft_start_time=

    def cost_per_hour_before_soft_start_time=(value) -> ::Float

**Parameter**

- **value** (::Float) --- A cost per hour added to other costs in the model if the event occurs before soft_start_time, computed as:


  `
  max(0, soft_start_time - t.seconds)
  * cost_per_hour_before_soft_start_time / 3600,
  t being the time of the event.
  `

  This cost must be positive, and the field can only be set if
  soft_start_time has been set.
**Returns**

- (::Float) --- A cost per hour added to other costs in the model if the event occurs before soft_start_time, computed as:

  `
  max(0, soft_start_time - t.seconds)
  * cost_per_hour_before_soft_start_time / 3600,
  t being the time of the event.
  `

  This cost must be positive, and the field can only be set if
  soft_start_time has been set.

### #end_time

    def end_time() -> ::Google::Protobuf::Timestamp

**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Protobuf-Timestamp)) --- The hard time window end time. If unspecified it will be set to `ShipmentModel.global_end_time`.

### #end_time=

    def end_time=(value) -> ::Google::Protobuf::Timestamp

**Parameter**

- **value** ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Protobuf-Timestamp)) --- The hard time window end time. If unspecified it will be set to `ShipmentModel.global_end_time`.
**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Protobuf-Timestamp)) --- The hard time window end time. If unspecified it will be set to `ShipmentModel.global_end_time`.

### #soft_end_time

    def soft_end_time() -> ::Google::Protobuf::Timestamp

**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Protobuf-Timestamp)) --- The soft end time of the time window.

### #soft_end_time=

    def soft_end_time=(value) -> ::Google::Protobuf::Timestamp

**Parameter**

- **value** ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Protobuf-Timestamp)) --- The soft end time of the time window.
**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Protobuf-Timestamp)) --- The soft end time of the time window.

### #soft_start_time

    def soft_start_time() -> ::Google::Protobuf::Timestamp

**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Protobuf-Timestamp)) --- The soft start time of the time window.

### #soft_start_time=

    def soft_start_time=(value) -> ::Google::Protobuf::Timestamp

**Parameter**

- **value** ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Protobuf-Timestamp)) --- The soft start time of the time window.
**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Protobuf-Timestamp)) --- The soft start time of the time window.

### #start_time

    def start_time() -> ::Google::Protobuf::Timestamp

**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Protobuf-Timestamp)) --- The hard time window start time. If unspecified it will be set to `ShipmentModel.global_start_time`.

### #start_time=

    def start_time=(value) -> ::Google::Protobuf::Timestamp

**Parameter**

- **value** ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Protobuf-Timestamp)) --- The hard time window start time. If unspecified it will be set to `ShipmentModel.global_start_time`.
**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-optimization-v1/latest/Google-Protobuf-Timestamp)) --- The hard time window start time. If unspecified it will be set to `ShipmentModel.global_start_time`.