A curated list of open technology projects to sustain a stable climate, energy supply, biodiversity and natural resources.

enerflow

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/enflow

Keywords

energy gymnasium modelling openai-gym python sequential-decision-making-problems

Keywords from Contributors

simulator

Last synced: 3 days ago
JSON representation

Acceptance Criteria

Repository metadata

โšก Open-source Python framework for modelling sequential decision problems in the energy sector

README.md

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 $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.

Sequential decision loop

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

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.

enflow Framework Structure

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:

  1. Define the considered energy system;
  2. Define state, action and exogenous variables;
  3. Create the environment and the transition function;
  4. Define the objective (cost or contribution);
  5. Create the model (simulator, predictor, optimizer and/or agent) to operate in environment; and
  6. 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:

# 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:

pip install enflow

Install the latest release:

pip install git+https://github.com/rebase-energy/enflow.git

Install in editable mode for development:

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.

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


GitHub Events

Total
Last Year

Committers metadata

Last synced: 6 days ago

Total Commits: 111
Total Committers: 4
Avg Commits per committer: 27.75
Development Distribution Score (DDS): 0.432

Commits in past year: 46
Committers in past year: 1
Avg Commits per committer in past year: 46.0
Development Distribution Score (DDS) in past year: 0.0

Name Email Commits
sebaheg s****n@r****y 63
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: 4 days ago

Total issues: 1
Total pull requests: 3
Average time to close issues: N/A
Average time to close pull requests: 2 minutes
Total issue authors: 1
Total pull request authors: 1
Average comments per issue: 7.0
Average comments per pull request: 0.0
Merged pull request: 3
Bot issues: 0
Bot pull requests: 3

Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/rebase-energy/enflow

Top Issue Authors

  • sebaheg (1)

Top Pull Request Authors

  • allcontributors[bot] (3)

Top Issue Labels

Top Pull Request Labels


Package metadata

pypi.org: enflow

โšก Open-source framework for sequential decision problems in the energy sector

  • Homepage:
  • Documentation: https://enflow.readthedocs.io/
  • Licenses: MIT
  • Latest release: 0.0.3 (published about 1 month ago)
  • Last Synced: 2025-04-24T01:31:23.700Z (4 days ago)
  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 289 Last month
  • Rankings:
    • Dependent packages count: 10.279%
    • Average: 34.067%
    • Dependent repos count: 57.854%
  • Maintainers (1)

Dependencies

docs/requirements.txt pypi
  • Sphinx ==4.2.0
  • sphinx_rtd_theme *
requirements.txt pypi
  • Sphinx ==4.2.0
  • sphinx_rtd_theme *
setup.py pypi
  • energydatamodel *
  • gymnasium *
  • pandas *
  • pytz *
pyproject.toml pypi
  • energydatamodel *
  • gymnasium *
  • pandas *
  • pytz *

Score: 10.968198289528557