Skip to content

Commit c736654

Browse files
committed
update vehicle routing and meeting scheduling quickstart guides
1 parent 6adace1 commit c736654

File tree

2 files changed

+98
-11
lines changed

2 files changed

+98
-11
lines changed

content/en/docs/getting-started/meeting-scheduling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
title: "Meeting Scheduling"
33
linkTitle: "Meeting Scheduling"
44
icon: fa-brands fa-python
5-
date: 2025-11-26
5+
date: 2025-12-22
66
weight: 20
7-
draft: true
7+
draft: false
88
description: "A comprehensive quickstart guide to understanding and building intelligent meeting scheduling with SolverForge"
99
categories: [Quickstarts]
1010
tags: [quickstart, python]

content/en/docs/getting-started/vehicle-routing.md

Lines changed: 96 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ This implementation includes several enhancements over the standard Timefold qui
7272
| Feature | Benefit |
7373
|---------|---------|
7474
| **Adaptive time windows** | Time windows dynamically scale based on problem area and visit count, ensuring feasible solutions |
75-
| **Haversine formula** | Realistic great-circle distances without external API dependencies |
75+
| **Haversine formula** | Fast great-circle distances without external API dependencies (default mode) |
76+
| **Real Roads mode** | Optional OSMnx integration for actual road network routing with visual route display |
77+
| **Real street addresses** | Demo data uses actual locations in Philadelphia, Hartford, and Florence for realistic routing |
7678

77-
These features give you more control over the performance/memory tradeoff during development and production.
79+
These features give you more control over the performance/accuracy tradeoff during development and production.
7880

7981
---
8082

@@ -119,6 +121,7 @@ src/vehicle_routing/
119121
├── solver.py # Solver configuration
120122
├── demo_data.py # Sample datasets (Philadelphia, Hartford, Florence)
121123
├── rest_api.py # HTTP API endpoints
124+
├── routing.py # Distance matrix and OSMnx routing
122125
├── converters.py # REST ↔ Domain model conversion
123126
├── json_serialization.py # JSON helpers
124127
└── score_analysis.py # Score breakdown DTOs
@@ -129,6 +132,7 @@ static/
129132
130133
tests/
131134
├── test_constraints.py # Unit tests for constraints
135+
├── test_routing.py # Unit tests for routing module
132136
└── test_feasible.py # Integration tests
133137
```
134138

@@ -733,10 +737,11 @@ Returns a specific demo dataset:
733737

734738
**Parameters:**
735739
- `demo_name`: Name of the demo dataset (PHILADELPHIA, HARTFORT, FIRENZE)
740+
- `routing` (query, optional): Routing mode - `haversine` (default) or `real_roads`
736741

737742
**Request:**
738743
```
739-
GET /demo-data/PHILADELPHIA
744+
GET /demo-data/PHILADELPHIA?routing=haversine
740745
```
741746

742747
**Response:**
@@ -789,6 +794,57 @@ GET /demo-data/PHILADELPHIA
789794
- **HARTFORT**: 50 visits, 6 vehicles, tighter capacity (20-30)
790795
- **FIRENZE**: 77 visits (largest), 6 vehicles, varied capacity (20-40)
791796

797+
#### GET /demo-data/{demo_name}/stream
798+
799+
Server-Sent Events (SSE) endpoint for loading demo data with progress updates. Use this when `routing=real_roads` to show download/computation progress.
800+
801+
**Parameters:**
802+
- `demo_name`: Name of the demo dataset
803+
- `routing` (query, optional): `haversine` (default) or `real_roads`
804+
805+
**Request:**
806+
```
807+
GET /demo-data/PHILADELPHIA/stream?routing=real_roads
808+
```
809+
810+
**SSE Events:**
811+
812+
Progress event (during computation):
813+
```json
814+
{"event": "progress", "phase": "network", "message": "Downloading OpenStreetMap road network...", "percent": 10, "detail": "Area: 0.08° × 0.12°"}
815+
```
816+
817+
Complete event (when ready):
818+
```json
819+
{"event": "complete", "solution": {...}, "geometries": {"0": ["encodedPolyline1", "encodedPolyline2"], "1": [...]}}
820+
```
821+
822+
Error event (on failure):
823+
```json
824+
{"event": "error", "message": "Demo data not found: INVALID"}
825+
```
826+
827+
**Geometry format:** Each vehicle's geometries are an array of encoded polylines (Google polyline format), one per route segment:
828+
- First: depot → first visit
829+
- Middle: visit → visit
830+
- Last: last visit → depot
831+
832+
#### GET /route-plans/{problem_id}/geometry
833+
834+
Get route geometries for displaying actual road paths:
835+
836+
**Response:**
837+
```json
838+
{
839+
"geometries": {
840+
"0": ["_p~iF~ps|U_ulLnnqC_mqNvxq`@", "afvkFnps|U~hbE~reK"],
841+
"1": ["_izlFnps|U_ulLnnqC"]
842+
}
843+
}
844+
```
845+
846+
Decode polylines on the frontend to display actual road routes instead of straight lines.
847+
792848
#### POST /route-plans
793849

794850
Submit a routing problem to solve:
@@ -1593,15 +1649,45 @@ def good_constraint(constraint_factory: ConstraintFactory):
15931649
- **Avoid** loops and complex logic in lambda functions
15941650
- **Use** efficient data structures (sets for membership, dicts for lookup)
15951651

1596-
### Distance Calculation: Built-in Performance Optimization
1652+
### Distance Calculation: Two Modes
1653+
1654+
This quickstart supports two routing modes, selectable via the UI toggle or API parameter:
15971655

1598-
SolverForge includes a **built-in distance mode selector** — no custom code required. Choose between:
1656+
#### Haversine Mode (Default)
15991657

1600-
This quickstart uses the Haversine formula for distance calculations, which provides realistic great-circle distances without external dependencies.
1658+
Fast great-circle distance calculation using the Haversine formula:
1659+
- No external dependencies or network calls
1660+
- Assumes 50 km/h average driving speed
1661+
- Routes display as straight lines on the map
1662+
- Best for: development, testing, and quick iterations
1663+
1664+
#### Real Roads Mode
1665+
1666+
Actual road network routing using OpenStreetMap data via OSMnx:
1667+
- Downloads and caches road network data locally
1668+
- Computes shortest paths using Dijkstra's algorithm
1669+
- Routes display as actual road paths on the map
1670+
- Progress streaming via Server-Sent Events (SSE)
1671+
1672+
**First-time use:** The initial load downloads ~5-15 MB of road network data for the demo area (cached for subsequent runs).
1673+
1674+
**How it works:**
1675+
1. Enable "Real Roads" toggle in the UI before loading demo data
1676+
2. The system downloads/loads the OSM road network for the bounding box
1677+
3. A distance matrix is precomputed for all location pairs
1678+
4. The solver uses real driving times; the UI displays actual road routes
1679+
1680+
```python
1681+
# The Location class automatically uses the distance matrix when set
1682+
Location.set_distance_matrix(matrix)
1683+
1684+
# Solver calls driving_time_to() which checks for matrix first
1685+
time = loc1.driving_time_to(loc2) # Uses matrix if available, else haversine
1686+
```
16011687

1602-
### Real Road Network Data
1688+
### Custom Routing APIs
16031689

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:
1690+
For production with proprietary routing (Google Maps, Mapbox, OSRM), pre-compute a distance matrix before solving:
16051691

16061692
```python
16071693
def build_real_distance_matrix(locations):
@@ -1819,7 +1905,8 @@ if solution.score and solution.score.hard_score < 0:
18191905
| Add field to Vehicle | `src/vehicle_routing/domain.py` + `converters.py` |
18201906
| Add field to Visit | `src/vehicle_routing/domain.py` + `converters.py` |
18211907
| Change solve time | `src/vehicle_routing/solver.py` |
1822-
| Change distance calculation | `src/vehicle_routing/domain.py` (Location class) |
1908+
| Change distance calculation | `src/vehicle_routing/routing.py` |
1909+
| Configure routing mode | `src/vehicle_routing/routing.py` |
18231910
| Add REST endpoint | `src/vehicle_routing/rest_api.py` |
18241911
| Change demo data | `src/vehicle_routing/demo_data.py` |
18251912
| Change UI/map | `static/index.html`, `static/app.js` |

0 commit comments

Comments
 (0)