Replace fixed input/output paths in platz.cfg with --indir switch

Tischedatei, XMLdatei_Bestellung, AusgabeTischePersonen and
AusgabePersonTisch are no longer configured in platz.cfg. Instead,
platz.py now requires a --indir <dir> command-line switch pointing
at a directory that must contain tische.ini and bestellung.xml, and
into which TischePersonen.txt/PersonenTische.csv are written - e.g.
work/test1 or work/test2. This makes it trivial to run against
different guest lists without editing platz.cfg. platz.bat/platz.sh
forward extra arguments so --indir can be passed through.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Michael Stangl
2026-07-09 12:13:17 +02:00
parent e8911df7e9
commit 1e2eedc62b
7 changed files with 79 additions and 56 deletions
+27 -17
View File
@@ -39,24 +39,31 @@ Entry point is `libs/platz.py`, invoked via the scripts in `bin/` (each provided
"$PLATZ_LIBS/platz.py"`. This is the actual program entry point (replaces the old
`bin/run` / `bin/run.bat`, which hardcoded absolute paths and have been removed).
Configuration is driven by `cfg/platz.cfg`, which points (via `$PLATZ_CFG`/`$PLATZ_WORK`
env-var expansion) to:
`libs/platz.py` requires a command-line switch `--indir <dir>` (parsed with `optparse`,
since this is Python 2) pointing at a directory that holds the per-run input files and
receives the output files — e.g. `work/test1/`, `work/test2/`, or any new folder following
the same layout:
- `tische.ini` — table definitions: id, `Nummer`, `Hof` (venue/court), `Plaetze` (seats),
`Nachbarliste` (neighbor table ids), `Koordinaten`.
- `bestellung.xml` — the guest order: `<Gruppe>` blocks containing `<Person>` (with
`Vorname`/`Nachname`/optional `Titel`) and an `<Anzahl>` (reservation count per person
template — this expands into that many identical bookings), plus optional `<Tisch>` to
pin a VIP group to a specific table.
- Output (written back into the same `--indir` directory): `TischePersonen.txt` (table →
seated people) and `PersonenTische.csv` (person → table, sorted).
`cfg/platz.cfg` (still located via `$PLATZ_CFG`, independent of `--indir`) only selects the
GA cycle/penalty config:
- `cfg/zyklus.cfg` — defines the GA run schedule ("Zyklus"): a sequence of actions
(`e`=erzeugen/create, `s`=selektieren/select-best, `S`=random-select, `m`=mutieren/mutate,
`j`=behalten/keep parents, `z`=neue Generation/advance generation) each with a count.
- `cfg/strafen.cfg` — the penalty ("Strafpunkte") table: cost of splitting a group across
tables (by group size and number of splits), cost of a lone person, and per-table
under-utilization penalties.
- A per-run working directory under `work/<name>/` (e.g. `work/test1/`, `work/test2/`)
containing:
- `tische.ini` — table definitions: id, `Nummer`, `Hof` (venue/court), `Plaetze` (seats),
`Nachbarliste` (neighbor table ids), `Koordinaten`.
- `bestellung.xml` — the guest order: `<Gruppe>` blocks containing `<Person>` (with
`Vorname`/`Nachname`/optional `Titel`) and an `<Anzahl>` (reservation count per person
template — this expands into that many identical bookings), plus optional `<Tisch>` to
pin a VIP group to a specific table.
- Output: `TischePersonen.txt` (table → seated people) and `PersonenTische.csv`
(person → table, sorted).
`tische.ini`/`bestellung.xml`/`TischePersonen.txt`/`PersonenTische.csv` are fixed filenames
resolved as `os.path.join(indir, ...)` in `platz.py` — they are no longer configured in
`platz.cfg`.
## Architecture
@@ -99,13 +106,16 @@ Domain-agnostic and reusable in principle:
that table rather than going through normal GA placement.
### Data flow through `platz.py` (`__main__`)
1. Read `platz.cfg` to locate the other config/data files (env-var expansion via
1. Parse `--indir` (required) from the command line via `optparse`.
2. Read `platz.cfg` to locate `zyklus.cfg`/`strafen.cfg` (env-var expansion via
`os.path.expandvars`).
2. Load `Zyklus` (GA schedule), `Strafliste` (penalties), `Tische` (table layout).
3. Load `bestellung.xml` via `XMLConfig` → people, groups, VIP group, VIP seat map.
4. Build a `Farm(Zyklus, Sitzplatzverteilung, Tische=..., Gruppen=..., Strafen=...,
3. Load `Zyklus` (GA schedule), `Strafliste` (penalties), `Tische` (table layout, from
`<indir>/tische.ini`).
4. Load `<indir>/bestellung.xml` via `XMLConfig` → people, groups, VIP group, VIP seat map.
5. Build a `Farm(Zyklus, Sitzplatzverteilung, Tische=..., Gruppen=..., Strafen=...,
VIPListe=..., VIPs=...)`, which runs the whole GA cycle in its constructor.
5. Take `Farm.Bester()` and call `.speichern(...)` to write the output files.
6. Take `Farm.Bester()` and call `.speichern(...)` to write `<indir>/TischePersonen.txt` and
`<indir>/PersonenTische.csv`.
Both `libs/platz.py` and `libs/Strukturdaten.py` also have self-test code under
`if __name__ == '__main__':` that exercises the classes directly with hardcoded sample data —