|
10 | 10 | "\n", |
11 | 11 | "**Pre-requisites**\n", |
12 | 12 | "- 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_." |
14 | 16 | ] |
15 | 17 | }, |
16 | 18 | { |
17 | 19 | "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": [], |
44 | 25 | "source": [ |
45 | 26 | "import pandas as pd\n", |
46 | 27 | "import ixmp\n", |
|
54 | 35 | { |
55 | 36 | "cell_type": "code", |
56 | 37 | "execution_count": 2, |
57 | | - "metadata": {}, |
| 38 | + "metadata": { |
| 39 | + "scrolled": true |
| 40 | + }, |
58 | 41 | "outputs": [], |
59 | 42 | "source": [ |
60 | 43 | "mp = ixmp.Platform()" |
|
93 | 76 | { |
94 | 77 | "cell_type": "code", |
95 | 78 | "execution_count": 3, |
96 | | - "metadata": {}, |
| 79 | + "metadata": { |
| 80 | + "scrolled": true |
| 81 | + }, |
97 | 82 | "outputs": [ |
98 | 83 | { |
99 | 84 | "name": "stderr", |
|
113 | 98 | { |
114 | 99 | "cell_type": "code", |
115 | 100 | "execution_count": 4, |
116 | | - "metadata": {}, |
| 101 | + "metadata": { |
| 102 | + "scrolled": true |
| 103 | + }, |
117 | 104 | "outputs": [], |
118 | 105 | "source": [ |
119 | 106 | "# Solving the new scenario again (testing the changes in the GAMS code)\n", |
|
131 | 118 | { |
132 | 119 | "cell_type": "code", |
133 | 120 | "execution_count": 5, |
134 | | - "metadata": {}, |
| 121 | + "metadata": { |
| 122 | + "scrolled": true |
| 123 | + }, |
135 | 124 | "outputs": [], |
136 | 125 | "source": [ |
137 | 126 | "# We assert that the objective values are the same\n", |
|
141 | 130 | { |
142 | 131 | "cell_type": "code", |
143 | 132 | "execution_count": 6, |
144 | | - "metadata": {}, |
| 133 | + "metadata": { |
| 134 | + "scrolled": true |
| 135 | + }, |
145 | 136 | "outputs": [], |
146 | 137 | "source": [ |
147 | 138 | "# We can compare the activity of one technology in one year too\n", |
|
174 | 165 | { |
175 | 166 | "cell_type": "code", |
176 | 167 | "execution_count": 7, |
177 | | - "metadata": {}, |
| 168 | + "metadata": { |
| 169 | + "scrolled": true |
| 170 | + }, |
178 | 171 | "outputs": [ |
179 | 172 | { |
180 | 173 | "data": { |
|
247 | 240 | "\n", |
248 | 241 | "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", |
249 | 242 | "\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" |
251 | 247 | ] |
252 | 248 | }, |
253 | 249 | { |
254 | 250 | "cell_type": "code", |
255 | 251 | "execution_count": 8, |
256 | | - "metadata": {}, |
| 252 | + "metadata": { |
| 253 | + "scrolled": true |
| 254 | + }, |
257 | 255 | "outputs": [], |
258 | 256 | "source": [ |
259 | 257 | "# Now, let's solve the scenario again\n", |
|
271 | 269 | { |
272 | 270 | "cell_type": "code", |
273 | 271 | "execution_count": 9, |
274 | | - "metadata": {}, |
| 272 | + "metadata": { |
| 273 | + "scrolled": true |
| 274 | + }, |
275 | 275 | "outputs": [ |
276 | 276 | { |
277 | 277 | "data": { |
|
415 | 415 | { |
416 | 416 | "cell_type": "code", |
417 | 417 | "execution_count": null, |
418 | | - "metadata": {}, |
| 418 | + "metadata": { |
| 419 | + "scrolled": true |
| 420 | + }, |
419 | 421 | "outputs": [], |
420 | 422 | "source": [ |
421 | 423 | "# Now, let's clone a new scenario and solve\n", |
|
426 | 428 | { |
427 | 429 | "cell_type": "code", |
428 | 430 | "execution_count": null, |
429 | | - "metadata": {}, |
| 431 | + "metadata": { |
| 432 | + "scrolled": true |
| 433 | + }, |
430 | 434 | "outputs": [], |
431 | 435 | "source": [ |
432 | 436 | "df = scen2.var(\"INVEST\", {\"node\": \"Westeros\"})\n", |
|
443 | 447 | { |
444 | 448 | "cell_type": "code", |
445 | 449 | "execution_count": null, |
446 | | - "metadata": {}, |
| 450 | + "metadata": { |
| 451 | + "scrolled": true |
| 452 | + }, |
447 | 453 | "outputs": [], |
448 | 454 | "source": [ |
449 | 455 | "# Adding input data for \"bound_investment_up\"\n", |
|
460 | 466 | { |
461 | 467 | "cell_type": "code", |
462 | 468 | "execution_count": null, |
463 | | - "metadata": {}, |
| 469 | + "metadata": { |
| 470 | + "scrolled": true |
| 471 | + }, |
464 | 472 | "outputs": [], |
465 | 473 | "source": [ |
466 | 474 | "# Adding the unit to the platform (if not exists yet)\n", |
|
476 | 484 | { |
477 | 485 | "cell_type": "code", |
478 | 486 | "execution_count": null, |
479 | | - "metadata": {}, |
| 487 | + "metadata": { |
| 488 | + "scrolled": true |
| 489 | + }, |
480 | 490 | "outputs": [], |
481 | 491 | "source": [ |
482 | 492 | "# Solving the scenario\n", |
|
497 | 507 | { |
498 | 508 | "cell_type": "code", |
499 | 509 | "execution_count": null, |
500 | | - "metadata": {}, |
| 510 | + "metadata": { |
| 511 | + "scrolled": true |
| 512 | + }, |
501 | 513 | "outputs": [], |
502 | 514 | "source": [ |
503 | 515 | "# Investment needs before the bound\n", |
|
507 | 519 | { |
508 | 520 | "cell_type": "code", |
509 | 521 | "execution_count": null, |
510 | | - "metadata": {}, |
| 522 | + "metadata": { |
| 523 | + "scrolled": true |
| 524 | + }, |
511 | 525 | "outputs": [], |
512 | 526 | "source": [ |
513 | 527 | "# Investment needs after the bound\n", |
|
527 | 541 | { |
528 | 542 | "cell_type": "code", |
529 | 543 | "execution_count": null, |
530 | | - "metadata": {}, |
| 544 | + "metadata": { |
| 545 | + "scrolled": true |
| 546 | + }, |
531 | 547 | "outputs": [], |
532 | 548 | "source": [ |
533 | 549 | "# Difference in the total system costs after investment limits (M$)\n", |
|
557 | 573 | { |
558 | 574 | "cell_type": "code", |
559 | 575 | "execution_count": null, |
560 | | - "metadata": {}, |
| 576 | + "metadata": { |
| 577 | + "scrolled": true |
| 578 | + }, |
561 | 579 | "outputs": [], |
562 | 580 | "source": [ |
563 | 581 | "# Close the connection to the database\n", |
|
0 commit comments