Bessere Verteilung: Strafen/Mutation, plus Abstammungsbaum mit Id-Herkunft
Weniger vermeidbare Gruppentrennungen:
- strafen.cfg: Tischbesetzung bestraft jetzt gestaffelt nach freien
Plaetzen (teilbelegte Tische am teuersten, mit Fallback auf den
naechstkleineren Eintrag), Trennungsstrafen deutlich erhoeht - so
werden Gruppen nicht mehr getrennt, obwohl leere Tische danebenstehen
- gibPunkte('Tischbesetzung') mit Naechst-kleiner-Fallback
- mutieren() setzt geraeumte Gruppen groesste-zuerst neu
(GruppenSetzen(GrosseZuerst=True)), damit grosse Gruppen die frei
gewordenen ganzen Tische bekommen und wieder zusammenkommen
(uebrig bleiben nur physisch unvermeidbare Trennungen, Gruppe > Tisch)
Abstammungsbaum (neuer Schalter --show-lineage -> Abstammung.svg):
- neue Klasse ga.Abstammung zeichnet den vollen Mutationsbaum aller
Loesungen; der Ast der finalen besten Loesung ist hervorgehoben und
mit ihrer Id beschriftet
- hierarchische Loesungs-Ids (Farm._WurzelId/_KindId): Wurzel '7',
Mutationskind '7.2', dessen Kind '7.2.1' - die ganze Abstammung ist
direkt aus der Id ablesbar
Tests (15 gruen), README und CLAUDE.md aktualisiert; Beispiele mit den
neuen Strafen und beiden Grafiken neu berechnet.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -93,7 +93,13 @@ the GA profile is chosen by the `--zyklus-art <name>` switch (default `Adaptiv`)
|
||||
resolved as `os.path.join(indir, ...)` in `platz.py`.
|
||||
|
||||
Pass `--tosvg` to additionally write `<indir>/Sitzplatzverteilung.svg` via
|
||||
`Sitzplatzverteilung.alsSVG()` (see below).
|
||||
`Sitzplatzverteilung.alsSVG()` (see below). `--show-development` writes
|
||||
`<indir>/Entwicklung.svg` (value curves + pool-size panel), and `--show-lineage` writes
|
||||
`<indir>/Abstammung.svg` — the full mutation tree of every solution, with the final best
|
||||
solution's ancestral branch highlighted and labelled with its lineage id. Lineage ids are
|
||||
hierarchical (`Farm._WurzelId`/`_KindId`): a root solution is a plain counter (`7`), each
|
||||
mutation appends `.<child-index>` (`7.2`, then `7.2.1`), so the whole ancestry is readable
|
||||
straight off the id.
|
||||
|
||||
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
|
||||
@@ -115,7 +121,14 @@ Domain-agnostic and reusable in principle:
|
||||
- `Farm` — owns the population (`Pool`/`PoolNeu`), and executes a `Zyklus` action-by-action
|
||||
against instances of a given solution class (passed as `Klasse` plus its constructor
|
||||
args/kwargs). `Bester()` returns the fittest (`max()`) solution found; solutions are ordered
|
||||
via `__eq__`/`__lt__` (`@total_ordering`) on `self.value`.
|
||||
via `__eq__`/`__lt__` (`@total_ordering`) on `self.value`. The Farm also tags every solution
|
||||
with a hierarchical lineage id (`_absid`; `_WurzelId`/`_KindId`) and records the mutation
|
||||
tree into `self.Abstammung`.
|
||||
- `Entwicklung` ("Development") — observer that records one measurement per cycle action
|
||||
(best/avg/worst value + pool size); `alsSVG()` draws the value curves plus a pool-size panel.
|
||||
- `Abstammung` ("Lineage") — observer that records the mutation tree (each solution's id,
|
||||
parent id, generation, value); `alsSVG(HervorId=...)` draws the tree and highlights/labels
|
||||
the ancestral branch of the given (usually the best) solution.
|
||||
|
||||
### `Strukturdaten.py` — domain model for this specific seating problem
|
||||
- `Person`, `Gruppe` (group — a `Set` of people, splittable via `teilen()`), `Tisch` (table —
|
||||
@@ -128,14 +141,18 @@ Domain-agnostic and reusable in principle:
|
||||
a group (`gibPunkte('Trennung', ...)`, recursing to smaller group sizes if no exact rule is
|
||||
configured), a person sitting with no group-mate at their table (`'allein'`), a person having
|
||||
no group-mate at a *neighboring* table (`'nichtNachbar'`), and poor seat utilization at a
|
||||
table (`'Tischbesetzung'`).
|
||||
table (`'Tischbesetzung'` — the penalty rises with the number of free seats, with a nearest-
|
||||
lower-key fallback, so partly-filled tables are penalised most and groups get pulled onto a
|
||||
single table instead of being split next to empty ones).
|
||||
- `Sitzplatzverteilung` ("Seating arrangement") — the actual `Loesung` subclass bred by the GA.
|
||||
Constructor seats VIPs first at pinned tables, then randomly seats groups either
|
||||
largest-first or smallest-first (coin flip), splitting a group across two neighboring tables
|
||||
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. `alsSVG()` renders the layout to
|
||||
worst-scoring groups (`SchlechteGruppenTopX`), evicts them, and reseats them largest-first
|
||||
(`GruppenSetzen(..., GrosseZuerst=True)`) so big groups grab the now-freed whole tables and
|
||||
come back together instead of being re-split; the initial constructor placement still uses
|
||||
the random largest/smallest coin flip (`GrosseZuerst=False`). `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
|
||||
|
||||
Reference in New Issue
Block a user