Compare commits
2 Commits
bd87b3df46
...
1e2eedc62b
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e2eedc62b | |||
| e8911df7e9 |
@@ -2,3 +2,7 @@
|
||||
__pycache__/
|
||||
*.pyo
|
||||
work/ausgabe.txt
|
||||
.venv/
|
||||
out/
|
||||
.vscode/
|
||||
*.swp
|
||||
|
||||
@@ -13,41 +13,57 @@ result to text/CSV output files.
|
||||
**This is Python 2 code** (print statements, `ConfigParser`, `sets.Set`, `UserList`,
|
||||
`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
|
||||
`requirements.txt`, build system, test suite, or linter configured in this repo — a Python 2
|
||||
interpreter with only the standard library is sufficient to run it.
|
||||
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`.
|
||||
|
||||
## Running the program
|
||||
|
||||
Entry point is `libs/platz.py`, invoked via the wrapper scripts in `bin/`, which set up
|
||||
environment variables and `PYTHONPATH` before calling it — the scripts never take a script
|
||||
argument, they just launch `platz.py`:
|
||||
Entry point is `libs/platz.py`, invoked via the scripts in `bin/` (each provided as a
|
||||
`.bat`/`.sh` pair, following the "Standard Programm Template" convention — see
|
||||
`~/.claude/CLAUDE.md` for the template rules):
|
||||
|
||||
- `bin/run` (bash, for Linux/macOS) — hardcodes `PLATZ=/Users/sm/develop/python/platz`
|
||||
- `bin/run.bat` (Windows) — hardcodes `PLATZ=h:\develop\python\platz` and a Python 2.4 interpreter path
|
||||
- `bin/setenv.bat` / `bin/setenv.sh` — derives `PLATZ` from the script's own location (no
|
||||
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
|
||||
`PYTHONPATH`, then run `python $PLATZ_LIBS/platz.py`. **The hardcoded paths at the top of
|
||||
these scripts must be edited to match wherever this repo is actually checked out** before
|
||||
they will work.
|
||||
|
||||
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:
|
||||
`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: `TischePersonen.txt` (table → seated people) and `PersonenTische.csv`
|
||||
(person → table, sorted).
|
||||
- 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.
|
||||
|
||||
`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
|
||||
|
||||
@@ -90,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 —
|
||||
|
||||
@@ -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`,
|
||||
`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
|
||||
(standard library only).
|
||||
`dict.iteritems`). There are no third-party dependencies (standard library only), so
|
||||
`requirements.txt` is empty — it exists only so `bin/install_py` has something to install.
|
||||
|
||||
## Project structure
|
||||
|
||||
```
|
||||
platz/
|
||||
├── bin/ # launcher scripts (bash + Windows batch)
|
||||
├── bin/ # environment + launcher scripts (.bat + .sh pairs)
|
||||
├── cfg/ # GA cycle definition and penalty scheme
|
||||
├── libs/ # the two Python modules (ga.py, Strukturdaten.py, platz.py)
|
||||
└── work/ # per-run input (table layout, guest list) and output
|
||||
@@ -29,48 +29,53 @@ platz/
|
||||
|
||||
## Setup
|
||||
|
||||
1. Install a Python 2 interpreter (2.4+; no `pip install` needed, standard library only).
|
||||
2. Edit the hardcoded paths at the top of the launcher script for your platform:
|
||||
- `bin/run` (bash): `PLATZ=/Users/sm/develop/python/platz`
|
||||
- `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
|
||||
```
|
||||
1. Install a Python interpreter (`py` on Windows / `python3` on Linux/macOS must be on
|
||||
`PATH`).
|
||||
2. Run the installer for your platform to create a `.venv` and install `requirements.txt`:
|
||||
|
||||
```bat
|
||||
:: Windows
|
||||
bin\run.bat
|
||||
bin\install_py.bat
|
||||
```
|
||||
|
||||
The launcher sets `PLATZ_CFG`, `PLATZ_LIBS`, `PLATZ_WORK`, adds `PLATZ_LIBS` to
|
||||
`PYTHONPATH`, and runs `libs/platz.py`.
|
||||
```bash
|
||||
# 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
|
||||
|
||||
`cfg/platz.cfg` selects which cycle/penalty config and which working directory
|
||||
(`work/<name>/`) to use for a given run:
|
||||
|
||||
```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:
|
||||
`--indir <dir>` is required and points at a directory containing the input files and
|
||||
receiving the output files for one run — e.g. `work/test1/` or `work/test2/`:
|
||||
|
||||
- `tische.ini` — one section per table: `Nummer`, `Hof` (venue/court), `Plaetze` (seat
|
||||
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
|
||||
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
|
||||
actions) and matching `Anzahl` (counts): `e` create, `s` select best, `S` select randomly,
|
||||
`m` mutate, `j` keep parents, `z` advance generation.
|
||||
@@ -89,7 +106,7 @@ a neighboring table, and per-table seat-utilization penalties.
|
||||
|
||||
### 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.
|
||||
- `PersonenTische.csv` — person → table, sorted alphabetically by name.
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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%"
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
# ================================================================
|
||||
# Shell mit gesetzten Umgebungsvariablen oeffnen
|
||||
# ================================================================
|
||||
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/setenv.sh"
|
||||
exec "$SHELL"
|
||||
@@ -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!
|
||||
)
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,8 @@
|
||||
@echo off
|
||||
REM ================================================================
|
||||
REM Startet das Sitzplatzprogramm
|
||||
REM ================================================================
|
||||
|
||||
call "%~dp0setenv.bat"
|
||||
|
||||
python "%PLATZ_LIBS%\platz.py" %*
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
# ================================================================
|
||||
# Startet das Sitzplatzprogramm
|
||||
# ================================================================
|
||||
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/setenv.sh"
|
||||
|
||||
python "$PLATZ_LIBS/platz.py" "$@"
|
||||
@@ -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
@@ -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
|
||||
@@ -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%
|
||||
|
||||
@@ -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
|
||||
@@ -2,9 +2,5 @@
|
||||
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
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
Referenz fuer die Eingabe- und Ausgabedateien eines `platz`-Laufs, mit Beispielen aus
|
||||
`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`
|
||||
|
||||
Ein INI-File mit einer Sektion pro Tisch. Sektionsname ist die Tisch-Id.
|
||||
|
||||
+20
-9
@@ -12,10 +12,26 @@ __license__ = "Python"
|
||||
from ga import *
|
||||
from Strukturdaten import *
|
||||
import ConfigParser
|
||||
import optparse
|
||||
|
||||
|
||||
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
|
||||
config = ConfigParser.ConfigParser()
|
||||
ConfigPath= os.path.join( os.getenv('PLATZ_CFG'), 'platz.cfg')
|
||||
@@ -30,16 +46,12 @@ if __name__ == '__main__':
|
||||
## print Strafenconfig
|
||||
|
||||
# lade Eingabedateien
|
||||
Tischconfig = os.path.normpath(config.get( 'Config', 'Tischedatei' ))
|
||||
Tischconfig = os.path.expandvars(Tischconfig)
|
||||
Bestellung = os.path.normpath(config.get( 'Config', 'XMLdatei_Bestellung' ))
|
||||
Bestellung = os.path.expandvars( Bestellung )
|
||||
Tischconfig = os.path.join( InDir, 'tische.ini' )
|
||||
Bestellung = os.path.join( InDir, 'bestellung.xml' )
|
||||
|
||||
# lade Ausgabedateien
|
||||
AusgabeTP= os.path.normpath(config.get( 'Config', 'AusgabeTischePersonen' ))
|
||||
AusgabeTP = os.path.expandvars(AusgabeTP)
|
||||
AusgabePT = os.path.normpath(config.get( 'Config', 'AusgabePersonTisch' ))
|
||||
AusgabePT = os.path.expandvars(AusgabePT)
|
||||
AusgabeTP= os.path.join( InDir, 'TischePersonen.txt' )
|
||||
AusgabePT = os.path.join( InDir, 'PersonenTische.csv' )
|
||||
|
||||
Z = Zyklus()
|
||||
Z.laden( Zyklusconfig, Zyklusart )
|
||||
@@ -70,4 +82,3 @@ else:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user