Commit Graph

7 Commits

Author SHA1 Message Date
lars 21eb9539d4 Merge pull request 'Fix routing and add tests' (#1) from fix-routing-and-add-tests into main
Reviewed-on: #1
2026-06-19 14:35:02 +02:00
lars fdd82e4c6f Add extensive README
Document the running-dinner concept, setup (uv + .env API key), CSV input
schema, how to run it (CLI and library), output format, a "what to tweak"
table mapping each knob to its file:line, the algorithm (group building,
rotation topology, annealing), testing (offline + opt-in e2e), limitations,
and development commands.
2026-06-19 14:32:51 +02:00
lars ba59235c3e Add opt-in live API end-to-end test
- test_e2e_api.py: minimal 2-address (4-element) call to the real Google
  Routes API; reads the real key from env/.env and skips on a placeholder.
- Marked `e2e` and deselected by default via addopts; run with
  `pytest -m e2e`.
2026-06-19 14:30:10 +02:00
lars 2c60b83d8a Load Google Maps API key from a .env file
- Add python-dotenv and call load_dotenv() in traveltimes.py before reading
  GOOGLE_MAPS_API_KEY (exported env vars still take precedence).
- Add .env.example template; the real .env stays gitignored.
2026-06-19 14:24:54 +02:00
lars 4da624bfcf Fix route optimizer and group assignment; add test suite
Route building / optimization (tatami_masterplan.py):
- fast_total_time was permutation-invariant: it applied get_courses to
  group *values* instead of slots and ignored the permutation, so every
  ordering scored identically and the annealing optimized nothing. It now
  maps each rotation slot to its assigned group via the permutation.
- Replaced the broken next_permutation/simulated_annealing (enumerated n!
  orderings per iteration, fed unnormalized Boltzmann weights to
  np.random.choice -> ValueError, and returned the last random sample) with
  a standard neighbor-swap annealer that tracks and returns the best
  solution and handles <2 slots.
- Convert the reduced Timedelta matrix to float seconds before annealing
  (np.exp can't operate on Timedelta).

Group building (tatami_masterplan.py):
- assign_courses set each group's hosts (sorted by course) before all
  courses were assigned, so hosts whose course was still None got
  mis-ordered. Assign all courses first, then wire up hosts.
- get_masterplan no longer mutates the caller's participant list.

classes.py:
- Narrow casts on distance-matrix lookups to satisfy the mypy gate
  (pre-existing failures).

Tests:
- Add pytest suite (74 tests) covering the rotation topology, route cost
  and optimization, the domain model, the masterplan pipeline, and the
  Routes API wrapper (HTTP mocked). The cost cross-check caught the
  assign_courses ordering bug above.
2026-06-19 14:19:00 +02:00
lars 51bc491cc8 Initial Commit. I'm afraid of testing it. 2025-05-01 15:48:11 +02:00
Lars Bogner e4dae9ec35 Initial commit 2025-04-16 08:11:25 +02:00