Step-by-step setup and run instructions, including a VS Code walk-through.
- Python 3.10 or newer (developed on 3.13)
- No API keys or accounts. All data is downloaded from the public SMARD.de endpoints on first run and cached locally.
git clone https://github.com/CodingxFaisal/bess-dispatch-optimizer.git
cd bess-dispatch-optimizerCreate a virtual environment (recommended) and install:
python -m venv .venvActivate it:
- Windows (PowerShell):
.\.venv\Scripts\Activate.ps1 - Windows (cmd):
.\.venv\Scripts\activate.bat - macOS / Linux:
source .venv/bin/activate
Then:
pip install -r requirements.txtFile -> Open Folder...and select this project folder.- Install the Microsoft Python extension if prompted.
- Select the interpreter:
Ctrl+Shift+P-> "Python: Select Interpreter" -> choose the.venvyou just created. - Open a terminal with
Ctrl+`. It starts in the project root.
You can run any script with the ▶ button in the editor, or from the terminal as shown below.
This downloads the data once (a few minutes the first time, then cached) and
runs all three stages, writing charts and CSVs to results/:
python scripts/run_all.pypython scripts/download_data.py --start 2022-01-01 --end 2025-01-01
python scripts/run_perfect_foresight.py --start 2022-01-01 --end 2025-01-01
python scripts/run_backtest.py --data-start 2022-01-01 --start 2023-01-01 --end 2025-01-01
python scripts/run_duration_sweep.py --start 2023-01-01 --end 2025-01-01The backtest is the slow step (it solves one small MILP per day and retrains the forecast model periodically), typically a few minutes.
pytestExpected: 19 passed. The tests check energy balance, state-of-charge bounds, the charge/discharge binary, the cycle cap, and a hand-computed revenue case.
Everything lands in results/:
capture_ratio.png,ml_dispatch_week.png,revenue_by_year.png,perfect_revenue_by_year.png,duration_sweep.png,tier1_dispatch_week.pngbacktest_summary.csvand per-strategydaily_*.csv
- Import errors running a script directly: run from the project root. The
scripts add
src/to the path themselves, sopython scripts/run_backtest.pyworks without installing the package. - First run is slow: it is downloading ~3 years of hourly data from SMARD.
Subsequent runs read the local cache in
data/.