Skip to content

Commit

Permalink
Merge pull request #25 from BDonnot/l2rpn2019
Browse files Browse the repository at this point in the history
Add setting of the l2rpn 2019 competitions
  • Loading branch information
BDonnot committed Jan 27, 2020
2 parents 49b5bfd + 4ca688b commit a7ace24
Show file tree
Hide file tree
Showing 36 changed files with 9,832 additions and 300 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,7 @@ grid2op/tests/start_datetime.info
l2rpn_2019/data/
l2rpn_2019/expe_saved/
l2rpn_2019/l2rpn2019_utils/data_location.py

**/sample_code_submission*
l2rpn_2019/saved_expe/
l2rpn_2019/starting_kit/output_notebook_2DevelopAndRunLocally/
l2rpn_2019/exped_saved/
13 changes: 13 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Change Log
=============

[0.5.2] - 2020-01-27
---------------------
- [ADDED] Adding a utility to retrieve the starting kit L2RPN 2019 competition.
- [ADDED] Layout of the powergrid graph of the substations for both the
`5bus_example` and the `CASE_14_L2RPN2019`.
- [FIXED] Runner skipped half the episode in some cases (sequential, even number of scenarios). Now fixed.
- [FIXED] Some typos on the notebook "getting_started\4-StudyYourAgent.ipynb".
- [FIXED] Error in the conversion of observation to dictionnary. Twice the same keys were used
('time_next_maintenance') for both `time_next_maintenance` and `duration_next_maintenance`.
- [UPDATED] The first chronics that is processed by a runner is not the "first" one on the hardrive
(if sorted in alphabetical order)
- [UPDATED] Better layout of substation layout (in case of multiple nodes) in PlotGraph

[0.5.1] - 2020-01-24
--------------------
- [ADDED] extra tag 'all' to install all optional dependencies.
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Benjamin Donnot'

# The full version, including alpha/beta/rc tags
release = '0.5.1'
release = '0.5.2'
version = '0.5'


Expand Down
289 changes: 64 additions & 225 deletions getting_started/3_TrainingAnAgent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,7 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"pygame 1.9.6\n",
"Hello from the pygame community. https://www.pygame.org/contribute.html\n"
]
}
],
"outputs": [],
"source": [
"import os\n",
"import sys\n",
Expand All @@ -79,136 +70,13 @@
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div id=\"my_id_menu_nb\">run previous cell, wait for 2 seconds</div>\n",
"<script>\n",
"function repeat_indent_string(n){\n",
" var a = \"\" ;\n",
" for ( ; n > 0 ; --n)\n",
" a += \" \";\n",
" return a;\n",
"}\n",
"// look up into all sections and builds an automated menu //\n",
"var update_menu_string = function(begin, lfirst, llast, sformat, send, keep_item, begin_format, end_format) {\n",
" var anchors = document.getElementsByClassName(\"section\");\n",
" if (anchors.length == 0) {\n",
" anchors = document.getElementsByClassName(\"text_cell_render rendered_html\");\n",
" }\n",
" var i,t;\n",
" var text_menu = begin;\n",
" var text_memo = \"<pre>\\nlength:\" + anchors.length + \"\\n\";\n",
" var ind = \"\";\n",
" var memo_level = 1;\n",
" var href;\n",
" var tags = [];\n",
" var main_item = 0;\n",
" var format_open = 0;\n",
" for (i = 0; i <= llast; i++)\n",
" tags.push(\"h\" + i);\n",
"\n",
" for (i = 0; i < anchors.length; i++) {\n",
" text_memo += \"**\" + anchors[i].id + \"--\\n\";\n",
"\n",
" var child = null;\n",
" for(t = 0; t < tags.length; t++) {\n",
" var r = anchors[i].getElementsByTagName(tags[t]);\n",
" if (r.length > 0) {\n",
"child = r[0];\n",
"break;\n",
" }\n",
" }\n",
" if (child == null) {\n",
" text_memo += \"null\\n\";\n",
" continue;\n",
" }\n",
" if (anchors[i].hasAttribute(\"id\")) {\n",
" // when converted in RST\n",
" href = anchors[i].id;\n",
" text_memo += \"#1-\" + href;\n",
" // passer à child suivant (le chercher)\n",
" }\n",
" else if (child.hasAttribute(\"id\")) {\n",
" // in a notebook\n",
" href = child.id;\n",
" text_memo += \"#2-\" + href;\n",
" }\n",
" else {\n",
" text_memo += \"#3-\" + \"*\" + \"\\n\";\n",
" continue;\n",
" }\n",
" var title = child.textContent;\n",
" var level = parseInt(child.tagName.substring(1,2));\n",
"\n",
" text_memo += \"--\" + level + \"?\" + lfirst + \"--\" + title + \"\\n\";\n",
"\n",
" if ((level < lfirst) || (level > llast)) {\n",
" continue ;\n",
" }\n",
" if (title.endsWith('¶')) {\n",
" title = title.substring(0,title.length-1).replace(\"<\", \"&lt;\")\n",
" .replace(\">\", \"&gt;\").replace(\"&\", \"&amp;\");\n",
" }\n",
" if (title.length == 0) {\n",
" continue;\n",
" }\n",
"\n",
" while (level < memo_level) {\n",
" text_menu += end_format + \"</ul>\\n\";\n",
" format_open -= 1;\n",
" memo_level -= 1;\n",
" }\n",
" if (level == lfirst) {\n",
" main_item += 1;\n",
" }\n",
" if (keep_item != -1 && main_item != keep_item + 1) {\n",
" // alert(main_item + \" - \" + level + \" - \" + keep_item);\n",
" continue;\n",
" }\n",
" while (level > memo_level) {\n",
" text_menu += \"<ul>\\n\";\n",
" memo_level += 1;\n",
" }\n",
" text_menu += repeat_indent_string(level-2);\n",
" text_menu += begin_format + sformat.replace(\"__HREF__\", href).replace(\"__TITLE__\", title);\n",
" format_open += 1;\n",
" }\n",
" while (1 < memo_level) {\n",
" text_menu += end_format + \"</ul>\\n\";\n",
" memo_level -= 1;\n",
" format_open -= 1;\n",
" }\n",
" text_menu += send;\n",
" //text_menu += \"\\n\" + text_memo;\n",
"\n",
" while (format_open > 0) {\n",
" text_menu += end_format;\n",
" format_open -= 1;\n",
" }\n",
" return text_menu;\n",
"};\n",
"var update_menu = function() {\n",
" var sbegin = \"\";\n",
" var sformat = '<a href=\"#__HREF__\">__TITLE__</a>';\n",
" var send = \"\";\n",
" var begin_format = '<li>';\n",
" var end_format = '</li>';\n",
" var keep_item = -1;\n",
" var text_menu = update_menu_string(sbegin, 2, 4, sformat, send, keep_item,\n",
" begin_format, end_format);\n",
" var menu = document.getElementById(\"my_id_menu_nb\");\n",
" menu.innerHTML=text_menu;\n",
"};\n",
"window.setTimeout(update_menu,2000);\n",
" </script>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
"name": "stdout",
"output_type": "stream",
"text": [
"Impossible to automatically add a menu / table of content to this notebook.\n",
"You can download \"jyquickhelper\" package with: \n",
"\"pip install jyquickhelper\"\n"
]
}
],
"source": [
Expand Down Expand Up @@ -1088,55 +956,43 @@
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /home/donnotben/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Colocations handled automatically by placer.\n",
"Successfully constructed networks.\n",
"WARNING:tensorflow:From /home/donnotben/.local/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.cast instead.\n",
"Lived with maximum time 56\n",
"Earned a total of reward equal to 1119.9867235500346\n",
"Lived with maximum time 6\n",
"Earned a total of reward equal to 99.99900274529449\n",
"We had a loss equal to 24369.516\n",
"Lived with maximum time 91\n",
"Earned a total of reward equal to 1799.9825665398848\n",
"Lived with maximum time 47\n",
"Earned a total of reward equal to 919.9873536471537\n",
"We had a loss equal to 197397.73\n",
"WARNING:tensorflow:From /home/benjamin/.local/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:422: The name tf.global_variables is deprecated. Please use tf.compat.v1.global_variables instead.\n",
"\n",
"Lived with maximum time 27\n",
"Earned a total of reward equal to 539.9930955752145\n",
"Lived with maximum time 2\n",
"Earned a total of reward equal to 19.999789920293725\n",
"Lived with maximum time 1\n",
"Earned a total of reward equal to 0.0\n",
"Lived with maximum time 1\n",
"Earned a total of reward equal to 0.0\n",
"Lived with maximum time 1\n",
"Earned a total of reward equal to 0.0\n",
"Lived with maximum time 1\n",
"Earned a total of reward equal to 0.0\n",
"Lived with maximum time 1\n",
"Earned a total of reward equal to 0.0\n",
"Lived with maximum time 1\n",
"Earned a total of reward equal to 0.0\n",
"Lived with maximum time 10\n",
"Earned a total of reward equal to 179.9982348312529\n",
"Lived with maximum time 13\n",
"Earned a total of reward equal to 239.9975871017263\n",
"Earned a total of reward equal to 19.999779186999163\n",
"Lived with maximum time 17\n",
"Earned a total of reward equal to 319.9963352443193\n",
"We had a loss equal to 415911.16\n",
"Lived with maximum time 89\n",
"Earned a total of reward equal to 1759.9736204339242\n",
"Lived with maximum time 47\n",
"Earned a total of reward equal to 919.9896974762444\n",
"We had a loss equal to 895179.1\n",
"Lived with maximum time 42\n",
"Earned a total of reward equal to 819.9913871544907\n",
"Lived with maximum time 48\n",
"Earned a total of reward equal to 939.9894397616745\n",
"Lived with maximum time 14\n",
"Earned a total of reward equal to 259.99683450592977\n",
"Earned a total of reward equal to 319.9959503003566\n",
"Lived with maximum time 41\n",
"Earned a total of reward equal to 799.980338746284\n",
"We had a loss equal to 1032318.44\n",
"Lived with maximum time 66\n",
"Earned a total of reward equal to 1299.9801766323187\n",
"We had a loss equal to 345275.62\n",
"Lived with maximum time 100\n",
"Earned a total of reward equal to 1979.9625451696331\n",
"Lived with maximum time 20\n",
"Earned a total of reward equal to 379.99202500143195\n",
"Lived with maximum time 9\n",
"Earned a total of reward equal to 159.9965188018483\n",
"We had a loss equal to 363823.0\n",
"Lived with maximum time 29\n",
"Earned a total of reward equal to 559.9819633743846\n",
"Lived with maximum time 9\n",
"Earned a total of reward equal to 159.9965188018483\n",
"Lived with maximum time 23\n",
"Earned a total of reward equal to 439.9913490331225\n",
"Lived with maximum time 11\n",
"Earned a total of reward equal to 199.99547338694836\n",
"Lived with maximum time 13\n",
"Earned a total of reward equal to 239.99761224674333\n",
"We had a loss equal to 957223.3\n",
"Lived with maximum time 38\n",
"Earned a total of reward equal to 739.9867481082264\n",
"Lived with maximum time 29\n",
"Earned a total of reward equal to 559.9944699634157\n",
"Saving Network\n",
"Successfully saved network.\n"
]
Expand Down Expand Up @@ -1229,8 +1085,8 @@
"output_type": "stream",
"text": [
"The results for the trained agent are:\n",
"\tFor chronics located at /home/donnotben/.local/lib/python3.6/site-packages/grid2op/data/test_multi_chronics/2\n",
"\t\t - cumulative reward: 199.997670\n",
"\tFor chronics located at /home/benjamin/.local/lib/python3.6/site-packages/grid2op/data/test_multi_chronics/1\n",
"\t\t - cumulative reward: 199.995297\n",
"\t\t - number of time steps completed: 10 / 10\n"
]
}
Expand All @@ -1240,7 +1096,8 @@
"path_save=\"trained_agent_log\"\n",
"\n",
"# delete the previous stored results\n",
"shutil.rmtree(path_save)\n",
"if os.path.exists(path_save):\n",
" shutil.rmtree(path_save)\n",
"\n",
"# run the episode\n",
"res = runner.run(nb_episode=1, path_save=path_save)\n",
Expand Down Expand Up @@ -1391,7 +1248,7 @@
{
"data": {
"text/plain": [
"9"
"0"
]
},
"execution_count": 19,
Expand Down Expand Up @@ -1543,40 +1400,22 @@
"output_type": "stream",
"text": [
"Successfully constructed networks.\n",
"Lived with maximum time 36\n",
"Earned a total of reward equal to 719.9895521483418\n",
"Lived with maximum time 8\n",
"Earned a total of reward equal to 139.99768011521434\n",
"Lived with maximum time 4\n",
"Earned a total of reward equal to 59.99906341223206\n",
"We had a loss equal to 1.8023443\n",
"Lived with maximum time 72\n",
"Earned a total of reward equal to 1419.9760873213631\n",
"Lived with maximum time 2\n",
"Earned a total of reward equal to 19.999660128304583\n",
"Lived with maximum time 46\n",
"Earned a total of reward equal to 899.9869612195764\n",
"Lived with maximum time 17\n",
"Earned a total of reward equal to 319.9950273884641\n",
"We had a loss equal to 1.8021951\n",
"Lived with maximum time 41\n",
"Earned a total of reward equal to 799.987719729006\n",
"Lived with maximum time 17\n",
"Earned a total of reward equal to 319.9949135892812\n",
"Lived with maximum time 21\n",
"Earned a total of reward equal to 399.9938856128067\n",
"We had a loss equal to 1.8023629\n",
"Lived with maximum time 63\n",
"Earned a total of reward equal to 1239.9800818087667\n",
"Lived with maximum time 16\n",
"Earned a total of reward equal to 299.9951132765008\n",
"Lived with maximum time 2\n",
"Earned a total of reward equal to 19.999660128304583\n",
"Lived with maximum time 31\n",
"Earned a total of reward equal to 599.9903531318918\n",
"We had a loss equal to 1.8029592\n",
"Lived with maximum time 106\n",
"Earned a total of reward equal to 2099.9686713192973\n",
"We had a loss equal to 1.860613\n",
"Lived with maximum time 128\n",
"Earned a total of reward equal to 2559.9692780641853\n",
"Lived with maximum time 66\n",
"Earned a total of reward equal to 1299.9883402713695\n",
"We had a loss equal to 1.8608918\n",
"Lived with maximum time 93\n",
"Earned a total of reward equal to 1839.9810125881186\n",
"We had a loss equal to 1.8612001\n",
"Lived with maximum time 56\n",
"Earned a total of reward equal to 1099.9853685836688\n",
"We had a loss equal to 1.8641238\n",
"Lived with maximum time 86\n",
"Earned a total of reward equal to 1699.9846723049036\n",
"Lived with maximum time 13\n",
"Earned a total of reward equal to 239.99656412011313\n",
"Saving Network\n",
"Successfully saved network.\n"
]
Expand Down Expand Up @@ -1607,7 +1446,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
"version": "3.6.8"
}
},
"nbformat": 4,
Expand Down

0 comments on commit a7ace24

Please sign in to comment.