Skip to content

Commit

Permalink
Add notice for restarting the kernel after modifying models.py
Browse files Browse the repository at this point in the history
  • Loading branch information
behnam-zakeri committed Dec 12, 2022
1 parent f617e06 commit f976c6c
Showing 1 changed file with 63 additions and 45 deletions.
108 changes: 63 additions & 45 deletions tutorial/westeros/westeros_investment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import ixmp\n",
Expand All @@ -54,7 +35,9 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"mp = ixmp.Platform()"
Expand Down Expand Up @@ -93,7 +76,9 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stderr",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -174,7 +165,9 @@
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -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",
Expand All @@ -271,7 +269,9 @@
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -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",
Expand All @@ -426,7 +428,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"df = scen2.var(\"INVEST\", {\"node\": \"Westeros\"})\n",
Expand All @@ -443,7 +447,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# Adding input data for \"bound_investment_up\"\n",
Expand All @@ -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",
Expand All @@ -476,7 +484,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# Solving the scenario\n",
Expand All @@ -497,7 +507,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# Investment needs before the bound\n",
Expand All @@ -507,7 +519,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# Investment needs after the bound\n",
Expand All @@ -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",
Expand Down Expand Up @@ -557,7 +573,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# Close the connection to the database\n",
Expand Down

0 comments on commit f976c6c

Please sign in to comment.