Skip to content

Commit

Permalink
Merge pull request #207 from JochenC/master
Browse files Browse the repository at this point in the history
Proposed changes for notebooks 07-10.
  • Loading branch information
BDonnot committed May 31, 2021
2 parents c1bb757 + 492ecdd commit 25022ce
Show file tree
Hide file tree
Showing 7 changed files with 250 additions and 232 deletions.
115 changes: 62 additions & 53 deletions getting_started/00_Introduction.ipynb

Large diffs are not rendered by default.

60 changes: 35 additions & 25 deletions getting_started/00_SmallExample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To demonstrate the use of the grid2op framework, we propose here to show how to make some quick studies on a purely fictious test case, a 5 bus system.\n",
"To demonstrate the use of the grid2op framework, we show how to make some quick studies on a purely fictitious test case, a 5 bus system.\n",
"\n",
"This system should not be used for deep research purpose. It is provided here as an example and a tool to get used to how some analyses can be performed using grid2op."
"This system should not be used for in-depth research purposes. It is provided here as a simple example to get familiar with the use of the grid2op framework."
]
},
{
Expand Down Expand Up @@ -44,7 +44,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"First, we can create a environment:"
"First, we have to create an environment:"
]
},
{
Expand All @@ -71,15 +71,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In grid2op, to make more concrete the powergrid, we also added some visual capabilities to represent, for example, the names of the objects on the grid, or the thermal limit, or any other data you want. All of that is for now only available in the matplotlib \"plot helper\" and can be accessed as followed."
"In grid2op, to make the powergrid more concrete, we also added some visual capabilities to represent, for example, the names of the objects on the grid, or the thermal limit, or any other data you want. All of that is for now only available in the matplotlib \"plot helper\" and can be accessed as follows."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Plotting the layout of the graph\n",
"This utility function allows you to visualize where are the object located on the map. Each object has its own color, and is represented with its name and its id (id starts at 0, following python convention)."
"This utility function allows you to view the location of the objects on the map. Each object has its own color, and is represented with its name and its id (id starts at 0, following Python convention)."
]
},
{
Expand Down Expand Up @@ -111,7 +111,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"It is, with the same method, also possible to visualize any data on the powergrid, for example, we can inspect the thermal limit (line property) as follow:"
"With the same method, it is also possible to visualize any data on the powergrid. For example, we can inspect the thermal limit (line property) as follow:"
]
},
{
Expand All @@ -127,7 +127,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Similarly, it is possible to display some data about the generators, for example the maximum value of power they can produce."
"Similarly, it is possible to display some data about the generators, for example the maximum power they can produce."
]
},
{
Expand Down Expand Up @@ -166,7 +166,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we can see how well the \"do nothing\" agent (the most basic imaginable) can performe, using some \"gym like\" methods"
"We can see how well the \"do nothing\" agent (the most basic imaginable) performs, using some \"gym like\" methods (see http://gym.openai.com/)"
]
},
{
Expand All @@ -183,7 +183,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now do the standard gym loop, and we save all the observations:"
"We run the \"standard gym loop\", and we save all the observations:"
]
},
{
Expand Down Expand Up @@ -213,7 +213,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We can check if the episode has been completed, or if there has been a game over:"
"We can check if the episode has been completed, or if there has been a \"game over\":"
]
},
{
Expand All @@ -230,9 +230,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As we see here, there is a game over: the agent successfully managed 94 timesteps, while the episode could have lasted 2016.\n",
"As we see here, there is a \"game over\": The agent successfully managed to run the network 94 timesteps, while the episode could have lasted 2016.\n",
"\n",
"Let's try to investigate this, for example by plotting the last observation. First we need to create a utilities that will make the plot:"
"Let's try to investigate this, for example by plotting the last observation. \n",
"\n",
"First, we need to create a utility object to make the plot:"
]
},
{
Expand All @@ -249,7 +251,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As we can see, the last obsevation is pretty clear: 4 powerlines have been disconnected, thus isolating the load on the bottom right. This lead to a game over. \n",
"As we can see, the last obsevation is pretty clear: 4 powerlines have been disconnected, thus isolating the load on the bottom right. This has led to a game over. \n",
"\n",
"It's also possible, of course, to inspect the previous state, just before this one:"
]
Expand All @@ -268,18 +270,18 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"And now we can know the cause for this problem: all the powerlines that could provide power on the bottom right load are overloaded in this situation, so the protection worked and disconnect them to prevent hurting the surroundings."
"And now we can see the cause of the problem: all the powerlines that could provide power on the bottom right load are overloaded in this situation, so the protection worked and disconnected the lines to prevent impacting the surroundings."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Highly non linear, non local effects\n",
"# Highly non linear and non local effects\n",
"\n",
"The previous case was particularly suited to get started with the problem adressed by the grid2op platform. On this second section we will show what is the principal way of acting on a grid and illustrate why it is rather difficult to do so.\n",
"The previous case was particularly suited to get started with the problem adressed by the grid2op platform. In this second section we will show what is the principal way of acting on a grid and illustrate why it is rather difficult to do so.\n",
"\n",
"For that we will use the \"rte_case14_realistic\" grid showed bellow"
"For that, we will use the \"rte_case14_realistic\" grid shown below"
]
},
{
Expand Down Expand Up @@ -314,9 +316,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As stated in the previous notebooks, there are 2 main types of actions in grid2op: action that consists in changing the status of the powerlines. Note that connecting / disconnecting powerline has a global, really non linear impact on the powergrid as illustrated below, when we disconnect the powerline of id `17` going from substation `4` to substations `5`. \n",
"As stated in the previous notebooks, there are two main types of actions in grid2op: Actions that change the status of powerlines (connected/disconnected) and actions that change the topology in a given substation.\n",
"\n",
"Note that connecting / disconnecting powerline can have a global, highly non linear impact on the powergrid as illustrated below, when we disconnect the powerline of id `17` going from substation `4` to substations `5`. \n",
"\n",
"The way we interact with the environment is described in detail in notebook [3_Action_GridManipulation](3_Action_GridManipulation.ipynb), so we focus here only on the consequences of these actions."
"The way we interact with the environment is described in detail in notebook [03_Action](03_Action.ipynb), so we focus here only on the consequences of these actions."
]
},
{
Expand Down Expand Up @@ -348,9 +352,9 @@
"| 2 | 3 | 15.65% |17.80%|\n",
"| 4 | 3 | 36.42% |56.29%|\n",
"\n",
"Though some of these powerlines are really close (in terms of graph distance) they don't seemed to be impacted too much (especially powerlines going from 0 to 4 and the one going from 1 to 4).\n",
"Though some of these powerlines are really close (in terms of graph distance \\*) they do not seem to be impacted too much (see the powerline going from (substation) 0 to 4 and the one going from 1 to 4).\n",
"\n",
"On the other hand, if you look at the topmost part of the grid, you can spot really high differences, though these power are extremely far (in terms of graph distance \\*\\*) from the powerline disconnected (3 or 4 substations apart for some). \n",
"On the other hand, if you look at the topmost part of the grid, you can spot really high differences, though these powerlines are extremely far (in terms of graph distance) from the powerline disconnected (3 or 4 substations apart for some of them). \n",
"\n",
"|origin | extremity | flow before | flow after |\n",
"|-------|-----------|-------------|------------|\n",
Expand All @@ -359,14 +363,20 @@
"| 9 | 10 | 41.52% |42.61% (opposite direction)|\n",
"| 8 | 13 | 45.53% |97.78%|\n",
"\n",
"To recap, to recap some powerline next to the disconnected have approximately the same flows (36.85% to 33.96% for example) while some others \"really far away\"\\* are dramatically impacted by this changes, seeing their flow completely blows up from $\\approx 7\\%$ to more than $\\approx 140\\%$.\n",
"To recap, some powerline next to the disconnected one have approximately the same flows (36.85% to 33.96% for example) while some others \"really far away\" are dramatically impacted by this change, seeing their flow completely blowing up from roughly $7\\%$ to more than $140 \\%$.\n",
"\n",
"\\* the maximum \"graph distance\"\\*\\* between two powerlines on this graph is 4 (between line 1->2 and 12->13 for example)\n",
"\n",
"\\*\\* when we mention distance on graph it's more of a figure of speech rather a true mathematical definition. We can say intuitively that the \"graph distance\" between two powerlines is the smallest on powerline i need to \"walk one\" if i want to move from one to the other.\n",
"\\* When we mention \"distance\" on a graph it is more of a figure of speech rather than a well defined mathematical distance on a set (with its triangle inequality, etc). We can intuitively define the \"graph distance\" between two powerlines by the smallest number of lines we need to \"go through\" if we want to move from the the first powerline to the second.\n",
"\n",
"Of course, the same kind of effect can be observe by change the topology of some substations. We will not illustrate them here however."
"Of course, the same kind of effect can be observed after a change in the topology of some substations. We will not illustrate this however."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
62 changes: 16 additions & 46 deletions getting_started/01_Grid2opFramework.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"\n",
"This notebook will cover some basic raw functionalities at first. It will then show how these raw functionalities are encapsulated in easy-to-use functions.\n",
"\n",
"The recommended way to use these is to through the Runner, and not by going through the instanciation of the different classes one after the other."
"As we will see later, the recommended way to use these functionalities is to go through the Runner, and not through the instanciation of the different classes one after the other."
]
},
{
Expand Down Expand Up @@ -130,7 +130,7 @@
"source": [
"It is also possible to list the environments that you have already downloaded (if any). \n",
"\n",
"**NB** We remind that downloading is automatic and is done on the first time that you call `make` with an environment that has not been already locally downloaded."
"**NB** : Downloading is automatic and is done the first time you call `make` with an environment that has not been already locally downloaded."
]
},
{
Expand All @@ -142,43 +142,6 @@
"grid2op.list_available_local_env()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally you can see which environments can be used for testing / illustration purpose with:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['educ_case14_redisp',\n",
" 'educ_case14_storage',\n",
" 'l2rpn_neurips_2020_track1',\n",
" 'l2rpn_neurips_2020_track2',\n",
" 'l2rpn_wcci_2020',\n",
" 'rte_case118_example',\n",
" 'rte_case14_opponent',\n",
" 'rte_case14_realistic',\n",
" 'rte_case14_redisp',\n",
" 'rte_case14_test',\n",
" 'rte_case5_example']"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"grid2op.list_available_test_env()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -262,9 +225,9 @@
"source": [
"An *Agent* is the name given to the \"operator\" / \"bot\" / \"algorithm\" that will perform some modifications of the powergrid when it faces some \"observation\".\n",
"\n",
"Some examples of Agents are provided in the file [Agent.py](grid2op/Agent/Agent.py).\n",
"Examples of Agents are provided in the grid2Op/Agent directory of the grid2Op code repository.\n",
"\n",
"A deeper look at the different provided Agents can be found in the [4_StudyYourAgent](4_StudyYourAgent.ipynb.ipynb) notebook. We suppose here that we use the most simple Agent, the one that does nothing (`DoNothingAgent`)."
"A deeper look at the different provided Agents can be found in the [05_StudyYourAgent](05_StudyYourAgent.ipynb) notebook. We suppose here that we use the most simple Agent, the one that does nothing (`DoNothingAgent`)."
]
},
{
Expand Down Expand Up @@ -469,7 +432,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"os.listdir(os.path.join(path_save_expe, \"0\"))"
Expand All @@ -479,11 +444,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"All the outcomes of the experiment are shown above. For more information, please don't hesitate to read the documentation of [Runner](https://grid2op.readthedocs.io/en/latest/runner.html) (if compiled locally) or consult the [Runner.py](../grid2op/Runner.py) file.\n",
"\n",
"**NB** A lot more of information about *Actions* is provided in the [2_Action_GridManipulation](2_Action_GridManipulation.ipynb) notebook. In the [3_TrainingAnAgent](3_TrainingAnAgent.ipynb) (last section), there is an quick example of how to read / write an action from a saved repository.\n",
"All the outcomes of the experiment are shown above. For more information, please don't hesitate to read the documentation of [Runner](https://grid2op.readthedocs.io/en/latest/runner.html).\n",
"\n",
"In the notebook 7, more details will be given concerning the advantages of the runner, especially for analyzing the agent's performances."
"**NB**: A lot more of information about *Actions* is provided in the [(03_Action](03_Action.ipynb) notebook. In the [04_TrainingAnAgent](04_TrainingAnAgent.ipynb) (last section), there is an quick example of how to read / write an action from a saved repository.\n"
]
},
{
Expand All @@ -492,6 +455,13 @@
"source": [
"Using `make` and `Runner` makes it easy to assess the performance of a trained agent. Besides, the `Runner` has been particularly integrated with other tools and makes it easy to replay and analyse an episode after it is finished. It is the recommended method to use in grid2op for the evaluation."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 25022ce

Please sign in to comment.