VRPTW Routing › Practical Implications

Michael BrenndoerferSeptember 4, 20256 min read
Machine Learning from ScratchAll chapters
Part 9 of 9Optimization
Chapter 66VRPTW Routing › Practical Implications
Reading section 6 of 8 · Practical Implications · 6 minSection 6 of 8 · 6 min

Book contents

Section 6 of 8 · 6 min read

VRPTW Routing › Practical ImplicationsOne section · Sections in this chapter6 / 8 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

VRPTW addresses logistics scenarios where customers have specific availability windows that constrain when service can occur. This makes it appropriate for last-mile delivery operations, field service scheduling, healthcare logistics, and any routing problem where temporal constraints are binding rather than advisory. The formulation captures the core tradeoff between route efficiency and schedule adherence that characterizes modern logistics operations.

The approach is most valuable when time windows represent hard constraints, situations where arriving outside the window is infeasible rather than merely undesirable. Examples include scheduled appointment services, store receiving hours, and perishable goods delivery where timing affects product quality. When time windows are soft (violations incur penalties but are permitted), the standard VRPTW formulation requires modification to include penalty terms in the objective function. For problems without meaningful temporal constraints, simpler VRP variants will be more appropriate and computationally tractable.

Consider the density and overlap of time windows when assessing problem suitability. Problems with highly restrictive, non-overlapping windows may have few or no feasible solutions, while problems with very wide windows offer little value from the time window constraint and may be better modeled as basic VRP. The interaction between window tightness and geographic dispersion determines problem difficulty: clustered customers with overlapping windows are easier than dispersed customers with tight, disjoint windows.

Best Practices

Configure OR-Tools with PATH_CHEAPEST_ARC as the initial solution strategy and GUIDED_LOCAL_SEARCH as the metaheuristic for general-purpose VRPTW solving. For problems dominated by capacity constraints, consider SAVINGS instead. Set time_limit.seconds based on operational requirements: 30-60 seconds provides good solutions for 50-100 customer problems, while 2-5 minutes yields near-optimal solutions for batch planning. Real-time dispatch applications may need 10-30 second limits, accepting some solution quality degradation.

Validate problem feasibility before invoking the solver by checking that total demand does not exceed total vehicle capacity and that each customer can be reached from the depot within its time window. This prevents wasted computation on infeasible instances. For problems exceeding 100 customers, apply geographic clustering or time-window-based partitioning to decompose the problem into tractable subproblems. Solve subproblems independently, then optionally refine inter-cluster connections.

Use conservative service time estimates rather than optimistic ones. Underestimating service duration propagates delays through the route, causing downstream time window violations that may not appear until execution. When service times vary significantly, model the 75th-90th percentile duration rather than the mean.

Data Requirements and Preprocessing

The travel time matrix is the most critical input, as errors directly translate to infeasible solutions or poor execution. Use routing APIs or historical GPS data to estimate actual driving times rather than computing Euclidean or Manhattan distances. Traffic patterns vary by time of day, so consider using time-dependent travel times for problems spanning multiple hours. For problems with 100+ customers, the matrix requires n2n^2 storage; consider sparse representations or on-demand distance computation for larger instances.

Time window data must be validated against travel time feasibility. For each customer, verify that the depot-to-customer travel time allows arrival within the window, accounting for earliest departure from the depot. Similarly, check that customer-to-depot return is possible within operational hours. Customers failing these checks indicate data errors or require special handling (e.g., dedicated vehicles, earlier depot opening).

Demand data should sum to less than total vehicle capacity with reasonable margin. If total demand approaches total capacity, the problem becomes tightly constrained and may require all vehicles regardless of route efficiency. Service times should include all activities at the customer location: parking, walking, handoff, signature collection, and departure preparation. Depot service time is typically zero unless vehicles require loading or inspection.

Common Pitfalls

Relying on Euclidean distances for the travel matrix creates solutions that appear optimal but fail during execution. Road networks, traffic lights, and restricted turns can double or triple actual travel time compared to straight-line distance. Validate computed routes against actual driving times for a sample of arcs and adjust the matrix if systematic errors exist.

Setting time windows without considering travel time dependencies creates infeasible instances. If customer A's window closes at 10:00 and customer B's window opens at 10:15, but travel between them requires 30 minutes, no single vehicle can serve both. These hidden conflicts may not be obvious until the solver reports infeasibility or produces poor solutions.

Ignoring service time variability leads to optimistic schedules. If actual service takes longer than modeled, delays accumulate along the route. A 5-minute underestimate at each of 8 customers creates 40 minutes of delay by route end. Model conservatively, especially for variable-duration services like installation or repair.

Computational Considerations

VRPTW solution time grows exponentially with problem size due to NP-hardness. Practical scaling guidelines:

Customer CountApproachTypical TimeMemory (Distance Matrix)
< 50Exact (branch-and-bound)1-5 minutes< 10 KB
50-100Heuristic (OR-Tools)30-120 seconds< 40 KB
100-200Heuristic with decomposition2-5 minutes< 160 KB
200-500Geographic partitioning5-15 minutes< 1 MB
> 500Hierarchical approaches15+ minutes1+ MB

The solver's memory footprint beyond the distance matrix is modest, typically under 100 MB for problems up to 500 customers. For larger problems, the primary bottleneck is solution time rather than memory. Decomposition strategies (clustering customers by location or time window) offer the best path to scaling, as they convert one large problem into several smaller, independently solvable problems.

Performance and Deployment Considerations

Evaluate solutions using multiple metrics: total travel distance (efficiency), number of vehicles used (resource utilization), time window adherence rate (service quality), and computation time (responsiveness). No single metric captures solution quality. A solution minimizing distance may require more vehicles; one using fewer vehicles may have tighter timing margins.

Production systems should distinguish batch and real-time scenarios. Batch planning (overnight route computation) can allocate 5-10 minutes per solve for near-optimal solutions. Real-time dispatch (responding to new orders) needs 10-30 second limits, using incremental re-optimization that modifies existing routes rather than solving from scratch.

Implement solution validation before deployment: programmatically verify that each route satisfies capacity constraints, arrives within time windows, and allows timely depot return. Solvers occasionally return solutions that violate constraints due to numerical issues or callback errors. Maintain fallback strategies for solver failures. Options include relaxing the tightest time windows, deploying additional vehicles, or flagging problematic customers for manual handling.