Skip to content

Commit

Permalink
Merge pull request #227 from JochenC/master
Browse files Browse the repository at this point in the history
Notebook 02,03,05,06 edits
  • Loading branch information
BDonnot committed Jun 21, 2021
2 parents 097b756 + 30c908b commit 559af47
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 76 deletions.
48 changes: 22 additions & 26 deletions getting_started/02_Observation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"source": [
"**Objective**\n",
"\n",
"This notebook will cover the basics of the information that can be retrieved about the state of the powergrid.\n",
"\n",
"Examples of \"expert agents\" that can take actions based on some fixed rules, will be given for illustration purpose. More generic types of *Agents*, relying for example on machine learning / deep learning will be covered in the notebook [04_TrainingAnAgent](04_TrainingAnAgent.ipynb).\n",
"This notebook covers the basics of the information that can be retrieved about the state of the powergrid. The basics are illustrated on examples of \"expert agents\" that can take actions based on some fixed rules. More generic types of *Agents*, relying for example on machine learning / deep learning will be covered in the notebook [04_TrainingAnAgent](04_TrainingAnAgent.ipynb).\n",
"\n",
"This notebook will also cover the description of the *Observation* class, which is useful to take some actions."
]
Expand Down Expand Up @@ -82,21 +80,21 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**NB** In this paragraph we will cover the observation class. For more information about it, we recommend to have a look at the official documentation, or [here](https://grid2op.readthedocs.io/en/latest/observation.html) or in the [Observations.py](grid2op/Observation/Observation.py) files for more information. Only basic concepts are detailed in this notebook."
"**NB** In this paragraph we will cover the basics of the observation class. Please visit the official documentation for more detailed information, or [here](https://grid2op.readthedocs.io/en/latest/observation.html) or in the [Observations.py](grid2op/Observation/Observation.py) files for more information. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### I.A) Getting an observation"
"### I.A) Obtaining an observation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"An observation can be accessed by calling `env.step()`. The next cell is dedicated to creating an environment and getting an observation instance. We use the default `rte_case14_realistic` environment from Grid2Op framework."
"An observation can be accessed by calling `env.step()`. The next cell is dedicated to creating an environment and obtaining one instance of an observation. For illustration purposed, we use the default `rte_case14_realistic` environment from Grid2Op framework."
]
},
{
Expand Down Expand Up @@ -127,14 +125,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In this notebook we will detail only the \"CompleteObservation\". `Grid2Op` allows to model different kinds of observations. For example, some observations could have incomplete data, or noisy data, etc. `CompleteObservation` gives the full state of the powergrid, without any noise. It's the default type of observation used."
"`Grid2Op` allows to model different kinds of observations. For example, some observations could have incomplete data, or noisy data, etc. As follows we will detail only the \"CompleteObservation\". `CompleteObservation` gives the full state of the powergrid, without any noise. It's the default type of observation used."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### a) Some of its attributes"
"#### a) Some attributes of complete observation"
]
},
{
Expand All @@ -157,7 +155,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"It has some powergrid generic information (that are static: the same environment has always these attributes, that have always the same values, but of course different environments can have different values)"
"An observation has some powergrid generic information (that are static: the same environment has always these attributes, that have always th same values, but of course different environments can have different values)"
]
},
{
Expand All @@ -177,7 +175,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"It has some information about the generators (each generator can be viewed as a point in a 3-dimensional space)"
"An observation has some information about the generators (each generator can be viewed as a point in a 3-dimensional space)"
]
},
{
Expand All @@ -195,7 +193,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"It has some information about the loads (each load is a point in a 3-dimensional space, too)"
"An observation has some information about the loads (each load is a point in a 3-dimensional space, too)"
]
},
{
Expand Down Expand Up @@ -246,7 +244,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Another powerline feature is the $\\rho$ ratio, *ie.* for each powerline, the ratio between the current flow in the powerline and its thermal limit. It can be accessed with:"
"Another powerline feature is the $\\rho$ ratio, the ratio between the current flow in the powerline and its thermal limit, *ie.* for each powerline. This feature $\\rho$ can be accessed with:"
]
},
{
Expand Down Expand Up @@ -326,15 +324,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"More information about this topology vector is given in the documentation [here](https://grid2op.readthedocs.io/en/latest/observation.html).\n",
" \n",
"More information about this topology vector will be given in the notebook dedicated to vizualisation. \n",
"More information about this topology vector is given in the documentation [here](https://grid2op.readthedocs.io/en/latest/observation.html). More information about this topology vector will be given in the notebook dedicated to vizualisation. \n",
"\n",
"#### b) Representation as \"a graph\"\n",
"\n",
"The powergrid is a graph. This \"topology vector\" is an efficient (in term of memory and speed) way to represent this graph. Hopefully, some utilities functions in grid2op allows to build these graphs rapidly.\n",
"The powergrid can be represented as a graph. The \"topology vector\" is an efficient way to store and use the graph in terms of memory and speed. Some utilities functions in grid2op allows to build these graphs rapidly. \n",
"\n",
"We say \"these graphs\" because \"the\" graph of the grid can mean different things. Yes, you have a lot of information whith something like:"
"We say \"these graphs\" because \"the\" graph of the grid can mean different things. Yes, you have a lot of information with something like:"
]
},
{
Expand All @@ -354,7 +350,7 @@
"source": [
"#### i) connectivity matrix\n",
"\n",
"the `connectivity matrix` which has as many rows / columns as the number of elements in the powergrid (remember that an element is either an end of a powerline, or a generator or a load) and that tells if 2 elements are connected to one another or not:\n",
"One way to represent the `graph` of the power system is the `connectivity matrix`. The `connectivity matrix` has as many rows / columns as the number of elements in the powergrid (remember that an element is either an end of a powerline, or a generator or a load) and that tells if 2 elements are connected to one another or not:\n",
"\n",
"$$\n",
"\\left\\{\n",
Expand Down Expand Up @@ -430,7 +426,7 @@
" \n",
"#### ii) bus connectivity matrix\n",
"\n",
"Another representation of the \"graph\" of the powergrid is through \"bus-bus\" matrix, that says if at least one powerline connect two bus together or not. \n",
"Another way to represent the \"graph\" of the powergrid is the \"bus-bus\" matrix, that says if at least one powerline connect two bus together or not. \n",
"\n",
"In grid2op this is called \"bus_connectivity_matrix\". \n",
"\n",
Expand Down Expand Up @@ -473,7 +469,7 @@
"- its dimension changes: you can have 2, or 1 bus at any given substation.\n",
" \n",
"#### iii) \"flow bus\" matrix\n",
"Finally, you can introduce informations about flows (*eg* label) on your graph.\n",
"Finally, the third way to represent the graph is to introduce informations about flows (*eg* label) on your graph.\n",
"\n",
"This \"flow bus matrix\" has the following properties:\n",
"\n",
Expand Down Expand Up @@ -546,7 +542,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"So you can see that the power from a bus to another is signed (if it's positive from 8 to 9 it means that the flow is going from 9 to 8: power is injected at bus 8 from bus 9)\n",
"So you can see that the power from a bus to another has a sign (if it's positive from 8 to 9 it means that the flow is going from 9 to 8: power is injected at bus 8 from bus 9)\n",
"\n",
"And also, the two values (power injected at one side, from another) do not sum at 0. This is because there are losses on the grid, mainly due to Joule's effect."
]
Expand Down Expand Up @@ -694,7 +690,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The observation can be converted to / from a flat numpy array. This function is useful for interacting with machine learning libraries or to store it, but it probably makes it less readable for a human. The function proceeds by stacking all the features mentionned above in a single `numpy.float64` vector."
"The observation can be converted to / from a flat numpy array. This conversion is useful for interacting with machine learning libraries or to store it, but it probably makes it less readable for a human. The function proceeds by stacking all the features mentionned above in a single `numpy.float64` vector."
]
},
{
Expand Down Expand Up @@ -784,9 +780,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As opposed to most RL problems, in this framework we add the possibility to \"simulate\" the impact of a possible action on the power grid. This helps calculating roll-outs in the RL setting, and can be close to \"model-based\" reinforcement learning approaches (except that nothing more has to be learned).\n",
"As opposed to most reinforcement learning (RL) problems, in this framework we add the possibility to \"simulate\" the impact of a possible action on the power grid. This helps calculating roll-outs in the RL setting, and can be close to \"model-based\" RL approaches (except that nothing more has to be learned).\n",
"\n",
"This \"simulate\" method uses the available forecast data (forecasts are made available by the same way we loaded the data here, with the class `GridStateFromFileWithForecasts`. For this class, only forecasts for 1 time step are provided, but this might be adapted in the future).\n",
"This \"simulate\" function uses the available forecast data (forecasts are made available by the same way we loaded the data here, with the class `GridStateFromFileWithForecasts`. For this class, only forecasts for 1 time step are provided, but this might be adapted in the future).\n",
"\n",
"Note that this `simulate` function can use a different simulator than the one used by the Environment. Fore more information, we encourage you to read the official documentation, or if it has been built locally (recommended), to consult [this page](https://grid2op.readthedocs.io/en/latest/observation.html#grid2op.Observation.Observation.simulate).\n",
"\n",
Expand Down Expand Up @@ -844,7 +840,7 @@
"source": [
"#### e) obs + act\n",
"\n",
"In gri2op >= 1.5 we also introduced a method that can be used to rapidly assess what would be the effect of a given \"action\" (see next notebook for a more detailed explanation of the actions) on the grid.\n",
"In gri2op >= 1.5 we also introduced a method that can be used to rapidly assess the effect of a given \"action\" (see next notebook for a more detailed explanation of the actions) on the grid.\n",
"\n",
"To use it, you can use the `obs.connectivity_matrix()` and `obs.bus_connectivity_matrix()` function combined with the grid2op `obs + act` implementation.\n",
"\n",
Expand Down Expand Up @@ -898,7 +894,7 @@
"\n",
"by using `simulate` on the corresponding actions, and choosing the one that has the highest predicted reward.\n",
"\n",
"Note that this kind of Agent is not particularly smart and is given only as an example.\n",
"Note that this kind of Agent is not particularly smart and is given only as an example for illustration purposes.\n",
"\n",
"More information about the creation / manipulation of *Action* will be given in the notebook [2_Action_GridManipulation](2_Action_GridManipulation.ipynb)"
]
Expand Down

0 comments on commit 559af47

Please sign in to comment.