enflow
⚡ Open-source Python framework for modelling sequential decision problems in the energy sector
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.9%) to scientific vocabulary
Keywords
Repository
⚡ Open-source Python framework for modelling sequential decision problems in the energy sector
Basic Info
- Host: GitHub
- Owner: rebase-energy
- License: mit
- Language: Jupyter Notebook
- Default Branch: main
- Homepage: https://enflow.org
- Size: 54.2 MB
Statistics
- Stars: 59
- Watchers: 4
- Forks: 4
- Open Issues: 1
- Releases: 0
Topics
Metadata Files
README.md
⚡ Open-source Python framework for modelling sequential decision problems in the energy sector
enflow 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. enflow 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
enflow allows to model sequential decison problems, where state information $S_t$ is provided, an action $at=A^{\pi}(St)$ is taken, exogenous information $W_{t+1}$ is revealed, whereby a new state $S{t+1} = S^M(St, at, W{t+1})$ is encountered and a cost/contribution $C(St,at,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(St,A^{\pi}(St),W{t+1}) \bigg| S0 \bigg] \ \textrm{s.t.} \quad & S{t+1} = S^M(St,at,W{t+1})\ \end{aligned} \end{equation} $$
Modules and Components
enflow 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 |
| :---- | :---- |
| 🔋 energysystem | All energy asset and concept components defined by EnergyDataModel |
| 📦 spaces | BaseSpace, InputSpace, StateSpace, OutputSpace,ActionSpace |
| 🧩 problems | Dataset, Environment, Objective |
| 🤖 models | Model, Simulator, Predictor, Optimizer, Agent |
| ➡️ experiments | Experiment, Benchmark, Scenario|
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
enflow 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
In enflow, a reproducible experiment is represented by the following 4 components:
Given a defined dataset, env (environment), agent (model) and obj (objective), the sequential decision loop is given by:
```python
First your code to define dataset, env, agent and obj, here.
env = Environment(dataset=dataset) agent = Agent(dataset=dataset) obj = Objective(dataset=dataset)
state = env.reset() done = False while done is not True: action = agent.act(state) state, exogeneous, done, info = env.step(action) cost = obj.calculate(state, action, exogeneous)
env.close() ```
For a full walkthrough go to the documentation or open in Colab.
Installation
We recommend installing using a virtual environment like venv, poetry or uv.
Install the stable release:
bash
pip install enflow
Install the latest release:
bash
pip install git+https://github.com/rebase-energy/enflow.git
Install in editable mode for development:
bash
git clone https://github.com/rebase-energy/EnergyDataModel.git
git clone https://github.com/rebase-energy/enflow.git
cd enflow
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 enflow:
- 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.
Sebastian Haglund 💻 |
dimili 💻 |
Mihai Chiru 💻 |
Nelson 🤔 |
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
- Name: rebase.energy
- Login: rebase-energy
- Kind: organization
- Location: Stockholm
- Website: http://rebase.energy/
- Repositories: 2
- Profile: https://github.com/rebase-energy
GitHub Events
Total
- Watch event: 22
- Push event: 32
- Fork event: 2
Last Year
- Watch event: 22
- Push event: 32
- Fork event: 2
Committers
Last synced: 6 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| sebaheg | s****n@r****y | 63 |
| Sebastian Haglund | s****g@S****l | 38 |
| allcontributors[bot] | 4****]@u****m | 6 |
| dimili | i****s@g****m | 4 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 26 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 3
- Total maintainers: 1
pypi.org: enflow
⚡ Open-source framework for sequential decision problems in the energy sector
- Documentation: https://enflow.readthedocs.io/
- License: MIT
-
Latest release: 0.0.3
published 11 months ago
Rankings
Maintainers (1)
Dependencies
- Sphinx ==4.2.0
- sphinx_rtd_theme *
- energydatamodel *
- gymnasium *
- pandas *
- pytz *
- 116 dependencies