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.
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
and
ShipmentModel.global_end_time)
and should respect:
google.protobuf.timestamp_pb2.Timestamp
The hard time window start time. If unspecified it will be
set to ShipmentModel.global_start_time.
end_time
google.protobuf.timestamp_pb2.Timestamp
The hard time window end time. If unspecified it will be set
to ShipmentModel.global_end_time.
soft_start_time
google.protobuf.timestamp_pb2.Timestamp
The soft start time of the time window.
soft_end_time
google.protobuf.timestamp_pb2.Timestamp
The soft end time of the time window.
cost_per_hour_before_soft_start_time
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.
This field is a member of oneof_ _cost_per_hour_before_soft_start_time.
cost_per_hour_after_soft_end_time
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.
This field is a member of oneof_ _cost_per_hour_after_soft_end_time.
[[["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 TimeWindow (1.11.2)\n\nVersion latestkeyboard_arrow_down\n\n- [1.11.2 (latest)](/python/docs/reference/optimization/latest/google.cloud.optimization_v1.types.TimeWindow)\n- [1.11.0](/python/docs/reference/optimization/1.11.0/google.cloud.optimization_v1.types.TimeWindow)\n- [1.10.0](/python/docs/reference/optimization/1.10.0/google.cloud.optimization_v1.types.TimeWindow)\n- [1.9.1](/python/docs/reference/optimization/1.9.1/google.cloud.optimization_v1.types.TimeWindow)\n- [1.8.5](/python/docs/reference/optimization/1.8.5/google.cloud.optimization_v1.types.TimeWindow)\n- [1.7.0](/python/docs/reference/optimization/1.7.0/google.cloud.optimization_v1.types.TimeWindow)\n- [1.6.0](/python/docs/reference/optimization/1.6.0/google.cloud.optimization_v1.types.TimeWindow)\n- [1.5.0](/python/docs/reference/optimization/1.5.0/google.cloud.optimization_v1.types.TimeWindow)\n- [1.4.3](/python/docs/reference/optimization/1.4.3/google.cloud.optimization_v1.types.TimeWindow)\n- [1.3.2](/python/docs/reference/optimization/1.3.2/google.cloud.optimization_v1.types.TimeWindow)\n- [1.2.0](/python/docs/reference/optimization/1.2.0/google.cloud.optimization_v1.types.TimeWindow)\n- [1.1.3](/python/docs/reference/optimization/1.1.3/google.cloud.optimization_v1.types.TimeWindow)\n- [1.0.1](/python/docs/reference/optimization/1.0.1/google.cloud.optimization_v1.types.TimeWindow)\n- [0.1.1](/python/docs/reference/optimization/0.1.1/google.cloud.optimization_v1.types.TimeWindow) \n\n TimeWindow(mapping=None, *, ignore_unknown_fields=False, **kwargs)\n\nTime windows constrain the time of an event, such as the arrival\ntime at a visit, or the start and end time of a vehicle.\n\nHard time window bounds, `start_time` and `end_time`, enforce\nthe earliest and latest time of the event, such that\n`start_time \u003c= event_time \u003c= end_time`. The soft time window lower\nbound, `soft_start_time`, expresses a preference for the event to\nhappen at or after `soft_start_time` by incurring a cost\nproportional to how long before soft_start_time the event occurs.\nThe soft time window upper bound, `soft_end_time`, expresses a\npreference for the event to happen at or before `soft_end_time` by\nincurring a cost proportional to how long after `soft_end_time`\nthe event occurs. `start_time`, `end_time`, `soft_start_time`\nand `soft_end_time` should be within the global time limits (see\nShipmentModel.global_start_time\nand\nShipmentModel.global_end_time)\nand should respect:\n\n:: \n\n 0 \u003c= `start_time` \u003c= `soft_start_time` \u003c= `end_time` and\n 0 \u003c= `start_time` \u003c= `soft_end_time` \u003c= `end_time`.\n\n.. _oneof: \u003chttps://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields\u003e"]]