# POC1: Braunkohle Supply Chain Modellierung ## Überblick Dieser POC modelliert eine Braunkohle Supply Chain mit Pyomo zur Optimierung von Produktions-, Transport- und Distributionsprozessen. ## Projektstruktur ``` POC1/ ├── src/ # Quellcode │ └── preprocessing/ │ └── exploration_preprocess.py # Notebook-exportiertes Preprocessing ├── data/ # Daten │ ├── input/ # Eingabe-Parameter (Excel) │ └── processed/ # Vorverarbeitete Parquet-Dateien ├── models/ # Modell-Definitionen │ └── README.md ├── notebooks/ # Jupyter Notebooks für Analyse ├── latex/ # Latex-Export/Artefakte ├── requirements.txt # Python Dependencies ├── pyproject.toml # Projektmetadaten └── setup.py # Setup-Skript ``` ## Installation ```bash pip install -r requirements.txt ``` ## Verwendung ```bash # Preprocessing-Skript ausführen python src/preprocessing/exploration_preprocess.py ``` ## Modell-Hinweise - Bergbauwoche: Wochenstart Samstag (Sa–Fr) über Datum+2‑Tage‑Shift. - IIS-Debug: Bei Infeasibility schreibt Gurobi eine `results/iis.ilp` mit lesbaren Constraint-Namen. - 3-Tage-Regel: `no_three_in_a_row` ist aktuell auf <= 3 gelockert (Debug). ## Aktuelle Änderungen (Modell & Output) - Tages/ Wochen/ Monatsabweichungen basieren auf **Lieferungen (x)**, nicht auf Bunkerabfluss. - Mischungsverhältnisse (min/max + Ziel) werden **auf Lieferungen** angewendet (nicht auf Bunkerbestand). - Zusätzliche weiche **Mid‑Ziel‑Abweichung** für Mix (linear) ist aktiv. - B3‑Bunker‑Mix: weiche Zielmischung auf B3‑Bunkerbestand (stark gewichtet), um Welzow im Bunker zu vermeiden. - Strecken‑Penalties/Bonuses wurden wieder **entfernt** (nur Mix‑/Abweichungs‑Penalties aktiv). - Excel‑Output: - Sheet1 bleibt unverändert, `mit_Bunkerbestand` enthält Bunkerzufluss und Bunkerbestand. - Neue Sheet `Kohlemischverhältnis` mit Zielwerten + empirischem Mix (Lieferung) + Bunkermix. - Empirischer Mix wird rot/grün markiert, Gruppenfarben nur bis Spalte F. ## Webapp-Prototyp Backend (FastAPI): ```bash uv run python -m uvicorn webapp.backend.main:app --reload ``` Frontend (React/Vite): ```bash cd webapp/frontend npm install npm run dev ``` Optional: eigene Input/Output-Pfade beim Preprocessing via Umgebungsvariablen: `POC1_INPUT_XLSX`, `POC1_OUTPUT_DIR`. ## Docker (All-in-One) Das Docker-Image enthält: - FastAPI Backend - React-Frontend als statischer Build (ausgeliefert über FastAPI) - Python Preprocessing + Optimierung Standard-Start über Docker Compose: ```bash docker compose up --build ``` Danach: - UI: `http://localhost:8000/` - Health: `http://localhost:8000/api/health` Persistenz: - Job-Artefakte und Logs bleiben unter `./var` erhalten (Volume-Mount `./var:/app/var`). Alternativ ohne Compose: ```bash docker build -t leag-coallog:latest . docker run --rm -p 8000:8000 -v "$(pwd)/var:/app/var" leag-coallog:latest ``` Optionale Runtime-Parameter: - `APP_HOST` (Default: `0.0.0.0`) - `APP_PORT` (Default: `8000`) - `LOG_LEVEL` (Default: `info`) - `GRB_LICENSE_FILE` (Default im Compose: `/app/licenses/gurobi.lic`) - optional für WLS: `GRB_WLSACCESSID`, `GRB_WLSSECRET`, `GRB_LICENSEID` ### Gurobi im Docker-Container - `gurobipy` wird im Runtime-Image installiert. - Für klassische Lizenzdatei: `./licenses/gurobi.lic` auf dem Host ablegen. - Für WLS statt Datei: die drei `GRB_*`-Variablen im Shell-Environment setzen. - Verfügbarkeit prüfen: ```bash curl http://localhost:8080/api/health ``` ## Abhängigkeiten - Pyomo (Optimierungsmodellierung) - Pandas (Datenverarbeitung) - NumPy (Numerische Berechnungen) - Matplotlib/Plotly (Visualisierung)