From 66789c321308f68214f164d4b4c388093e55a0f5 Mon Sep 17 00:00:00 2001 From: daymontas1 <53146798+daymontas1@users.noreply.github.com> Date: Fri, 22 Mar 2024 20:20:10 +0100 Subject: [PATCH 1/4] Update MESSAGE-MACRO_run.gms Introducing a parameter (''solve_param'') to control the solving mechanism for MACRO. Setting ''solve_param'' to 1 (the default value) triggers sequential solving across regions, whereas setting it to 2 enables concurrent solving. --- message_ix/model/MESSAGE-MACRO_run.gms | 2 ++ 1 file changed, 2 insertions(+) diff --git a/message_ix/model/MESSAGE-MACRO_run.gms b/message_ix/model/MESSAGE-MACRO_run.gms index abdd3b352..fe3815569 100644 --- a/message_ix/model/MESSAGE-MACRO_run.gms +++ b/message_ix/model/MESSAGE-MACRO_run.gms @@ -89,7 +89,9 @@ Set * NB MAX_ADJUSTMENT and max_adjustment have different meanings: * - MAX_ADJUSTMENT is a fixed threshold used to truncate the relative demand change produced by MACRO. * - max_adjustment is the amount of that change, after any truncation. +*setting solve_param to 1 (the default values) triggers sequential solving across regions in MACRO, whereas setting it to 2 enables concurrent solving for all regions Scalar + solve_param solving mechanism for MACRO / 1 / max_adjustment_pre maximum adjustment in previous iteration / 0 / max_adjustment_pos maximum positive adjustment in current iteration max_adjustment_neg maximum negative adjustment in current iteration From 69fb07ac551f4eb437e67fa67122d52745540b31 Mon Sep 17 00:00:00 2001 From: daymontas1 <53146798+daymontas1@users.noreply.github.com> Date: Fri, 22 Mar 2024 20:52:44 +0100 Subject: [PATCH 2/4] Update macro_solve.gms An if statement has been introduced to allow users to select whether they want to solve sequentially or concurrently for all regions. This is determined by the ''solve_param'' parameter, defined in ''MESSAGE-MACRO_run''. The default solving is sequential (for ''solve_param''=1), so if the user doesn't update the solving mechanism, the macro is solved as it used to be. In terms of efficiency, the concurrent solving is slightly more efficient. For the concurrent solving mechanism (for ''solve_param''=2), all nodes are activated from the beginning, thereby enabling simultaneous solving for all regions. This setting allows for factoring in interregional interactions into the optimization process. We want this concurrent optimization option, as we intend to incorporate interregional feedback mechanisms into MACRO, e.g., interregional investments. Given that in the current version of MACRO regions are independent, both solving mechanisms should produce the same results. --- message_ix/model/MACRO/macro_solve.gms | 38 ++++++++++++++------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/message_ix/model/MACRO/macro_solve.gms b/message_ix/model/MACRO/macro_solve.gms index 86933c9a3..c88324239 100755 --- a/message_ix/model/MACRO/macro_solve.gms +++ b/message_ix/model/MACRO/macro_solve.gms @@ -38,30 +38,32 @@ C.FX(node_macro, macro_base_period) = c0(node_macro) ; I.FX(node_macro, macro_base_period) = i0(node_macro) ; EC.FX(node_macro, macro_base_period) = y0(node_macro) - i0(node_macro) - c0(node_macro) ; -* ------------------------------------------------------------------------------ +* Conditional execution based on solve_param +if (solve_param = 1, * solving the model region by region -* ------------------------------------------------------------------------------ - -node_active(node) = no ; - -LOOP(node $ node_macro(node), - - node_active(node_macro) = no ; - node_active(node) = YES; -* DISPLAY node_active ; - -* ------------------------------------------------------------------------------ + node_active(node) = no ; + LOOP(node $ node_macro(node), + node_active(node_macro) = no ; + node_active(node) = YES; +* DISPLAY node_active ; * solve statement -* ------------------------------------------------------------------------------ - - SOLVE MESSAGE_MACRO MAXIMIZING UTILITY USING NLP ; - + SOLVE MESSAGE_MACRO MAXIMIZING UTILITY USING NLP ; * write model status summary (by node) * status(node,'modelstat') = MESSAGE_MACRO.modelstat ; * status(node,'solvestat') = MESSAGE_MACRO.solvestat ; * status(node,'resUsd') = MESSAGE_MACRO.resUsd ; * status(node,'objEst') = MESSAGE_MACRO.objEst ; * status(node,'objVal') = MESSAGE_MACRO.objVal ; - + ) +elseif (solve_param = 2), +*Solving model with all regions concurrently + node_active(node_macro) = YES; +* solve statement + SOLVE MESSAGE_MACRO MAXIMIZING UTILITY USING NLP; +* write model status summary +* status('all','modelstat') = MESSAGE_MACRO.modelstat; +* status('all','solvestat') = MESSAGE_MACRO.solvestat; +* status('all','resUsd') = MESSAGE_MACRO.resUsd; +* status('all','objEst') = MESSAGE_MACRO.objEst; +* status('all','objVal') = MESSAGE_MACRO.objVal; ) ; - From 1beede5fc1dcdf19dff6ad3da9a550a27e43f82c Mon Sep 17 00:00:00 2001 From: daymontas1 <53146798+daymontas1@users.noreply.github.com> Date: Fri, 3 May 2024 16:07:27 +0200 Subject: [PATCH 3/4] Update macro_data_load.gms Introducing a parameter (''solve_param'') to control the solving mechanism for MACRO. Setting ''solve_param'' to 1 (the default value) triggers sequential solving across regions, whereas setting it to 2 enables concurrent solving. --- message_ix/model/MACRO/macro_data_load.gms | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/message_ix/model/MACRO/macro_data_load.gms b/message_ix/model/MACRO/macro_data_load.gms index 8cbb9eb9d..f6209dc05 100755 --- a/message_ix/model/MACRO/macro_data_load.gms +++ b/message_ix/model/MACRO/macro_data_load.gms @@ -43,7 +43,10 @@ Sets ; * parameters specific to MACRO - +*setting solve_param to 1 (the default values) triggers sequential solving across regions in MACRO, whereas setting it to 2 enables concurrent solving for all regions +SCALAR solve_param solving mechanism for MACRO + / 1 / +; SCALAR node_counter 'node counter for looping over regions' ; SCALAR epsilon small number to avoid divergences From b7a9eea3e1a5f2942caa7f44be540a3fa38b91f3 Mon Sep 17 00:00:00 2001 From: daymontas1 <53146798+daymontas1@users.noreply.github.com> Date: Fri, 3 May 2024 16:10:43 +0200 Subject: [PATCH 4/4] Update MESSAGE-MACRO_run.gms Defining ''solve_param'' in ''MESSAGE-MACRO_run.gms'' creates a problem in testing. Therefore, ''solve_param'' is defined in ''macro_data_load.gms'' instead. --- message_ix/model/MESSAGE-MACRO_run.gms | 2 -- 1 file changed, 2 deletions(-) diff --git a/message_ix/model/MESSAGE-MACRO_run.gms b/message_ix/model/MESSAGE-MACRO_run.gms index fe3815569..abdd3b352 100644 --- a/message_ix/model/MESSAGE-MACRO_run.gms +++ b/message_ix/model/MESSAGE-MACRO_run.gms @@ -89,9 +89,7 @@ Set * NB MAX_ADJUSTMENT and max_adjustment have different meanings: * - MAX_ADJUSTMENT is a fixed threshold used to truncate the relative demand change produced by MACRO. * - max_adjustment is the amount of that change, after any truncation. -*setting solve_param to 1 (the default values) triggers sequential solving across regions in MACRO, whereas setting it to 2 enables concurrent solving for all regions Scalar - solve_param solving mechanism for MACRO / 1 / max_adjustment_pre maximum adjustment in previous iteration / 0 / max_adjustment_pos maximum positive adjustment in current iteration max_adjustment_neg maximum negative adjustment in current iteration