Grid2Op
A testbed platform to model sequential decision making in power systems.
https://github.com/Grid2op/grid2op
Category: Energy Systems
Sub Category: Grid Analysis and Planning
Keywords
grid2op gym-environments powergrid powergrid-operation reinforcement-learning reinforcement-learning-environments
Keywords from Contributors
baseline reinforcement-learning-algorithms grid kpi power-systems load-flow powerflow
Last synced: 23 minutes ago
JSON representation
Repository metadata
Grid2Op a testbed platform to model sequential decision making in power systems.
- Host: GitHub
- URL: https://github.com/Grid2op/grid2op
- Owner: Grid2op
- License: mpl-2.0
- Created: 2019-10-10T17:04:46.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-04-15T14:20:31.000Z (13 days ago)
- Last Synced: 2025-04-26T08:01:47.197Z (2 days ago)
- Topics: grid2op, gym-environments, powergrid, powergrid-operation, reinforcement-learning, reinforcement-learning-environments
- Language: Python
- Homepage: https://grid2op.readthedocs.io/
- Size: 85.4 MB
- Stars: 336
- Watchers: 20
- Forks: 126
- Open Issues: 58
- Releases: 35
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.rst
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
- Authors: AUTHORS.txt
README.md
Grid2Op
Grid2Op is a platform, built with modularity in mind, that allows to perform powergrid operation.
And that's what it stands for: Grid To Operate.
It is used as a library used for the Learning To Run Power Network L2RPN,
but also for research purpose (especially by the Reinforcement Learning community applied to power system)
This framework allows to perform most kind of powergrid operations, from modifying the setpoint of generators,
to load shedding, performing maintenance operations or modifying the topology of a powergrid
to solve security issues.
Official documentation: the official documentation is available at
https://grid2op.readthedocs.io/.
- 1 Installation
- 2 Main features of Grid2Op
- 3 Getting Started
- 4 Citing
- 5 Documentation
- 6 Contribute
- 7 Test and known issues
- 8 License information
Installation
Requirements
- Python >= 3.6
Setup a Virtualenv (optional)
Create a virtual environment
cd my-project-folder
pip3 install -U virtualenv
python3 -m virtualenv venv_grid2op
Enter virtual environment
source venv_grid2op/bin/activate
Install from PyPI
pip3 install grid2op
Install from source
git clone https://github.com/grid2op/Grid2Op.git
cd Grid2Op
pip3 install -U .
cd ..
Install for contributors
git clone https://github.com/grid2op/Grid2Op.git
cd Grid2Op
pip3 install -e .
pip3 install -e .[optional]
pip3 install -e .[docs]
Docker
Grid2Op docker containers are available on dockerhub.
To install the latest Grid2Op container locally, use the following:
docker pull bdonnot/grid2op:latest
Main features of Grid2Op
Core functionalities
Built with modulartiy in mind, Grid2Op is a library used for the "Learning To Run Power Network" L2RPN
competitions series. It can also
Its main features are:
- emulates the behavior of a powergrid of any size at any format (provided that a backend is properly implemented)
- allows for grid modifications (active and reactive load values, generator voltages setpoints, active production but most
importantly grid topology beyond powerline connection / disconnection) - allows for maintenance operations and powergrid topological changes
- can adopt any powergrid modeling, especially Alternating Current (AC) and Direct Current (DC) approximation to
when performing the compitations - supports changes of powerflow solvers, actions, observations to better suit any need in performing power system operations modeling
- has an RL-focused interface, compatible with OpenAI-gym: same interface for the
Environment class. - parameters, game rules or type of actions are perfectly parametrizable
- can adapt to any kind of input data, in various format (might require the rewriting of a class)
Powerflow solver
Grid2Op relies on an open source powerflow solver (PandaPower),
but is also compatible with other Backend. If you have at your disposal another powerflow solver,
the documentation of grid2op/Backend can help you integrate it into a proper "Backend"
and have Grid2Op using this powerflow instead of PandaPower.
Getting Started
Some Jupyter notebook are provided as tutorials for the Grid2Op package. They are located in the
getting_started directories.
TODO: this needs to be redone, refactorize and better explained for some of them.
These notebooks will help you in understanding how this framework is used and cover the most
interesting part of this framework:
- 00_Introduction
and 00_SmallExample
describe what is
adressed by the grid2op framework (with a tiny introductions to both power systems and reinforcement learning)
and give and introductory example to a small powergrid manipulation. - 01_Grid2opFramework
covers the basics
of the
Grid2Op framework. It also covers how to create a valid environment and how to use the
Runner
class to assess how well an agent is performing rapidly. - 02_Observation
details how to create
an "expert agent" that will take pre defined actions based on the observation it gets from
the environment. This Notebook also covers the functioning of the BaseObservation class. - 03_Action
demonstrates
how to use the BaseAction class and how to manipulate the powergrid. - 04_TrainingAnAgent
shows how to get started with
reinforcement learning with the grid2op environment. It shows the basic on how to train a "PPO" model operating the grid relying on "stable baselines 3" PPO implementation. - 05_StudyYourAgent
shows how to study an BaseAgent, for example
the methods to reload a saved experiment, or to plot the powergrid given an observation for
example. This is an introductory notebook. More user friendly graphical interface should
come soon. - 06_Redispatching_Curtailment
explains what is the
"redispatching" and curtailment from the point
of view of a company who's in charge of keeping the powergrid safe (aka a Transmission System Operator) and how to
manipulate this concept in grid2op. Redispatching (and curtailment) allows you to perform continuous
actions on the powergrid
problem. - 07_MultiEnv
details how grid2op natively support a single agent interacting
with multiple environments at the same time. This is particularly handy to train "asynchronous" agent in the
Reinforcement Learning community for example. - 08_PlottingCapabilities
shows you the different ways with which you
can represent (visually) the grid your agent interact with. A renderer is available like in many open AI gym
environment. But you also have the possibility to post process an agent and make some movies out of it, and we also
developed a Graphical User Interface (GUI) called "grid2viz" that allows
to perform in depth study of your agent's behaviour on different scenarios and even to compare it with baselines. - 09_EnvironmentModifications
elaborates on the maintenance,
hazards
and attacks. All three of these represents external events that can disconnect some powerlines. This notebook
covers how to spot when such things happened and what can be done when the maintenance or the attack is over. - 10_StorageUnits
details the usage and behaviour of the storage units
in grid2op. - 11_IntegrationWithExistingRLFrameworks
explains how to use grid2op with other reinforcement learning framework. TODO: this needs to be redone - 12_DetachmentOfLoadsAndGenerators.ipynb
explains briefly what is detachment.
Try them out in your own browser without installing
anything with the help of mybinder:
Or thanks to google colab (all links are provided near the notebook description)
Citing
If you use this package in one of your work, please cite:
@software{grid2op,
author = {B. Donnot},
title = {{Grid2op- A testbed platform to model sequential decision making in power systems. }},
url = {\url{https://GitHub.com/Grid2Op/grid2op}},
year = {2020},
publisher = {GitHub},
}
Documentation
The official documentation is available at
https://grid2op.readthedocs.io/.
Build the documentation locally
A copy of the documentation can be built if the project is installed from source:
you will need Sphinx, a Documentation building tool, and a nice-looking custom
Sphinx theme similar to the one of readthedocs.io. These
can be installed with:
pip3 install -U grid2op[docs]
This installs both the Sphinx package and the custom template.
Then, on systems where make
is available (mainly gnu-linux and macos) the documentation can be built with the command:
make html
For windows, or systems where make
is not available, the command:
sphinx-build -b html docs documentation
This will create a "documentation" subdirectory and the main entry point of the document will be located at
index.html.
It is recommended to build this documentation locally, for convenience.
For example, the "getting started" notebooks referenced some pages of the help.
Contributing
Please consult the "CONTRIBUTING.md" file for extra information. This is a summary and
in case of conflicting instructions, follow the one given in the CONTRIBUTING.md
file
and discard these ones.
We welcome contributions from everyone. They can take the form of pull requests for smaller changed.
In case of a major change (or if you have a doubt on what is "a small change"), please open an issue first
to discuss what you would like to change.
To contribute to this code, you need to:
- fork the repository located at https://github.com/Grid2Op/grid2op
- synch your fork with the "latest developement branch of grid2op". For example, if the latest grid2op release
on pypi is1.6.5
you need to synch your repo with the branch nameddev_1.6.6
ordev_1.7.0
(if
the branchdev_1.6.6
does not exist). It will be the highest number in the branchesdev_*
on
grid2op official github repository. - implement your functionality / code your modifications or anything else
- make sure to add tests and documentation if applicable
- once it is developed, synch your repo with the last development branch again (see point 2 above) and
make sure to solve any possible conflicts - write a pull request and make sure to target the right branch (the "last development branch")
Code in the contribution should pass all the tests, have some dedicated tests for the new feature (if applicable)
and documentation (if applicable).
Before implementing any major feature, please write a github issue first.
Tests and known issues
Tests performed currently
Grid2op is currently tested on windows, linux and macos.
The unit tests includes testing, on linux machines the correct integration of grid2op with:
- python 3.8
- python 3.9
- python 3.10
- python 3.11
- python 3.12
On all of these cases, we tested grid2op on all available numpy versions >= 1.20 (nb available numpy versions depend
on python version).
The complete test suit is run on linux with the latest numpy version on python 3.10.
Known issues
Multi processing
Due to the underlying behaviour of the "multiprocessing" package on windows based python versions,
the "multiprocessing" of the grid2op "Runner" is not supported on windows. This might change in the future,
but it is currently not on our priorities.
A quick fix that is known to work include to set the experimental_read_from_local_dir
when creating the
environment with grid2op.make(..., experimental_read_from_local_dir=True)
(see doc for more information)
Sometimes, on some configuration (python version) we do not recommend to use grid2op with pandas>=2.2
If you encounter any trouble, please downgrade to pandas<2.2. This behaviour occured in our continuous
integration environment for python >=3.9 but could not be reproduced locally.
python 3.11
Some version of grid2op (eg 1.6.3) are not compatible with python 3.10 or 3.11.
Either use python version 3.8 or 3.9 or upgrade grid2op (1.6.5 works) if that is the case.
Perform tests locally
Provided that Grid2Op is installed from source:
Install additional dependencies
pip3 install -U grid2op[optional]
Launch tests
cd grid2op/tests
python3 -m unittest discover
License information
Copyright 2019-2020 RTE France
RTE: http://www.rte-france.com
This Source Code is subject to the terms of the Mozilla Public License (MPL) v2 also available
here
Owner metadata
- Name: Grid2op
- Login: Grid2op
- Email:
- Kind: organization
- Description:
- Website:
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/184606084?v=4
- Repositories: 1
- Last ynced at: 2024-10-15T07:31:00.856Z
- Profile URL: https://github.com/Grid2op
GitHub Events
Total
- Create event: 9
- Release event: 6
- Issues event: 27
- Watch event: 48
- Delete event: 7
- Member event: 1
- Issue comment event: 256
- Push event: 37
- Pull request review comment event: 35
- Pull request review event: 37
- Pull request event: 60
- Fork event: 12
Last Year
- Create event: 9
- Release event: 6
- Issues event: 27
- Watch event: 48
- Delete event: 7
- Member event: 1
- Issue comment event: 256
- Push event: 37
- Pull request review comment event: 35
- Pull request review event: 37
- Pull request event: 60
- Fork event: 12
Committers metadata
Last synced: 7 days ago
Total Commits: 2,658
Total Committers: 30
Avg Commits per committer: 88.6
Development Distribution Score (DDS): 0.306
Commits in past year: 356
Committers in past year: 3
Avg Commits per committer in past year: 118.667
Development Distribution Score (DDS) in past year: 0.098
Name | Commits | |
---|---|---|
DONNOT Benjamin | b****t@r****m | 1845 |
Tezirg | j****t@g****m | 453 |
Laure CROCHEPIERRE | l****e@r****m | 56 |
GoubetClem | c****b@g****m | 52 |
marota | a****t@l****r | 50 |
Vincent Renault | v****7@g****m | 46 |
Loic | l****s@f****r | 40 |
Xavier Weiss | x****w@k****e | 34 |
mjothy | m****y@a****m | 24 |
mmohandi | m****i@a****m | 9 |
JochenC | 3****C | 7 |
Eva BOGUSLAWSKI | e****i@g****m | 7 |
Tezirg | j****t@r****m | 6 |
dejaegherjer | j****r@r****m | 5 |
Farid-Najar | f****8@g****m | 4 |
fmarten | f****n@i****e | 4 |
mowang | 3****8@z****n | 2 |
Ubuntu | u****u@i****l | 2 |
Benedikt | b****h@g****m | 1 |
anton | a****r@e****i | 1 |
Vincent Renault | v****t@a****m | 1 |
Brett Witherspoon | b****t@w****m | 1 |
Florian Schaefer | f****r@u****e | 1 |
Gaëtan Serré | 5****e | 1 |
Kamil A. Kaczmarek | k****k@n****i | 1 |
Mehdy | 4****1 | 1 |
Talha Rehman | 1****T | 1 |
Tom Davies | t****n | 1 |
jeffw | j****t@g****m | 1 |
wduguay-air | w****m@a****m | 1 |
Committer domains:
- rte-france.com: 4
- artelys.com: 3
- ai-r.com: 1
- neptune.ai: 1
- uni-kassel.de: 1
- witherspoondesign.com: 1
- enlite.ai: 1
- ip-172-31-4-42.eu-central-1.compute.internal: 1
- zju.edu.cn: 1
- iee.fraunhofer.de: 1
- kth.se: 1
- free.fr: 1
- live.fr: 1
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 147
Total pull requests: 135
Average time to close issues: 3 months
Average time to close pull requests: 8 days
Total issue authors: 35
Total pull request authors: 16
Average comments per issue: 2.59
Average comments per pull request: 0.65
Merged pull request: 108
Bot issues: 0
Bot pull requests: 1
Past year issues: 39
Past year pull requests: 64
Past year average time to close issues: 2 months
Past year average time to close pull requests: 11 days
Past year issue authors: 12
Past year pull request authors: 8
Past year average comments per issue: 1.64
Past year average comments per pull request: 1.17
Past year merged pull request: 55
Past year bot issues: 0
Past year bot pull requests: 1
Top Issue Authors
- BDonnot (53)
- DEUCE1957 (11)
- EBoguslawski (9)
- Tezirg (9)
- jhmenke (9)
- marota (6)
- camiloromers (5)
- sunghoonhong (4)
- pwdemars (3)
- GonFreecsHxH (3)
- MatthijsdeJ (3)
- ML-IEE (2)
- djmax008 (2)
- mariegirod (2)
- mhassouna95 (2)
Top Pull Request Authors
- BDonnot (103)
- DEUCE1957 (7)
- Tezirg (6)
- vinault (3)
- marota (2)
- EBoguslawski (2)
- BamunugeDR99 (2)
- YacineAbd (2)
- loriab (1)
- FlorianShepherd (1)
- emesk (1)
- dependabot[bot] (1)
- zhouk2020 (1)
- benedikt-schesch (1)
- Ashargin (1)
Top Issue Labels
- enhancement (55)
- bug (46)
- documentation (15)
- help wanted (7)
- good first issue (1)
- version 2.0 (1)
- cannot_reproduce (1)
- question (1)
Top Pull Request Labels
- dependencies (1)
Package metadata
- Total packages: 1
-
Total downloads:
- pypi: 3,082 last-month
- Total dependent packages: 8
- Total dependent repositories: 16
- Total versions: 91
- Total maintainers: 1
pypi.org: grid2op
An gymnasium compatible environment to model sequential decision making for powersystems
- Homepage: https://github.com/Grid2Op/grid2op
- Documentation: https://grid2op.readthedocs.io/
- Licenses: Mozilla Public License 2.0 (MPL 2.0)
- Latest release: 1.11.0 (published 13 days ago)
- Last Synced: 2025-04-27T08:30:38.365Z (1 day ago)
- Versions: 91
- Dependent Packages: 8
- Dependent Repositories: 16
- Downloads: 3,082 Last month
-
Rankings:
- Dependent packages count: 2.156%
- Dependent repos count: 3.668%
- Average: 4.144%
- Stargazers count: 4.245%
- Forks count: 4.494%
- Downloads: 6.157%
- Maintainers (1)
Dependencies
- python 3.8-buster build
- actions/checkout v1 composite
- actions/download-artifact v2 composite
- actions/setup-python v2 composite
- actions/upload-artifact v2 composite
- grid2op *
- imageio *
- jyquickhelper *
- keras *
- l2rpn-baselines *
- numba *
- numpy *
- plotly *
- ray *
- seaborn *
Score: 17.418961200353138