Add --tosvg switch to render seating as SVG, plus test images and docs

Sitzplatzverteilung.alsSVG() (libs/Strukturdaten.py) draws tables as
white circles and people as colored circles inside their table's
circle, colored by group membership. Table radius is derived from
the number of seats so all person-circles fit without touching; the
table-to-table grid spacing is derived from the largest table radius
so tables never overlap regardless of their Koordinaten values.

libs/platz.py gains a --tosvg switch that writes
<indir>/Sitzplatzverteilung.svg alongside the existing text/CSV
output.

The three unittest scenarios now each write their rendering to
doc/images/, and doc/docu_tests.md explains the three configurations
and what each test actually verifies (including why the "split
groups land on true neighbor tables" property only holds for a
specifically chosen seed in the circle scenario, not in general).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Michael Stangl
2026-07-09 12:55:32 +02:00
parent 0232e54f37
commit 74e08f389c
9 changed files with 292 additions and 4 deletions
+18 -4
View File
@@ -29,9 +29,10 @@ artifacts to be aware of when touching this code:
Python 3 raises `TypeError` for that, which is what surfaced it. Fixed to call
`G.Anzahl()`.
There is no build system, test suite, or linter configured in this repo. `requirements.txt`
exists but is empty/commented — everything used is standard library — it's there only so
`bin/install_py.*` has something to install into the `.venv`.
There is no build system or linter configured in this repo. A `tests/` unittest suite
exists (see below); `requirements.txt` is still empty/commented — everything used is
standard library — it's there only so `bin/install_py.*` has something to install into the
`.venv`.
## Running the program
@@ -81,6 +82,15 @@ GA cycle/penalty config:
resolved as `os.path.join(indir, ...)` in `platz.py` — they are no longer configured in
`platz.cfg`.
Pass `--tosvg` to additionally write `<indir>/Sitzplatzverteilung.svg` via
`Sitzplatzverteilung.alsSVG()` (see below).
Run the test suite with `bin/run_tests.bat` / `bin/run_tests.sh` (or directly: `python -m
unittest discover -s tests -p "test_*.py" -v`). A stray global `PYTHONPATH` entry on this
machine points at an unrelated project that also defines a `tests` package — this shadows
`import tests` but does not affect `unittest discover`, which is what the run_tests
scripts use.
## Architecture
Two library modules under `libs/`, imported via `PYTHONPATH=$PLATZ_LIBS`:
@@ -115,7 +125,11 @@ Domain-agnostic and reusable in principle:
when no single table has enough free seats, recursively splitting further if needed, then
calls `bewerten()` to score the arrangement per `Strafliste`. `mutieren()` picks the
worst-scoring groups (`SchlechteGruppenTopX`), evicts them, and reseats them, hoping for a
better score. `speichern()` writes the two output files.
better score. `speichern()` writes the two output files. `alsSVG()` renders the layout to
SVG: tables as white circles sized to fit all their seats' person-circles without
touching, people as colored circles (color = group, via `SVGGruppenFarben`) placed evenly
around the inside of their table's circle. The table-to-table grid spacing is derived
from the largest table radius so tables never overlap regardless of their `Koordinaten`.
- `XMLConfig` — parses `bestellung.xml` into `Personen`/`Gruppen`/VIP-group/VIP-seat-map,
expanding each `<Person>` template by its sibling `<Anzahl>` into that many individual
bookings, and treating any `<Gruppe>` containing a `<Tisch>` tag as a VIP group pinned to