{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Basic Agent Sudy" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It is recommended to have a look at the [0_basic_functionalities](0_basic_functionalities.ipynb), [1_Observation_Agents](1_Observation_Agents.ipynb), [2_Action_GridManipulation](3_TrainingAnAgent.ipynb) and [3_TrainingAnAgent](3_TrainingAnAgent.ipynb) notebooks before getting into this one." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Objectives**\n", "\n", "In this notebook we will expose how to study an Agent. For this notebook to be interested, we first use a dummy agent, and then we look at how to study his behaviour from the file saved.\n", "\n", "This notebook will also show you how to use the Graphical User Interface built for analyzing grid2Op agents called \"Grid2Viz\".\n", "\n", "It is more than recommended to know how to define an Agent and use a Runner before doing this tutotial!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Evaluate the performance of a simple Agen" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os\n", "import sys\n", "import grid2op\n", "import copy\n", "import numpy as np\n", "import shutil\n", "import seaborn as sns\n", "import plotly.graph_objects as go\n", "\n", "from tqdm.notebook import tqdm\n", "from grid2op.Agent import PowerLineSwitch\n", "from grid2op.Reward import L2RPNReward\n", "from grid2op.Runner import Runner\n", "from grid2op.Chronics import GridStateFromFileWithForecasts, Multifolder\n", "path_agents = \"study_agent_getting_started\"\n", "max_iter = 30" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the next cell we evaluate the agent \"PowerLineSwitch\" and save the results of this evaluation in \"study_agent_getting_started\"" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/donnotben/Documents/Grid2Op_dev/getting_started/grid2op/MakeEnv.py:667: UserWarning:\n", "\n", "Your are using only 2 chronics for this environment. More can be download by running, from a command line:\n", "python -m grid2op.download --name \"case14_realistic\" --path_save PATH\\WHERE\\YOU\\WANT\\TO\\DOWNLOAD\\DATA\n", "\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "f5756e4b0c984816b6b7bbf95b3a745a", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(FloatProgress(value=0.0, description='episode', max=2.0, style=ProgressStyle(description_width=…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "85cb0edd011d4e54b2f760ed2383fdc5", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(FloatProgress(value=0.0, description='episode', max=30.0, style=ProgressStyle(description_width…" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "7e75ecd01dc547e08753a7f12803b1b2", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(FloatProgress(value=0.0, description='episode', max=30.0, style=ProgressStyle(description_width…" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "The results for the evaluated agent are:\n", "\tFor chronics with id 000\n", "\t\t - cumulative reward: 1094.640995\n", "\t\t - number of time steps completed: 2 / 30\n", "\tFor chronics with id 001\n", "\t\t - cumulative reward: 4374.827712\n", "\t\t - number of time steps completed: 5 / 30\n" ] } ], "source": [ "scoring_function = L2RPNReward\n", "env = grid2op.make()\n", "# env.chronics_handler.set_max_iter(max_iter)\n", "shutil.rmtree(os.path.abspath(path_agents), ignore_errors=True)\n", "if not os.path.exists(path_agents):\n", " os.mkdir(path_agents)\n", "\n", "# make a runner for this agent\n", "path_agent = os.path.join(path_agents, \"PowerLineSwitch\")\n", "shutil.rmtree(os.path.abspath(path_agent), ignore_errors=True)\n", "\n", "runner = Runner(**env.get_params_for_runner(),\n", " agentClass=PowerLineSwitch\n", " )\n", "res = runner.run(path_save=path_agent, nb_episode=2, \n", " max_iter=max_iter,\n", " pbar=tqdm)\n", "print(\"The results for the evaluated agent are:\")\n", "for _, chron_id, cum_reward, nb_time_step, max_ts in res:\n", " msg_tmp = \"\\tFor chronics with id {}\\n\".format(chron_id)\n", " msg_tmp += \"\\t\\t - cumulative reward: {:.6f}\\n\".format(cum_reward)\n", " msg_tmp += \"\\t\\t - number of time steps completed: {:.0f} / {:.0f}\".format(nb_time_step, max_ts)\n", " print(msg_tmp)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Looking at the results, understand the behaviour of the Agent" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The content of the folder is the following:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "000 dict_action_space.json\t dict_observation_space.json\r\n", "001 dict_env_modification_space.json\r\n" ] } ], "source": [ "!ls $path_agent" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As we notice, there are 2 json that represents the action space and the observation space, used to read the data store. These objects can be loaded this way:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "from grid2op.Utils import ActionSpace, ObservationSpace\n", "\n", "action_space = ActionSpace.from_dict(os.path.join(path_agent, \"dict_action_space.json\"))\n", "env_modif_space = ActionSpace.from_dict(os.path.join(path_agent, \"dict_env_modification_space.json\"))\n", "observation_space = ObservationSpace.from_dict(os.path.join(path_agent, \"dict_observation_space.json\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we can load the data corresponding to episode 1 for example, we can load the actions and the observations and de-serialize them properly into proper objects:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "path_episode_1 = os.path.join(path_agent, \"001\")\n", "actions_npy = np.load(os.path.join(path_episode_1, \"actions.npy\"))\n", "li_actions = []\n", "for i in range(actions_npy.shape[0]):\n", " try:\n", " tmp = action_space.from_vect(actions_npy[i,:])\n", " li_actions.append(tmp)\n", " except:\n", " break\n", " \n", "observations_npy = np.load(os.path.join(path_episode_1, \"observations.npy\"))\n", "li_observations = []\n", "for i in range(observations_npy.shape[0]):\n", " try:\n", " tmp = observation_space.from_vect(observations_npy[i,:])\n", " li_observations.append(tmp)\n", " except:\n", " break\n", " \n", "env_modifications = np.load(os.path.join(path_episode_1, \"env_modifications.npy\"))\n", "li_env_modifs = []\n", "for i in range(env_modifications.shape[0]):\n", " try:\n", " tmp = env_modif_space.from_vect(env_modifications[i,:])\n", " li_env_modifs.append(tmp)\n", " except:\n", " break" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Inspect the actions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And now we can start to study the given agent, for example, let's inspect its actions and wonder how many powerlines it has disconnected (for example, this is probably not the best thing to do here...)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "line_disc = 0\n", "line_reco = 0\n", "for act in li_actions:\n", " dict_ = act.as_dict() # representation of an action as a dictionnary, see the documentation for more information\n", " if \"set_line_status\" in dict_:\n", " line_reco += dict_[\"set_line_status\"][\"nb_connected\"]\n", " line_disc += dict_[\"set_line_status\"][\"nb_disconnected\"]\n", "line_disc" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also wonder how many times this Agent acted on the powerline with id 1, and inspect how many times it has change its status:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "line_disconnected = 0\n", "for act in li_actions:\n", " dict_ = act.effect_on(line_id=1) # which effect has this action action on the substation with id 1\n", " # other objects are: load_id, gen_id, line_id or substation_id\n", " if dict_['set_line_status'] == 1 :\n", " line_disconnected += 1\n", "line_disconnected" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Inspect the modification of the environment" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For example, we might want to inspect the number of hazards and maintenance of a total scenario, to see how difficult it was." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nb_hazards = 0\n", "nb_maintenance = 0\n", "for act in li_env_modifs:\n", " dict_ = act.as_dict() # representation of an action as a dictionnary, see the documentation for more information\n", " if \"nb_hazards\" in dict_:\n", " nb_hazards += 1\n", " if \"nb_maintenance\" in dict_:\n", " nb_maintenance += 1\n", "nb_maintenance" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Inspect the observations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For example, let's look at the value consumed by load 1. For this cell to work, it requires plotly for displaying the results." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5 ], "y": [ 87.4, 85.8, 87.1, 87.8, 86.9, 86.9 ] } ], "layout": { "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 } } }, "title": { "text": "Consumption of load 1" }, "xaxis": { "title": { "text": "Time step" } }, "yaxis": { "title": { "text": "Load (MW)" } } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import plotly.graph_objects as go\n", "load_id = 1\n", "# extract the data\n", "val_load1 = np.zeros(len(li_observations))\n", "for i, obs in enumerate(li_observations):\n", " dict_ = obs.state_of(load_id=load_id) # which effect has this action action on the substation with id 1\n", " # other objects are: load_id, gen_id, line_id or substation_id\n", " # see the documentation for more information.\n", " val_load1[i] = dict_['p']\n", "\n", "# plot it\n", "fig = go.Figure(data=[go.Scatter(x=[i for i in range(len(val_load1))],\n", " y=val_load1)])\n", "fig.update_layout(title=\"Consumption of load {}\".format(load_id),\n", " xaxis_title=\"Time step\",\n", " yaxis_title=\"Load (MW)\")\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Or the values of generator 3 (it's supposed to represent a solar energy source)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5 ], "y": [ 75.57900088523799, 71.38701584228819, 77.82220205791653, 73.88946197447214, 38.100000000000065, 38.100000000000065 ] } ], "layout": { "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 } } }, "title": { "text": "Production of generator 4" }, "xaxis": { "title": { "text": "Time step" } }, "yaxis": { "title": { "text": "Production (MW)" } } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "gen_id = 4\n", "# extract the data\n", "val_lgen3 = np.zeros(len(li_observations))\n", "for i, obs in enumerate(li_observations):\n", " dict_ = obs.state_of(gen_id=gen_id) # which effect has this action action on the substation with id 1\n", " # other objects are: load_id, gen_id, line_id or substation_id\n", " # see the documentation for more information.\n", " val_lgen3[i] = dict_['p']\n", "\n", "# plot it\n", "fig = go.Figure(data=[go.Scatter(x=[i for i in range(len(val_lgen3))],\n", " y=val_lgen3)])\n", "fig.update_layout(title=\"Production of generator {}\".format(gen_id),\n", " xaxis_title=\"Time step\",\n", " yaxis_title=\"Production (MW)\")\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the same fashion, we might want to get the flows on powerline connecting bus 3 to bus 4 (without knowing its id by using the appropriate method of the observation_space):" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5 ], "y": [ 138.4017424785368, 234.78747315053926, 243.46678861380752, 164.41492202242117, 177.803304038686, 177.803304038686 ] } ], "layout": { "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 } } }, "title": { "text": "Flow on powerline 6 (going from 3 to 4)" }, "xaxis": { "title": { "text": "Time step" } }, "yaxis": { "title": { "text": "Production (MW)" } } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from_ = 3\n", "to_ = 4\n", "found_ids = observation_space.get_lines_id(from_=from_, to_=to_)\n", "line_id = found_ids[0]\n", "\n", "# extract the data\n", "val_l3_4 = np.zeros(len(li_observations))\n", "for i, obs in enumerate(li_observations):\n", " dict_ = obs.state_of(line_id=line_id) # which effect has this action action on the substation with id 1\n", " # other objects are: load_id, gen_id, line_id or substation_id\n", " # see the documentation for more information.\n", " val_l3_4[i] = dict_[\"origin\"]['a']\n", "\n", "# plot it\n", "fig = go.Figure(data=[go.Scatter(x=[i for i in range(len(val_l3_4))],\n", " y=val_l3_4)])\n", "fig.update_layout(title=\"Flow on powerline {} (going from {} to {})\".format(line_id, from_, to_),\n", " xaxis_title=\"Time step\",\n", " yaxis_title=\"Production (MW)\")\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Quick display of a grid using an observation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Bellow you can find an example on how to plot a observation and the underlying powergrid. This is an example, the results doesn't look really great. It uses plotly and requires the layout of the grid (eg the coordinates of the substations) to be specified.\n", "\n", "Note also that this code is not optimized at all." ] }, { "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": [ "11.8%" ], "type": "scatter", "x": [ -190 ], "y": [ -175.5 ] }, { "mode": "text", "showlegend": false, "text": [ "52.0%" ], "type": "scatter", "x": [ -172 ], "y": [ -67.5 ] }, { "mode": "text", "showlegend": false, "text": [ "45.7%" ], "type": "scatter", "x": [ 133 ], "y": [ -270 ] }, { "mode": "text", "showlegend": false, "text": [ "0.0%" ], "type": "scatter", "x": [ 133 ], "y": [ -162 ] }, { "mode": "text", "showlegend": false, "text": [ "0.0%" ], "type": "scatter", "x": [ -82 ], "y": [ -162 ] }, { "mode": "text", "showlegend": false, "text": [ "31.2%" ], "type": "scatter", "x": [ 366 ], "y": [ -162 ] }, { "mode": "text", "showlegend": false, "text": [ "46.8%" ], "type": "scatter", "x": [ 151 ], "y": [ -54 ] }, { "mode": "text", "showlegend": false, "text": [ "42.9%" ], "type": "scatter", "x": [ 7.5000000000000036 ], "y": [ 108 ] }, { "mode": "text", "showlegend": false, "text": [ "0.0%" ], "type": "scatter", "x": [ -117 ], "y": [ 162 ] }, { "mode": "text", "showlegend": false, "text": [ "0.0%" ], "type": "scatter", "x": [ -64 ], "y": [ 162 ] }, { "mode": "text", "showlegend": false, "text": [ "56.8%" ], "type": "scatter", "x": [ 274 ], "y": [ 81 ] }, { "mode": "text", "showlegend": false, "text": [ "0.0%" ], "type": "scatter", "x": [ 274 ], "y": [ 135 ] }, { "mode": "text", "showlegend": false, "text": [ "53.9%" ], "type": "scatter", "x": [ 150.5 ], "y": [ 135 ] }, { "mode": "text", "showlegend": false, "text": [ "0.0%" ], "type": "scatter", "x": [ -117 ], "y": [ 270 ] }, { "mode": "text", "showlegend": false, "text": [ "0.0%" ], "type": "scatter", "x": [ 79 ], "y": [ 243 ] }, { "mode": "text", "showlegend": false, "text": [ "16.9%" ], "type": "scatter", "x": [ 408 ], "y": [ -27 ] }, { "mode": "text", "showlegend": false, "text": [ "16.4%" ], "type": "scatter", "x": [ 346 ], "y": [ 0 ] }, { "mode": "text", "showlegend": false, "text": [ "0.0%" ], "type": "scatter", "x": [ -64 ], "y": [ 0 ] }, { "mode": "text", "showlegend": false, "text": [ "0.0%" ], "type": "scatter", "x": [ 500 ], "y": [ -1.5308084989341915e-15 ] }, { "mode": "text", "showlegend": false, "text": [ "13.2%" ], "type": "scatter", "x": [ 388 ], "y": [ 27 ] }, { "mode": "text", "showlegend": false, "text": [ "- 22 MW" ], "type": "scatter", "x": [ -135.00000000000003 ], "y": [ -330.6217782649107 ] }, { "mode": "text", "showlegend": false, "text": [ "- 87 MW" ], "type": "scatter", "x": [ 436 ], "y": [ -270 ] }, { "mode": "text", "showlegend": false, "text": [ "- 47 MW" ], "type": "scatter", "x": [ 436 ], "y": [ -54 ] }, { "mode": "text", "showlegend": false, "text": [ "- 7 MW" ], "type": "scatter", "x": [ -120.6311896062463 ], "y": [ -12.85503233952685 ] }, { "mode": "text", "showlegend": false, "text": [ "- 11 MW" ], "type": "scatter", "x": [ -134 ], "y": [ 54.00000000000001 ] }, { "mode": "text", "showlegend": false, "text": [ "- 30 MW" ], "type": "scatter", "x": [ 269.3688103937537 ], "y": [ 12.855032339526872 ] }, { "mode": "text", "showlegend": false, "text": [ "- 9 MW" ], "type": "scatter", "x": [ 187 ], "y": [ 47.378221735089305 ] }, { "mode": "text", "showlegend": false, "text": [ "- 3 MW" ], "type": "scatter", "x": [ 44.000000000000014 ], "y": [ 222.62177826491072 ] }, { "mode": "text", "showlegend": false, "text": [ "- 5 MW" ], "type": "scatter", "x": [ -205 ], "y": [ 330.6217782649107 ] }, { "mode": "text", "showlegend": false, "text": [ "- 12 MW" ], "type": "scatter", "x": [ -63.99999999999999 ], "y": [ 340 ] }, { "mode": "text", "showlegend": false, "text": [ "- 14 MW" ], "type": "scatter", "x": [ 187 ], "y": [ 155.3782217350893 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 76 MW" ], "type": "scatter", "x": [ -64.99999999999997 ], "y": [ -330.6217782649107 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 73 MW" ], "type": "scatter", "x": [ 366 ], "y": [ -340 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 29 MW" ], "type": "scatter", "x": [ -99.00000000000003 ], "y": [ -6.621778264910681 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 0 MW" ], "type": "scatter", "x": [ 620 ], "y": [ 0 ] }, { "mode": "text", "showlegend": false, "text": [ "+ 38 MW" ], "type": "scatter", "x": [ -315 ], "y": [ -141.6217782649107 ] } ], "layout": { "height": 600, "margin": { "b": 100, "l": 20, "r": 20 }, "plot_bgcolor": "white", "shapes": [ { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -305, "x1": -255, "xref": "x", "y0": -106, "y1": -56, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -125, "x1": -75, "xref": "x", "y0": -295, "y1": -245, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 341, "x1": 391, "xref": "x", "y0": -295, "y1": -245, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 341, "x1": 391, "xref": "x", "y0": -79, "y1": -29, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -89, "x1": -39, "xref": "x", "y0": -79, "y1": -29, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -89, "x1": -39, "xref": "x", "y0": 29, "y1": 79, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 425, "x1": 475, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 525, "x1": 575, "xref": "x", "y0": -25, "y1": 25, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 301, "x1": 351, "xref": "x", "y0": 29, "y1": 79, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 197, "x1": 247, "xref": "x", "y0": 83, "y1": 133, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 54, "x1": 104, "xref": "x", "y0": 137, "y1": 187, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -195, "x1": -145, "xref": "x", "y0": 245, "y1": 295, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": -89, "x1": -39, "xref": "x", "y0": 245, "y1": 295, "yref": "y" }, { "fillcolor": "lightgray", "line": { "color": "LightSeaGreen" }, "type": "circle", "x0": 197, "x1": 247, "xref": "x", "y0": 191, "y1": 241, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": -262.7586206896552, "x1": -117.24137931034483, "xref": "x", "y0": -99.10344827586206, "y1": -251.89655172413794, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": -255.19305308215831, "x1": -88.80694691784169, "xref": "x", "y0": -77.89913163526978, "y1": -57.10086836473021, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": -75, "x1": 341, "xref": "x", "y0": -270, "y1": -270, "yref": "y" }, { "line": { "color": "gray", "dash": "dash" }, "type": "line", "x0": -77.31814069641977, "x1": 343.3181406964198, "xref": "x", "y0": -259.4865201511302, "y1": -64.51347984886979, "yref": "y" }, { "line": { "color": "gray", "dash": "dash" }, "type": "line", "x0": -95.89002531736607, "x1": -68.10997468263393, "xref": "x", "y0": -245.3401519041964, "y1": -78.6598480958036, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 366, "x1": 366, "xref": "x", "y0": -245, "y1": -79, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 341, "x1": -39, "xref": "x", "y0": -54, "y1": -54, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": -44.050335037219895, "x1": 59.0503350372199, "xref": "x", "y0": 69.06687983202973, "y1": 146.93312016797026, "yref": "y" }, { "line": { "color": "gray", "dash": "dash" }, "type": "line", "x0": -75.01378507227128, "x1": -158.98621492772872, "xref": "x", "y0": 76.44318467557166, "y1": 247.55681532442833, "yref": "y" }, { "line": { "color": "gray", "dash": "dash" }, "type": "line", "x0": -64, "x1": -64, "xref": "x", "y0": 79, "y1": 245, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 303.8125980799565, "x1": 244.1874019200435, "xref": "x", "y0": 65.52038176617643, "y1": 96.47961823382357, "yref": "y" }, { "line": { "color": "gray", "dash": "dash" }, "type": "line", "x0": 312.4941898533551, "x1": 235.50581014664488, "xref": "x", "y0": 75.03789657458142, "y1": 194.96210342541858, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 198.61199632229705, "x1": 102.38800367770297, "xref": "x", "y0": 116.8318335566151, "y1": 153.1681664433849, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": -145, "x1": -89, "xref": "x", "y0": 270, "y1": 270, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": -39.434049401783135, "x1": 197.43404940178314, "xref": "x", "y0": 265.36167366327373, "y1": 220.63832633672627, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 387.0294618844138, "x1": 428.9705381155862, "xref": "x", "y0": -40.48106021716253, "y1": -13.518939782837473, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 357.31714110441015, "x1": 334.68285889558985, "xref": "x", "y0": -30.55628098190741, "y1": 30.55628098190741, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": -64, "x1": -64, "xref": "x", "y0": -29, "y1": 29, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 475, "x1": 525, "xref": "x", "y0": 0, "y1": -3.061616997868383e-15, "yref": "y" }, { "line": { "color": "#efc5c5" }, "type": "line", "x0": 348.92086997347906, "x1": 427.07913002652094, "xref": "x", "y0": 44.01833081800107, "y1": 9.981669181998933, "yref": "y" }, { "type": "line", "x0": -125.00000000000001, "x1": -112.50000000000001, "xref": "x", "y0": -313.3012701892219, "y1": -291.65063509461095, "yref": "y" }, { "type": "line", "x0": 416, "x1": 391, "xref": "x", "y0": -270, "y1": -270, "yref": "y" }, { "type": "line", "x0": 416, "x1": 391, "xref": "x", "y0": -54, "y1": -54, "yref": "y" }, { "type": "line", "x0": -104.45084971874735, "x1": -84.22542485937367, "xref": "x", "y0": -24.61073738537632, "y1": -39.30536869268817, "yref": "y" }, { "type": "line", "x0": -114, "x1": -89, "xref": "x", "y0": 54.00000000000001, "y1": 54, "yref": "y" }, { "type": "line", "x0": 285.54915028125265, "x1": 305.7745751406263, "xref": "x", "y0": 24.61073738537634, "y1": 39.30536869268818, "yref": "y" }, { "type": "line", "x0": 197, "x1": 209.5, "xref": "x", "y0": 64.69872981077808, "y1": 86.34936490538904, "yref": "y" }, { "type": "line", "x0": 54.000000000000014, "x1": 66.5, "xref": "x", "y0": 205.30127018922195, "y1": 183.65063509461098, "yref": "y" }, { "type": "line", "x0": -195, "x1": -182.5, "xref": "x", "y0": 313.3012701892219, "y1": 291.65063509461095, "yref": "y" }, { "type": "line", "x0": -63.99999999999999, "x1": -64, "xref": "x", "y0": 320, "y1": 295, "yref": "y" }, { "type": "line", "x0": 197, "x1": 209.5, "xref": "x", "y0": 172.69872981077808, "y1": 194.34936490538905, "yref": "y" }, { "type": "line", "x0": -74.99999999999997, "x1": -87.5, "xref": "x", "y0": -313.3012701892219, "y1": -291.65063509461095, "yref": "y" }, { "type": "line", "x0": 366, "x1": 366, "xref": "x", "y0": -320, "y1": -295, "yref": "y" }, { "type": "line", "x0": -89.00000000000001, "x1": -76.50000000000001, "xref": "x", "y0": 10.698729810778083, "y1": 32.34936490538904, "yref": "y" }, { "type": "line", "x0": 600, "x1": 575, "xref": "x", "y0": 0, "y1": 0, "yref": "y" }, { "type": "line", "x0": -305, "x1": -292.5, "xref": "x", "y0": -124.30127018922192, "y1": -102.65063509461096, "yref": "y" }, { "fillcolor": "#ff7f0e", "line": { "color": "#ff7f0e" }, "type": "circle", "x0": -100.28088574543456, "x1": -92.28088574543456, "xref": "x", "y0": -261.9613875732505, "y1": -253.96138757325048, "yref": "y" }, { "fillcolor": "#1f77b4", "line": { "color": "#1f77b4" }, "type": "circle", "x0": -107.71911425456544, "x1": -99.71911425456544, "xref": "x", "y0": -286.0386124267495, "y1": -278.0386124267495, "yref": "y" }, { "line": { "color": "#ff7f0e" }, "type": "line", "x0": -112.50000000000001, "x1": -96.28088574543456, "xref": "x", "y0": -291.65063509461095, "y1": -257.9613875732505, "yref": "y" }, { "line": { "color": "#ff7f0e" }, "type": "line", "x0": -87.5, "x1": -96.28088574543456, "xref": "x", "y0": -291.65063509461095, "y1": -257.9613875732505, "yref": "y" }, { "line": { "color": "#1f77b4" }, "type": "line", "x0": -75, "x1": -103.71911425456544, "xref": "x", "y0": -270, "y1": -282.0386124267495, "yref": "y" }, { "line": { "color": "#1f77b4" }, "type": "line", "x0": -77.31814069641977, "x1": -103.71911425456544, "xref": "x", "y0": -259.4865201511302, "y1": -282.0386124267495, "yref": "y" }, { "line": { "color": "#ff7f0e" }, "type": "line", "x0": -95.89002531736607, "x1": -96.28088574543456, "xref": "x", "y0": -245.3401519041964, "y1": -257.9613875732505, "yref": "y" }, { "line": { "color": "#1f77b4" }, "type": "line", "x0": -117.24137931034483, "x1": -103.71911425456544, "xref": "x", "y0": -251.89655172413794, "y1": -282.0386124267495, "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": [ -422.5, 692.5 ], "zeroline": false }, "yaxis": { "range": [ -412.5, 412.5 ] } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from grid2op.Plot.PlotPlotly import PlotPlotly\n", "obs = copy.deepcopy(li_observations[-1])\n", "# and change the topology (just to have something to represent)\n", "obs.topo_vect[3:9] = [2,2,2,1,1,1]\n", "\n", "plot_helper = PlotPlotly(observation_space=observation_space)\n", "fig = plot_helper.get_plot_observation(obs)\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Synching Observation and Action" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As stated in the documentation, at row i, it's the observation at time \"i\" and the action at time \"i\". So at row i of the numpy matrices, we see what the agent saw when he took his actions. We have \"an agent view\".\n", "\n", "In case we want to see the impact of an Action, it is then necessary to:\n", "\n", "- look at action i\n", "- look at observation i+1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using the dedicated grid2viz framework\n", "\n", "Grid2viz is a package that has been developped to help you visualize the behaviour of your agent. \n", "\n", "It is available for now in a github repository [grid2viz](https://github.com/mjothy/grid2viz). In the few following cells we will demonstrate how to use it to inspect in more detail the log of the agents generated by the runner (second cell of this notebook).\n", "\n", "\n", "We will first run some other agents to show the full potential of grid2viz (optional). Then we emphasize a constraint on the use of grid2viz: the folder tree must respect a certain order. Then we show how to install it and finally how to launch it on the data generated by this notebook.\n", "\n", "![](https://raw.githubusercontent.com/mjothy/grid2viz/master/grid2viz/assets/screenshots/scenario_overview.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### More agents to compare\n", "\n", "This section is not mandatory, but it is better to show the full capabilities of grid2viz. We will first run 2 others agents: the do nothing agent, and the topology greedy agents." ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The results for the DoNothingAgent agent are:\n", "\tFor chronics with id 000\n", "\t\t - cumulative reward: 34403.382277\n", "\t\t - number of time steps completed: 30 / 30\n", "\tFor chronics with id 001\n", "\t\t - cumulative reward: 34420.375574\n", "\t\t - number of time steps completed: 30 / 30\n" ] } ], "source": [ "# make a runner for this agent\n", "from grid2op.Agent import DoNothingAgent, TopologyGreedy\n", "\n", "for agentClass, agentName in zip([DoNothingAgent], # , TopologyGreedy\n", " [\"DoNothingAgent\"]): # , \"TopologyGreedy\"\n", " path_agent = os.path.join(path_agents, agentName)\n", " shutil.rmtree(os.path.abspath(path_agent), ignore_errors=True)\n", " runner = Runner(**env.get_params_for_runner(),\n", " agentClass=agentClass\n", " )\n", " res = runner.run(path_save=path_agent, nb_episode=2, \n", " max_iter=max_iter)\n", " print(\"The results for the {} agent are:\".format(agentName))\n", " for _, chron_id, cum_reward, nb_time_step, max_ts in res:\n", " msg_tmp = \"\\tFor chronics with id {}\\n\".format(chron_id)\n", " msg_tmp += \"\\t\\t - cumulative reward: {:.6f}\\n\".format(cum_reward)\n", " msg_tmp += \"\\t\\t - number of time steps completed: {:.0f} / {:.0f}\".format(nb_time_step, max_ts)\n", " print(msg_tmp)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Caution" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Grid2Viz for now require a specific organization of the folders. You must:\n", "- use the runner to save the results of your experiment, using the \"path_save\" argument\n", "- the agent must be \"alone\" in this directory: you should save it to an empty directory\n", "- the path where the agent is stored must contain only folder of agents.\n", "\n", "These contraints give the following \"architecture\":\n", "\n", "+ regular directory\n", " + runner log\n", " + agent log 1\n", " - scenario log 1\n", " - scenario log 2\n", " ...\n", " - scenario log n\n", " + agent log 2\n", " - scenario log 1\n", " ...\n", " - scenario log p\n", " + agent log 3\n", " - scenario log 1\n", " ...\n", " + other folders\n", "+ other folders\n", "\n", "An example is given in the \"path_agents\" directory used in this notebook." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "study_agent_getting_started:\r\n", "DoNothingAgent\tPowerLineSwitch\r\n", "\r\n", "study_agent_getting_started/DoNothingAgent:\r\n", "000 dict_action_space.json\t dict_observation_space.json\r\n", "001 dict_env_modification_space.json\r\n", "\r\n", "study_agent_getting_started/DoNothingAgent/000:\r\n", "actions.npy\t\t\t episode_meta.json _parameters.json\r\n", "agent_exec_times.npy\t\t episode_times.json rewards.npy\r\n", "disc_lines_cascading_failure.npy observations.npy\r\n", "env_modifications.npy\t\t other_rewards.json\r\n", "\r\n", "study_agent_getting_started/DoNothingAgent/001:\r\n", "actions.npy\t\t\t episode_meta.json _parameters.json\r\n", "agent_exec_times.npy\t\t episode_times.json rewards.npy\r\n", "disc_lines_cascading_failure.npy observations.npy\r\n", "env_modifications.npy\t\t other_rewards.json\r\n", "\r\n", "study_agent_getting_started/PowerLineSwitch:\r\n", "000 dict_action_space.json\t dict_observation_space.json\r\n", "001 dict_env_modification_space.json\r\n", "\r\n", "study_agent_getting_started/PowerLineSwitch/000:\r\n", "actions.npy\t\t\t episode_meta.json _parameters.json\r\n", "agent_exec_times.npy\t\t episode_times.json rewards.npy\r\n", "disc_lines_cascading_failure.npy observations.npy\r\n", "env_modifications.npy\t\t other_rewards.json\r\n", "\r\n", "study_agent_getting_started/PowerLineSwitch/001:\r\n", "actions.npy\t\t\t episode_meta.json _parameters.json\r\n", "agent_exec_times.npy\t\t episode_times.json rewards.npy\r\n", "disc_lines_cascading_failure.npy observations.npy\r\n", "env_modifications.npy\t\t other_rewards.json\r\n" ] } ], "source": [ "!ls -R $path_agents" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If the command \"tree\" is installed on your machine, you can uncomment the following cell to have a better layout." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "# !tree $path_agents" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Installation\n", "\n", "Grid2Viz is not yet on pypi, the python package repository. So you need a specific command to install it. It can be done super easily by running the cell bellow (more information can be found on the grid2iz github)." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "To install it, either uncomment the cell bellow, or type, in a command prompt:\n", "\t/usr/bin/python3 -m pip install git+https://github.com/mjothy/grid2viz.git --user --extra-index-url https://test.pypi.org/simple/\n" ] } ], "source": [ "import sys\n", "print(\"To install it, either uncomment the cell bellow, or type, in a command prompt:\\n{}\".format(\n", " (\"\\t{} -m pip install git+https://github.com/mjothy/grid2viz.git --user --extra-index-url https://test.pypi.org/simple/\".format(sys.executable))))" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "# !$sys.executable -m pip install git+https://github.com/mjothy/grid2viz --user --extra-index-url https://test.pypi.org/simple/" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Usage" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once the above package is installed, you can now start to study what your agent did (NB the agent must have been run with a runner and the \"path_save\" argument in order for grid2viz to work properly." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "You can start this server either by running the next cell, or by typing in a cmd:\n", "\t\t/usr/bin/python3 -m grid2viz.main --path /home/donnotben/Documents/Grid2Op_dev/getting_started/study_agent_getting_started\n" ] } ], "source": [ "print(\"You can start this server either by running the next cell, or by typing in a cmd:\\n\"\\\n", " \"\\t\\t{} -m grid2viz.main --path {}\".format(sys.executable, os.path.abspath(path_agents)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For performance optimization, grid2viz uses a cache. This notebook being an example, it is recommended to clear the cache before starting the grid2viz app. Of course, if you study different generation of your agent, it is NOT recommended to clear the cache before any study." ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "shutil.rmtree(os.path.join(os.path.abspath(path_agents), \"_cache\"), ignore_errors=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/usr/lib64/python3.6/runpy.py:125: RuntimeWarning: 'grid2viz.main' found in sys.modules after import of package 'grid2viz', but prior to execution of 'grid2viz.main'; this may result in unpredictable behaviour\n", " warn(RuntimeWarning(msg))\n", " * Serving Flask app \"/home/donnotben/.local/lib/python3.6/site-packages/grid2viz/index.py\"\n", " * Environment: production\n", "\u001b[31m WARNING: This is a development server. Do not use it in a production deployment.\u001b[0m\n", "\u001b[2m Use a production WSGI server instead.\u001b[0m\n", " * Debug mode: off\n", "the config file used is located at: /home/donnotben/Documents/Grid2Op_dev/getting_started/config.ini\n", "Agents ata used are located at: /home/donnotben/Documents/Grid2Op_dev/getting_started/study_agent_getting_started\n", "Data used are located at: /home/donnotben/Documents/Grid2Op_dev/getting_started/study_agent_getting_started\n", " * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\n" ] } ], "source": [ "!$sys.executable -m grid2viz.main --path=$path_agents" ] } ], "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 }