Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the option to solve concurrently for all regions in MACRO #808

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion message_ix/model/MACRO/macro_data_load.gms
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 20 additions & 18 deletions message_ix/model/MACRO/macro_solve.gms
Original file line number Diff line number Diff line change
Expand Up @@ -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;
) ;

Loading