From f976c6c446ba2e437bab3ee1d5939e637343cd3f Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 12 Dec 2022 13:26:15 +0100 Subject: [PATCH] Add notice for restarting the kernel after modifying models.py --- tutorial/westeros/westeros_investment.ipynb | 108 ++++++++++++-------- 1 file changed, 63 insertions(+), 45 deletions(-) diff --git a/tutorial/westeros/westeros_investment.ipynb b/tutorial/westeros/westeros_investment.ipynb index d8c87a8cb..873773477 100644 --- a/tutorial/westeros/westeros_investment.ipynb +++ b/tutorial/westeros/westeros_investment.ipynb @@ -10,37 +10,18 @@ "\n", "**Pre-requisites**\n", "- You have the *MESSAGEix* framework installed and working\n", - "- You have run Westeros baseline scenario (``westeros_baseline.ipynb``) and solved it successfully" + "- You have run Westeros baseline scenario (``westeros_baseline.ipynb``) and solved it successfully\n", + "\n", + "_This tutorial was presented by [Behnam Zakeri](https://iiasa.ac.at/staff/behnam-zakeri) at the **MESSAGEix Community Meeting** May 2022. Please feel free to suggest improvements through issues and pull-requests_." ] }, { "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "C:\\Users\\zakeri\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\numpy\\_distributor_init.py:32: UserWarning: loaded more than 1 DLL from .libs:\n", - "C:\\Users\\zakeri\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\numpy\\.libs\\libopenblas.NOIJJG62EMASZI6NYURL6JBKM4EVBGM7.gfortran-win_amd64.dll\n", - "C:\\Users\\zakeri\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\numpy\\.libs\\libopenblas.XWYDX2IKJW2NMTWSFYNGFUWKQU3LYTCZ.gfortran-win_amd64.dll\n", - " stacklevel=1)\n" - ] - }, - { - "data": { - "application/javascript": [ - "IPython.OutputArea.prototype._should_scroll = function(lines) { return false; }" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "execution_count": null, + "metadata": { + "scrolled": true + }, + "outputs": [], "source": [ "import pandas as pd\n", "import ixmp\n", @@ -54,7 +35,9 @@ { "cell_type": "code", "execution_count": 2, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "mp = ixmp.Platform()" @@ -93,7 +76,9 @@ { "cell_type": "code", "execution_count": 3, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [ { "name": "stderr", @@ -113,7 +98,9 @@ { "cell_type": "code", "execution_count": 4, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "# Solving the new scenario again (testing the changes in the GAMS code)\n", @@ -131,7 +118,9 @@ { "cell_type": "code", "execution_count": 5, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "# We assert that the objective values are the same\n", @@ -141,7 +130,9 @@ { "cell_type": "code", "execution_count": 6, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "# We can compare the activity of one technology in one year too\n", @@ -174,7 +165,9 @@ { "cell_type": "code", "execution_count": 7, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [ { "data": { @@ -247,13 +240,18 @@ "\n", "2. For being able to retrieve the content of this new variable, we need to explicitly pass it through the `var_list` option when calling `solve()`. This has to be done because this variable is not among the default variables of `message_ix`. So, the notation for solving will be:\n", "\n", - "`solve(var_list=[\"INVEST\"])`\n" + "`solve(var_list=[\"INVEST\"])`\n", + "\n", + "#### Notice: Restart the kernel\n", + "For these changes to be effective, you need to re-import the `message_ix` package to your session. This means you need to restart the kernel at this stage and run the notebook again.\n" ] }, { "cell_type": "code", "execution_count": 8, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "# Now, let's solve the scenario again\n", @@ -271,7 +269,9 @@ { "cell_type": "code", "execution_count": 9, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [ { "data": { @@ -415,7 +415,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "# Now, let's clone a new scenario and solve\n", @@ -426,7 +428,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "df = scen2.var(\"INVEST\", {\"node\": \"Westeros\"})\n", @@ -443,7 +447,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "# Adding input data for \"bound_investment_up\"\n", @@ -460,7 +466,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "# Adding the unit to the platform (if not exists yet)\n", @@ -476,7 +484,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "# Solving the scenario\n", @@ -497,7 +507,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "# Investment needs before the bound\n", @@ -507,7 +519,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "# Investment needs after the bound\n", @@ -527,7 +541,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "# Difference in the total system costs after investment limits (M$)\n", @@ -557,7 +573,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "# Close the connection to the database\n",