Compare commits

...

2 Commits

Author SHA1 Message Date
Michael Stangl 1e2eedc62b 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>
2026-07-09 12:13:17 +02:00
Michael Stangl e8911df7e9 Use setenv in launcher scripts, add requirements.txt and missing .sh scripts
platz.bat/platz.sh now derive PLATZ via setenv instead of hardcoded
paths, matching the Standard Programm Template already applied to
setenv/install_py/activate_venv/get_cmd. Added the missing .sh
counterparts to those .bat scripts, an empty requirements.txt for
install_py to install (project only uses the stdlib), and ignore
entries for .venv/, out/, .vscode/, *.swp.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-09 11:57:05 +02:00
19 changed files with 319 additions and 116 deletions
+4
View File
@@ -2,3 +2,7 @@
__pycache__/ __pycache__/
*.pyo *.pyo
work/ausgabe.txt work/ausgabe.txt
.venv/
out/
.vscode/
*.swp
+48 -29
View File
@@ -13,41 +13,57 @@ result to text/CSV output files.
**This is Python 2 code** (print statements, `ConfigParser`, `sets.Set`, `UserList`, **This is Python 2 code** (print statements, `ConfigParser`, `sets.Set`, `UserList`,
`string.split`, old-style `raise Exception, "msg"`, `xrange`, `dict.has_key`, `string.split`, old-style `raise Exception, "msg"`, `xrange`, `dict.has_key`,
`dict.iteritems`). It will not run under Python 3 without a 2to3-style port. There is no `dict.iteritems`). It will not run under Python 3 without a 2to3-style port. There is no
`requirements.txt`, build system, test suite, or linter configured in this repo — a Python 2 build system, test suite, or linter configured in this repo. `requirements.txt` exists but
interpreter with only the standard library is sufficient to run it. is 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 ## Running the program
Entry point is `libs/platz.py`, invoked via the wrapper scripts in `bin/`, which set up Entry point is `libs/platz.py`, invoked via the scripts in `bin/` (each provided as a
environment variables and `PYTHONPATH` before calling it — the scripts never take a script `.bat`/`.sh` pair, following the "Standard Programm Template" convention — see
argument, they just launch `platz.py`: `~/.claude/CLAUDE.md` for the template rules):
- `bin/run` (bash, for Linux/macOS) — hardcodes `PLATZ=/Users/sm/develop/python/platz` - `bin/setenv.bat` / `bin/setenv.sh` — derives `PLATZ` from the script's own location (no
- `bin/run.bat` (Windows) — hardcodes `PLATZ=h:\develop\python\platz` and a Python 2.4 interpreter path path editing needed), sets `PLATZ_BIN`, `PLATZ_CFG`, `PLATZ_LIBS`, `PLATZ_WORK`,
`PLATZ_IN`, `PLATZ_OUT`, adds `PLATZ_LIBS` to `PYTHONPATH` (idempotently), and creates
missing folders. Sourced by every other script; not normally invoked directly. The `.sh`
variant must be sourced (`source bin/setenv.sh`), not executed.
- `bin/install_py.bat` / `bin/install_py.sh` — calls `setenv`, then creates `.venv` (via
`py -m venv` / `python3 -m venv`) and `pip install -r requirements.txt` if `.venv` doesn't
already exist.
- `bin/activate_venv.bat` / `bin/activate_venv.sh` — calls `setenv`, then activates the
existing `.venv` (errors out if `install_py` hasn't been run yet).
- `bin/get_cmd.bat` / `bin/get_cmd.sh` — calls `setenv`, then opens a new shell with the
`PLATZ_*` environment already set.
- `bin/platz.bat` / `bin/platz.sh` — calls `setenv`, then runs `python
"$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).
Both scripts set `PLATZ_CFG`, `PLATZ_LIBS`, `PLATZ_WORK` and add `PLATZ_LIBS` to `libs/platz.py` requires a command-line switch `--indir <dir>` (parsed with `optparse`,
`PYTHONPATH`, then run `python $PLATZ_LIBS/platz.py`. **The hardcoded paths at the top of since this is Python 2) pointing at a directory that holds the per-run input files and
these scripts must be edited to match wherever this repo is actually checked out** before receives the output files — e.g. `work/test1/`, `work/test2/`, or any new folder following
they will work. the same layout:
Configuration is driven by `cfg/platz.cfg`, which points (via `$PLATZ_CFG`/`$PLATZ_WORK`
env-var expansion) to:
- `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), - `tische.ini` — table definitions: id, `Nummer`, `Hof` (venue/court), `Plaetze` (seats),
`Nachbarliste` (neighbor table ids), `Koordinaten`. `Nachbarliste` (neighbor table ids), `Koordinaten`.
- `bestellung.xml` — the guest order: `<Gruppe>` blocks containing `<Person>` (with - `bestellung.xml` — the guest order: `<Gruppe>` blocks containing `<Person>` (with
`Vorname`/`Nachname`/optional `Titel`) and an `<Anzahl>` (reservation count per person `Vorname`/`Nachname`/optional `Titel`) and an `<Anzahl>` (reservation count per person
template — this expands into that many identical bookings), plus optional `<Tisch>` to template — this expands into that many identical bookings), plus optional `<Tisch>` to
pin a VIP group to a specific table. pin a VIP group to a specific table.
- Output: `TischePersonen.txt` (table → seated people) and `PersonenTische.csv` - Output (written back into the same `--indir` directory): `TischePersonen.txt` (table →
(person → table, sorted). 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.
`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 ## Architecture
@@ -90,13 +106,16 @@ Domain-agnostic and reusable in principle:
that table rather than going through normal GA placement. that table rather than going through normal GA placement.
### Data flow through `platz.py` (`__main__`) ### 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`). `os.path.expandvars`).
2. Load `Zyklus` (GA schedule), `Strafliste` (penalties), `Tische` (table layout). 3. Load `Zyklus` (GA schedule), `Strafliste` (penalties), `Tische` (table layout, from
3. Load `bestellung.xml` via `XMLConfig` → people, groups, VIP group, VIP seat map. `<indir>/tische.ini`).
4. Build a `Farm(Zyklus, Sitzplatzverteilung, Tische=..., Gruppen=..., Strafen=..., 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. 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 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 — `if __name__ == '__main__':` that exercises the classes directly with hardcoded sample data —
+55 -38
View File
@@ -7,14 +7,14 @@ using a small custom GA framework, and writes the result to text/CSV output file
**This is Python 2 code** (print statements, `ConfigParser`, `sets.Set`, `UserList`, **This is Python 2 code** (print statements, `ConfigParser`, `sets.Set`, `UserList`,
`string.split`, old-style `raise Exception, "msg"`, `xrange`, `dict.has_key`, `string.split`, old-style `raise Exception, "msg"`, `xrange`, `dict.has_key`,
`dict.iteritems`). It needs a Python 2 interpreter; there are no third-party dependencies `dict.iteritems`). There are no third-party dependencies (standard library only), so
(standard library only). `requirements.txt` is empty — it exists only so `bin/install_py` has something to install.
## Project structure ## Project structure
``` ```
platz/ platz/
├── bin/ # launcher scripts (bash + Windows batch) ├── bin/ # environment + launcher scripts (.bat + .sh pairs)
├── cfg/ # GA cycle definition and penalty scheme ├── cfg/ # GA cycle definition and penalty scheme
├── libs/ # the two Python modules (ga.py, Strukturdaten.py, platz.py) ├── libs/ # the two Python modules (ga.py, Strukturdaten.py, platz.py)
└── work/ # per-run input (table layout, guest list) and output └── work/ # per-run input (table layout, guest list) and output
@@ -29,48 +29,53 @@ platz/
## Setup ## Setup
1. Install a Python 2 interpreter (2.4+; no `pip install` needed, standard library only). 1. Install a Python interpreter (`py` on Windows / `python3` on Linux/macOS must be on
2. Edit the hardcoded paths at the top of the launcher script for your platform: `PATH`).
- `bin/run` (bash): `PLATZ=/Users/sm/develop/python/platz` 2. Run the installer for your platform to create a `.venv` and install `requirements.txt`:
- `bin/run.bat` (Windows): `PLATZ=h:\develop\python\platz` and `PYTHONSHELL=l:\tools\i486_nt\python24`
Point `PLATZ` at wherever you checked out this repository.
## Running
From a shell:
```bash
# Linux/macOS
source bin/run
```
```bat ```bat
:: Windows :: Windows
bin\run.bat bin\install_py.bat
``` ```
The launcher sets `PLATZ_CFG`, `PLATZ_LIBS`, `PLATZ_WORK`, adds `PLATZ_LIBS` to ```bash
`PYTHONPATH`, and runs `libs/platz.py`. # Linux/macOS
bin/install_py.sh
```
All `bin/` scripts derive `PLATZ` automatically from their own location (no path editing
required) by calling `setenv.bat`/`setenv.sh` first.
## Running
```bat
:: Windows
bin\activate_venv.bat
bin\platz.bat --indir work\test1
```
```bash
# Linux/macOS
source bin/activate_venv.sh
bin/platz.sh --indir work/test1
```
`bin/platz.bat` / `bin/platz.sh` call `setenv` to set `PLATZ`, `PLATZ_CFG`, `PLATZ_LIBS`,
`PLATZ_WORK`, `PLATZ_IN`, `PLATZ_OUT`, add `PLATZ_LIBS` to `PYTHONPATH`, and then run
`libs/platz.py`, forwarding any extra arguments (like `--indir`) to it.
Other helper scripts (`bin/setenv.*`, `bin/get_cmd.*`) follow the same environment
convention:
- `setenv` — sets all `PLATZ_*` environment variables and creates missing folders; sourced
by every other script, not normally called directly.
- `activate_venv` — activates the `.venv` created by `install_py`.
- `get_cmd` — opens a new shell with the `PLATZ_*` environment already set.
### Configuring a run ### Configuring a run
`cfg/platz.cfg` selects which cycle/penalty config and which working directory `--indir <dir>` is required and points at a directory containing the input files and
(`work/<name>/`) to use for a given run: receiving the output files for one run — e.g. `work/test1/` or `work/test2/`:
```ini
[Config]
Zyklusdatei=$PLATZ_CFG/zyklus.cfg
Zyklusart=Easy
Strafendatei=$PLATZ_CFG/strafen.cfg
Tischedatei=$PLATZ_WORK/test1/tische.ini
XMLdatei_Bestellung=$PLATZ_WORK/test1/bestellung.xml
AusgabeTischePersonen=$PLATZ_WORK/test1/TischePersonen.txt
AusgabePersonTisch=$PLATZ_WORK/test1/PersonenTische.csv
```
To run against a different dataset, point the `Tischedatei`/`XMLdatei_Bestellung`/output
entries at another `work/<name>/` folder, or add a new one following the same layout:
- `tische.ini` — one section per table: `Nummer`, `Hof` (venue/court), `Plaetze` (seat - `tische.ini` — one section per table: `Nummer`, `Hof` (venue/court), `Plaetze` (seat
count), `Nachbarliste` (neighboring table ids), `Koordinaten`. count), `Nachbarliste` (neighboring table ids), `Koordinaten`.
@@ -79,6 +84,18 @@ entries at another `work/<name>/` folder, or add a new one following the same la
that template into). A `<Gruppe>` containing a `<Tisch>` tag is treated as a VIP group that template into). A `<Gruppe>` containing a `<Tisch>` tag is treated as a VIP group
pinned to that table instead of being placed by the GA. pinned to that table instead of being placed by the GA.
To run against a different dataset, create a new folder with a `tische.ini` and
`bestellung.xml` following the same layout and pass it via `--indir`.
`cfg/platz.cfg` still selects the GA cycle/penalty config (independent of `--indir`):
```ini
[Config]
Zyklusdatei=$PLATZ_CFG/zyklus.cfg
Zyklusart=Easy
Strafendatei=$PLATZ_CFG/strafen.cfg
```
`cfg/zyklus.cfg` defines the GA run schedule ("Zyklus") as an `Abfolge` (sequence of `cfg/zyklus.cfg` defines the GA run schedule ("Zyklus") as an `Abfolge` (sequence of
actions) and matching `Anzahl` (counts): `e` create, `s` select best, `S` select randomly, actions) and matching `Anzahl` (counts): `e` create, `s` select best, `S` select randomly,
`m` mutate, `j` keep parents, `z` advance generation. `m` mutate, `j` keep parents, `z` advance generation.
@@ -89,7 +106,7 @@ a neighboring table, and per-table seat-utilization penalties.
### Output ### Output
A run writes two files into the configured working directory: A run writes two files into the `--indir` directory:
- `TischePersonen.txt` — table → seated people, with venue/table/seat numbers. - `TischePersonen.txt` — table → seated people, with venue/table/seat numbers.
- `PersonenTische.csv` — person → table, sorted alphabetically by name. - `PersonenTische.csv` — person → table, sorted alphabetically by name.
+20
View File
@@ -0,0 +1,20 @@
@echo off
REM ================================================================
REM TEST - Python Virtual Environment aktivieren
REM ================================================================
call "%~dp0setenv.bat"
if not exist "%PLATZ%\.venv" (
echo FEHLER: Virtual environment nicht gefunden.
echo Bitte zuerst bin\install_py.bat ausfuehren.
exit /b 1
)
call "%PLATZ%\.venv\Scripts\activate.bat"
echo Virtuelle Umgebung aktiviert.
echo Python-Version:
python --version
echo.
echo Installierte Pakete:
pip list
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
# ================================================================
# Python Virtual Environment aktivieren
# ================================================================
source "$(dirname "${BASH_SOURCE[0]}")/setenv.sh"
if [ ! -d "$PLATZ/.venv" ]; then
echo "FEHLER: Virtual environment nicht gefunden."
echo "Bitte zuerst bin/install_py.sh ausfuehren."
return 1 2>/dev/null || exit 1
fi
source "$PLATZ/.venv/bin/activate"
echo "Virtuelle Umgebung aktiviert."
echo "Python-Version:"
python --version
echo ""
echo "Installierte Pakete:"
pip list
+7
View File
@@ -0,0 +1,7 @@
@echo off
REM ================================================================
REM TEST - Shell mit gesetzten Umgebungsvariablen oeffnen
REM ================================================================
call "%~dp0setenv.bat"
start cmd /k "echo TEST Umgebung aktiv. && echo PLATZ=%PLATZ%"
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
# ================================================================
# Shell mit gesetzten Umgebungsvariablen oeffnen
# ================================================================
source "$(dirname "${BASH_SOURCE[0]}")/setenv.sh"
exec "$SHELL"
+21
View File
@@ -0,0 +1,21 @@
@echo off
REM ================================================================
REM TEST - Python Virtual Environment einrichten
REM ================================================================
call "%~dp0setenv.bat"
if not exist "%PLATZ%\.venv" (
echo Initialisiere Python virtual environment...
py -m venv "%PLATZ%\.venv" --upgrade-deps
echo Erfolgreich.
call "%PLATZ%\.venv\Scripts\activate.bat"
echo Installiere erforderliche Python Packages...
pip install -r "%PLATZ%\requirements.txt" -q
echo Erfolgreich.
deactivate
) else (
echo Erforderliche Python Packages bereits installiert!
)
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
# ================================================================
# Python Virtual Environment einrichten
# ================================================================
source "$(dirname "${BASH_SOURCE[0]}")/setenv.sh"
if [ ! -d "$PLATZ/.venv" ]; then
echo "Initialisiere Python virtual environment..."
python3 -m venv "$PLATZ/.venv" --upgrade-deps
echo "Erfolgreich."
source "$PLATZ/.venv/bin/activate"
echo "Installiere erforderliche Python Packages..."
pip install -r "$PLATZ/requirements.txt" -q
echo "Erfolgreich."
deactivate
else
echo "Erforderliche Python Packages bereits installiert!"
fi
+8
View File
@@ -0,0 +1,8 @@
@echo off
REM ================================================================
REM Startet das Sitzplatzprogramm
REM ================================================================
call "%~dp0setenv.bat"
python "%PLATZ_LIBS%\platz.py" %*
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
# ================================================================
# Startet das Sitzplatzprogramm
# ================================================================
source "$(dirname "${BASH_SOURCE[0]}")/setenv.sh"
python "$PLATZ_LIBS/platz.py" "$@"
-17
View File
@@ -1,17 +0,0 @@
#!/bin/bash
# -------------------------------------
# Wo ist das Programm hinkopiert
export PLATZ=/Users/sm/develop/python/platz
echo $PLATZ
# -------------------------------------
# Umgebung setzen
export PLATZ_CFG=$PLATZ/cfg
export PLATZ_LIBS=$PLATZ/libs
export PLATZ_WORK=$PLATZ/work
# Wo sind die Pythonskripte ?
export PYTHONPATH=$PYTHONPATH:$PLATZ_LIBS
# Startet das Sitzplatzprogramm
python $PLATZ_LIBS/platz.py
-21
View File
@@ -1,21 +0,0 @@
echo off
REM Hier die Umgebung anpassen
REM -------------------------------------
REM Wo ist das Programm hinkopiert
set PLATZ=h:\develop\python\platz
REM Wo liegt der Interpreter
set PYTHONSHELL=l:\tools\i486_nt\python24
REM -------------------------------------
REM Umgebung setzen
set PLATZ_CFG=%PLATZ%\cfg
set PLATZ_LIBS=%PLATZ%\libs
set PLATZ_WORK=%PLATZ%\work
set PATH=%PYTHONSHELL%;%PATH%
REM Wo sind die Pythonskripte ?
set PYTHONPATH=%PLATZ_LIBS%
REM Startet das Sitzplatzprogramm
python %PLATZ_LIBS%\platz.py
+35
View File
@@ -0,0 +1,35 @@
@echo off
REM -------------------------------------
REM Wo ist das Programm hinkopiert
for %%I in ("%~dp0..") do set PLATZ=%%~fI
echo %PLATZ%
REM -------------------------------------
REM Umgebung setzen
set PLATZ_BIN=%PLATZ%\bin
set PLATZ_CFG=%PLATZ%\cfg
set PLATZ_LIBS=%PLATZ%\libs
set PLATZ_WORK=%PLATZ%\work
set PLATZ_IN=%PLATZ%\in
set PLATZ_OUT=%PLATZ%\out
REM Wo sind die Pythonskripte ?
if "%PYTHONPATH%"=="" (
set PYTHONPATH=%PLATZ_LIBS%
) else (
echo %PYTHONPATH% | find /I "%PLATZ_LIBS%" > nul
if errorlevel 1 set PYTHONPATH=%PYTHONPATH%;%PLATZ_LIBS%
)
if not exist "%PLATZ_WORK%" mkdir "%PLATZ_WORK%"
if not exist "%PLATZ_OUT%" mkdir "%PLATZ_OUT%"
echo PLATZ=%PLATZ%
echo PLATZ_BIN=%PLATZ_BIN%
echo PLATZ_CFG=%PLATZ_CFG%
echo PLATZ_LIBS=%PLATZ_LIBS%
echo PLATZ_WORK=%PLATZ_WORK%
echo PLATZ_IN=%PLATZ_IN%
echo PLATZ_OUT=%PLATZ_OUT%
echo PYTHONPATH=%PYTHONPATH%
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
# -------------------------------------
# Wo ist das Programm hinkopiert
export PLATZ="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
echo $PLATZ
# -------------------------------------
# Umgebung setzen
export PLATZ_BIN=$PLATZ/bin
export PLATZ_CFG=$PLATZ/cfg
export PLATZ_LIBS=$PLATZ/libs
export PLATZ_WORK=$PLATZ/work
export PLATZ_IN=$PLATZ/in
export PLATZ_OUT=$PLATZ/out
# Wo sind die Pythonskripte ?
case ":$PYTHONPATH:" in
*":$PLATZ_LIBS:"*) ;;
*) export PYTHONPATH=$PYTHONPATH:$PLATZ_LIBS ;;
esac
mkdir -p "$PLATZ_WORK"
mkdir -p "$PLATZ_OUT"
echo PLATZ=$PLATZ
echo PLATZ_BIN=$PLATZ_BIN
echo PLATZ_CFG=$PLATZ_CFG
echo PLATZ_LIBS=$PLATZ_LIBS
echo PLATZ_WORK=$PLATZ_WORK
echo PLATZ_IN=$PLATZ_IN
echo PLATZ_OUT=$PLATZ_OUT
echo PYTHONPATH=$PYTHONPATH
-4
View File
@@ -2,9 +2,5 @@
Zyklusdatei=$PLATZ_CFG/zyklus.cfg Zyklusdatei=$PLATZ_CFG/zyklus.cfg
Zyklusart=Easy Zyklusart=Easy
Strafendatei=$PLATZ_CFG/strafen.cfg Strafendatei=$PLATZ_CFG/strafen.cfg
Tischedatei=$PLATZ_WORK/test1/tische.ini
XMLdatei_Bestellung=$PLATZ_WORK/test1/bestellung.xml
AusgabeTischePersonen=$PLATZ_WORK/test1/TischePersonen.txt
AusgabePersonTisch=$PLATZ_WORK/test1/PersonenTische.csv
+8
View File
@@ -3,6 +3,14 @@
Referenz fuer die Eingabe- und Ausgabedateien eines `platz`-Laufs, mit Beispielen aus Referenz fuer die Eingabe- und Ausgabedateien eines `platz`-Laufs, mit Beispielen aus
`work/test1/` und `work/test2/`. `work/test1/` und `work/test2/`.
Alle vier Dateien liegen unter dem mit `--indir <dir>` angegebenen Verzeichnis (z.B.
`work/test1/` oder `work/test2/`) unter festen Namen: `tische.ini`, `bestellung.xml` als
Eingabe, `TischePersonen.txt` und `PersonenTische.csv` als Ausgabe. Beispielaufruf:
```bash
bin/platz.sh --indir work/test1
```
## Tischaufstellung: `tische.ini` ## Tischaufstellung: `tische.ini`
Ein INI-File mit einer Sektion pro Tisch. Sektionsname ist die Tisch-Id. Ein INI-File mit einer Sektion pro Tisch. Sektionsname ist die Tisch-Id.
+20 -9
View File
@@ -12,10 +12,26 @@ __license__ = "Python"
from ga import * from ga import *
from Strukturdaten import * from Strukturdaten import *
import ConfigParser import ConfigParser
import optparse
if __name__ == '__main__': if __name__ == '__main__':
# Kommandozeilenoption --indir: Verzeichnis mit den Eingabedateien
# (tische.ini, bestellung.xml) und Ziel fuer die Ausgabedateien
# (TischePersonen.txt, PersonenTische.csv)
parser = optparse.OptionParser()
parser.add_option( "--indir", dest="indir", default=None,
help="Verzeichnis mit tische.ini und bestellung.xml; "
"dort werden auch TischePersonen.txt und PersonenTische.csv abgelegt" )
(options, args) = parser.parse_args()
if options.indir is None:
parser.error( "--indir ist erforderlich" )
InDir = os.path.expandvars( os.path.expanduser( options.indir ) )
if not os.path.isdir( InDir ):
parser.error( "--indir '%s' ist kein Verzeichnis" % InDir )
# lade Vorgaben fuer Optimierungszyklus und # lade Vorgaben fuer Optimierungszyklus und
config = ConfigParser.ConfigParser() config = ConfigParser.ConfigParser()
ConfigPath= os.path.join( os.getenv('PLATZ_CFG'), 'platz.cfg') ConfigPath= os.path.join( os.getenv('PLATZ_CFG'), 'platz.cfg')
@@ -30,16 +46,12 @@ if __name__ == '__main__':
## print Strafenconfig ## print Strafenconfig
# lade Eingabedateien # lade Eingabedateien
Tischconfig = os.path.normpath(config.get( 'Config', 'Tischedatei' )) Tischconfig = os.path.join( InDir, 'tische.ini' )
Tischconfig = os.path.expandvars(Tischconfig) Bestellung = os.path.join( InDir, 'bestellung.xml' )
Bestellung = os.path.normpath(config.get( 'Config', 'XMLdatei_Bestellung' ))
Bestellung = os.path.expandvars( Bestellung )
# lade Ausgabedateien # lade Ausgabedateien
AusgabeTP= os.path.normpath(config.get( 'Config', 'AusgabeTischePersonen' )) AusgabeTP= os.path.join( InDir, 'TischePersonen.txt' )
AusgabeTP = os.path.expandvars(AusgabeTP) AusgabePT = os.path.join( InDir, 'PersonenTische.csv' )
AusgabePT = os.path.normpath(config.get( 'Config', 'AusgabePersonTisch' ))
AusgabePT = os.path.expandvars(AusgabePT)
Z = Zyklus() Z = Zyklus()
Z.laden( Zyklusconfig, Zyklusart ) Z.laden( Zyklusconfig, Zyklusart )
@@ -70,4 +82,3 @@ else:
+8
View File
@@ -0,0 +1,8 @@
# Python-Abhaengigkeiten fuer platz
#
# Aktuell werden nur Module aus der Standardbibliothek verwendet
# (ConfigParser, xml.dom.minidom, sets, UserList, random, ...).
# Keine externen Pakete erforderlich.
#
# Beispiel:
# requests==2.31.0