marota / Oracle4Grid

Documentation at https://oracle4grid.readthedocs.io/en/latest/
Mozilla Public License 2.0
3 stars 1 forks source link

Oracle4Grid

This is a repository to compute an Oracle score on a scenario for a given Grid2op environment. It finds the best course of actions a posteriori, within a given perimeter of actions (cf « Learning to run a power network challenge for training topology controllers »)

An Oracle system is defined by it's ability to know all possible outcome, in order to deduce the best course of actions. Named after an Oracle, who knows the future.

This is an Oracle System that tries to brute force the best possible combination of actions taken by an agent, in a certain Grid2op environment. It does so by using data from a set of user-fed actions played in a dummy environment that allows any actions. It then finds the best possible course of actions that an agent can take, called "Best path" (computed with or without possibility of overload). Finally, a few KPIs are produced in order to give a quick rundown of the state of the environment initially provided.

This can allow you to test the boundaries of a given network environment, the feasibility of a given scenario or get a better understanding of the potential weaknesses in the decision making process of an agent

Influence Graph

Table of Contents

Documentation

You can find the more comprehensive documentation on ReadTheDocs: https://oracle4grid.readthedocs.io/en/latest/

Run

Run example (from the root folder)

pipenv run python -m oracle4grid.main -d 1 -f oracle4grid/ressources/actions/rte_case14_realistic/test_unitary_actions.json -e data/rte_case14_realistic -c 0

For more customisation options, see section "Configuration for the user" below

Results

Oracle returns 2 different action path that respect the game rules allowed transitions (see Constants section)

When printed, the OracleActions have a simple representation. For example sub-1-2_line-4-3 combines the second and third unitary actions that impacts respectively substation 1 and line 4 The best path can look as below

Best path example

Additionaly, a Pandas.DataFrame with interesting cumulated rewards for various standard behaviour (indicators) is returned in order to give context and boundaries to the performance of Oracle but also your agents.

KPI example

See the documentation for further details about the results through a simple use case. In debug mode, more info will be printed and serialized.

Installation

For normal usage :

For development, please proceed as follows:

git clone https://github.com/mjothy/Grid2Op.git

git checkout -b mj-devs-pr

cd Grid2Op/

pip install -U .

Configuration for the user

Config.ini

The main configuration of the oracle module is located in ./oracle4grid/ressources/config.ini This file contains the following options :

Unitary (atomic) actions

Oracle requires a base of atomic actions which are provided in .json format. These unitary elements plays the role of action "bricks" that will be combined by Oracle to build more consistent actions on the grid.

As a limitation, two types of atomic actions are handled, each one having a standard format:

A user-friendly notebook is provided to help the user defining atomic actions and visualize their impact on the grid. See oracle4grid/core/actions_utils/Atomic_Actions_Helper.ipynb

2 other formats are handled by class oracle4grid/core/utils/launch_utils::OracleParser. It should be easy for a user to develop an additional parser to handle his action format using the same API

constants.py

In addition to the ini file, there is a constant API available for easy local overrides of some common behaviors / implementations. Especially if one wants to use its customized reward function, or some other indicators that can be computed by "other_rewards" and used as path filters to derive some kpis. This API can be used in two ways :

Workflow and API overview

Influence Graph

Tests

There are a lot of integration tests already implemented, one can run them with :

python -m pytest oracle4grid/test --verbose --continue-on-collection-errors -p no:warning

License information

Copyright 2020-2021 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