Skip to content

Commit 00bec74

Browse files
authored
Merge pull request #451 from iiasa/material_stock
Add commodity flow of capacity variables
2 parents 9fb0b97 + d77ab2b commit 00bec74

23 files changed

+9526
-16241
lines changed

RELEASE_NOTES.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ Next release
44
All changes
55
-----------
66

7+
- Add representation of commodity flows associated with construction and retirement of technology capacity (:pull:`451`).
8+
9+
- New parameters
10+
|input_cap|,
11+
|input_cap_new|,
12+
|input_cap_ret|,
13+
|output_cap|,
14+
|output_cap_new|, and
15+
|output_cap_ret|.
16+
When loading a Scenario created with :mod:`message_ix` version 3.11.0 or earlier,
17+
these items are automatically initialized (and left empty),
18+
using at most one call to :meth:`~message_ix.Scenario.commit`.
19+
See :meth:`.MESSAGE.initialize`.
20+
- Revise :ref:`equation_commodity_balance_aux` to include input and output flows based on |CAP| and |CAP_NEW|.
21+
- New :class:`.MESSAGE` / :meth:`.Scenario.solve` option :py:`cap_comm=True` to enable this representation.
22+
723
- Document the :ref:`minimum version of Java <install-java>` required for :class:`ixmp.JDBCBackend <ixmp.backend.jdbc.JDBCBackend>` (:pull:`962`).
824
- Improve type hinting (:pull:`963`).
925

doc/api.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,18 @@ Model classes
249249
:exclude-members: defaults
250250
:show-inheritance:
251251

252+
MESSAGE accepts the following *model_options* to control its behaviour:
253+
254+
- **cap_comm** (:class:`bool` or equivalent :class:`int` or :class:`float`):
255+
If :any:`True`, include **comm** odity flows associated with **cap** acity changes of technologies
256+
in :ref:`equation_commodity_balance_aux`.
257+
If :any:`False` (the default), these flow are omitted,
258+
and values of the associated parameters have no effect.
259+
This corresponds to the GAMS compile-time variable ``MESSAGE_CAP_COMM``.
260+
261+
.. note:: For some models, this can significantly increase the linear program (LP) size
262+
and thus the solve time.
263+
252264
.. autoattribute:: items
253265
:no-value:
254266

@@ -263,10 +275,10 @@ Model classes
263275
The MACRO class solves only the MACRO model in “standalone” mode—that is, without MESSAGE.
264276
It is also invoked from :class:`.MESSAGE_MACRO` to process *model_options* to control the behaviour of MACRO:
265277

266-
- **concurrent** (:class:`int` or :class:`float`, either :py:`0` or :py:`1`).
278+
- **concurrent** (:class:`bool` or equivalent :class:`int` or :class:`float`).
267279
This corresponds to the GAMS compile-time variable ``MACRO_CONCURRENT``.
268-
If set to :py:`0` (the default), MACRO is solved in a loop, once for each node in the Scenario.
269-
If set to :py:`1`, MACRO is solved only once, for all nodes simultaneously.
280+
If :any:`False` (the default), MACRO is solved in a loop, once for each node in the Scenario.
281+
If :any:`True`, MACRO is solved only once, for all nodes simultaneously.
270282

271283
.. autoattribute:: items
272284
:no-value:
@@ -279,7 +291,8 @@ Model classes
279291
MESSAGE_MACRO solves the MESSAGE and MACRO models iteratively, connecting changes in technology activity and resource demands (from MESSAGE) to changes in final demands and prices (from MACRO).
280292
This iteration continues until the solution *converges*; i.e. the two models reach a stable point for the values of these parameters.
281293

282-
MESSAGE_MACRO accepts three additional *model_options* that control the behaviour of this iteration algorithm:
294+
MESSAGE_MACRO accepts all of the *model_options* recognized by :class:`.MESSAGE` and :class:`.MACRO`,
295+
plus additional options that control the behaviour of this iteration algorithm:
283296

284297
- **max_adjustment** (:class:`float`, default 0.2): the maximum absolute relative change in final demands between iterations.
285298
If MACRO returns demands that have changed by more than a factor outside the range (1 - `max_adjustment`, 1 + `max_adjustment`) since the previous iteration, then the change is confined to the limits of that range for the next run of MESSAGE.

doc/conf.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
6868
<abbr title="International Institute for Applied Systems Analysis">IIASA</abbr>
6969
70+
.. |y0| replace:: :math:`y_0`
7071
.. |yA| replace:: :math:`y^A`
7172
.. |yV| replace:: :math:`y^V`
7273
"""
@@ -77,13 +78,29 @@
7778
# sometimes multiple targets appear above a single heading, and that heading text would
7879
# be automatically used for the link text.
7980
for name in (
81+
"ACT",
82+
"CAP",
83+
"CAP_NEW",
84+
"LAND",
85+
"STOCK_CHG",
8086
"duration_period",
8187
"duration_period_sum",
8288
"growth_new_capacity_up",
8389
"historical_new_capacity",
8490
"initial_new_capacity_up",
91+
"input",
92+
"input_cap",
93+
"input_cap_new",
94+
"input_cap_ret",
95+
"output",
96+
"output_cap",
97+
"output_cap_new",
98+
"output_cap_ret",
99+
"land_input",
100+
"land_output",
85101
"map_tec_lifetime",
86102
"remaining_capacity",
103+
"technical_lifetime",
87104
):
88105
rst_prolog += f"\n.. |{name}| replace:: :ref:`{name} <{name}>`"
89106

@@ -222,8 +239,9 @@ def local_inv(name: str, *parts: str) -> Optional[str]:
222239
macros = {}
223240
macros.update(
224241
{
225-
k.replace("_", ""): r"\text{{{k}}}"
242+
k.replace("_", ""): rf"\text{{{k}}}"
226243
for k in """ACT
244+
COMMODITY_BALANCE
227245
STORAGE
228246
STORAGE_CHARGE
229247
duration_time_rel

message_ix/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,8 @@ def solve(self, model="MESSAGE", solve_options={}, **kwargs):
755755
See the :class:`.MESSAGE` class and :obj:`.DEFAULT_CPLEX_OPTIONS`.
756756
kwargs :
757757
Other options control the execution of the underlying GAMS code; see the
758-
:class:`.MESSAGE_MACRO` class and :class:`.GAMSModel`.
758+
*model_options* described for :class:`.MESSAGE`, :class:`.MACRO`,
759+
:class:`.MESSAGE_MACRO`, and :class:`.GAMSModel`.
759760
"""
760761
super().solve(model=model, solve_options=solve_options, **kwargs)
761762

0 commit comments

Comments
 (0)