A time window is the period between a start and end time in which a network location, such as a stop in a route analysis, should be visited by a route.
Two network analysis layers incorporate time windows: route and vehicle routing problem analysis layers. The following two tables provide a list of the network analysis classes for which you can set time windows.
Time window fields in route analysis layers
|Network analysis class||Time window field|
Time windows are used when any of the time window fields (TimeWindowStart and TimeWindowEnd) in the Stops layer are populated. The time zone for time window fields can be specified when creating a new Route analysis layer using the Time Zone for Time Fields parameter on the Make Route Analysis Layer geoprocessing tool dialog box. You can also specify the time zone for time window fields by using the Reference Time Zone drop-down list on the Route ribbon. To update the time zone for time window fields on an existing layer, use the timeZoneUsageForTimeFields property of the RouteSolverProperties class in Python.
Time window fields in vehicle routing problem analysis layers
|Network analysis class||Time window field|
You don't need to check any properties in the vehicle routing problem analysis layer to make time windows available; they are always available. The Orders and Depots classes allow you to set two time windows.
Time windows are used when any of the time window fields (TimeWindowStart and TimeWindowEnd) in the Orders and Depots layer are populated. The time zone for time window fields can be specified when creating a Vehicle Routing Problem analysis layer using the Time Zone for Time Fields parameter on the Make Vehicle Routing Problem Analysis Layer geoprocessing tool dialog box. You can also specify the time zone for time window fields by using the Reference Time Zone drop-down list on the VRP ribbon. To update the time zone for time window fields on an existing layer, use the timeZoneUsageForTimeFields property of the VehicleRoutingProblemSolverProperties class in Python.
Route objects in the vehicle routing problem also have time window fields: EarliestStartTime and LatestStartTime. They specify the period in which a route can begin its journey.
Using dates in time windows
For a Route analysis layer to solve for "Today", the time window fields and the Time of Day should be set to the value of Today—12/30/1899. Similarly, to solve for "Today" for a Vehicle Routing Problem Layer analysis layer, the Default Date should be set to the value of Today—12/30/1899.
If preferring to solve for a day of the week, the time window fields continue to use the "Today" value but the Time of Day for a Route analysis layer and the Default Date for a Vehicle Routing Problem analysis layer should specify the corresponding date for the day of the week.
Instead of using a particular date, a day of the week can be specified using the following dates:
The time window date should match the date specified for the time of day (for a Route analysis) or default date (for a Vehicle Routing Problem Layer analysis).
Time window example
To better understand time windows, take the example of four stops—a, b, c, and d—for which a route needs to be found. The time window for each stop is given by its TimeWindowStart and TimeWindowEnd fields.
The route can begin from point a at any time between 8:00 and 9:00 a.m. However, it should not reach point b before 9:10 a.m. As shown below, the route reaches b at 9:05:08 a.m.
Since b should be visited only between 9:10 and 9:12 a.m., the route waits at b for 4 minutes and 52 seconds and departs at 9:10 a.m. This wait time is stored in the Wait_TravelTime field of stop b as 4.66 minutes and is added to the total time taken for the route. The Cumul_TraveTime field for a stop stores the total time taken to reach it. The cumulative travel time of b is 10 minutes (5 minutes and 8 seconds of travel and 4 minutes and 52 seconds of waiting to honor the time window of stop b).
The route departs from stop b at 9:10 a.m. and reaches stop c at 9:15:20 a.m. However, stop c has a time window of 9:10 to 9:12 a.m. There is a violation of 3 minutes and 20 seconds, which is stored in the Violation_TravelTime field as 3.33 minutes, since the route is unable to honor the time window of stop c.
Time windows are treated as a soft constraint. This means that although the solver attempts to honor time windows, it will violate the time windows of some stops to reach them if necessary. This is different from a hard constraint, in which there is no route to the stop that has a time window violation. Hard time windows are not supported by the Route analysis layer. You can, however, use them for the Order time windows in a Vehicle Routing Problem analysis layer by setting the corresponding MaxViolationTime field to zero.
A route solver attempts to find the least-cost route through a series of stops while respecting chosen restrictions on the network and honoring all time windows. If time window violations are inevitable, the solver attempts to minimize the total violation time.