You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Remove distance calculation mode selector from features table
- Simplify Location class to show only Haversine formula
- Remove distanceMode API parameter documentation
- Remove UI dropdown and distance mode testing sections
- Update constraint names to match actual code (camelCase)
- Add Vehicle.name field to class definition
- Fix ConstraintVerifier import path
Copy file name to clipboardExpand all lines: content/en/docs/getting-started/vehicle-routing.md
+11-90Lines changed: 11 additions & 90 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,6 @@ This implementation includes several enhancements over the standard Timefold qui
71
71
72
72
| Feature | Benefit |
73
73
|---------|---------|
74
-
|**Distance calculation mode selector**| Choose between on-demand Haversine (memory-efficient) or pre-computed matrix (faster solving) directly from the UI |
75
74
|**Adaptive time windows**| Time windows dynamically scale based on problem area and visit count, ensuring feasible solutions |
76
75
|**Haversine formula**| Realistic great-circle distances without external API dependencies |
-`driving_time_to()`: Calculates driving time using the Haversine formula
240
196
241
197
**Haversine formula details:**
242
198
- Accounts for Earth's curvature using great-circle distance
243
199
- Assumes 50 km/h average driving speed
244
200
- Example: Philadelphia to New York (~130 km) → ~9,400 seconds (~2.6 hours)
245
201
246
-
**Optimization concept:** The Haversine formula provides realistic geographic distances without external API dependencies. For production with real road networks, you can replace the distance calculation with a pre-loaded matrix from a routing API (Google Maps, OSRM, etc.) — the solver doesn't care how distances are calculated, only that they're fast to retrieve.
202
+
**Optimization concept:** The Haversine formula provides realistic geographic distances without external API dependencies. For production with real road networks, you can replace the distance calculation with a routing API (Google Maps, OSRM, etc.).
247
203
248
204
### The Visit Class (Planning Entity)
249
205
@@ -777,13 +733,10 @@ Returns a specific demo dataset:
777
733
778
734
**Parameters:**
779
735
-`demo_name`: Name of the demo dataset (PHILADELPHIA, HARTFORT, FIRENZE)
|**Pre-computed**| Production, large problems, performance-critical deployments |
1653
-
1654
-
**From the UI:** Use the calculator dropdown in the header to switch modes.
1655
-
1656
-
**Programmatically:**
1657
-
1658
-
```python
1659
-
from vehicle_routing.domain import init_driving_time_matrix, clear_driving_time_matrix
1660
-
from vehicle_routing.demo_data import generate_demo_data, DemoData
1661
-
1662
-
# Option 1: Generate demo data with pre-computed matrix
1663
-
plan = generate_demo_data(DemoData.PHILADELPHIA, use_precomputed_matrix=True)
1664
-
1665
-
# Option 2: Initialize matrix manually for custom data
1666
-
all_locations = [v.home_location for v in vehicles] + [v.location for v in visits]
1667
-
init_driving_time_matrix(all_locations) # Pre-computes n² driving times
1668
-
1669
-
# To switch back to on-demand
1670
-
clear_driving_time_matrix()
1671
-
```
1672
-
1673
-
**Why this matters:**
1674
-
1675
-
The solver evaluates distances **millions of times** during optimization. With 77 locations (FIRENZE dataset), pre-computing stores only 5,929 entries but eliminates repeated trigonometric calculations.
1600
+
This quickstart uses the Haversine formula for distance calculations, which provides realistic great-circle distances without external dependencies.
1676
1601
1677
1602
### Real Road Network Data
1678
1603
1679
-
For production deployments requiring actual road distances (not straight-line approximations), pre-compute using a routing API**before** solving:
1604
+
For production deployments requiring actual road distances (not straight-line approximations), you can replace the distance calculation in `Location.driving_time_to()` with a pre-computed matrix from a routing API:
1680
1605
1681
1606
```python
1682
1607
defbuild_real_distance_matrix(locations):
1683
-
"""Fetch actual driving times from routing API (run once)."""
1608
+
"""Fetch actual driving times from routing API (run once, before solving)."""
0 commit comments