{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", "

Transmission system operation

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "

Table of Contents

\n", "
\n", "
    \n", "
  1. Introduction
  2. \n", "
  3. Motivation
  4. \n", "
  5. Load an environment with grid2op
  6. \n", "
  7. Grid information and electrical losses
  8. \n", "
  9. The 5 substation grid
  10. \n", "
  11. A line disconnection and its effect
  12. \n", "
  13. Inside a substation
  14. \n", "
  15. A remedial solution
  16. \n", "
  17. Conclusion
  18. \n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

1. Introduction

\n", "

\n", " This notebook is an introduction to power system operations and the grid2op pacakge. The operation of electrical power grids have been studied for many years around the world and involves many activities. Power grids, especially transmission grid, aims to transporting electricity over long distances from power plants to consumers. To be efficient and minimize energy losses, power grids often operate under high voltages (above 20kV). One of the main goals for power grid operators is to ensure a reliable and secure continuity of delivery of electricity to consumers under some additional quality criterion that can vary from one country to another. \n", "

\n", " For simplicity, a four substations grid is presented here with producers and consumers meshed through a grid. However, transmission grids are more complex and involve many long lines that connect different cities or states. A grid often connects an entire country linking hundreds of power plants and distribution networks but our current example should illustrate clearly enough how congestion could arise on the power grid and which operation could help manage it. Congestion management is actually the most critical and time-consuming task for a power grid operator.\n", "

\n", " \n", "

\n", "(courtesy by Marvin Lerousseau -- if images does not display correctly, make sure to start the jupyter notebook server from the root directory of the starting kit.)\n", "

\n", "

\n", "

\n", "For more information on the grid2op platforme, some explanatory notebooks are available withing the package of this plateform located at https://github.com/rte-france/Grid2Op. If these notebooks still do not answer your question, a technical documentation on most of the platform can is available online at https://grid2op.readthedocs.io/. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

2. Motivation

\n", "\n", "

\n", " A power line has some physical capacity, aka thermal limit as illustrated in the figures below.\n", " Situation ok Not a lot of flows are flowing on this powerline. It is far from the tree bellow it, thus presenting very little risk.\n", " Situation at risk More current flows on the powerline. Due to Joule heating it gets hotter and gets closer to the tree bellow it. Typically, powergrids operators want to be alerted when such a situation is becoming critical.\n", " Too late to act Even More current flows on the powerline. Due to Joule heating it gets even hotter and ends up in contact with the tree. At this point nothing can be made. The tree can catch fire (due to heat), the powerline can break etc. This situation should be avoided.\n", "

\n", " To prevent this potentially dramatic effect, power lines are often equiped with \"sensors\" that detects when the flows is above a certain threshold (called \"thermal limit\"), typically in the second figure above. And if the flows is above this thermal limit for a given amount of time, then the powerline is automatically disconnected form the powergrid without any human intervention. To prevent the disconnection of more and more powerlines (phenomenon called \"cascading failure\") operators often prefers to act before the powerline is disconnected and try to re route the flows in other powerlines.\n", "

\n", " To be as efficient as possible operators monitor the grid in real time. They know the power flowing through all the powerlines of the grid and it allows them to anticipated problems by relying on their expertise and making extensive simulations requiring \"powerflow solver\" that can compute how much power flow on each powerlines given the productions and consumptions location as well as the topology of the powergrid.\n", "

\n", " As a first intuition, power flows increase when electrical consumption increases. More specifically, the flows in lines are affected by the dynamics of power consumption and the availability of power plants or productions. It often varies along the course of a day, as consumer behaviors and usages change depending on the hour of the day: there are more activities in the middle of the day, while lighting is used mostly overnight and people finally get to sleep, leaving mostly electrical heating systems as well as some few industries in operations. \n", "

\n", " The congestion could be caused by day to day demand, but can also be due to some external factors such as topology grid changes by operator's actions, lines in maintenance or transient faults that can lead to cascading failures or put the system in instable conditions.\n", "

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

3. Loading the environment

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", " Grid2Op is an open-source platform that relies on powerflow solvers (typically pandapower) to compute the power flows in a grid. The main focus of this package is to be able to interact with the powergrid allowing to adopt a Reinforcement Learning approach.\n", "

\n", " Right now, we are going to load all libraries and grid2op environment. The environment contains all essential information about the power grid such as the substations ids where the loads, generators and transmission lines are connected, the power flows and so on.\n", "

" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "pygame 1.9.6\n", "Hello from the pygame community. https://www.pygame.org/contribute.html\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/home/donnotben/.local/lib/python3.6/site-packages/pandapower/io_utils.py:8: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.\n", " from pandas.util.testing import assert_series_equal, assert_frame_equal\n" ] } ], "source": [ "import warnings\n", "import os\n", "import numpy as np\n", "import pandas as pd\n", "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "import grid2op\n", "from grid2op.MakeEnv import make\n", "from grid2op.PlotPlotly import PlotObs" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Initialize the environment\n", "environment = make(\"case5_example\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", " A powergrid has been loaded, it consists a grid with 5 substations, 8 powerlines, 3 loads and 2 generators. It is displayed in the next cell.\n", "

\n", " Though perfectly adapted for smaller grid, this kind of representation is not advised when dealing with powergrid with more than 10-15 substations.\n", "

" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "mode": "text", "showlegend": false, "text": [ "73.7%" ], "type": "scatter", "x": [ 1.5308084989341915e-15 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "90.3%" ], "type": "scatter", "x": [ 100 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "72.8%" ], "type": "scatter", "x": [ 200 ], "y": [ 199.99999999999997 ] }, { "mode": "text", "showlegend": false, "text": [ "58.5%" ], "type": "scatter", "x": [ 200 ], "y": [ -1.5308084989341915e-15 ] }, { "mode": "text", "showlegend": false, "text": [ "73.7%" ], "type": "scatter", "x": [ 100 ], "y": [ 400 ] }, { "mode": "text", "showlegend": false, "text": [ "37.0%" ], "type": "scatter", "x": [ 300 ], "y": [ 410.5654565435175 ] }, { "mode": "text", "showlegend": false, "text": [ "37.0%" ], "type": "scatter", "x": [ 300 ], "y": [ 389.4345434564825 ] }, { "mode": "text", "showlegend": false, "text": [ "57.5%" ], "type": "scatter", "x": [ 400 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "- 9 MW" ], "type": "scatter", "x": [ -70 ], "y": [ 8.572527594031473e-15 ] }, { "mode": "text", "showlegend": false, "text": [ "- 8 MW" ], "type": "scatter", "x": [ 470 ], "y": [ 400 ] }, { "mode": "text", "showlegend": false, "text": [ "- 8 MW" ], "type": "scatter", "x": [ 470 ], "y": [ 0 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 2 MW" ], "type": "scatter", "x": [ -35.000000000000036 ], "y": [ -60.62177826491068 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 26 MW" ], "type": "scatter", "x": [ -35.000000000000014 ], "y": [ 460.6217782649107 ] } ], "layout": { "height": 600, "margin": { "b": 100, "l": 20, "r": 20 }, "plot_bgcolor": "white", "shapes": [ { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -25, "x1": 25, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -25, "x1": 25, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 175, "x1": 225, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 375, "x1": 425, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 375, "x1": 425, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "line": { "color": "#dea4a4" }, "type": "line", "x0": 1.5308084989341915e-15, "x1": 1.5308084989341915e-15, "xref": "x", "y0": 25, "y1": 375, "yref": "y" }, { "line": { "color": "#bd6262" }, "type": "line", "x0": 11.18033988749895, "x1": 188.81966011250105, "xref": "x", "y0": 22.360679774997898, "y1": 377.6393202250021, "yref": "y" }, { "line": { "color": "#dea4a4" }, "type": "line", "x0": 17.67766952966369, "x1": 382.32233047033634, "xref": "x", "y0": 17.677669529663685, "y1": 382.3223304703363, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 25, "x1": 375, "xref": "x", "y0": 0, "y1": -3.061616997868383e-15, "yref": "y" }, { "line": { "color": "#dea4a4" }, "type": "line", "x0": 25, "x1": 175, "xref": "x", "y0": 400, "y1": 400, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 222.65769467591625, "x1": 377.3423053240837, "xref": "x", "y0": 410.5654565435175, "y1": 410.5654565435175, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 222.65769467591625, "x1": 377.3423053240838, "xref": "x", "y0": 389.4345434564825, "y1": 389.4345434564825, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 400, "x1": 400, "xref": "x", "y0": 375, "y1": 25, "yref": "y" }, { "type": "line", "x0": -50, "x1": -25, "xref": "x", "y0": 6.123233995736767e-15, "y1": 3.061616997868383e-15, "yref": "y" }, { "type": "line", "x0": 450, "x1": 425, "xref": "x", "y0": 400, "y1": 400, "yref": "y" }, { "type": "line", "x0": 450, "x1": 425, "xref": "x", "y0": 0, "y1": 0, "yref": "y" }, { "type": "line", "x0": -25.000000000000025, "x1": -12.50000000000001, "xref": "x", "y0": -43.30127018922192, "y1": -21.65063509461096, "yref": "y" }, { "type": "line", "x0": -25.00000000000001, "x1": -12.499999999999995, "xref": "x", "y0": 443.3012701892219, "y1": 421.65063509461095, "yref": "y" } ], "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "width": 800, "xaxis": { "range": [ -142.5, 542.5 ], "zeroline": false }, "yaxis": { "range": [ -142.5, 542.5 ] } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "graph_layout = [(0,0), (0,400), (200,400), (400, 400), (400, 0)]\n", "plot_helper = PlotObs(substation_layout=graph_layout, observation_space=environment.observation_space)\n", "\n", "fig = plot_helper.get_plot_observation(environment.get_obs())\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", "Another representation of the powergrid, where generators and loads location as well as label for each powerline and generators load is:\n", " \n", "

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

4. Grid Information and electrical losses

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", "Despide the grid is very small and simple, all information is accessible directly using the grid2op environment. Let's get some information about the most important objects over a power grid: power lines, electrical bus, loads (aka consumptions) and generators (aka productions). \n", "

\n", " The state of those objects are very important in the reinforcement learning challenge as they will be used in observations. It means that given you observe the switch status, power flows, etc the agent should be able to take the correct action to keep flows in normal condition as possible. The following lines of code retrieve the nodes or substations ids and the numbers of elements connected to each busbar. \n", "

" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Injection information:\n", "\t- There are 3 loads connected to substations with id: [0 3 4]\n", "\t -There are 2 generators, connected to substations with id: [0 1]\n", "\n", "Powerline information:\n", "There are 8 transmissions lines on this grid. They connect:\n", "\t- Substation origin id 0 to substation extremity id 1\n", "\t- Substation origin id 0 to substation extremity id 2\n", "\t- Substation origin id 0 to substation extremity id 3\n", "\t- Substation origin id 0 to substation extremity id 4\n", "\t- Substation origin id 1 to substation extremity id 2\n", "\t- Substation origin id 2 to substation extremity id 3\n", "\t- Substation origin id 2 to substation extremity id 3\n", "\t- Substation origin id 3 to substation extremity id 4\n", "\n", "Substations information:\n", "\t-On susbtation 0 there are 6 elements.\n", "\t-On susbtation 1 there are 3 elements.\n", "\t-On susbtation 2 there are 4 elements.\n", "\t-On susbtation 3 there are 5 elements.\n", "\t-On susbtation 4 there are 3 elements.\n" ] } ], "source": [ "# Load ids\n", "print(\"\\nInjection information:\")\n", "load_to_subid = environment.load_to_subid\n", "print ('\\t- There are {} loads connected to substations with id: {}'.format(len(load_to_subid), load_to_subid))\n", "\n", "# Generators irds\n", "gen_to_subid = environment.gen_to_subid\n", "print ('\\t -There are {} generators, connected to substations with id: {}'.format(len(gen_to_subid), gen_to_subid))\n", "\n", "# Line id sender\n", "print(\"\\nPowerline information:\")\n", "line_or_to_subid = environment.line_or_to_subid\n", "line_ex_to_subid = environment.line_ex_to_subid\n", "print ('There are {} transmissions lines on this grid. They connect:'.format(len(line_or_to_subid)))\n", "for ori, ext in zip(line_or_to_subid, line_ex_to_subid):\n", " print(\"\\t- Substation origin id {} to substation extremity id {}\".format(ori, ext))\n", "\n", "# Num of elements per SE\n", "print(\"\\nSubstations information:\")\n", "for i, nb_el in enumerate(environment.sub_info):\n", " print(\"\\t-On susbtation {} there are {} elements.\".format(i, nb_el))\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", "The Grid2Op package offers to perform actions on the powergrid. It also allows the powergrid to be modified by the environment (load can increase because lots of people are getting home and start to heat their appartment for example).\n", "

\n", " In the L2RPN competition, you are asked to adapted the powergrid to face these changes. These changes are \"automatically\" performed on the powergrid when calling \"environment.step(agent_action)\" function. This function expects the agent to give the action it has performed at this timestep. This mechanism is explained in the cell bellow, where we suppose the agent take the \"do nothing\" action (eg. it does not change anything to the state of the powergrid.)\n", "

" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "action_space = environment.action_space\n", "observation_space = environment.observation_space\n", "\n", "# Create do_nothing action.\n", "agent_action = action_space({}) # this is the do nothing action" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n" ] } ], "source": [ "# Run one step in the environment\n", "obs, *_ = environment.step(agent_action)\n", "print (type(obs))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", "As you see the observation is a nspecial class. Sometimes is better to transform it as a vector in the following way:\n", "

" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[ 2.01900000e+03 1.00000000e+00 1.00000000e+00 0.00000000e+00\n", " 1.00000000e+01 1.00000000e+00 1.70000000e+00 2.58836408e+01\n", " 1.53004910e+02 -1.54597290e+02 1.02000000e+02 1.02000000e+02\n", " 8.70000000e+00 7.80000000e+00 8.10000000e+00 6.10000000e+00\n", " 5.50000000e+00 5.70000000e+00 1.02000000e+02 1.01891698e+02\n", " 1.01838128e+02 -9.29031639e+00 -2.22259328e+00 2.63984592e-01\n", " 4.24892508e+00 1.50771758e+01 5.88759181e+00 5.88759181e+00\n", " 3.98139683e+00 7.64489279e+01 3.44619596e+01 2.02373940e+01\n", " 1.57566285e+01 -7.55988240e+01 -1.84191194e+01 -1.84191194e+01\n", " -1.55192609e+01 1.02000000e+02 1.02000000e+02 1.02000000e+02\n", " 1.02000000e+02 1.02000000e+02 1.01936713e+02 1.01936713e+02\n", " 1.01891698e+02 4.35907114e+02 1.95470183e+02 1.14559401e+02\n", " 9.23729745e+01 4.36338888e+02 1.09522302e+02 1.09522302e+02\n", " 9.07846962e+01 1.08064650e+01 2.58135340e+00 -9.24987371e-02\n", " -4.17204555e+00 -1.43565370e+01 -5.84444905e+00 -5.84444905e+00\n", " -3.92795445e+00 -7.89984658e+01 -3.74818279e+01 -2.40891989e+01\n", " -1.84878865e+01 7.43200667e+01 1.70542299e+01 1.70542299e+01\n", " 1.27878865e+01 1.02000000e+02 1.01936713e+02 1.01891698e+02\n", " 1.01838128e+02 1.01936713e+02 1.01891698e+02 1.01891698e+02\n", " 1.01838128e+02 4.51319043e+02 2.12792837e+02 1.36497951e+02\n", " 1.07448884e+02 4.28716535e+02 1.02151596e+02 1.02151596e+02\n", " 7.58412662e+01 7.26511857e-01 8.88500830e-01 7.15996257e-01\n", " 5.77331091e-01 7.27231481e-01 3.65074340e-01 3.65074340e-01\n", " 5.67404351e-01 1.00000000e+00 1.00000000e+00 1.00000000e+00\n", " 1.00000000e+00 1.00000000e+00 1.00000000e+00 1.00000000e+00\n", " 1.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 1.00000000e+00 1.00000000e+00 1.00000000e+00\n", " 1.00000000e+00 1.00000000e+00 1.00000000e+00 1.00000000e+00\n", " 1.00000000e+00 1.00000000e+00 1.00000000e+00 1.00000000e+00\n", " 1.00000000e+00 1.00000000e+00 1.00000000e+00 1.00000000e+00\n", " 1.00000000e+00 1.00000000e+00 1.00000000e+00 1.00000000e+00\n", " 1.00000000e+00 1.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 -1.00000000e+00\n", " -1.00000000e+00 -1.00000000e+00 -1.00000000e+00 -1.00000000e+00\n", " -1.00000000e+00 -1.00000000e+00 -1.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00]\n" ] } ], "source": [ "obs_as_vect = obs.to_vect()\n", "print(obs_as_vect)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", "Please refer to the official getting_started notebooks here for more informations.\n", "
\n", " They can be launched interactively with the help of \"mybinder\" at the following address:\n", " https://mybinder.org/v2/gh/rte-france/Grid2Op/master\n", "
\n", " For more information on mybinder, visit https://mybinder.org/\n", "

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", "The next function allows us to perform a few iterations using the step method in the environment given an action as an input and returns the observation variables as the power flow results, switches states, etc.\n", "

" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "import copy\n", "\n", "def sim(action, \n", " t_action=0):\n", " \n", " # Restart all the game from the scratch.\n", " env = None\n", " env = make(\"case5_example\") \n", " obs_as_class = None\n", " obs_as_vect = None\n", " # Iterating process..\n", " for i in range(t_action+1):\n", " obs_as_class, reward, done, info = env.step(action)\n", " obs_as_vect = obs_as_class.to_vect()\n", " if done:\n", " raise RuntimeError(\"Impossible to complete the scenario. GAME OVER.\")\n", " return env, obs_as_class, obs_as_vect" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "mode": "text", "showlegend": false, "text": [ "70.5%" ], "type": "scatter", "x": [ 1.5308084989341915e-15 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "86.1%" ], "type": "scatter", "x": [ 100 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "69.3%" ], "type": "scatter", "x": [ 200 ], "y": [ 199.99999999999997 ] }, { "mode": "text", "showlegend": false, "text": [ "56.0%" ], "type": "scatter", "x": [ 200 ], "y": [ -1.5308084989341915e-15 ] }, { "mode": "text", "showlegend": false, "text": [ "70.7%" ], "type": "scatter", "x": [ 100 ], "y": [ 400 ] }, { "mode": "text", "showlegend": false, "text": [ "35.5%" ], "type": "scatter", "x": [ 300 ], "y": [ 410.5654565435175 ] }, { "mode": "text", "showlegend": false, "text": [ "35.5%" ], "type": "scatter", "x": [ 300 ], "y": [ 389.4345434564825 ] }, { "mode": "text", "showlegend": false, "text": [ "55.3%" ], "type": "scatter", "x": [ 400 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "- 9 MW" ], "type": "scatter", "x": [ -70 ], "y": [ 8.572527594031473e-15 ] }, { "mode": "text", "showlegend": false, "text": [ "- 8 MW" ], "type": "scatter", "x": [ 470 ], "y": [ 400 ] }, { "mode": "text", "showlegend": false, "text": [ "- 8 MW" ], "type": "scatter", "x": [ 470 ], "y": [ 0 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 2 MW" ], "type": "scatter", "x": [ -35.000000000000036 ], "y": [ -60.62177826491068 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 25 MW" ], "type": "scatter", "x": [ -35.000000000000014 ], "y": [ 460.6217782649107 ] } ], "layout": { "height": 600, "margin": { "b": 100, "l": 20, "r": 20 }, "plot_bgcolor": "white", "shapes": [ { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -25, "x1": 25, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -25, "x1": 25, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 175, "x1": 225, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 375, "x1": 425, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 375, "x1": 425, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "line": { "color": "#dea4a4" }, "type": "line", "x0": 1.5308084989341915e-15, "x1": 1.5308084989341915e-15, "xref": "x", "y0": 25, "y1": 375, "yref": "y" }, { "line": { "color": "#cd8383" }, "type": "line", "x0": 11.18033988749895, "x1": 188.81966011250105, "xref": "x", "y0": 22.360679774997898, "y1": 377.6393202250021, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 17.67766952966369, "x1": 382.32233047033634, "xref": "x", "y0": 17.677669529663685, "y1": 382.3223304703363, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 25, "x1": 375, "xref": "x", "y0": 0, "y1": -3.061616997868383e-15, "yref": "y" }, { "line": { "color": "#dea4a4" }, "type": "line", "x0": 25, "x1": 175, "xref": "x", "y0": 400, "y1": 400, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 222.65769467591625, "x1": 377.3423053240837, "xref": "x", "y0": 410.5654565435175, "y1": 410.5654565435175, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 222.65769467591625, "x1": 377.3423053240838, "xref": "x", "y0": 389.4345434564825, "y1": 389.4345434564825, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 400, "x1": 400, "xref": "x", "y0": 375, "y1": 25, "yref": "y" }, { "type": "line", "x0": -50, "x1": -25, "xref": "x", "y0": 6.123233995736767e-15, "y1": 3.061616997868383e-15, "yref": "y" }, { "type": "line", "x0": 450, "x1": 425, "xref": "x", "y0": 400, "y1": 400, "yref": "y" }, { "type": "line", "x0": 450, "x1": 425, "xref": "x", "y0": 0, "y1": 0, "yref": "y" }, { "type": "line", "x0": -25.000000000000025, "x1": -12.50000000000001, "xref": "x", "y0": -43.30127018922192, "y1": -21.65063509461096, "yref": "y" }, { "type": "line", "x0": -25.00000000000001, "x1": -12.499999999999995, "xref": "x", "y0": 443.3012701892219, "y1": 421.65063509461095, "yref": "y" } ], "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "width": 800, "xaxis": { "range": [ -142.5, 542.5 ], "zeroline": false }, "yaxis": { "range": [ -142.5, 542.5 ] } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "env, obs, osb_as_vect = sim(agent_action, t_action=3)\n", "fig = plot_helper.get_plot_observation(obs)\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

5. A simple grid

\n", "\n", "

\n", "The five substation grid is presented as follows. All power plants, consumptions and lines are on service and the load flows are indicating in each substation.\n", "

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", " Note: How to interprate the flows?... A powergrid can be modeled as an oriented graph. Powerline have then an \"origin\" and an \"extremity\" representing the direction of the powerlines (from \"origin\" to \"extremity\"). This means that is there is a positive flow, the actual powerflow goes from origin to extremity, if the powerflow is negative, this means it goes from extremity to origin.\n", "
\n", " Due to losses, one will notice that the flows getting out of the powerline at the origin bus (node) is not equal to the powerflow entering at the extremity bus. This is because some power is \"lost\" during the transportation. Typical losses are about 2% of the total consumption of the powergrid.\n", "
" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "scrolled": false }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "mode": "text", "showlegend": false, "text": [ "67.9%" ], "type": "scatter", "x": [ 1.5308084989341915e-15 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "82.7%" ], "type": "scatter", "x": [ 100 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "66.3%" ], "type": "scatter", "x": [ 200 ], "y": [ 199.99999999999997 ] }, { "mode": "text", "showlegend": false, "text": [ "53.6%" ], "type": "scatter", "x": [ 200 ], "y": [ -1.5308084989341915e-15 ] }, { "mode": "text", "showlegend": false, "text": [ "68.3%" ], "type": "scatter", "x": [ 100 ], "y": [ 400 ] }, { "mode": "text", "showlegend": false, "text": [ "34.3%" ], "type": "scatter", "x": [ 300 ], "y": [ 410.5654565435175 ] }, { "mode": "text", "showlegend": false, "text": [ "34.3%" ], "type": "scatter", "x": [ 300 ], "y": [ 389.4345434564825 ] }, { "mode": "text", "showlegend": false, "text": [ "53.5%" ], "type": "scatter", "x": [ 400 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "- 8 MW" ], "type": "scatter", "x": [ -70 ], "y": [ 8.572527594031473e-15 ] }, { "mode": "text", "showlegend": false, "text": [ "- 8 MW" ], "type": "scatter", "x": [ 470 ], "y": [ 400 ] }, { "mode": "text", "showlegend": false, "text": [ "- 8 MW" ], "type": "scatter", "x": [ 470 ], "y": [ 0 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 2 MW" ], "type": "scatter", "x": [ -35.000000000000036 ], "y": [ -60.62177826491068 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 24 MW" ], "type": "scatter", "x": [ -35.000000000000014 ], "y": [ 460.6217782649107 ] } ], "layout": { "height": 600, "margin": { "b": 100, "l": 20, "r": 20 }, "plot_bgcolor": "white", "shapes": [ { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -25, "x1": 25, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -25, "x1": 25, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 175, "x1": 225, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 375, "x1": 425, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 375, "x1": 425, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 1.5308084989341915e-15, "x1": 1.5308084989341915e-15, "xref": "x", "y0": 25, "y1": 375, "yref": "y" }, { "line": { "color": "#cd8383" }, "type": "line", "x0": 11.18033988749895, "x1": 188.81966011250105, "xref": "x", "y0": 22.360679774997898, "y1": 377.6393202250021, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 17.67766952966369, "x1": 382.32233047033634, "xref": "x", "y0": 17.677669529663685, "y1": 382.3223304703363, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 25, "x1": 375, "xref": "x", "y0": 0, "y1": -3.061616997868383e-15, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 25, "x1": 175, "xref": "x", "y0": 400, "y1": 400, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 222.65769467591625, "x1": 377.3423053240837, "xref": "x", "y0": 410.5654565435175, "y1": 410.5654565435175, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 222.65769467591625, "x1": 377.3423053240838, "xref": "x", "y0": 389.4345434564825, "y1": 389.4345434564825, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 400, "x1": 400, "xref": "x", "y0": 375, "y1": 25, "yref": "y" }, { "type": "line", "x0": -50, "x1": -25, "xref": "x", "y0": 6.123233995736767e-15, "y1": 3.061616997868383e-15, "yref": "y" }, { "type": "line", "x0": 450, "x1": 425, "xref": "x", "y0": 400, "y1": 400, "yref": "y" }, { "type": "line", "x0": 450, "x1": 425, "xref": "x", "y0": 0, "y1": 0, "yref": "y" }, { "type": "line", "x0": -25.000000000000025, "x1": -12.50000000000001, "xref": "x", "y0": -43.30127018922192, "y1": -21.65063509461096, "yref": "y" }, { "type": "line", "x0": -25.00000000000001, "x1": -12.499999999999995, "xref": "x", "y0": 443.3012701892219, "y1": 421.65063509461095, "yref": "y" } ], "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "width": 800, "xaxis": { "range": [ -142.5, 542.5 ], "zeroline": false }, "yaxis": { "range": [ -142.5, 542.5 ] } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Run the game.\n", "t_action = 5\n", "\n", "# Run the environment.\n", "env, obs, obs_as_vect = sim(agent_action, t_action=t_action)\n", "\n", "fig = plot_helper.get_plot_observation(obs)\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

How to interpret the results?

\n", "\n", "

\n", "The values of the power flows are attached reprenseted by the color of the powegrid the more red, the more flow there is. In this case the situation is not really good. With most of the powerline being loaded at 90% the situation is quite tense;\n", "

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

6. Line disconnection

\n", "\n", "

\n", " Transmission lines link different states or regions between productions and consumptions. They have long distance and are subjected to suddenly disconnections due to thunderstorms. It is natural to have one or more lines out-of-service along the day because of thunder hits a line. This number tends to increase during winter. \n", "

\n", " A disconnected line changes the configuration on the grid and causes a power flow's redistribution in the grid. Sometimes these undesired events lead to some overloads in other lines. You have not guess the reason why yet? The answer is very intuitive. When a line get disconnected, the same amount of energy is still demanded by customers, but now you have one less path in the grid to transport the energy, and the others will hence be loaded with more power.\n", "

\n", " Substations are equipped with switches to disconnect a line when a fault or congestion is detected (as explained in the first section of this notebook). Normally the criteria to disconnect a line under a congestion is to measure the flow and the time a line remains congested above a given threshold the switch automatically open a line.\n", "

\n", " This behavior occurs many times in electrical systems and the expertise and vast knowledge of operators help to alleviate the stress in order to guarantee energy to customers. A similar action could be replicated using grid2op. We simulate a disconnection in our small grid to see the resultant state of the grid.\n", "

\n", " In the few next cells we will explain how to disconnect powerlines. First we create the action that will tell the grid to disconnect a powerline. Then we apply it on the grid, and then we look at the result.\n", "

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", " Note: The user can modify and play with other lines.\n", "
" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This action will:\n", "\t - NOT change anything to the injections\n", "\t - NOT perform any redispatching action\n", "\t - force disconnection of 1 powerlines ([2])\n", "\t - NOT switch any line status\n", "\t - NOT switch anything in the topology\n", "\t - NOT force any particular bus configuration\n" ] } ], "source": [ "# Specify the disconnection of line with id 2 (it's python, so id starts at 0)\n", "id_line = 2\n", "# Initialize action class\n", "action = action_space({\"set_line_status\": [(id_line, -1)]})\n", "print(action)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", "Make an environment and look at the powergrid:\n", "

" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "mode": "text", "showlegend": false, "text": [ "73.7%" ], "type": "scatter", "x": [ 1.5308084989341915e-15 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "90.3%" ], "type": "scatter", "x": [ 100 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "72.8%" ], "type": "scatter", "x": [ 200 ], "y": [ 199.99999999999997 ] }, { "mode": "text", "showlegend": false, "text": [ "58.5%" ], "type": "scatter", "x": [ 200 ], "y": [ -1.5308084989341915e-15 ] }, { "mode": "text", "showlegend": false, "text": [ "73.7%" ], "type": "scatter", "x": [ 100 ], "y": [ 400 ] }, { "mode": "text", "showlegend": false, "text": [ "37.0%" ], "type": "scatter", "x": [ 300 ], "y": [ 410.5654565435175 ] }, { "mode": "text", "showlegend": false, "text": [ "37.0%" ], "type": "scatter", "x": [ 300 ], "y": [ 389.4345434564825 ] }, { "mode": "text", "showlegend": false, "text": [ "57.5%" ], "type": "scatter", "x": [ 400 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "- 9 MW" ], "type": "scatter", "x": [ -70 ], "y": [ 8.572527594031473e-15 ] }, { "mode": "text", "showlegend": false, "text": [ "- 8 MW" ], "type": "scatter", "x": [ 470 ], "y": [ 400 ] }, { "mode": "text", "showlegend": false, "text": [ "- 8 MW" ], "type": "scatter", "x": [ 470 ], "y": [ 0 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 2 MW" ], "type": "scatter", "x": [ -35.000000000000036 ], "y": [ -60.62177826491068 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 26 MW" ], "type": "scatter", "x": [ -35.000000000000014 ], "y": [ 460.6217782649107 ] } ], "layout": { "height": 600, "margin": { "b": 100, "l": 20, "r": 20 }, "plot_bgcolor": "white", "shapes": [ { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -25, "x1": 25, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -25, "x1": 25, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 175, "x1": 225, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 375, "x1": 425, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 375, "x1": 425, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "line": { "color": "#dea4a4" }, "type": "line", "x0": 1.5308084989341915e-15, "x1": 1.5308084989341915e-15, "xref": "x", "y0": 25, "y1": 375, "yref": "y" }, { "line": { "color": "#bd6262" }, "type": "line", "x0": 11.18033988749895, "x1": 188.81966011250105, "xref": "x", "y0": 22.360679774997898, "y1": 377.6393202250021, "yref": "y" }, { "line": { "color": "#dea4a4" }, "type": "line", "x0": 17.67766952966369, "x1": 382.32233047033634, "xref": "x", "y0": 17.677669529663685, "y1": 382.3223304703363, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 25, "x1": 375, "xref": "x", "y0": 0, "y1": -3.061616997868383e-15, "yref": "y" }, { "line": { "color": "#dea4a4" }, "type": "line", "x0": 25, "x1": 175, "xref": "x", "y0": 400, "y1": 400, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 222.65769467591625, "x1": 377.3423053240837, "xref": "x", "y0": 410.5654565435175, "y1": 410.5654565435175, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 222.65769467591625, "x1": 377.3423053240838, "xref": "x", "y0": 389.4345434564825, "y1": 389.4345434564825, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 400, "x1": 400, "xref": "x", "y0": 375, "y1": 25, "yref": "y" }, { "type": "line", "x0": -50, "x1": -25, "xref": "x", "y0": 6.123233995736767e-15, "y1": 3.061616997868383e-15, "yref": "y" }, { "type": "line", "x0": 450, "x1": 425, "xref": "x", "y0": 400, "y1": 400, "yref": "y" }, { "type": "line", "x0": 450, "x1": 425, "xref": "x", "y0": 0, "y1": 0, "yref": "y" }, { "type": "line", "x0": -25.000000000000025, "x1": -12.50000000000001, "xref": "x", "y0": -43.30127018922192, "y1": -21.65063509461096, "yref": "y" }, { "type": "line", "x0": -25.00000000000001, "x1": -12.499999999999995, "xref": "x", "y0": 443.3012701892219, "y1": 421.65063509461095, "yref": "y" } ], "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "width": 800, "xaxis": { "range": [ -142.5, 542.5 ], "zeroline": false }, "yaxis": { "range": [ -142.5, 542.5 ] } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Run simulation\n", "environment = make(\"case5_example\")\n", "init_obs = environment.get_obs()\n", "fig = plot_helper.get_plot_observation(init_obs)\n", "fig.show()" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Grid State after disconnection of powerline with id 2:\n" ] }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "mode": "text", "showlegend": false, "text": [ "72.0%" ], "type": "scatter", "x": [ 1.5308084989341915e-15 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "102.7%" ], "type": "scatter", "x": [ 100 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "0.0%" ], "type": "scatter", "x": [ 200 ], "y": [ 199.99999999999997 ] }, { "mode": "text", "showlegend": false, "text": [ "76.2%" ], "type": "scatter", "x": [ 200 ], "y": [ -1.5308084989341915e-15 ] }, { "mode": "text", "showlegend": false, "text": [ "60.4%" ], "type": "scatter", "x": [ 100 ], "y": [ 400 ] }, { "mode": "text", "showlegend": false, "text": [ "20.4%" ], "type": "scatter", "x": [ 300 ], "y": [ 410.5654565435175 ] }, { "mode": "text", "showlegend": false, "text": [ "20.4%" ], "type": "scatter", "x": [ 300 ], "y": [ 389.4345434564825 ] }, { "mode": "text", "showlegend": false, "text": [ "75.2%" ], "type": "scatter", "x": [ 400 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "- 9 MW" ], "type": "scatter", "x": [ -70 ], "y": [ 8.572527594031473e-15 ] }, { "mode": "text", "showlegend": false, "text": [ "- 8 MW" ], "type": "scatter", "x": [ 470 ], "y": [ 400 ] }, { "mode": "text", "showlegend": false, "text": [ "- 8 MW" ], "type": "scatter", "x": [ 470 ], "y": [ 0 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 2 MW" ], "type": "scatter", "x": [ -35.000000000000036 ], "y": [ -60.62177826491068 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 26 MW" ], "type": "scatter", "x": [ -35.000000000000014 ], "y": [ 460.6217782649107 ] } ], "layout": { "height": 600, "margin": { "b": 100, "l": 20, "r": 20 }, "plot_bgcolor": "white", "shapes": [ { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -25, "x1": 25, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -25, "x1": 25, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 175, "x1": 225, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 375, "x1": 425, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 375, "x1": 425, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "line": { "color": "#dea4a4" }, "type": "line", "x0": 1.5308084989341915e-15, "x1": 1.5308084989341915e-15, "xref": "x", "y0": 25, "y1": 375, "yref": "y" }, { "line": { "color": "#9b2020" }, "type": "line", "x0": 11.18033988749895, "x1": 188.81966011250105, "xref": "x", "y0": 22.360679774997898, "y1": 377.6393202250021, "yref": "y" }, { "line": { "color": "gray", "dash": "dash" }, "type": "line", "x0": 17.67766952966369, "x1": 382.32233047033634, "xref": "x", "y0": 17.677669529663685, "y1": 382.3223304703363, "yref": "y" }, { "line": { "color": "#dea4a4" }, "type": "line", "x0": 25, "x1": 375, "xref": "x", "y0": 0, "y1": -3.061616997868383e-15, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 25, "x1": 175, "xref": "x", "y0": 400, "y1": 400, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 222.65769467591625, "x1": 377.3423053240837, "xref": "x", "y0": 410.5654565435175, "y1": 410.5654565435175, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 222.65769467591625, "x1": 377.3423053240838, "xref": "x", "y0": 389.4345434564825, "y1": 389.4345434564825, "yref": "y" }, { "line": { "color": "#dea4a4" }, "type": "line", "x0": 400, "x1": 400, "xref": "x", "y0": 375, "y1": 25, "yref": "y" }, { "type": "line", "x0": -50, "x1": -25, "xref": "x", "y0": 6.123233995736767e-15, "y1": 3.061616997868383e-15, "yref": "y" }, { "type": "line", "x0": 450, "x1": 425, "xref": "x", "y0": 400, "y1": 400, "yref": "y" }, { "type": "line", "x0": 450, "x1": 425, "xref": "x", "y0": 0, "y1": 0, "yref": "y" }, { "type": "line", "x0": -25.000000000000025, "x1": -12.50000000000001, "xref": "x", "y0": -43.30127018922192, "y1": -21.65063509461096, "yref": "y" }, { "type": "line", "x0": -25.00000000000001, "x1": -12.499999999999995, "xref": "x", "y0": 443.3012701892219, "y1": 421.65063509461095, "yref": "y" } ], "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "width": 800, "xaxis": { "range": [ -142.5, 542.5 ], "zeroline": false }, "yaxis": { "range": [ -142.5, 542.5 ] } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "obs_as_class, reward, done, info = environment.step(action)\n", "print(\"Grid State after disconnection of powerline with id 2:\")\n", "fig = plot_helper.get_plot_observation(obs_as_class)\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Analyzing results...

\n", "\n", "

\n", "In the previous results, we simulated a line disconnection caused by a lightning in the path 1-2. You immediately may notice some lines have changed the color. Overload events have been detected over the lines 1-4 and 1-3. The resulting power flow, after the redistribution, causes a flow increments over their thermal limits. In such condition, electrical operators have a few minutes to execute remedial actions to alleviate the system.\n", "
\n", " We can more qualitatively measure the difference of some flows.\n", "

" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The difference in the current flows at the origin of powerlines is:\n", "[ -10.06438784 27.36021026 -116.50533305 28.34172692 -79.90703863\n", " -49.76020435 -49.76020435 28.31287501]\n" ] } ], "source": [ "print(\"The difference in the current flows at the origin of powerlines is:\\n{}\".format(obs_as_class.a_or - init_obs.a_or))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", " In this case, disconnecting powerline with id 2 will (for example) reduce the flows of the the powerline with id 0 of 10 amperes, but will increase the flows on powerline with id 1 of 27 amperes\n", "

\n", " We can also have a look at the ratio \"current flows / thermal limit\" on each powerline, and compare them:\n", "

" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The difference in the loading of powerlines is:\n", "[-0.01677398 0.12436459 -0.72815833 0.17713579 -0.1331784 -0.16586735\n", " -0.16586735 0.17695547]\n" ] } ], "source": [ "print(\"The difference in the loading of powerlines is:\\n{}\".format(obs_as_class.rho - init_obs.rho))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

7. Inside a Substation

\n", "\n", "

\n", " A power grid is composed of power lines connected through substations. Within a substation, there can be several arrangements between branches (lines, generators and loads) that allow them to meet. There exist many predefined configurations and each of them are better than others in terms of reliability.\n", "

\n", " In grid2op, substations have \"double busbar layout\", which means that you can make no more than two electrical nodes per substations. The double busbar configuration consists of two bars on which you can connect together generators, loads and lines. For each of those elements, you have to choose the busbar it is connected to at a given time. The following figure is a representation of such configuration.\n", "

\n", " \n", "

\n", " On the left you can the modeling of the substation 1 of the powergrid. It is composed of 2 busbar, named \"bus 1\" (blue) and \"bus 2\" (orange). Each object (in this case: consumption c1, production p1, and origin of powerline l1, origin of powerline l2, origin of powerline l3 and origin of powerline l4 and origin of powerline l5) can be connected either to bus 1 or to bus 2. We showed the example where l1, l2 and c1 are connected to bus 1 and p2, l2 and l4 are connected to bus 1. There is no connection between these bus 1 and bus 2. On the right is the representation as a graph of the relevant powergrid.\n", "

\n", " Note that to simplify the action the Agents don't act directly on the switches (which would add some constraints on the problem, for example, an element can be connected on only one busbar: one switch open at most). In grid2op we choose to have people specifying on which bus the object is connected. The switch states are handled directly by the platform.\n", "

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

8. A Remedial Action

\n", "\n", "

\n", " When an overload is detected, operators have to execute a remedial action to alleviate the stress in the system. Normally the experience gained by years by people who work in electrical control rooms is a crucial factor to determine the best one. \n", "

\n", " Transmission networks are a bit complex with many paths where the power can flow (mesh grids). This also gives many alternatives to solve the congestions. In many countries changing the production is a valid solution. For instance, you can decrease the production of the generators which are connected to the overloaded line and increase others that are near the consumptions and it will reduce the overall flows on the powergrid.\n", "

\n", " However, the previous one is costly, especially in countries where producers are market actors. An always cheap one is to play with the main grid configuration, thus one does not have to change the productions. These are the kind of actions Rte wants to use to build a new smart controllers for the power grid through the challenge. \n", "

\n", " To illustrate the issue, let's take a step back to the previous grid state. Let's imagine something disconnected the powerline with id 2 (connecting subsation 0 with substation 3) on the powergrid (the powergrid is showed in the figure \"Grid State after disconnection of powerline with id 2:\" above). As we can see, this powergrid is not safe at all. The current flow on powerline with id 1 (connecting substation 0 and substation 2) is at 100% of its thermal limit. Something need to be done !\n", "

\n", " In this section we will see if performing a node splitting of substation with id 2 will solve the problem. The proposed action to performed is equivalent to change from the grid represented on the left, to the grid represented on the right in the figure below:\n", " \n", "

" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "# SE id we want to modify.\n", "sub_id = 2" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "id_l2_ingrid, *_ = environment.get_lines_id(from_=0, to_=sub_id)\n", "# we know l2 is connected to its \"extremity\" end at substation 2, so we look at its position in this substation \n", "# for its extremity part\n", "id_in_sub2_l2 = environment.line_ex_to_sub_pos[id_l2_ingrid]\n", "\n", "id_l5_ingrid, *_ = environment.get_lines_id(from_=1, to_=sub_id)\n", "id_in_sub2_l5 = environment.line_ex_to_sub_pos[id_l5_ingrid]\n", "\n", "id_l6l7_ingrid = environment.get_lines_id(from_=sub_id, to_=3)\n", "# we know l6 and l7 are connected to their \"origin\" end at substation 2, so we look at its position in this substation \n", "# for its origin part\n", "id_in_sub2_l6 = environment.line_or_to_sub_pos[id_l6l7_ingrid[0]]\n", "id_in_sub2_l7 = environment.line_or_to_sub_pos[id_l6l7_ingrid[1]]" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This action will:\n", "\t - NOT change anything to the injections\n", "\t - NOT perform any redispatching action\n", "\t - NOT force any line status\n", "\t - NOT switch any line status\n", "\t - Change the bus of the following element:\n", "\t \t - switch bus of line (extremity) 1 [on substation 2]\n", "\t \t - switch bus of line (origin) 6 [on substation 2]\n", "\t - NOT force any particular bus configuration\n" ] } ], "source": [ "# now we tell we want l5 connected to l6 and l2 to l7.\n", "# we can achieve that, for example, by changing the bus of l2 and l7, but not the one of l5 and l6.\n", "# this way, l5 and l6 will stay connected to bus 1 in substation with id 2 and l2 and l7 will be connected to bus 2.\n", "\n", "modified_bus = np.full(shape=4, dtype=bool, fill_value=False)\n", "# 4 because there are 4 elements in substation with id 2\n", "modified_bus[id_in_sub2_l2] = True\n", "modified_bus[id_in_sub2_l7] = True\n", "applied_action = environment.action_space({\"change_bus\": {\"substations_id\": [(sub_id, modified_bus)]}})\n", "print(applied_action)" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Grid State after the proposed topological action:\n" ] }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "mode": "text", "showlegend": false, "text": [ "90.6%" ], "type": "scatter", "x": [ 1.5308084989341915e-15 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "68.4%" ], "type": "scatter", "x": [ 100 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "0.0%" ], "type": "scatter", "x": [ 200 ], "y": [ 199.99999999999997 ] }, { "mode": "text", "showlegend": false, "text": [ "83.9%" ], "type": "scatter", "x": [ 200 ], "y": [ -1.5308084989341915e-15 ] }, { "mode": "text", "showlegend": false, "text": [ "49.8%" ], "type": "scatter", "x": [ 100 ], "y": [ 400 ] }, { "mode": "text", "showlegend": false, "text": [ "97.1%" ], "type": "scatter", "x": [ 300 ], "y": [ 410.5654565435175 ] }, { "mode": "text", "showlegend": false, "text": [ "55.9%" ], "type": "scatter", "x": [ 300 ], "y": [ 389.4345434564825 ] }, { "mode": "text", "showlegend": false, "text": [ "83.4%" ], "type": "scatter", "x": [ 400 ], "y": [ 200 ] }, { "mode": "text", "showlegend": false, "text": [ "- 9 MW" ], "type": "scatter", "x": [ -70 ], "y": [ 8.572527594031473e-15 ] }, { "mode": "text", "showlegend": false, "text": [ "- 8 MW" ], "type": "scatter", "x": [ 470 ], "y": [ 400 ] }, { "mode": "text", "showlegend": false, "text": [ "- 8 MW" ], "type": "scatter", "x": [ 470 ], "y": [ 0 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 2 MW" ], "type": "scatter", "x": [ -35.000000000000036 ], "y": [ -60.62177826491068 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 27 MW" ], "type": "scatter", "x": [ -35.000000000000014 ], "y": [ 460.6217782649107 ] } ], "layout": { "height": 600, "margin": { "b": 100, "l": 20, "r": 20 }, "plot_bgcolor": "white", "shapes": [ { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -25, "x1": 25, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -25, "x1": 25, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 175, "x1": 225, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 375, "x1": 425, "xref": "x", "y0": 375, "y1": 425, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 375, "x1": 425, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "line": { "color": "#bd6262" }, "type": "line", "x0": 1.5308084989341915e-15, "x1": 1.5308084989341915e-15, "xref": "x", "y0": 25, "y1": 375, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 11.18033988749895, "x1": 188.81966011250105, "xref": "x", "y0": 22.360679774997898, "y1": 377.6393202250021, "yref": "y" }, { "line": { "color": "gray", "dash": "dash" }, "type": "line", "x0": 17.67766952966369, "x1": 382.32233047033634, "xref": "x", "y0": 17.677669529663685, "y1": 382.3223304703363, "yref": "y" }, { "line": { "color": "#cd8383" }, "type": "line", "x0": 25, "x1": 375, "xref": "x", "y0": 0, "y1": -3.061616997868383e-15, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 25, "x1": 175, "xref": "x", "y0": 400, "y1": 400, "yref": "y" }, { "line": { "color": "#bd6262" }, "type": "line", "x0": 222.65769467591625, "x1": 377.3423053240837, "xref": "x", "y0": 410.5654565435175, "y1": 410.5654565435175, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 222.65769467591625, "x1": 377.3423053240838, "xref": "x", "y0": 389.4345434564825, "y1": 389.4345434564825, "yref": "y" }, { "line": { "color": "#cd8383" }, "type": "line", "x0": 400, "x1": 400, "xref": "x", "y0": 375, "y1": 25, "yref": "y" }, { "type": "line", "x0": -50, "x1": -25, "xref": "x", "y0": 6.123233995736767e-15, "y1": 3.061616997868383e-15, "yref": "y" }, { "type": "line", "x0": 450, "x1": 425, "xref": "x", "y0": 400, "y1": 400, "yref": "y" }, { "type": "line", "x0": 450, "x1": 425, "xref": "x", "y0": 0, "y1": 0, "yref": "y" }, { "type": "line", "x0": -25.000000000000025, "x1": -12.50000000000001, "xref": "x", "y0": -43.30127018922192, "y1": -21.65063509461096, "yref": "y" }, { "type": "line", "x0": -25.00000000000001, "x1": -12.499999999999995, "xref": "x", "y0": 443.3012701892219, "y1": 421.65063509461095, "yref": "y" }, { "fillcolor": "#ff7f0e", "line": { "color": "#ff7f0e" }, "type": "circle", "x0": 199.44315826429968, "x1": 207.44315826429968, "xref": "x", "y0": 383.87957669192264, "y1": 391.87957669192264, "yref": "y" }, { "fillcolor": "#1f77b4", "line": { "color": "#1f77b4" }, "type": "circle", "x0": 192.55684173570032, "x1": 200.55684173570032, "xref": "x", "y0": 408.12042330807736, "y1": 416.12042330807736, "yref": "y" }, { "line": { "color": "#ff7f0e" }, "type": "line", "x0": 222.65769467591625, "x1": 203.44315826429968, "xref": "x", "y0": 410.5654565435175, "y1": 387.87957669192264, "yref": "y" }, { "line": { "color": "#1f77b4" }, "type": "line", "x0": 222.65769467591625, "x1": 196.55684173570032, "xref": "x", "y0": 389.4345434564825, "y1": 412.12042330807736, "yref": "y" }, { "line": { "color": "#1f77b4" }, "type": "line", "x0": 188.81966011250105, "x1": 196.55684173570032, "xref": "x", "y0": 377.6393202250021, "y1": 412.12042330807736, "yref": "y" }, { "line": { "color": "#ff7f0e" }, "type": "line", "x0": 175, "x1": 203.44315826429968, "xref": "x", "y0": 400, "y1": 387.87957669192264, "yref": "y" } ], "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "width": 800, "xaxis": { "range": [ -142.5, 542.5 ], "zeroline": false }, "yaxis": { "range": [ -142.5, 542.5 ] } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Run the environment.\n", "after_obs, reward, done, info = environment.step(applied_action)\n", "\n", "# Plot the grid.\n", "if not done:\n", " print(\"Grid State after the proposed topological action:\")\n", " fig = plot_helper.get_plot_observation(after_obs)\n", " fig.show()\n", "else:\n", " print(\"Unfortunately the solution caused a lot of trouble, no powerflow can be computed by the solver.\"\n", " \"This is a GAME OVER\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", " The proposed solution solved the problem for powerline with id 1 without creating new problem. The agent sucessfully overcome this difficulty. \n", "

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

9. Conclusion

\n", "\n", "

\n", " In this notebook, we reviewed very quickly the main operation principles in transmission networks with a small grid. The continuity of the electric power service is crucial for nowadays economy and should be robust enough to any hazards or atypical sistuations in its operations. A undesired line disconnection without an effective action that could solve the problem might bring blackouts and economic losses. \n", "

\n", " As we mentioned earlier, transmission operation involves many tasks but all of them are met to have one single objective: supply reliable and secure electricity. Operators work every day to minimize the impact of external factors that put the electrical system at risk but eventually when the grid is large and meshed, the daily operation is more complicated.\n", "

\n", " The Grid2Op platform was designed to interact together with the reinforcement learning approach. It allows executing actions in the transmission grid to manage lines with congestion without any cost involved. We covered all actions such as line disconnection and node splitting in the respective section. A user could play and execute more complicated ones through combinations. \n", "

\n", " The end state during the challenge is to train an agent able to learn a policy that could overcome obstacles, aka congestions, while optimizing the line usage rates to reflect a real operation in transmission grids.\n", "

" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.6" } }, "nbformat": 4, "nbformat_minor": 2 }