enerflow 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. enerflow 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 Community Slack
enerflow allows to model sequential decison problems, where state information
The goal is to find an agent policy
enerflow 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 , OutputSpace StateSpace ActionSpace |
🧩 problems |
Dataset , Environment , Objective |
🤖 models |
Model , Simulator , Predictor , Optimizer , Agent |
➡️ experiment |
Experiment |
Below is a diagram of the components' relation to each other and how they together enable creation of reproducible results from energy models.
enerflow 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.
In enerflow, 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:
# Create the env, agent and obj. Your code goes in defining these classes.
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.
Install the stable release:
pip install enerflow
Install the latest release:
pip install git+https://github.com/rebase-energy/enerflow
Install in editable mode for development:
git clone https://github.com/rebase-energy/enerflow.git
cd enerflow
pip install -e .
We welcome contributions from anyone interested in this project! Here are some ways to contribute to enerflow:
- 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 Community Slack so that we can discuss it.
This project uses allcontributors.org to recognize all contributors, including those that don't push code.
Sebastian Haglund 💻 |
dimili 💻 |
Mihai Chiru 💻 |
Nelson 🤔 |
This project uses the MIT Licence.