Skip to content

AI4REALNET/GNPDT

Evolving Power System Operating Rules for Real-Time Congestion management

This work proposes a novel hybrid AI framework for power grid topology control that integrates genetic network programming (GNP), reinforcement learning, and decision trees. A new variant of GNP is introduced that is capable of evolving the decision-making rules by learning from data in a reinforcement learning framework.

AIagent_GNP_modules:

This script is the genetic Network Programming (GNP) network graph nodal (judgment and processing nodes) functions and the genetic main modules including mutaton, crossover, selection and replacement. This script includes many functions that could not be used individually but is essential to run other scripts. This code is dependent to lines_SI.py, reconfig_result.py, reconfigflx.py, Reconfiguration.py, VI_sens_l2rpn_wcci_2022.py for addressing lne switching and power flexbility actions.

AIagent_GNPRL_train:

This is the main code used for training the adaptive GNP model in intraction with Reinforcement Learning (RL) and will extract the best-evolved (elite) decision graph per episode.

top_rule_pool:

This script accumulates optimized rules through following the trajectory of actions (𝒂𝟎,𝒂𝟏, . . , 𝒂𝒏 ) selected per grid sate (𝒔𝟎, 𝒔𝟏, . . , 𝒔𝒏) by elite graphs.

AIagent_test_predictor:

This script does the Rule Extraction by Decision Tree (DT) and will evaluate the AI agent over the test set using L2RPN score.

Setup

Make sure you have Python 3.10+ and required packages installed.

Make sure the neccessary Python libraries are installed as mentioned in requirements.txt.

Clone the repository and move to the project directory.

Usage:

  1. The first step is to train the agent for a specific grid and parametrs and call the train function which will save the elite graphs in the training folder.

from GNPDT import AIagent_GNPRL_train from AIagent_GNPRL_train import train

The script contains an example execution in the if __name__ == "__main__": section at the end of the file, which demonstrates how to run the code with sample inputs.

To tune the GNP hyperparameters using bayesian optimization refer to AIagent_GNPRL_hyperparam.py before setting the training parameters.

  1. Secondly, call pool function from the top_rule_track.py to accumulate the action trajectory by elite decsion graphs from training.

from GNPDT import top_rule_track from AIagent_GNPRL_train import pool

The script contains an example execution in the if __name__ == "__main__": section at the end of the file, which demonstrates how to run the code with sample inputs.

  1. Thirdly, call pool function from AIagent_test_predictor.py to run the decision tree for the selected test set and calcultae the metrics.

from GNPDT import AIagent_test_predictor from AIagent_test_predictor import validation, generate_random_numbers_in_range

The script contains an example execution in the if __name__ == "__main__": section at the end of the file, which demonstrates how to run the code with sample inputs.

Usage Notes

The file <underlying_statistics.py> from the external Python package <Grid2Op> was modified for this work. During execution, this modified file must replace the corresponding file in the installed <Grid2Op\grid2op\utils> package.

The grid layout must be converted to Json format from \texttt{pandapower}. The resulting JSON file should be placed in the \texttt{case_study} directory within the repository. This ensures that the scripts can load and simulate the grid configuration correctly when interaction with \texttt{pandapower} is needed.

Citation

This repository contains the code accompanying the accepted paper:

F. Moaidi, R.J. Bessa, "Evolving Power System Operating Rules for Real-Time Congestion Management", Energy and AI Journal, 2025.

License

This code is released under the Mozilla Public License 2.0 (MPL-2.0).

You may use, modify, and redistribute this software under the terms of the MPL 2.0. See the LICENSE file for details.

About

Evolving Power System Operating Rules for Real-Time Congestion Management

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages