Expert system recommender for power grid contingency analysis based on ExpertOp4Grid principles.
Project description
ExpertOp4Grid Recommender
Expert system recommender for power grid contingency analysis based on ExpertOp4Grid principles. This tool analyzes N-1 contingencies in Grid2Op/pypowsybl environments, builds overflow graphs, applies expert rules to filter potential actions, and identifies relevant corrective measures to alleviate line overloads.
Features
- Contingency Simulation: Simulates N-1 contingencies in a Grid2Op environment.
- Overflow Graph Generation: Builds and visualizes overflow graphs using
alphaDeespandnetworkx. - Expert Rule Engine: Filters potential grid actions (line switching, topology changes) based on predefined rules derived from operator expertise.
- Action Prioritization: Identifies and scores relevant corrective actions (line reconnections, disconnections, node splitting/merging).
- Modular Structure: Organized code for better maintainability and testing.
Installation
-
Clone the repository:
git clone https://github.com/marota/Expert_op4grid_recommender.git cd Expert_op4grid_recommender
-
Recommended: Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the package and dependencies:
- Core dependencies: Make sure you have the necessary libraries installed. If
alphaDeespor specificgrid2opversions are not on PyPI, you might need to install them manually first according to their own instructions. - Install this package: For development (recommended), use editable mode:
pip install -e .
Or for a standard installation:pip install .
- Install test dependencies (optional):
pip install -e .[test]
- Core dependencies: Make sure you have the necessary libraries installed. If
Usage Example
Configure the desired scenario in expert_op4grid_recommender/config.py (Date, Timestep, Contingency Lines, etc.).
Then, run the main analysis script from the project root directory:
python expert_op4grid_recommender/main.py --date 2024-08-28 --timestep 36 --lines-defaut FRON5L31LOUHA P.SAOL31RONCI
The script will:
- Set up the Grid2Op environment.
- Simulate the specified contingency.
- Build and save an overflow graph visualization in the
Overflow_Graph/directory. - Apply expert rules to filter actions loaded from the action space file.
- Identify and print a list of prioritized corrective actions.
An option that can be activated for specific use is to rebuild an action space from one segmentation of a grid to another or the full grid:
python expert_op4grid_recommender/main.py --rebuild-actions --repas-file allLogics.json --grid-snapshot-file data/snapshot/pf_20240828T0100Z_20240828T0100Z.xiidm
From all known logics on the full grid, and targeted action ids in the ACTION_FILE, it rebuilds the actions to be applied on the grid snapshot (in detailed topology format with switches) at the date of interest.
Configuration
Key parameters can be adjusted in expert_op4grid_recommender/config.py:
DATE,TIMESTEP,LINES_DEFAUT: Define the specific case to analyze.ENV_FOLDER,ENV_NAME: Specify the Grid2Op environment location.ACTION_FILE_PATH: Path to the JSON file containing the action space.USE_DC_LOAD_FLOW: Set toTrueto use DC power flow if AC flow fails.PARAM_OPTIONS_EXPERT_OP: Thresholds and parameters for the overflow graph analysis.
Dependencies
This project relies on several external libraries, including:
numpypandasnetworkxpypowsyblgrid2op(Ensure you have a compatible version installed)alphaDeesp(Ensure this library is installed in your environment)expertop4grid>=0.2.8
See pyproject.toml for the full list.
Testing
To run the unit and integration tests, navigate to the project root and use pytest:
pytest
Note: Some integration tests (@pytest.mark.slow) require the Grid2Op environment data to be present and may take longer to run.
License
This project is licensed under the Mozilla Public License 2.0 (MPL 2.0). See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file expert_op4grid_recommender-0.1.0.post1.tar.gz.
File metadata
- Download URL: expert_op4grid_recommender-0.1.0.post1.tar.gz
- Upload date:
- Size: 176.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15ac41e885b1d20eb383fde023d889a9a3b402df9efeb42968ad51c14db90b59
|
|
| MD5 |
ab4986b0a22695079a4c9e689173859a
|
|
| BLAKE2b-256 |
7025b4b0331e62f9dfa40d04ed33b851c6845c82b09ee6e1560a1d489e8edc0a
|
Provenance
The following attestation bundles were made for expert_op4grid_recommender-0.1.0.post1.tar.gz:
Publisher:
python-publish.yml on marota/Expert_op4grid_recommender
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
expert_op4grid_recommender-0.1.0.post1.tar.gz -
Subject digest:
15ac41e885b1d20eb383fde023d889a9a3b402df9efeb42968ad51c14db90b59 - Sigstore transparency entry: 938346799
- Sigstore integration time:
-
Permalink:
marota/Expert_op4grid_recommender@eaffba27b22597a2e53e9f34ac1df1b0f2db0904 -
Branch / Tag:
refs/tags/0.1.0_post1 - Owner: https://github.com/marota
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@eaffba27b22597a2e53e9f34ac1df1b0f2db0904 -
Trigger Event:
release
-
Statement type:
File details
Details for the file expert_op4grid_recommender-0.1.0.post1-py3-none-any.whl.
File metadata
- Download URL: expert_op4grid_recommender-0.1.0.post1-py3-none-any.whl
- Upload date:
- Size: 147.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3d12d27e8a88c64d2fc21339b2a088a50a5c61c837036cb3b7f8248e10dc0da
|
|
| MD5 |
32fdcdf134f99e7abe236b22e487c8c6
|
|
| BLAKE2b-256 |
4dd93f0606da0f4625e1bcfdf2d5b97f04525a21f4c1b412d947d4f25d1ffd1d
|
Provenance
The following attestation bundles were made for expert_op4grid_recommender-0.1.0.post1-py3-none-any.whl:
Publisher:
python-publish.yml on marota/Expert_op4grid_recommender
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
expert_op4grid_recommender-0.1.0.post1-py3-none-any.whl -
Subject digest:
a3d12d27e8a88c64d2fc21339b2a088a50a5c61c837036cb3b7f8248e10dc0da - Sigstore transparency entry: 938346800
- Sigstore integration time:
-
Permalink:
marota/Expert_op4grid_recommender@eaffba27b22597a2e53e9f34ac1df1b0f2db0904 -
Branch / Tag:
refs/tags/0.1.0_post1 - Owner: https://github.com/marota
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@eaffba27b22597a2e53e9f34ac1df1b0f2db0904 -
Trigger Event:
release
-
Statement type: