From 82d365637c7939f29256d331d1b6258dee20b663 Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Fri, 4 Apr 2025 13:40:40 +0200 Subject: [PATCH 01/19] small bugfix + switch to set Tol_Optimality --- config/default.cfg | 2 ++ modules/18_residues/flexreg_apr16/declarations.gms | 4 ---- modules/18_residues/flexreg_apr16/equations.gms | 6 +++--- modules/80_optimization/nlp_apr17/input.gms | 3 ++- modules/80_optimization/nlp_apr17/solve.gms | 1 + 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 5207c74bc5..d21a0d74f6 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -2087,6 +2087,8 @@ cfg$gms$c80_nlp_solver <- "conopt4" # def = conopt4 # * 1: using optfile for specified solver settings # * 0: default settings (optfile will be ignored) cfg$gms$s80_optfile <- 0 # def = 0 +cfg$gms$s80_toloptimal <- 1.0e-7 # def = 1.0e-7 + # * Optional second solve statement (0=off, 1=on) cfg$gms$s80_secondsolve <- 0 # def = 0 diff --git a/modules/18_residues/flexreg_apr16/declarations.gms b/modules/18_residues/flexreg_apr16/declarations.gms index e000474151..e5564e7c50 100644 --- a/modules/18_residues/flexreg_apr16/declarations.gms +++ b/modules/18_residues/flexreg_apr16/declarations.gms @@ -18,19 +18,15 @@ positive variables ; equations - q18_prod_res_ag_reg(i,kcr,attributes) Production constraint of aboveground residues (mio. tDM) q18_prod_res_bg_reg(i,kcr,dm_nr) Production constraint of belowground residues (mio. tDM) - q18_res_field_balance(i,kcr,attributes) Calculation of the residues amount recycled to soils (mio. tDM) q18_res_field_burn(i,kcr,attributes) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX) q18_translate(i,kres,attributes) Transformation of the multiple crop residues into supply balance crop redisues in respective attribute units DM GJ Nr P K WM C (mio. tX) q18_prod_res_cell(j,kres) Allows for distribution of residues to cellular level (mio. tDM) - q18_res_recycling_nr(i) Nutrient recycling of reaactive nitrogen (mio. tNr) q18_res_recycling_pk(i,pk18) Nutrient recycling of phosphorus and potash (mio. tX) q18_cost_prod_res(i,kres) Production costs of harvesting crop residues (mio. USD17MER) - ; parameters diff --git a/modules/18_residues/flexreg_apr16/equations.gms b/modules/18_residues/flexreg_apr16/equations.gms index e01b0d2072..09df6c8bcc 100644 --- a/modules/18_residues/flexreg_apr16/equations.gms +++ b/modules/18_residues/flexreg_apr16/equations.gms @@ -73,10 +73,10 @@ vm_prod_reg(i2,kres) * fm_attributes(attributes,kres); *' Amount produced at cellular level is flexible, can be distributed as it wants - q18_prod_res_cell(j2,kres).. - sum(cell(i2,j2), vm_prod_reg(i2,kres)) + q18_prod_res_cell(i2,kres).. + sum(cell(i2,j2), v18_prod_res(j2,kres)) =e= - v18_prod_res(j2,kres) ; + vm_prod_reg(i2,kres); *' Residues recycled to croplands in nutrients `vm_res_recycling(i2,"nr")` are diff --git a/modules/80_optimization/nlp_apr17/input.gms b/modules/80_optimization/nlp_apr17/input.gms index 051075eec3..eb6297de44 100644 --- a/modules/80_optimization/nlp_apr17/input.gms +++ b/modules/80_optimization/nlp_apr17/input.gms @@ -8,5 +8,6 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 0 / - s80_secondsolve second solve statement (binary) / 0 / + s80_secondsolve second solve statement (binary) / 0 / + s80_toloptimal switch to set Tol_Optimality / 1.0e-7 / ; diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index ffdb6bfc0e..efe6879568 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -20,6 +20,7 @@ magpie.holdfixed = 1 ; $onecho > conopt4.opt Lim_Variable = 1.e25 +Tol_Optimality = s80_toloptimal $offecho $onecho > conopt4.op2 From 14787e05ee5612cc8cfafcefd688e221e0a865df Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Mon, 7 Apr 2025 12:17:03 +0200 Subject: [PATCH 02/19] add config entry for setting Tol_Optimality solver setting dynamically --- config/default.cfg | 7 +++++-- core/calculations.gms | 1 + modules/18_residues/flexreg_apr16/declarations.gms | 4 ++-- modules/18_residues/flexreg_apr16/postsolve.gms | 8 ++++---- modules/44_biodiversity/bv_btc_mar21/input.gms | 2 +- modules/80_optimization/lp_nlp_apr17/input.gms | 2 +- modules/80_optimization/nlp_apr17/input.gms | 4 ++-- modules/80_optimization/nlp_apr17/solve.gms | 8 ++++---- modules/80_optimization/nlp_par/input.gms | 2 +- 9 files changed, 21 insertions(+), 17 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index adb34f8f51..e574d7b2cc 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -2157,9 +2157,12 @@ cfg$gms$c80_nlp_solver <- "conopt4" # def = conopt4 # * 1: using optfile for specified solver settings # * 0: default settings (optfile will be ignored) -cfg$gms$s80_optfile <- 0 # def = 0 -cfg$gms$s80_toloptimal <- 1.0e-7 # def = 1.0e-7 +cfg$gms$s80_optfile <- 1 # def = 0 +# Solver setting Tol_Optimality (real): +# Optimality tolerance for reduced gradient when feasible. +# Range: [3.e-13, 1], Solver default: 1.e-7 +cfg$gms$s80_toloptimal <- 1.0e-8 # def = 1.0e-8 # * Optional second solve statement (0=off, 1=on) cfg$gms$s80_secondsolve <- 0 # def = 0 diff --git a/core/calculations.gms b/core/calculations.gms index 9063d06f87..bf7e4bf3ef 100644 --- a/core/calculations.gms +++ b/core/calculations.gms @@ -21,6 +21,7 @@ $batinclude "./modules/include.gms" preloop * to be done here because a file declaration cannot be inside a loop file dummy; dummy.pw=2000; put dummy; +File optfile /conopt4.opt/; ************************OPTIMIZATION PROCESS START****************************** * This section contains only sourcecode that is directly connected to the diff --git a/modules/18_residues/flexreg_apr16/declarations.gms b/modules/18_residues/flexreg_apr16/declarations.gms index e5564e7c50..9bad777ea0 100644 --- a/modules/18_residues/flexreg_apr16/declarations.gms +++ b/modules/18_residues/flexreg_apr16/declarations.gms @@ -23,7 +23,7 @@ equations q18_res_field_balance(i,kcr,attributes) Calculation of the residues amount recycled to soils (mio. tDM) q18_res_field_burn(i,kcr,attributes) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX) q18_translate(i,kres,attributes) Transformation of the multiple crop residues into supply balance crop redisues in respective attribute units DM GJ Nr P K WM C (mio. tX) - q18_prod_res_cell(j,kres) Allows for distribution of residues to cellular level (mio. tDM) + q18_prod_res_cell(i,kres) Allows for distribution of residues to cellular level (mio. tDM) q18_res_recycling_nr(i) Nutrient recycling of reaactive nitrogen (mio. tNr) q18_res_recycling_pk(i,pk18) Nutrient recycling of phosphorus and potash (mio. tX) q18_cost_prod_res(i,kres) Production costs of harvesting crop residues (mio. USD17MER) @@ -48,7 +48,7 @@ parameters oq18_res_field_balance(t,i,kcr,attributes,type) Calculation of the residues amount recycled to soils (mio. tDM) oq18_res_field_burn(t,i,kcr,attributes,type) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX) oq18_translate(t,i,kres,attributes,type) Transformation of the multiple crop residues into supply balance crop redisues in respective attribute units DM GJ Nr P K WM C (mio. tX) - oq18_prod_res_cell(t,j,kres,type) Allows for distribution of residues to cellular level (mio. tDM) + oq18_prod_res_cell(t,i,kres,type) Allows for distribution of residues to cellular level (mio. tDM) oq18_res_recycling_nr(t,i,type) Nutrient recycling of reaactive nitrogen (mio. tNr) oq18_res_recycling_pk(t,i,pk18,type) Nutrient recycling of phosphorus and potash (mio. tX) oq18_cost_prod_res(t,i,kres,type) Production costs of harvesting crop residues (mio. USD17MER) diff --git a/modules/18_residues/flexreg_apr16/postsolve.gms b/modules/18_residues/flexreg_apr16/postsolve.gms index 0b0007332b..65d25686e2 100644 --- a/modules/18_residues/flexreg_apr16/postsolve.gms +++ b/modules/18_residues/flexreg_apr16/postsolve.gms @@ -23,7 +23,7 @@ oq18_res_field_balance(t,i,kcr,attributes,"marginal") = q18_res_field_balance.m(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"marginal") = q18_res_field_burn.m(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"marginal") = q18_translate.m(i,kres,attributes); - oq18_prod_res_cell(t,j,kres,"marginal") = q18_prod_res_cell.m(j,kres); + oq18_prod_res_cell(t,i,kres,"marginal") = q18_prod_res_cell.m(i,kres); oq18_res_recycling_nr(t,i,"marginal") = q18_res_recycling_nr.m(i); oq18_res_recycling_pk(t,i,pk18,"marginal") = q18_res_recycling_pk.m(i,pk18); oq18_cost_prod_res(t,i,kres,"marginal") = q18_cost_prod_res.m(i,kres); @@ -40,7 +40,7 @@ oq18_res_field_balance(t,i,kcr,attributes,"level") = q18_res_field_balance.l(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"level") = q18_res_field_burn.l(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"level") = q18_translate.l(i,kres,attributes); - oq18_prod_res_cell(t,j,kres,"level") = q18_prod_res_cell.l(j,kres); + oq18_prod_res_cell(t,i,kres,"level") = q18_prod_res_cell.l(i,kres); oq18_res_recycling_nr(t,i,"level") = q18_res_recycling_nr.l(i); oq18_res_recycling_pk(t,i,pk18,"level") = q18_res_recycling_pk.l(i,pk18); oq18_cost_prod_res(t,i,kres,"level") = q18_cost_prod_res.l(i,kres); @@ -57,7 +57,7 @@ oq18_res_field_balance(t,i,kcr,attributes,"upper") = q18_res_field_balance.up(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"upper") = q18_res_field_burn.up(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"upper") = q18_translate.up(i,kres,attributes); - oq18_prod_res_cell(t,j,kres,"upper") = q18_prod_res_cell.up(j,kres); + oq18_prod_res_cell(t,i,kres,"upper") = q18_prod_res_cell.up(i,kres); oq18_res_recycling_nr(t,i,"upper") = q18_res_recycling_nr.up(i); oq18_res_recycling_pk(t,i,pk18,"upper") = q18_res_recycling_pk.up(i,pk18); oq18_cost_prod_res(t,i,kres,"upper") = q18_cost_prod_res.up(i,kres); @@ -74,7 +74,7 @@ oq18_res_field_balance(t,i,kcr,attributes,"lower") = q18_res_field_balance.lo(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"lower") = q18_res_field_burn.lo(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"lower") = q18_translate.lo(i,kres,attributes); - oq18_prod_res_cell(t,j,kres,"lower") = q18_prod_res_cell.lo(j,kres); + oq18_prod_res_cell(t,i,kres,"lower") = q18_prod_res_cell.lo(i,kres); oq18_res_recycling_nr(t,i,"lower") = q18_res_recycling_nr.lo(i); oq18_res_recycling_pk(t,i,pk18,"lower") = q18_res_recycling_pk.lo(i,pk18); oq18_cost_prod_res(t,i,kres,"lower") = q18_cost_prod_res.lo(i,kres); diff --git a/modules/44_biodiversity/bv_btc_mar21/input.gms b/modules/44_biodiversity/bv_btc_mar21/input.gms index 8d2940474a..b751e9804c 100644 --- a/modules/44_biodiversity/bv_btc_mar21/input.gms +++ b/modules/44_biodiversity/bv_btc_mar21/input.gms @@ -6,7 +6,7 @@ *** | Contact: magpie@pik-potsdam.de scalars - s44_start_year Start year of biodiversity price (1) / 2025 / + s44_start_year Start year of biodiversity price (1) / 2030 / s44_target_year Target year of biodiversity price (1) / 2100 / s44_start_price Price for biodiversity stock loss in start year (USD17MER per ha) / 0 / s44_target_price Price for biodiversity stock loss in target year (USD17MER per ha) / 0 / diff --git a/modules/80_optimization/lp_nlp_apr17/input.gms b/modules/80_optimization/lp_nlp_apr17/input.gms index 3945d0c594..8cec7331f5 100644 --- a/modules/80_optimization/lp_nlp_apr17/input.gms +++ b/modules/80_optimization/lp_nlp_apr17/input.gms @@ -7,7 +7,7 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / - s80_optfile switch to use specfied solver settings (1) / 0 / + s80_optfile switch to use specfied solver settings (1) / 1 / s80_add_cplex add cplex optimization after conopt4 (1) / 0 / s80_add_conopt3 add conopt3 optimization after conopt4 (1) / 0 / s80_secondsolve second solve statement (binary) / 0 / diff --git a/modules/80_optimization/nlp_apr17/input.gms b/modules/80_optimization/nlp_apr17/input.gms index eb6297de44..1efe568d07 100644 --- a/modules/80_optimization/nlp_apr17/input.gms +++ b/modules/80_optimization/nlp_apr17/input.gms @@ -7,7 +7,7 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / - s80_optfile switch to use specfied solver settings (1) / 0 / + s80_optfile switch to use specfied solver settings (1) / 1 / s80_secondsolve second solve statement (binary) / 0 / - s80_toloptimal switch to set Tol_Optimality / 1.0e-7 / + s80_toloptimal switch to set Tol_Optimality / 1e-08 / ; diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index efe6879568..414539fc24 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -18,10 +18,10 @@ magpie.scaleopt = 1 ; magpie.solprint = 0 ; magpie.holdfixed = 1 ; -$onecho > conopt4.opt -Lim_Variable = 1.e25 -Tol_Optimality = s80_toloptimal -$offecho +put optfile; +put 'Lim_Variable = 1.e25' /; +put 'Tol_Optimality = ', s80_toloptimal:12:11 /; +putclose optfile; $onecho > conopt4.op2 Flg_Prep = FALSE diff --git a/modules/80_optimization/nlp_par/input.gms b/modules/80_optimization/nlp_par/input.gms index 39891d8b17..f3fbe6695c 100644 --- a/modules/80_optimization/nlp_par/input.gms +++ b/modules/80_optimization/nlp_par/input.gms @@ -7,6 +7,6 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / - s80_optfile switch to use specfied solver settings (1) / 0 / + s80_optfile switch to use specfied solver settings (1) / 1 / s80_secondsolve second solve statement (binary) / 0 / ; From 822dbded579f327477e3d8bd8c6970adb7600aec Mon Sep 17 00:00:00 2001 From: Kristine Karstens <33092354+k4rst3ns@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:32:29 +0200 Subject: [PATCH 03/19] Update config/default.cfg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Florian Humpenöder --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index e574d7b2cc..a65b0c189b 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -2157,7 +2157,7 @@ cfg$gms$c80_nlp_solver <- "conopt4" # def = conopt4 # * 1: using optfile for specified solver settings # * 0: default settings (optfile will be ignored) -cfg$gms$s80_optfile <- 1 # def = 0 +cfg$gms$s80_optfile <- 1 # def = 1 # Solver setting Tol_Optimality (real): # Optimality tolerance for reduced gradient when feasible. From 7a7d1b34f4b6b65bea8d805e963cd7f46740b904 Mon Sep 17 00:00:00 2001 From: Kristine Karstens <33092354+k4rst3ns@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:34:55 +0200 Subject: [PATCH 04/19] Update modules/80_optimization/nlp_apr17/input.gms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Florian Humpenöder --- modules/80_optimization/nlp_apr17/input.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/80_optimization/nlp_apr17/input.gms b/modules/80_optimization/nlp_apr17/input.gms index 1efe568d07..1486c3a2a0 100644 --- a/modules/80_optimization/nlp_apr17/input.gms +++ b/modules/80_optimization/nlp_apr17/input.gms @@ -9,5 +9,5 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 1 / s80_secondsolve second solve statement (binary) / 0 / - s80_toloptimal switch to set Tol_Optimality / 1e-08 / + s80_toloptimal value for CONOPT4 Tol_Optimality / 1e-08 / ; From 2a66f8415bcc5ac44f34cb81e351b817d6c5c0a1 Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Wed, 9 Apr 2025 14:37:00 +0200 Subject: [PATCH 05/19] rename residue production equation from q18_prod_res_cell to q18_prod_res_reg --- modules/18_residues/flexreg_apr16/declarations.gms | 2 +- modules/18_residues/flexreg_apr16/equations.gms | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/18_residues/flexreg_apr16/declarations.gms b/modules/18_residues/flexreg_apr16/declarations.gms index 9bad777ea0..f5dd9fbe6e 100644 --- a/modules/18_residues/flexreg_apr16/declarations.gms +++ b/modules/18_residues/flexreg_apr16/declarations.gms @@ -23,7 +23,7 @@ equations q18_res_field_balance(i,kcr,attributes) Calculation of the residues amount recycled to soils (mio. tDM) q18_res_field_burn(i,kcr,attributes) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX) q18_translate(i,kres,attributes) Transformation of the multiple crop residues into supply balance crop redisues in respective attribute units DM GJ Nr P K WM C (mio. tX) - q18_prod_res_cell(i,kres) Allows for distribution of residues to cellular level (mio. tDM) + q18_prod_res_reg(i,kres) Allows for distribution of residues to cellular level (mio. tDM) q18_res_recycling_nr(i) Nutrient recycling of reaactive nitrogen (mio. tNr) q18_res_recycling_pk(i,pk18) Nutrient recycling of phosphorus and potash (mio. tX) q18_cost_prod_res(i,kres) Production costs of harvesting crop residues (mio. USD17MER) diff --git a/modules/18_residues/flexreg_apr16/equations.gms b/modules/18_residues/flexreg_apr16/equations.gms index 09df6c8bcc..0f216710f5 100644 --- a/modules/18_residues/flexreg_apr16/equations.gms +++ b/modules/18_residues/flexreg_apr16/equations.gms @@ -73,7 +73,7 @@ vm_prod_reg(i2,kres) * fm_attributes(attributes,kres); *' Amount produced at cellular level is flexible, can be distributed as it wants - q18_prod_res_cell(i2,kres).. + q18_prod_res_reg(i2,kres).. sum(cell(i2,j2), v18_prod_res(j2,kres)) =e= vm_prod_reg(i2,kres); From faf30e2bc646ebfbd265b031f0c2e29609c76540 Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Wed, 9 Apr 2025 17:59:42 +0200 Subject: [PATCH 06/19] update s80_resolve_option cascade --- modules/80_optimization/nlp_apr17/solve.gms | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index 414539fc24..d9facfe83a 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -19,16 +19,11 @@ magpie.solprint = 0 ; magpie.holdfixed = 1 ; put optfile; -put 'Lim_Variable = 1.e25' /; put 'Tol_Optimality = ', s80_toloptimal:12:11 /; putclose optfile; $onecho > conopt4.op2 -Flg_Prep = FALSE -$offecho - -$onecho > conopt4.op3 -Flg_NoDefc = TRUE +Lim_Variable = 1.e25 $offecho if(execerror > 0, @@ -63,14 +58,10 @@ if (magpie.modelstat > 2, option nlp = conopt4; magpie.optfile = 1; elseif s80_resolve_option = 3, - display "Modelstat > 2 | Retry solve with CONOPT4 w/o preprocessing"; + display "Modelstat > 2 | Retry solve with CONOPT4 increasing largest allowable value"; option nlp = conopt4; magpie.optfile = 2; elseif s80_resolve_option = 4, - display "Modelstat > 2 | Retry solve with CONOPT4 w/o search for definitional constraints"; - option nlp = conopt4; - magpie.optfile = 3; - elseif s80_resolve_option = 5, display "Modelstat > 2 | Retry solve with CONOPT3"; option nlp = conopt3; magpie.optfile = 0; @@ -95,7 +86,7 @@ if (magpie.modelstat > 2, * Otherwise, the repeat loop will never end. magpie.modelStat$(magpie.modelStat=NA) = 13; - s80_resolve_option$(s80_resolve_option >= 5) = 0; + s80_resolve_option$(s80_resolve_option >= 4) = 0; until (magpie.modelstat <= 2 or s80_counter >= s80_maxiter) ); From fa8cdb9b54ec08e517026579c8d1844b9708f119 Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Fri, 11 Apr 2025 15:37:57 +0200 Subject: [PATCH 07/19] shift conopt.opt file creation to preloop of optimization module --- core/calculations.gms | 2 -- modules/80_optimization/nlp_apr17/preloop.gms | 9 +++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 modules/80_optimization/nlp_apr17/preloop.gms diff --git a/core/calculations.gms b/core/calculations.gms index bf7e4bf3ef..e8c37db7e2 100644 --- a/core/calculations.gms +++ b/core/calculations.gms @@ -21,8 +21,6 @@ $batinclude "./modules/include.gms" preloop * to be done here because a file declaration cannot be inside a loop file dummy; dummy.pw=2000; put dummy; -File optfile /conopt4.opt/; - ************************OPTIMIZATION PROCESS START****************************** * This section contains only sourcecode that is directly connected to the * optimization process. That means that everything on the following lines diff --git a/modules/80_optimization/nlp_apr17/preloop.gms b/modules/80_optimization/nlp_apr17/preloop.gms new file mode 100644 index 0000000000..115c631cc6 --- /dev/null +++ b/modules/80_optimization/nlp_apr17/preloop.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +File optfile /conopt4.opt/; + From e1097213bab2da44e67ef9861d2700885d80af91 Mon Sep 17 00:00:00 2001 From: caviddhen Date: Tue, 22 Apr 2025 13:13:17 +0200 Subject: [PATCH 08/19] update export share to fix historic time steps --- modules/21_trade/exo/not_used.txt | 2 ++ modules/21_trade/free_apr16/not_used.txt | 2 ++ modules/21_trade/input/files | 2 +- modules/21_trade/off/not_used.txt | 2 ++ modules/21_trade/selfsuff_reduced/declarations.gms | 3 +++ modules/21_trade/selfsuff_reduced/equations.gms | 2 +- modules/21_trade/selfsuff_reduced/input.gms | 4 ++-- modules/21_trade/selfsuff_reduced/preloop.gms | 14 +++++++++++++- .../selfsuff_reduced_bilateral22/not_used.txt | 2 ++ 9 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 modules/21_trade/exo/not_used.txt create mode 100644 modules/21_trade/free_apr16/not_used.txt create mode 100644 modules/21_trade/off/not_used.txt create mode 100644 modules/21_trade/selfsuff_reduced_bilateral22/not_used.txt diff --git a/modules/21_trade/exo/not_used.txt b/modules/21_trade/exo/not_used.txt new file mode 100644 index 0000000000..4dd79412da --- /dev/null +++ b/modules/21_trade/exo/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +sm_fix_SSP2,input,not needed diff --git a/modules/21_trade/free_apr16/not_used.txt b/modules/21_trade/free_apr16/not_used.txt new file mode 100644 index 0000000000..4dd79412da --- /dev/null +++ b/modules/21_trade/free_apr16/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +sm_fix_SSP2,input,not needed diff --git a/modules/21_trade/input/files b/modules/21_trade/input/files index dbc4131c7f..5b70512a5d 100644 --- a/modules/21_trade/input/files +++ b/modules/21_trade/input/files @@ -1,6 +1,6 @@ * list of files that are required here f21_trade_self_suff.cs3 -f21_trade_export_share.cs3 +f21_trade_domestic_supply.cs3 f21_trade_balanceflow.cs3 f21_trade_margin.cs3 f21_trade_tariff.cs3 diff --git a/modules/21_trade/off/not_used.txt b/modules/21_trade/off/not_used.txt new file mode 100644 index 0000000000..4dd79412da --- /dev/null +++ b/modules/21_trade/off/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +sm_fix_SSP2,input,not needed diff --git a/modules/21_trade/selfsuff_reduced/declarations.gms b/modules/21_trade/selfsuff_reduced/declarations.gms index 74732e2631..ccf11f6a03 100644 --- a/modules/21_trade/selfsuff_reduced/declarations.gms +++ b/modules/21_trade/selfsuff_reduced/declarations.gms @@ -7,8 +7,11 @@ parameters i21_trade_bal_reduction(t_all,k_trade) Trade balance reduction (1) + i21_exp_shr(t_all,h,k_trade) Trade export shr (1) i21_trade_margin(h,k_trade) Trade margins (USD17MER per tDM) i21_trade_tariff(h,k_trade) Trade tariffs (USD17MER per tDM) + i21_exports(t_all,h,k_trade) Total exports (tDM) + i21_exp_glo(t_all,k_trade) Total global exports (tDM) ; positive variables diff --git a/modules/21_trade/selfsuff_reduced/equations.gms b/modules/21_trade/selfsuff_reduced/equations.gms index a2a624e2a3..0c387ac850 100644 --- a/modules/21_trade/selfsuff_reduced/equations.gms +++ b/modules/21_trade/selfsuff_reduced/equations.gms @@ -55,7 +55,7 @@ q21_excess_supply(h2,k_trade).. v21_excess_prod(h2,k_trade) =e= - v21_excess_dem(k_trade)*sum(ct,f21_exp_shr(ct,h2,k_trade)); + v21_excess_dem(k_trade)*sum(ct,i21_exp_shr(ct,h2,k_trade)); * Trade costs are associated with exporting superregions. They are dependent on net exports, trade margin, and tariffs. diff --git a/modules/21_trade/selfsuff_reduced/input.gms b/modules/21_trade/selfsuff_reduced/input.gms index 7c7ef24511..6cfe28dffd 100644 --- a/modules/21_trade/selfsuff_reduced/input.gms +++ b/modules/21_trade/selfsuff_reduced/input.gms @@ -29,9 +29,9 @@ $ondelim $include "./modules/21_trade/input/f21_trade_self_suff.cs3" $offdelim; -table f21_exp_shr(t_all,h,kall) Superregional and crop-specific export share (1) +table f21_dom_supply(t_all,h,kall) Superregional domestic supply (mio. tDM per yr) $ondelim -$include "./modules/21_trade/input/f21_trade_export_share.cs3" +$include "./modules/21_trade/input/f21_trade_domestic_supply.cs3" $offdelim; table f21_trade_balanceflow(t_all,kall) Domestic balance flows (mio. tDM per yr) diff --git a/modules/21_trade/selfsuff_reduced/preloop.gms b/modules/21_trade/selfsuff_reduced/preloop.gms index a35770df1c..d13ec8b145 100644 --- a/modules/21_trade/selfsuff_reduced/preloop.gms +++ b/modules/21_trade/selfsuff_reduced/preloop.gms @@ -5,8 +5,20 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -i21_trade_bal_reduction(t_all,k_trade)=f21_trade_bal_reduction(t_all,"easytrade","%c21_trade_liberalization%"); + +loop(t_all, + if(m_year(t_all) <= sm_fix_SSP2, + i21_trade_bal_reduction(t_all,k_trade)=1; + i21_trade_bal_reduction(t_all,k_hardtrade21)=1; + else + i21_trade_bal_reduction(t_all,k_trade)=f21_trade_bal_reduction(t_all,"easytrade","%c21_trade_liberalization%"); i21_trade_bal_reduction(t_all,k_hardtrade21)=f21_trade_bal_reduction(t_all,"hardtrade","%c21_trade_liberalization%"); + ); +); + +i21_exports(t_all,h,k_trade) = ((f21_self_suff(t_all,h,k_trade) * f21_dom_supply(t_all,h,k_trade)) - f21_dom_supply(t_all,h,k_trade))$(f21_self_suff(t_all,h,k_trade) > 1); +i21_exp_glo(t_all,k_trade) = sum(h, i21_exports(t_all,h,k_trade)); +i21_exp_shr(t_all,h,k_trade) = i21_exports(t_all,h,k_trade) / (i21_exp_glo(t_all,k_trade) + 0.001$(i21_exp_glo(t_all,k_trade) = 0)); i21_trade_margin(h,k_trade) = f21_trade_margin(h,k_trade); diff --git a/modules/21_trade/selfsuff_reduced_bilateral22/not_used.txt b/modules/21_trade/selfsuff_reduced_bilateral22/not_used.txt new file mode 100644 index 0000000000..4dd79412da --- /dev/null +++ b/modules/21_trade/selfsuff_reduced_bilateral22/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +sm_fix_SSP2,input,not needed From f39bfbb3a9de94bac66af5a9acf4b26ba4ed9e35 Mon Sep 17 00:00:00 2001 From: caviddhen Date: Tue, 22 Apr 2025 13:21:51 +0200 Subject: [PATCH 09/19] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4240797c8b..9b1d696411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### changed +- **21_trade** changed export share calculation to be done at region level in the model - **default.cfg** input data upgraded from rev4.117 to rev4.118, default for bioenergy demand and GHG prices changed from R32M46 to R34M410, `rcp4p5` used for SSP2-NPi2025 in line with MAGICC climate outcome and REMIND assumptions. - **script/start/test_runs.R** Test runs adjusted based on availability from coupled runs for R34M410. From 3ae0f6150fa23b5f800264ea501b83b100af92c4 Mon Sep 17 00:00:00 2001 From: caviddhen Date: Tue, 22 Apr 2025 15:02:39 +0200 Subject: [PATCH 10/19] update code documentation --- modules/21_trade/selfsuff_reduced/preloop.gms | 2 ++ modules/21_trade/selfsuff_reduced/realization.gms | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/21_trade/selfsuff_reduced/preloop.gms b/modules/21_trade/selfsuff_reduced/preloop.gms index d13ec8b145..9666063c52 100644 --- a/modules/21_trade/selfsuff_reduced/preloop.gms +++ b/modules/21_trade/selfsuff_reduced/preloop.gms @@ -6,6 +6,8 @@ *** | Contact: magpie@pik-potsdam.de +*' Trade liberalization i.e. shift from self-sufficiency fixed pool to free pool begins +*' with sm_fix_SSP2 to keep values matching historical data until then. loop(t_all, if(m_year(t_all) <= sm_fix_SSP2, i21_trade_bal_reduction(t_all,k_trade)=1; diff --git a/modules/21_trade/selfsuff_reduced/realization.gms b/modules/21_trade/selfsuff_reduced/realization.gms index 809c0ffba7..56e6db501b 100644 --- a/modules/21_trade/selfsuff_reduced/realization.gms +++ b/modules/21_trade/selfsuff_reduced/realization.gms @@ -9,7 +9,8 @@ *' together with regional demands, establish a baseline value for the production of traded products in the superregions. *' Production is then allowed to fluctuate freely within a band around this baseline value, *' only being enforced to maintain the condition of global production exceeding global demand. -*' The width of the production band is determined by the `i21_trade_bal_reduction` (ptb) factor. +*' The width of the production band is determined by the `i21_trade_bal_reduction` (ptb) factor, which +*' is allowed to deviate from 1 after the year assigned in sm_fix_SSP2. *' *' Effectively, this factor splits the global demand into two pools: The `ptb` share of demand goes *' into a pool for which the origin of products is fixed by the self-sufficiency ratios and export shares. From 8226d3e12a8082a1917c5711e37af96ba300e7ed Mon Sep 17 00:00:00 2001 From: caviddhen Date: Tue, 22 Apr 2025 17:14:37 +0200 Subject: [PATCH 11/19] update sm_fix to ssp2 value --- modules/21_trade/selfsuff_reduced/preloop.gms | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/21_trade/selfsuff_reduced/preloop.gms b/modules/21_trade/selfsuff_reduced/preloop.gms index 9666063c52..8a1bfb2f5c 100644 --- a/modules/21_trade/selfsuff_reduced/preloop.gms +++ b/modules/21_trade/selfsuff_reduced/preloop.gms @@ -10,8 +10,8 @@ *' with sm_fix_SSP2 to keep values matching historical data until then. loop(t_all, if(m_year(t_all) <= sm_fix_SSP2, - i21_trade_bal_reduction(t_all,k_trade)=1; - i21_trade_bal_reduction(t_all,k_hardtrade21)=1; + i21_trade_bal_reduction(t_all,k_trade)=f21_trade_bal_reduction(t_all,"easytrade","l909090r808080"); + i21_trade_bal_reduction(t_all,k_hardtrade21)=f21_trade_bal_reduction(t_all,"hardtrade","l909090r808080"); else i21_trade_bal_reduction(t_all,k_trade)=f21_trade_bal_reduction(t_all,"easytrade","%c21_trade_liberalization%"); i21_trade_bal_reduction(t_all,k_hardtrade21)=f21_trade_bal_reduction(t_all,"hardtrade","%c21_trade_liberalization%"); From d21c52a65319901686ae62637a7b7e638ea13948 Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Wed, 23 Apr 2025 12:28:04 +0200 Subject: [PATCH 12/19] small update of automatically written code --- modules/18_residues/flexreg_apr16/declarations.gms | 2 +- modules/18_residues/flexreg_apr16/postsolve.gms | 8 ++++---- modules/80_optimization/nlp_apr17/realization.gms | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/18_residues/flexreg_apr16/declarations.gms b/modules/18_residues/flexreg_apr16/declarations.gms index f5dd9fbe6e..b4ce1a141c 100644 --- a/modules/18_residues/flexreg_apr16/declarations.gms +++ b/modules/18_residues/flexreg_apr16/declarations.gms @@ -48,7 +48,7 @@ parameters oq18_res_field_balance(t,i,kcr,attributes,type) Calculation of the residues amount recycled to soils (mio. tDM) oq18_res_field_burn(t,i,kcr,attributes,type) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX) oq18_translate(t,i,kres,attributes,type) Transformation of the multiple crop residues into supply balance crop redisues in respective attribute units DM GJ Nr P K WM C (mio. tX) - oq18_prod_res_cell(t,i,kres,type) Allows for distribution of residues to cellular level (mio. tDM) + oq18_prod_res_reg(t,i,kres,type) Allows for distribution of residues to cellular level (mio. tDM) oq18_res_recycling_nr(t,i,type) Nutrient recycling of reaactive nitrogen (mio. tNr) oq18_res_recycling_pk(t,i,pk18,type) Nutrient recycling of phosphorus and potash (mio. tX) oq18_cost_prod_res(t,i,kres,type) Production costs of harvesting crop residues (mio. USD17MER) diff --git a/modules/18_residues/flexreg_apr16/postsolve.gms b/modules/18_residues/flexreg_apr16/postsolve.gms index 65d25686e2..4633ea69e2 100644 --- a/modules/18_residues/flexreg_apr16/postsolve.gms +++ b/modules/18_residues/flexreg_apr16/postsolve.gms @@ -23,7 +23,7 @@ oq18_res_field_balance(t,i,kcr,attributes,"marginal") = q18_res_field_balance.m(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"marginal") = q18_res_field_burn.m(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"marginal") = q18_translate.m(i,kres,attributes); - oq18_prod_res_cell(t,i,kres,"marginal") = q18_prod_res_cell.m(i,kres); + oq18_prod_res_reg(t,i,kres,"marginal") = q18_prod_res_reg.m(i,kres); oq18_res_recycling_nr(t,i,"marginal") = q18_res_recycling_nr.m(i); oq18_res_recycling_pk(t,i,pk18,"marginal") = q18_res_recycling_pk.m(i,pk18); oq18_cost_prod_res(t,i,kres,"marginal") = q18_cost_prod_res.m(i,kres); @@ -40,7 +40,7 @@ oq18_res_field_balance(t,i,kcr,attributes,"level") = q18_res_field_balance.l(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"level") = q18_res_field_burn.l(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"level") = q18_translate.l(i,kres,attributes); - oq18_prod_res_cell(t,i,kres,"level") = q18_prod_res_cell.l(i,kres); + oq18_prod_res_reg(t,i,kres,"level") = q18_prod_res_reg.l(i,kres); oq18_res_recycling_nr(t,i,"level") = q18_res_recycling_nr.l(i); oq18_res_recycling_pk(t,i,pk18,"level") = q18_res_recycling_pk.l(i,pk18); oq18_cost_prod_res(t,i,kres,"level") = q18_cost_prod_res.l(i,kres); @@ -57,7 +57,7 @@ oq18_res_field_balance(t,i,kcr,attributes,"upper") = q18_res_field_balance.up(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"upper") = q18_res_field_burn.up(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"upper") = q18_translate.up(i,kres,attributes); - oq18_prod_res_cell(t,i,kres,"upper") = q18_prod_res_cell.up(i,kres); + oq18_prod_res_reg(t,i,kres,"upper") = q18_prod_res_reg.up(i,kres); oq18_res_recycling_nr(t,i,"upper") = q18_res_recycling_nr.up(i); oq18_res_recycling_pk(t,i,pk18,"upper") = q18_res_recycling_pk.up(i,pk18); oq18_cost_prod_res(t,i,kres,"upper") = q18_cost_prod_res.up(i,kres); @@ -74,7 +74,7 @@ oq18_res_field_balance(t,i,kcr,attributes,"lower") = q18_res_field_balance.lo(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"lower") = q18_res_field_burn.lo(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"lower") = q18_translate.lo(i,kres,attributes); - oq18_prod_res_cell(t,i,kres,"lower") = q18_prod_res_cell.lo(i,kres); + oq18_prod_res_reg(t,i,kres,"lower") = q18_prod_res_reg.lo(i,kres); oq18_res_recycling_nr(t,i,"lower") = q18_res_recycling_nr.lo(i); oq18_res_recycling_pk(t,i,pk18,"lower") = q18_res_recycling_pk.lo(i,pk18); oq18_cost_prod_res(t,i,kres,"lower") = q18_cost_prod_res.lo(i,kres); diff --git a/modules/80_optimization/nlp_apr17/realization.gms b/modules/80_optimization/nlp_apr17/realization.gms index f4c3750a8a..dd35745758 100644 --- a/modules/80_optimization/nlp_apr17/realization.gms +++ b/modules/80_optimization/nlp_apr17/realization.gms @@ -14,5 +14,6 @@ *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "declarations" $include "./modules/80_optimization/nlp_apr17/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/80_optimization/nlp_apr17/input.gms" +$Ifi "%phase%" == "preloop" $include "./modules/80_optimization/nlp_apr17/preloop.gms" $Ifi "%phase%" == "solve" $include "./modules/80_optimization/nlp_apr17/solve.gms" *######################## R SECTION END (PHASES) ############################### From 5ef68d9abc444c0b09a8cfc6719d2ab805087ba1 Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Wed, 23 Apr 2025 13:42:00 +0200 Subject: [PATCH 13/19] Update Changelog --- CHANGELOG.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4240797c8b..c82e668b69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,15 +9,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### changed - **default.cfg** input data upgraded from rev4.117 to rev4.118, default for bioenergy demand and GHG prices changed from R32M46 to R34M410, `rcp4p5` used for SSP2-NPi2025 in line with MAGICC climate outcome and REMIND assumptions. - **script/start/test_runs.R** Test runs adjusted based on availability from coupled runs for R34M410. +- **default.cfg** changed running magpie by default with optfile for specified solver settings (Tol_Optimality) ### added -- +- **default.cfg** added option to set Tol_Optimality (GAMS solver setting) to a certain value (GAMS-default 1e-7, new MAgPIE-default 1e-8) +- **80_optimzation** added writing of conopt opt files with using scalars from input ### removed -- +- **80_optimzation** removed older optfile, that should be tried if not foptimal solution can be found ### fixed -- +- **18_residues** fixed equation for cluster level production of crop residues in flexreg_apr16 realization ## [4.10.0] - 2025-04-03 From 63b7924d069180426139c3e64aad4e60b0ad039e Mon Sep 17 00:00:00 2001 From: caviddhen Date: Wed, 23 Apr 2025 13:45:12 +0200 Subject: [PATCH 14/19] delete depreciated trade ralizations --- config/default.cfg | 4 +-- modules/21_trade/free_apr16/declarations.gms | 29 -------------------- modules/21_trade/free_apr16/equations.gms | 18 ------------ modules/21_trade/free_apr16/input.gms | 11 -------- modules/21_trade/free_apr16/not_used.txt | 2 -- modules/21_trade/free_apr16/postsolve.gms | 22 --------------- modules/21_trade/free_apr16/preloop.gms | 9 ------ modules/21_trade/free_apr16/realization.gms | 19 ------------- modules/21_trade/free_apr16/sets.gms | 22 --------------- modules/21_trade/off/declarations.gms | 21 -------------- modules/21_trade/off/equations.gms | 13 --------- modules/21_trade/off/input.gms | 16 ----------- modules/21_trade/off/not_used.txt | 2 -- modules/21_trade/off/postsolve.gms | 18 ------------ modules/21_trade/off/preloop.gms | 9 ------ modules/21_trade/off/realization.gms | 19 ------------- 16 files changed, 1 insertion(+), 233 deletions(-) delete mode 100644 modules/21_trade/free_apr16/declarations.gms delete mode 100644 modules/21_trade/free_apr16/equations.gms delete mode 100644 modules/21_trade/free_apr16/input.gms delete mode 100644 modules/21_trade/free_apr16/not_used.txt delete mode 100644 modules/21_trade/free_apr16/postsolve.gms delete mode 100644 modules/21_trade/free_apr16/preloop.gms delete mode 100644 modules/21_trade/free_apr16/realization.gms delete mode 100644 modules/21_trade/free_apr16/sets.gms delete mode 100644 modules/21_trade/off/declarations.gms delete mode 100644 modules/21_trade/off/equations.gms delete mode 100644 modules/21_trade/off/input.gms delete mode 100644 modules/21_trade/off/not_used.txt delete mode 100644 modules/21_trade/off/postsolve.gms delete mode 100644 modules/21_trade/off/preloop.gms delete mode 100644 modules/21_trade/off/realization.gms diff --git a/config/default.cfg b/config/default.cfg index f2be8a9e02..39fb66a242 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -14,7 +14,7 @@ cfg <- list() #### Main settings #### # short description of the actual run -cfg$title <- "default" +cfg$title <- "NewExpShr_New2" # path to the submodel to be used relative to main model folder cfg$model <- "main.gms" #def = "main.gms" @@ -597,8 +597,6 @@ cfg$gms$processing <- "substitution_may21" # def = substitution_may21 cfg$gms$c20_scp_type <- "sugar" # def = sugar # ***--------------------- 21_trade -------------------------------------- -# * (free_apr16): free trade without restrictions -# * (off): no trade at all # * (exo): exogenously prescribed trade # * (selfsuff_reduced): self-sufficiency based trade with trade costs related to exports # * (selfsuff_reduced_bilateral22): same as `selfsuff_reduced` but with bilateral trade flows diff --git a/modules/21_trade/free_apr16/declarations.gms b/modules/21_trade/free_apr16/declarations.gms deleted file mode 100644 index 6654381530..0000000000 --- a/modules/21_trade/free_apr16/declarations.gms +++ /dev/null @@ -1,29 +0,0 @@ -*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -parameters - i21_trade_bal_reduction(t_all,k_trade) Trade balance reduction (1) - i21_trade_margin(h,k_trade) Trade margins (USD17MER per tDM) - i21_trade_tariff(h,k_trade) Trade tariffs (USD17MER per tDM) -; - -positive variables - vm_cost_trade(i) Regional trade costs (mio. USD17MER per yr) -; - -equations - q21_trade_glo(k_trade) Global production constraint (mio. tDM per yr) - q21_notrade(h,k_notrade) Superregional production constraint of non-tradable commodities (mio. tDM per yr) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_cost_trade(t,i,type) Regional trade costs (mio. USD17MER per yr) - oq21_trade_glo(t,k_trade,type) Global production constraint (mio. tDM per yr) - oq21_notrade(t,h,k_notrade,type) Superregional production constraint of non-tradable commodities (mio. tDM per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/21_trade/free_apr16/equations.gms b/modules/21_trade/free_apr16/equations.gms deleted file mode 100644 index 3926ac0232..0000000000 --- a/modules/21_trade/free_apr16/equations.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -*' @equations -*' For traded goods the only active constraint is that the global supply is larger or equal to demand. -*' This means that production can be freely allocated globally based on comparative advantages. - -q21_trade_glo(k_trade).. sum(i2 ,vm_prod_reg(i2,k_trade)) =g= sum(i2, vm_supply(i2,k_trade)); - -*' -*' For non-tradable commodites, the regional supply should be larger or equal to the regional demand. - - q21_notrade(h2,k_notrade).. - sum(supreg(h2,i2),vm_prod_reg(i2,k_notrade)) =g= sum(supreg(h2,i2), vm_supply(i2,k_notrade)); diff --git a/modules/21_trade/free_apr16/input.gms b/modules/21_trade/free_apr16/input.gms deleted file mode 100644 index 24f41963ec..0000000000 --- a/modules/21_trade/free_apr16/input.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -table f21_self_suff(t_all,h,kall) Superregional self-sufficiency rates (1) -$ondelim -$include "./modules/21_trade/input/f21_trade_self_suff.cs3" -$offdelim; diff --git a/modules/21_trade/free_apr16/not_used.txt b/modules/21_trade/free_apr16/not_used.txt deleted file mode 100644 index 4dd79412da..0000000000 --- a/modules/21_trade/free_apr16/not_used.txt +++ /dev/null @@ -1,2 +0,0 @@ -name,type,reason -sm_fix_SSP2,input,not needed diff --git a/modules/21_trade/free_apr16/postsolve.gms b/modules/21_trade/free_apr16/postsolve.gms deleted file mode 100644 index b405f11f5b..0000000000 --- a/modules/21_trade/free_apr16/postsolve.gms +++ /dev/null @@ -1,22 +0,0 @@ -*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_trade(t,i,"marginal") = vm_cost_trade.m(i); - oq21_trade_glo(t,k_trade,"marginal") = q21_trade_glo.m(k_trade); - oq21_notrade(t,h,k_notrade,"marginal") = q21_notrade.m(h,k_notrade); - ov_cost_trade(t,i,"level") = vm_cost_trade.l(i); - oq21_trade_glo(t,k_trade,"level") = q21_trade_glo.l(k_trade); - oq21_notrade(t,h,k_notrade,"level") = q21_notrade.l(h,k_notrade); - ov_cost_trade(t,i,"upper") = vm_cost_trade.up(i); - oq21_trade_glo(t,k_trade,"upper") = q21_trade_glo.up(k_trade); - oq21_notrade(t,h,k_notrade,"upper") = q21_notrade.up(h,k_notrade); - ov_cost_trade(t,i,"lower") = vm_cost_trade.lo(i); - oq21_trade_glo(t,k_trade,"lower") = q21_trade_glo.lo(k_trade); - oq21_notrade(t,h,k_notrade,"lower") = q21_notrade.lo(h,k_notrade); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/21_trade/free_apr16/preloop.gms b/modules/21_trade/free_apr16/preloop.gms deleted file mode 100644 index e5db56cc6e..0000000000 --- a/modules/21_trade/free_apr16/preloop.gms +++ /dev/null @@ -1,9 +0,0 @@ -*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -*set vm_cost_trade zero in order to avoid a free variable -vm_cost_trade.fx(i) = 0; diff --git a/modules/21_trade/free_apr16/realization.gms b/modules/21_trade/free_apr16/realization.gms deleted file mode 100644 index 5d69350249..0000000000 --- a/modules/21_trade/free_apr16/realization.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -*' @description In this realization, agricultural trade is fully liberalized in all timesteps. - -*' @limitations This realization does not account for current trends in agricultural trade. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/21_trade/free_apr16/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/21_trade/free_apr16/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/21_trade/free_apr16/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/21_trade/free_apr16/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/21_trade/free_apr16/preloop.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/21_trade/free_apr16/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/21_trade/free_apr16/sets.gms b/modules/21_trade/free_apr16/sets.gms deleted file mode 100644 index 0a23e00b10..0000000000 --- a/modules/21_trade/free_apr16/sets.gms +++ /dev/null @@ -1,22 +0,0 @@ -*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -sets -*sets should be in sync with default trade realisation; currently selfsuff_reduced - k_notrade(kall) Production activities of non-tradable commodites - / oilpalm, foddr, pasture, res_cereals, res_fibrous, res_nonfibrous, begr,betr / -* oilpalm not traded, only its oil and oilcake due to FAOSTAT complications, and as trade is little -* foddr is not traded as too bulky -* pasture it not traded as too bulky -* begr and betr are not traded because biomass is traded in REMIND - k_trade(kall) Production activities of tradable commodities - / tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,puls_pro, - potato,cassav_sp,sugr_cane,sugr_beet,others,cottn_pro, - oils,oilcakes,sugar,molasses,alcohol,ethanol,distillers_grain,brans,scp,fibres, - livst_rum, livst_pig,livst_chick, livst_egg, livst_milk, fish, wood, woodfuel / - -; diff --git a/modules/21_trade/off/declarations.gms b/modules/21_trade/off/declarations.gms deleted file mode 100644 index 834bc74db3..0000000000 --- a/modules/21_trade/off/declarations.gms +++ /dev/null @@ -1,21 +0,0 @@ -*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -positive variables - vm_cost_trade(i) Regional trade costs (mio. USD17MER per yr) -; - -equations - q21_notrade(h,kall) Superregional production constraint of non-tradable commodities (mio. tDM per yr) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_cost_trade(t,i,type) Regional trade costs (mio. USD17MER per yr) - oq21_notrade(t,h,kall,type) Superregional production constraint of non-tradable commodities (mio. tDM per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/21_trade/off/equations.gms b/modules/21_trade/off/equations.gms deleted file mode 100644 index a7f78a3132..0000000000 --- a/modules/21_trade/off/equations.gms +++ /dev/null @@ -1,13 +0,0 @@ -*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -*' @equations -*' For all commodites, the regional supply should be larger or equal to the -*' regional demand. - -q21_notrade(h2,kall).. - sum(supreg(h2,i2),vm_prod_reg(i2,kall)) =g= sum(supreg(h2,i2), vm_supply(i2,kall)); diff --git a/modules/21_trade/off/input.gms b/modules/21_trade/off/input.gms deleted file mode 100644 index e13b626af9..0000000000 --- a/modules/21_trade/off/input.gms +++ /dev/null @@ -1,16 +0,0 @@ -*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -table f21_trade_balance(t_all,h,kall) trade balance of positive exports and negative imports (mio. tDM per yr) -$ondelim -$include "./modules/21_trade/input/f21_trade_balance.cs3" -$offdelim; - -table f21_self_suff(t_all,h,kall) Superregional self-sufficiency rates (1) -$ondelim -$include "./modules/21_trade/input/f21_trade_self_suff.cs3" -$offdelim; diff --git a/modules/21_trade/off/not_used.txt b/modules/21_trade/off/not_used.txt deleted file mode 100644 index 4dd79412da..0000000000 --- a/modules/21_trade/off/not_used.txt +++ /dev/null @@ -1,2 +0,0 @@ -name,type,reason -sm_fix_SSP2,input,not needed diff --git a/modules/21_trade/off/postsolve.gms b/modules/21_trade/off/postsolve.gms deleted file mode 100644 index 3dfc56b519..0000000000 --- a/modules/21_trade/off/postsolve.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_trade(t,i,"marginal") = vm_cost_trade.m(i); - oq21_notrade(t,h,kall,"marginal") = q21_notrade.m(h,kall); - ov_cost_trade(t,i,"level") = vm_cost_trade.l(i); - oq21_notrade(t,h,kall,"level") = q21_notrade.l(h,kall); - ov_cost_trade(t,i,"upper") = vm_cost_trade.up(i); - oq21_notrade(t,h,kall,"upper") = q21_notrade.up(h,kall); - ov_cost_trade(t,i,"lower") = vm_cost_trade.lo(i); - oq21_notrade(t,h,kall,"lower") = q21_notrade.lo(h,kall); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/21_trade/off/preloop.gms b/modules/21_trade/off/preloop.gms deleted file mode 100644 index e5db56cc6e..0000000000 --- a/modules/21_trade/off/preloop.gms +++ /dev/null @@ -1,9 +0,0 @@ -*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -*set vm_cost_trade zero in order to avoid a free variable -vm_cost_trade.fx(i) = 0; diff --git a/modules/21_trade/off/realization.gms b/modules/21_trade/off/realization.gms deleted file mode 100644 index 4a5f9f3fa0..0000000000 --- a/modules/21_trade/off/realization.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2025 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -*' @description In this realization, there is no agricultural trade, i.e. regions -*' are fully self-sufficient and dependent on domestic production. - -*' @limitations This realization does not account for current trends in agricultural trade. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "declarations" $include "./modules/21_trade/off/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/21_trade/off/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/21_trade/off/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/21_trade/off/preloop.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/21_trade/off/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### From 7bb77a0af47d37b6e48913c178bf3bddc3cce1fe Mon Sep 17 00:00:00 2001 From: caviddhen Date: Wed, 23 Apr 2025 15:02:07 +0200 Subject: [PATCH 15/19] re-word documenation --- modules/21_trade/selfsuff_reduced/realization.gms | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/21_trade/selfsuff_reduced/realization.gms b/modules/21_trade/selfsuff_reduced/realization.gms index 56e6db501b..d506a989c4 100644 --- a/modules/21_trade/selfsuff_reduced/realization.gms +++ b/modules/21_trade/selfsuff_reduced/realization.gms @@ -9,8 +9,8 @@ *' together with regional demands, establish a baseline value for the production of traded products in the superregions. *' Production is then allowed to fluctuate freely within a band around this baseline value, *' only being enforced to maintain the condition of global production exceeding global demand. -*' The width of the production band is determined by the `i21_trade_bal_reduction` (ptb) factor, which -*' is allowed to deviate from 1 after the year assigned in sm_fix_SSP2. +*' The width of the production band is determined by the `i21_trade_bal_reduction` (ptb) factor, which differentiates +*' itself by SSP after the year prescribed by sm_fix_SSP2. *' *' Effectively, this factor splits the global demand into two pools: The `ptb` share of demand goes *' into a pool for which the origin of products is fixed by the self-sufficiency ratios and export shares. From cba4bd9bd4f71406295e42932d52ff91eee6cf3e Mon Sep 17 00:00:00 2001 From: caviddhen Date: Wed, 23 Apr 2025 16:21:37 +0200 Subject: [PATCH 16/19] rename to default cfg --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 39fb66a242..6694a7dc20 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -14,7 +14,7 @@ cfg <- list() #### Main settings #### # short description of the actual run -cfg$title <- "NewExpShr_New2" +cfg$title <- "default" # path to the submodel to be used relative to main model folder cfg$model <- "main.gms" #def = "main.gms" From ce027e02dcdd79f8d8b67702380027b0a31fb677 Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Wed, 23 Apr 2025 16:22:12 +0200 Subject: [PATCH 17/19] Update small typos, a bit more explaination and adding new optsettings to other realizations --- CHANGELOG.md | 4 ++-- .../18_residues/flexreg_apr16/equations.gms | 2 ++ .../80_optimization/lp_nlp_apr17/input.gms | 16 ++++----------- .../80_optimization/lp_nlp_apr17/solve.gms | 8 ++++---- modules/80_optimization/nlp_par/input.gms | 7 ++++--- modules/80_optimization/nlp_par/solve.gms | 20 ++++++------------- 6 files changed, 22 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c82e668b69..8f3717efe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,10 +13,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### added - **default.cfg** added option to set Tol_Optimality (GAMS solver setting) to a certain value (GAMS-default 1e-7, new MAgPIE-default 1e-8) -- **80_optimzation** added writing of conopt opt files with using scalars from input +- **80_optimization** added writing of conopt opt files with using scalars from input ### removed -- **80_optimzation** removed older optfile, that should be tried if not foptimal solution can be found +- **80_optimization** removed older optfile, that should be tried if no optimal solution can be found ### fixed - **18_residues** fixed equation for cluster level production of crop residues in flexreg_apr16 realization diff --git a/modules/18_residues/flexreg_apr16/equations.gms b/modules/18_residues/flexreg_apr16/equations.gms index 0f216710f5..7bf6de8aad 100644 --- a/modules/18_residues/flexreg_apr16/equations.gms +++ b/modules/18_residues/flexreg_apr16/equations.gms @@ -73,6 +73,8 @@ vm_prod_reg(i2,kres) * fm_attributes(attributes,kres); *' Amount produced at cellular level is flexible, can be distributed as it wants +*' and is just bound by the regional sum via + q18_prod_res_reg(i2,kres).. sum(cell(i2,j2), v18_prod_res(j2,kres)) =e= diff --git a/modules/80_optimization/lp_nlp_apr17/input.gms b/modules/80_optimization/lp_nlp_apr17/input.gms index 8cec7331f5..1486c3a2a0 100644 --- a/modules/80_optimization/lp_nlp_apr17/input.gms +++ b/modules/80_optimization/lp_nlp_apr17/input.gms @@ -6,16 +6,8 @@ *** | Contact: magpie@pik-potsdam.de scalars - s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / - s80_optfile switch to use specfied solver settings (1) / 1 / - s80_add_cplex add cplex optimization after conopt4 (1) / 0 / - s80_add_conopt3 add conopt3 optimization after conopt4 (1) / 0 / - s80_secondsolve second solve statement (binary) / 0 / + s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / + s80_optfile switch to use specfied solver settings (1) / 1 / + s80_secondsolve second solve statement (binary) / 0 / + s80_toloptimal value for CONOPT4 Tol_Optimality / 1e-08 / ; - - -$setglobal c80_nlp_solver conopt4 -* options: (conopt3): conopt3 -* (conopt4): conopt4 -* (conopt4+cplex): conopt4 followed by cplex with landdiff optimization -* (conopt4+conopt3): conopt4 followed by conopt3 diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index d9306a5dbd..d5f5e517d2 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -34,12 +34,12 @@ $elseif "%c80_nlp_solver%" == "conopt4+conopt3" s80_add_conopt3 = 1; $endif -$onecho > conopt4.opt -Lim_Variable = 1.e25 -$offecho +put optfile; +put 'Tol_Optimality = ', s80_toloptimal:12:11 /; +putclose optfile; $onecho > conopt4.op2 -Flg_Prep = FALSE +Lim_Variable = 1.e25 $offecho repeat( diff --git a/modules/80_optimization/nlp_par/input.gms b/modules/80_optimization/nlp_par/input.gms index f3fbe6695c..1486c3a2a0 100644 --- a/modules/80_optimization/nlp_par/input.gms +++ b/modules/80_optimization/nlp_par/input.gms @@ -6,7 +6,8 @@ *** | Contact: magpie@pik-potsdam.de scalars - s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / - s80_optfile switch to use specfied solver settings (1) / 1 / - s80_secondsolve second solve statement (binary) / 0 / + s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / + s80_optfile switch to use specfied solver settings (1) / 1 / + s80_secondsolve second solve statement (binary) / 0 / + s80_toloptimal value for CONOPT4 Tol_Optimality / 1e-08 / ; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 87be8fa8de..198a2c48eb 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -21,16 +21,12 @@ magpie.solprint = 0 ; magpie.holdfixed = 1 ; magpie.savepoint = 0; -$onecho > conopt4.opt -Lim_Variable = 1.e25 -$offecho +put optfile; +put 'Tol_Optimality = ', s80_toloptimal:12:11 /; +putclose optfile; $onecho > conopt4.op2 -Flg_Prep = FALSE -$offecho - -$onecho > conopt4.op3 -Flg_NoDefc = TRUE +Lim_Variable = 1.e25 $offecho h2(h) = no; @@ -111,14 +107,10 @@ repeat option nlp = conopt4; magpie.optfile = 1; elseif p80_resolve_option(h) = 3, - display "Modelstat > 2 | Retry solve with CONOPT4 w/o preprocessing"; + display "Modelstat > 2 | Retry solve with CONOPT4 increasing largest allowable value"; option nlp = conopt4; magpie.optfile = 2; elseif p80_resolve_option(h) = 4, - display "Modelstat > 2 | Retry solve with CONOPT4 w/o search for definitional constraints"; - option nlp = conopt4; - magpie.optfile = 3; - elseif p80_resolve_option(h) = 5, display "Modelstat > 2 | Retry solve with CONOPT3"; option nlp = conopt3; magpie.optfile = 0; @@ -131,7 +123,7 @@ repeat option nlp = conopt4; magpie.optfile = s80_optfile; - p80_resolve_option(h)$(p80_resolve_option(h) >= 5) = 0; + p80_resolve_option(h)$(p80_resolve_option(h) >= 4) = 0; ); h2(h) = no; i2(i) = no; From ec0424e19ac36ad083e0f6f786dae9619c1e2cdd Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Wed, 23 Apr 2025 17:16:32 +0200 Subject: [PATCH 18/19] update lp_nlp realization --- modules/21_trade/module.gms | 2 -- modules/80_optimization/lp_nlp_apr17/solve.gms | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/21_trade/module.gms b/modules/21_trade/module.gms index ea081a3124..0e62aed9df 100644 --- a/modules/21_trade/module.gms +++ b/modules/21_trade/module.gms @@ -16,8 +16,6 @@ *' @authors Xiaoxi Wang, Anne Biewald, Christoph Schmitz, Markus Bonsch *###################### R SECTION START (MODULETYPES) ########################## $Ifi "%trade%" == "exo" $include "./modules/21_trade/exo/realization.gms" -$Ifi "%trade%" == "free_apr16" $include "./modules/21_trade/free_apr16/realization.gms" -$Ifi "%trade%" == "off" $include "./modules/21_trade/off/realization.gms" $Ifi "%trade%" == "selfsuff_reduced" $include "./modules/21_trade/selfsuff_reduced/realization.gms" $Ifi "%trade%" == "selfsuff_reduced_bilateral22" $include "./modules/21_trade/selfsuff_reduced_bilateral22/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index d5f5e517d2..a8a3db3dca 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -143,7 +143,7 @@ $batinclude "./modules/include.gms" nl_relax * if solve stopped with an error, try it again with CONOPT4 and OPTFILE if((magpie.modelstat = 13), - display "WARNING: Modelstat 13 | retry without Conopt4 pre-processing"; + display "WARNING: Modelstat 13 | Retry solve with CONOPT4 increasing largest allowable value"; option nlp = conopt4; magpie.optfile = 2 solve magpie USING nlp MINIMIZING vm_cost_glo; From 6f6ad1713ba34d66a05d59de78f73773254ab707 Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Thu, 24 Apr 2025 10:30:04 +0200 Subject: [PATCH 19/19] small change in order in CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e98ec71ec..0dfdf833a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### changed - **21_trade** changed export share calculation to be done at region level in the model - **default.cfg** input data upgraded from rev4.117 to rev4.118, default for bioenergy demand and GHG prices changed from R32M46 to R34M410, `rcp4p5` used for SSP2-NPi2025 in line with MAGICC climate outcome and REMIND assumptions. -- **script/start/test_runs.R** Test runs adjusted based on availability from coupled runs for R34M410. - **default.cfg** changed running magpie by default with optfile for specified solver settings (Tol_Optimality) +- **script/start/test_runs.R** Test runs adjusted based on availability from coupled runs for R34M410. ### added - **default.cfg** added option to set Tol_Optimality (GAMS solver setting) to a certain value (GAMS-default 1e-7, new MAgPIE-default 1e-8)