enflow
An open-source Python framework that enables energy data scientists and modellers to write modular and reproducible energy models that solves sequential decision problems.
https://github.com/rebase-energy/emflow
Category: Energy Systems
Sub Category: Energy System Modeling Frameworks
Keywords
energy gymnasium modelling openai-gym python sequential-decision-making-problems
Keywords from Contributors
simulator
Last synced: about 11 hours ago
JSON representation
Repository metadata
โก Open-source Python framework for modelling sequential decision problems in the energy sector
- Host: GitHub
- URL: https://github.com/rebase-energy/emflow
- Owner: rebase-energy
- License: mit
- Created: 2024-01-09T20:16:08.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2026-08-07T16:18:09.000Z (7 days ago)
- Last Synced: 2026-08-09T22:39:02.416Z (4 days ago)
- Topics: energy, gymnasium, modelling, openai-gym, python, sequential-decision-making-problems
- Language: Jupyter Notebook
- Homepage: https://enflow.org
- Size: 59.4 MB
- Stars: 73
- Watchers: 4
- Forks: 6
- Open Issues: 1
- Releases: 0
-
Metadata Files:
- Readme: README.md
README.md
emflow is an open-source Python framework that enables energy data scientists and modellers to write modular and reproducible energy models that solves sequential decision problems. It is based on both OpenAI Gym (now Gymnasium) and Warran Powell's universal sequential decision framework. emflow lets you:
- ๐ค๏ธ Structure your code as modular and reusable components and adopt the "model first, then solve"-mantra;
- ๐ฑ Forumate your problems with datasets, environments and objectives;
- ๐๏ธ Build agents, predictors, optimizers and simulators to solve sequential decision problems;
- ๐งช Run parametrized experiments that generate reproducible results (code, data and parameters); and
- โฟ Run sweeps for benchmarking, scenario analysis and parameter tuning.
โฌ๏ธ Installation
โ|โ
๐ Documentation
โ|โ
๐ Try out now in Colab
โ|โ
๐ Join Slack Community
The Sequential Decision Loop
emflow allows to model sequential decison problems, where state information $S_t$ is provided, an action $a_t=A^{\pi}(S_t)$ is taken, exogenous information $W_{t+1}$ is revealed, whereby a new state $S_{t+1} = S^M(S_t, a_t, W_{t+1})$ is encountered and a cost/contribution $C(S_t,a_t,W_{t+1})$ can be calculated. The sequential decision loop then repeats until the end of the evaluation/problem time.

The goal is to find an agent policy $\pi$ that maximizes the contribution (or minimizes the cost) over the full time horizon $t \in [0, T]$. Mathematically formulated as:
$$
\begin{equation*}
\begin{aligned}
\max_{\pi \in \Pi} \quad & \mathbb{E}^{\pi} \bigg[ \sum_{t=0}^T C(S_t,A^{\pi}(S_t),W_{t+1}) \bigg| S_0 \bigg] \
\textrm{s.t.} \quad & S_{t+1} = S^M(S_t,a_t,W_{t+1})\
\end{aligned}
\end{equation*}
$$
Modules and Components
emflow consists of a set of components that serve as building blocks to create modular and reusable energy models. One of the main dependencies is EnergyDataModel that provides functionality to represent energy systems. The table below gives a summary of the available modules and concepts.
| Module | Components |
|---|---|
๐ย assets |
All energy asset and concept components defined by EnergyDataModel |
๐๏ธย data |
Field, Dataset, DataPortal โ point-in-time data access with availability semantics (leak-proof by construction) |
๐งฉย problems |
Problem, IssueSchedule, Objective, metrics (pinball, MAE, RMSE, peak timing, trading revenue) |
๐ย envs |
ForecastEnv, TradingEnv โ rolling-origin evaluation on the gymnasium API |
๐งฎย features |
Lag, Rolling, ForecastField, Calendar โ declarative, point-in-time-correct feature specs |
๐คย models |
Model, Predictor, Simulator, Optimizer, Agent |
โป๏ธย run |
Experiment, Result, Verifier, analyzers |
๐ย benchmarks |
Historical competition problems: heftcom2024 (forecasting + trading), gefcom2012/2014/2017, bfcom2018, bigdeal2022 |
Below is a diagram of the components' relation to each other and how they together enable creation of reproducible results from energy models.

Framework 6-Step Approach
emflow is about adopting a problem-centric, stepwise approach that follows the "model first, then solve"-mantra. The idea is to first gain a deep problem understanding before rushing to the solution. Or as Albert Einstien expressed it:
"If I had an hour to solve a problem I'd spend 55 minutes thinking about the problem and five minutes thinking about solutions."
Concretely, this means that problems are solved through the following steps:
- Define the considered energy system;
- Define state, action and exogenous variables;
- Create the environment and the transition function;
- Define the objective (cost or contribution);
- Create the model (simulator, predictor, optimizer and/or agent) to operate in environment; and
- Run the sequential decision loop and evaluate performance.
Steps 1-4 are about understanding the problem and steps 5-6 are about creating and evaluating the solution.
Basic Usage
A benchmark problem bundles a dataset, an environment factory, a schedule, an
objective and temporal splits. Load one, run a model through an Experiment,
and inspect the Result:
import emflow as ef
from emflow.benchmarks.heftcom2024.baseline import BinnedQuantileBaseline
problem = ef.load_problem("heftcom2024:forecasting") # a real competition
result = ef.Experiment(problem, BinnedQuantileBaseline()).run()
print(result.score) # pinball loss on the validation split
print(result.analysis["PersistenceSkill"]) # skill vs the persistence baseline
print(result.rank_against(problem)) # place on the official 2024 leaderboard
Every observation a model sees is served through the point-in-time
DataPortal, so
look-ahead leakage is impossible by construction โ which is what makes the
scores trustworthy for agent benchmarking. Untrusted submissions are scored
with the Verifier
on a held-out split whose labels live in a private repo (see
submissions/README.md).
Installation
We recommend installing using a virtual environment like venv, poetry or uv.
Install the stable release:
pip install emflow
Install the latest release:
pip install git+https://github.com/rebase-energy/emflow.git
Install in editable mode for development:
git clone https://github.com/rebase-energy/EnergyDataModel.git
git clone https://github.com/rebase-energy/emflow.git
cd emflow
pip install -e .[dev]
pip install -e ../EnergyDataModel[dev]
Ways to Contribute
We welcome contributions from anyone interested in this project! Here are some ways to contribute to emflow:
- Create a new environment;
- Create a new energy model (simulator, predictor, optimizer or agent);
- Create a new objective function; or
- Create an integration with another energy modelling framework.
If you are interested in contributing, then feel free to join our Slack Community so that we can discuss it.
Contributors
This project uses allcontributors.org to recognize all contributors, including those that don't push code.
Licence
This project uses the MIT Licence.
Acknowledgement
The authors of this project would like to thank the Swedish Energy Agency for their financial support under the E2B2 program (project number P2022-00903)
Owner metadata
- Name: rebase.energy
- Login: rebase-energy
- Email:
- Kind: organization
- Description:
- Website: https://www.rebase.energy/
- Location: Stockholm
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/68502348?v=4
- Repositories: 27
- Last ynced at: 2026-06-15T16:31:13.540Z
- Profile URL: https://github.com/rebase-energy
GitHub Events
Total
- Fork event: 1
- Watch event: 1
- Push event: 1
Last Year
- Fork event: 1
- Watch event: 1
- Push event: 1
Committers metadata
Last synced: 1 day ago
Total Commits: 137
Total Committers: 4
Avg Commits per committer: 34.25
Development Distribution Score (DDS): 0.35
Commits in past year: 26
Committers in past year: 1
Avg Commits per committer in past year: 26.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| sebaheg | s****n@r****y | 89 |
| Sebastian Haglund | s****g@S****l | 38 |
| allcontributors[bot] | 4****] | 6 |
| dimili | i****s@g****m | 4 |
Committer domains:
Issue and Pull Request metadata
Last synced: about 1 month ago
Total issues: 0
Total pull requests: 1
Average time to close issues: N/A
Average time to close pull requests: 2 minutes
Total issue authors: 0
Total pull request authors: 1
Average comments per issue: 0
Average comments per pull request: 0.0
Merged pull request: 1
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 1
Past year average time to close issues: N/A
Past year average time to close pull requests: 2 minutes
Past year issue authors: 0
Past year pull request authors: 1
Past year average comments per issue: 0
Past year average comments per pull request: 0.0
Past year merged pull request: 1
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
Top Pull Request Authors
- sebaheg (1)
Top Issue Labels
Top Pull Request Labels
Package metadata
- Total packages: 1
-
Total downloads:
- pypi: 176 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 8
- Total maintainers: 1
pypi.org: emflow
โก Open-source framework for sequential decision problems in the energy sector
- Homepage: https://emflow.org
- Documentation: https://docs.emflow.org/en/latest
- Licenses: MIT
- Latest release: 0.3.1 (published 7 days ago)
- Last Synced: 2026-08-12T19:22:02.101Z (1 day ago)
- Versions: 8
- Dependent Packages: 0
- Dependent Repositories: 1
- Downloads: 176 Last month
-
Rankings:
- Dependent packages count: 10.095%
- Dependent repos count: 21.615%
- Average: 23.765%
- Downloads: 39.585%
- Maintainers (1)
Dependencies
- Sphinx ==4.2.0
- sphinx_rtd_theme *
- energydatamodel *
- gymnasium *
- pandas *
- pytz *
- 116 dependencies
Score: 10.872143004616145