Skip to content

Commit f976c6c

Browse files
committed
Add notice for restarting the kernel after modifying models.py
1 parent f617e06 commit f976c6c

File tree

1 file changed

+63
-45
lines changed

1 file changed

+63
-45
lines changed

tutorial/westeros/westeros_investment.ipynb

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,18 @@
1010
"\n",
1111
"**Pre-requisites**\n",
1212
"- You have the *MESSAGEix* framework installed and working\n",
13-
"- You have run Westeros baseline scenario (``westeros_baseline.ipynb``) and solved it successfully"
13+
"- You have run Westeros baseline scenario (``westeros_baseline.ipynb``) and solved it successfully\n",
14+
"\n",
15+
"_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_."
1416
]
1517
},
1618
{
1719
"cell_type": "code",
18-
"execution_count": 1,
19-
"metadata": {},
20-
"outputs": [
21-
{
22-
"name": "stderr",
23-
"output_type": "stream",
24-
"text": [
25-
"C:\\Users\\zakeri\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\numpy\\_distributor_init.py:32: UserWarning: loaded more than 1 DLL from .libs:\n",
26-
"C:\\Users\\zakeri\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\numpy\\.libs\\libopenblas.NOIJJG62EMASZI6NYURL6JBKM4EVBGM7.gfortran-win_amd64.dll\n",
27-
"C:\\Users\\zakeri\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\numpy\\.libs\\libopenblas.XWYDX2IKJW2NMTWSFYNGFUWKQU3LYTCZ.gfortran-win_amd64.dll\n",
28-
" stacklevel=1)\n"
29-
]
30-
},
31-
{
32-
"data": {
33-
"application/javascript": [
34-
"IPython.OutputArea.prototype._should_scroll = function(lines) { return false; }"
35-
],
36-
"text/plain": [
37-
"<IPython.core.display.Javascript object>"
38-
]
39-
},
40-
"metadata": {},
41-
"output_type": "display_data"
42-
}
43-
],
20+
"execution_count": null,
21+
"metadata": {
22+
"scrolled": true
23+
},
24+
"outputs": [],
4425
"source": [
4526
"import pandas as pd\n",
4627
"import ixmp\n",
@@ -54,7 +35,9 @@
5435
{
5536
"cell_type": "code",
5637
"execution_count": 2,
57-
"metadata": {},
38+
"metadata": {
39+
"scrolled": true
40+
},
5841
"outputs": [],
5942
"source": [
6043
"mp = ixmp.Platform()"
@@ -93,7 +76,9 @@
9376
{
9477
"cell_type": "code",
9578
"execution_count": 3,
96-
"metadata": {},
79+
"metadata": {
80+
"scrolled": true
81+
},
9782
"outputs": [
9883
{
9984
"name": "stderr",
@@ -113,7 +98,9 @@
11398
{
11499
"cell_type": "code",
115100
"execution_count": 4,
116-
"metadata": {},
101+
"metadata": {
102+
"scrolled": true
103+
},
117104
"outputs": [],
118105
"source": [
119106
"# Solving the new scenario again (testing the changes in the GAMS code)\n",
@@ -131,7 +118,9 @@
131118
{
132119
"cell_type": "code",
133120
"execution_count": 5,
134-
"metadata": {},
121+
"metadata": {
122+
"scrolled": true
123+
},
135124
"outputs": [],
136125
"source": [
137126
"# We assert that the objective values are the same\n",
@@ -141,7 +130,9 @@
141130
{
142131
"cell_type": "code",
143132
"execution_count": 6,
144-
"metadata": {},
133+
"metadata": {
134+
"scrolled": true
135+
},
145136
"outputs": [],
146137
"source": [
147138
"# We can compare the activity of one technology in one year too\n",
@@ -174,7 +165,9 @@
174165
{
175166
"cell_type": "code",
176167
"execution_count": 7,
177-
"metadata": {},
168+
"metadata": {
169+
"scrolled": true
170+
},
178171
"outputs": [
179172
{
180173
"data": {
@@ -247,13 +240,18 @@
247240
"\n",
248241
"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",
249242
"\n",
250-
"`solve(var_list=[\"INVEST\"])`\n"
243+
"`solve(var_list=[\"INVEST\"])`\n",
244+
"\n",
245+
"#### Notice: Restart the kernel\n",
246+
"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"
251247
]
252248
},
253249
{
254250
"cell_type": "code",
255251
"execution_count": 8,
256-
"metadata": {},
252+
"metadata": {
253+
"scrolled": true
254+
},
257255
"outputs": [],
258256
"source": [
259257
"# Now, let's solve the scenario again\n",
@@ -271,7 +269,9 @@
271269
{
272270
"cell_type": "code",
273271
"execution_count": 9,
274-
"metadata": {},
272+
"metadata": {
273+
"scrolled": true
274+
},
275275
"outputs": [
276276
{
277277
"data": {
@@ -415,7 +415,9 @@
415415
{
416416
"cell_type": "code",
417417
"execution_count": null,
418-
"metadata": {},
418+
"metadata": {
419+
"scrolled": true
420+
},
419421
"outputs": [],
420422
"source": [
421423
"# Now, let's clone a new scenario and solve\n",
@@ -426,7 +428,9 @@
426428
{
427429
"cell_type": "code",
428430
"execution_count": null,
429-
"metadata": {},
431+
"metadata": {
432+
"scrolled": true
433+
},
430434
"outputs": [],
431435
"source": [
432436
"df = scen2.var(\"INVEST\", {\"node\": \"Westeros\"})\n",
@@ -443,7 +447,9 @@
443447
{
444448
"cell_type": "code",
445449
"execution_count": null,
446-
"metadata": {},
450+
"metadata": {
451+
"scrolled": true
452+
},
447453
"outputs": [],
448454
"source": [
449455
"# Adding input data for \"bound_investment_up\"\n",
@@ -460,7 +466,9 @@
460466
{
461467
"cell_type": "code",
462468
"execution_count": null,
463-
"metadata": {},
469+
"metadata": {
470+
"scrolled": true
471+
},
464472
"outputs": [],
465473
"source": [
466474
"# Adding the unit to the platform (if not exists yet)\n",
@@ -476,7 +484,9 @@
476484
{
477485
"cell_type": "code",
478486
"execution_count": null,
479-
"metadata": {},
487+
"metadata": {
488+
"scrolled": true
489+
},
480490
"outputs": [],
481491
"source": [
482492
"# Solving the scenario\n",
@@ -497,7 +507,9 @@
497507
{
498508
"cell_type": "code",
499509
"execution_count": null,
500-
"metadata": {},
510+
"metadata": {
511+
"scrolled": true
512+
},
501513
"outputs": [],
502514
"source": [
503515
"# Investment needs before the bound\n",
@@ -507,7 +519,9 @@
507519
{
508520
"cell_type": "code",
509521
"execution_count": null,
510-
"metadata": {},
522+
"metadata": {
523+
"scrolled": true
524+
},
511525
"outputs": [],
512526
"source": [
513527
"# Investment needs after the bound\n",
@@ -527,7 +541,9 @@
527541
{
528542
"cell_type": "code",
529543
"execution_count": null,
530-
"metadata": {},
544+
"metadata": {
545+
"scrolled": true
546+
},
531547
"outputs": [],
532548
"source": [
533549
"# Difference in the total system costs after investment limits (M$)\n",
@@ -557,7 +573,9 @@
557573
{
558574
"cell_type": "code",
559575
"execution_count": null,
560-
"metadata": {},
576+
"metadata": {
577+
"scrolled": true
578+
},
561579
"outputs": [],
562580
"source": [
563581
"# Close the connection to the database\n",

0 commit comments

Comments
 (0)