{"id":25965915,"url":"https://github.com/rebase-energy/enerflow","last_synced_at":"2025-03-04T22:01:57.043Z","repository":{"id":216947844,"uuid":"741156834","full_name":"rebase-energy/enflow","owner":"rebase-energy","description":"⚡ Open-source Python framework for modelling sequential decision problems in the energy sector","archived":false,"fork":false,"pushed_at":"2024-11-06T20:43:01.000Z","size":42771,"stargazers_count":36,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-07T09:19:24.375Z","etag":null,"topics":["energy","gymnasium","modelling","openai-gym","python","sequential-decision-making-problems"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rebase-energy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-09T20:16:08.000Z","updated_at":"2024-11-06T20:43:04.000Z","dependencies_parsed_at":"2024-11-06T21:38:15.593Z","dependency_job_id":null,"html_url":"https://github.com/rebase-energy/enflow","commit_stats":{"total_commits":75,"total_committers":4,"mean_commits":18.75,"dds":0.4933333333333333,"last_synced_commit":"b0e51080337cae39577d7287916c3e62b2f53df7"},"previous_names":["rebase-energy/emflow","rebase-energy/enerflow","rebase-energy/enflow"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebase-energy%2Fenflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebase-energy%2Fenflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebase-energy%2Fenflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebase-energy%2Fenflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rebase-energy","download_url":"https://codeload.github.com/rebase-energy/enflow/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240105437,"owners_count":19748463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["energy","gymnasium","modelling","openai-gym","python","sequential-decision-making-problems"],"created_at":"2025-03-04T22:00:50.351Z","updated_at":"2025-03-04T22:01:57.027Z","avatar_url":"https://github.com/rebase-energy.png","language":"Jupyter Notebook","readme":"\u003cdiv align=\"center\"\u003e\n\t\u003cimg width=\"300\" src=\"https://github.com/rebase-energy/enerflow/blob/main/assets/enerflow-logo.png?raw=true\" alt=\"enerflow\"\u003e\n\u003ch2 style=\"margin-top: 0px;\"\u003e\n    ⚡ Open-source Python framework for modelling sequential decision problems in the energy sector\n\u003c/h2\u003e\n\u003c/div\u003e\n\n[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)\n[![PyPI version](https://badge.fury.io/py/enerflow.svg)](https://badge.fury.io/py/enerflow) \n[![All Contributors](https://img.shields.io/github/all-contributors/rebase-energy/enerflow?color=ee8449\u0026style=flat-square)](#contributors)\n[![Join us on Slack](https://img.shields.io/badge/Join%20us%20on%20Slack-%2362BEAF?style=flat\u0026logo=slack\u0026logoColor=white)](https://join.slack.com/t/rebase-community/shared_invite/zt-1dtd0tdo6-sXuCEy~zPnvJw4uUe~tKeA) \n[![GitHub Repo stars](https://img.shields.io/github/stars/rebase-energy/enerflow?style=social)](https://github.com/rebase-energy/enerflow)\n\n**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](https://github.com/Farama-Foundation/Gymnasium)) and [Warran Powell's universal sequential decision framework](https://castle.princeton.edu/rlso/). **enerflow** lets you: \n\n* 🛤️ Structure your code as modular and reusable components and adopt the \"model first, then solve\"-mantra;\n* 🌱 Forumate your problems with datasets, environments and objectives;\n* 🏗️ Build agents, predictors, optimizers and simulators to solve sequential decision problems;\n* 🧪 Run parametrized experiments that generate reproducible results (code, data and parameters); and\n* ➿ Run sweeps for benchmarking, scenario analysis and parameter tuning.\n\n**⬇️ [Installation](#installation)**\n\u0026ensp;|\u0026ensp;\n**📖 [Documentation](https://docs.energydatamodel.org/en/latest/)**\n\u0026ensp;|\u0026ensp;\n**🚀 [Try out now in Colab](https://colab.research.google.com/github/rebase-energy/enerflow/blob/main/enerflow/examples/heftcom2024/notebook.ipynb)**\n\u0026ensp;|\u0026ensp;\n**👋 [Join Community Slack](https://join.slack.com/t/rebase-community/shared_invite/zt-1dtd0tdo6-sXuCEy~zPnvJw4uUe~tKeA)**\n\n## The Sequential Decision Loop\n**enerflow** 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. \n\n![Sequential decision loop](assets/sequential-decision-loop.png)\n\nThe 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: \n\n$$\n\\begin{equation*}\n\\begin{aligned}\n\\max_{\\pi \\in \\Pi} \\quad \u0026 \\mathbb{E}^{\\pi} \\bigg[ \\sum_{t=0}^T C(S_t,A^{\\pi}(S_t),W_{t+1}) \\bigg| S_0 \\bigg] \\\\\n\\textrm{s.t.} \\quad \u0026 S_{t+1} = S^M(S_t,a_t,W_{t+1})\\\\\n\\end{aligned}\n\\end{equation*}\n$$\n\n## Modules and Components\n**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](https://github.com/rebase-energy/EnergyDataModel) that provides functionality to represent energy systems. The table below gives a summary of the available modules and concepts.\n\n| Module         | Components     |\n| :----          | :----            |\n| 🔋\u0026nbsp;`energysystem` | All energy asset and concept components defined by [EnergyDataModel](https://github.com/rebase-energy/EnergyDataModel) | \n| 📦\u0026nbsp;`spaces` | [`BaseSpace`](), [`InputSpace`](), [`OutputSpace`]() [`StateSpace`]() [`ActionSpace`]() | \n| 🧩\u0026nbsp;`problems` | [`Dataset`](), [`Environment`](), [`Objective`]() | \n| 🤖\u0026nbsp;`models` | [`Model`](), [`Simulator`](), [`Predictor`](), [`Optimizer`](), [`Agent`]() | \n| ➡️\u0026nbsp;`experiment` | [`Experiment`]()| \n\nBelow is a diagram of the components' relation to each other and how they together enable creation of reproducible results from energy models. \n\n![enerflow Framework Structure](assets/enerflow-framework-structure.png)\n\n## Framework 6-Step Approach\n**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: \n\n\u003e **\"If I had an hour to solve a problem I'd spend 55 minutes thinking about the problem and five minutes thinking about solutions.\"**\n\nConcretely, this means that problems are solved through the following steps: \n\n1. Define the considered **energy system**;\n2. Define **state**, **action** and **exogenous** variables;\n3. Create the **environment** and the transition function;\n4. Define the **objective** (cost or contribution);\n5. Create the **model** (simulator, predictor, optimizer and/or agent) to operate in environment; and\n6. Run the **sequential decision loop** and evaluate performance.\n\nSteps 1-4 are about understanding the **problem** and steps 5-6 are about creating and evaluating the **solution**. \n\n## Basic Usage\nIn **enerflow**, a reproducible experiment is represented by the following 4 components: \n\n* [`Dataset`]()\n* [`Environment`]()\n* [`Agent`]()\n* [`Objective`]()\n\nGiven a defined `dataset`, `env` (environment), `agent` (model) and `obj` (objective), the sequential decision loop is given by: \n\n```python\n# Create the env, agent and obj. Your code goes in defining these classes. \nenv = Environment(dataset=dataset)\nagent = Agent(dataset=dataset)\nobj = Objective(dataset=dataset)\n\nstate = env.reset()\ndone = False\nwhile done is not True:\n    action = agent.act(state)\n    state, exogeneous, done, info = env.step(action)\n    cost = obj.calculate(state, action, exogeneous)\n\nenv.close()\n```\n\nFor a full walkthrough go to the [documentation](https://docs.enerflow.org/en/latest/walkthrough.html#) or open in [Colab](https://colab.research.google.com/github/rebase-energy/enerflow/blob/main/enerflow/examples/walkthrough/notebook.ipynb). \n\n## Installation\nInstall the **stable** release: \n```bash\npip install enerflow\n```\n\nInstall the **latest** release: \n```bash\npip install git+https://github.com/rebase-energy/enerflow\n```\n\nInstall in editable mode for **development**: \n```bash\ngit clone https://github.com/rebase-energy/enerflow.git\ncd enerflow\npip install -e . \n```\n\n## Ways to Contribute\nWe welcome contributions from anyone interested in this project! Here are some ways to contribute to **enerflow**:\n\n* Create a new environment; \n* Create a new energy model (simulator, predictor, optimizer or agent); \n* Create a new objective function; or\n* Create an integration with another energy modelling framework.\n\nIf you are interested in contributing, then feel free to join our [Community Slack](https://join.slack.com/t/rebase-community/shared_invite/zt-1dtd0tdo6-sXuCEy~zPnvJw4uUe~tKeA) so that we can discuss it. \n\n## Contributors\nThis project uses [allcontributors.org](https://allcontributors.org/) to recognize all contributors, including those that don't push code. \n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/sebaheg\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/26311427?v=4?s=100\" width=\"100px;\" alt=\"Sebastian Haglund\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eSebastian Haglund\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#code-sebaheg\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/dimili\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/13037448?v=4?s=100\" width=\"100px;\" alt=\"dimili\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003edimili\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#code-dimili\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/rocipher\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/4830171?v=4?s=100\" width=\"100px;\" alt=\"Mihai Chiru\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMihai Chiru\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#code-rocipher\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/nelson-sommerfeldt\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/95913116?v=4?s=100\" width=\"100px;\" alt=\"Nelson\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eNelson\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-nelson-sommerfeldt\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\n## Licence\nThis project uses the [MIT Licence](LICENCE.md).  \n\n\n","funding_links":[],"categories":["Energy Systems"],"sub_categories":["Energy System Modeling Frameworks"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebase-energy%2Fenerflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frebase-energy%2Fenerflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebase-energy%2Fenerflow/lists"}