Skip to content

Commit

Permalink
clean up of new past implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mppalves committed Apr 13, 2024
1 parent 95c1868 commit bd76178
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 78 deletions.
24 changes: 2 additions & 22 deletions modules/31_past/grasslands_apr22/declarations.gms
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,10 @@ i31_grassl_areas(t_all,j) Celullar grassland areas
i31_lambda_grass(t,i,grassland) Grassland Scaling factor for non-linear management calibration (1)
i31_grassl_yld_hist_reg(t,i,grassland) Grassland FAO yields per region at the historical referende year (tDM per ha)
i31_grass_hist_yld(t_all,i, grassland) FAO gassland yields (tDM per ha)
p31_pastr_suit_sf(j) Pasture suitability scaling factor (1)
p31_pastr_suit_sf(j) Pasture suitability scaling factor (1)
pc31_scaled_expansion_cost(t,j) Adjusted expansion costs to avoid unrealistic exchange between pastr and range in the first time step (USD05MER per ha)
;

*new parameters for grassland expansion cost (test)

parameters
p31_abs_discrepancy(j) Absolute discrepancy between actual and modeled grassland areas
p31_total_discrepancy Sum of absolute discrepancies for normalization purposes
p31_cost_adj_index(j) Cost adjustment index based on relative discrepancy between actual and modeled pasture areas
pc31_scaled_expansion_cost(t,j) Dynamically adjusted expansion costs based on discrepancy index until 2010, then constant
p31_abs_discrepancy_log(t,j) Absolute discrepancy between actual and modeled grassland areas log
p31_total_discrepancy_log(t) Sum of absolute discrepancies for normalization purposes log
pc31_scaled_expansion_cost_log(t,j) Dynamically adjusted expansion costs based on discrepancy index until 2010, then constant log
;

$ontext
parameters
p31_abs_discrepancy(t,i) Absolute discrepancy between actual and modeled grassland areas
pc31_scaled_expansion_cost(t,i) Dynamically adjusted expansion costs based on discrepancy index until 2010, then constant
p31_abs_discrepancy_log(t,i) Absolute discrepancy between actual and modeled grassland areas log
p31_total_discrepancy_log(t) Sum of absolute discrepancies for normalization purposes log
pc31_scaled_expansion_cost_log(t,i) Dynamically adjusted expansion costs based on discrepancy index until 2010, then constant log
;
$offtext
*#################### R SECTION START (OUTPUT DECLARATIONS) ####################
parameters
ov31_grass_area(t,j,grassland,type) Grassland areas (mio. ha)
Expand Down
4 changes: 0 additions & 4 deletions modules/31_past/grasslands_apr22/equations.gms
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ q31_pasture_areas(j2)..
*' a cost is associated with the expansion of rangelands and managed pastures 'v31_cost_grass_expansion'
*' in comparison with areas in the previous time step 'pc31_grass'.

*q31_expansion_cost(j2,grassland) ..
* v31_cost_grass_expansion(j2, grassland) =g=
* (v31_grass_area(j2, grassland) - pc31_grass(j2,grassland)) * s31_cost_expansion;

q31_expansion_cost(j2,grassland) ..
v31_cost_grass_expansion(j2, grassland) =g=
(v31_grass_area(j2, grassland) - pc31_grass(j2,grassland)) * sum(ct, pc31_scaled_expansion_cost(ct,j2));
Expand Down
9 changes: 0 additions & 9 deletions modules/31_past/grasslands_apr22/input.gms
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j)
$if "%c31_grassl_yld_scenario%" == "nocc" i31_manpast_suit(t_all,j) = f31_pastr_suitability("y1995",j);
$if "%c31_grassl_yld_scenario%" == "nocc_hist" i31_manpast_suit(t_all,j)$(m_year(t_all) > sm_fix_cc) = i31_manpast_suit(t_all,j)$(m_year(t_all) = sm_fix_cc);


scalar s31_limit_calib Relative managament calibration switch (1=limited 0=pure relative) / 1 /;


table f31_grassl_yld(t_all,j,grassland,w) LPJmL potential yields per cell (rainfed only) (tDM per ha)
$ondelim
$include "./modules/31_past/input/f31_grassl_yld.cs3"
Expand All @@ -50,10 +48,3 @@ table f31_LUH2v2(t_all,j, f31_luh) LUH2v2 land classes separating rangelands fro
$ondelim
$include "./modules/31_past/input/f31_LUH2v2.cs3"
$offdelim;


table f31_land(t_all, j, land31) Land area for different land pools at cluster level (mio. ha)
$ondelim
$include "./modules/31_past/input/avl_land_full_t.cs3"
$offdelim
;
30 changes: 0 additions & 30 deletions modules/31_past/grasslands_apr22/postsolve.gms
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,6 @@
*** Land Patterns are transferred to next timestep
pc31_grass(j,grassland) = v31_grass_area.l(j,grassland);


if(ord(t)<=card(t_past),
* Calculation of absolute discrepancy and total discrepancy for normalization
p31_abs_discrepancy(j) = f31_land(t,j,"past") - v31_grass_area.l(j,"pastr");
p31_total_discrepancy = sum(j, p31_abs_discrepancy(j));
p31_total_discrepancy$(p31_total_discrepancy = 0) = 1e-6;
p31_cost_adj_index(j) = (p31_abs_discrepancy(j) / p31_total_discrepancy);
pc31_scaled_expansion_cost(t,j) = s31_cost_expansion * ((1 + p31_cost_adj_index(j)) * 1000);
);
* Beyond 2010, carrying forward the last historical year adjusted costs
p31_abs_discrepancy_log(t,j) = p31_abs_discrepancy(j);
p31_total_discrepancy_log(t) = p31_total_discrepancy;
pc31_scaled_expansion_cost_log(t,j) = pc31_scaled_expansion_cost(t,j);


$ontext
if(ord(t)<=card(t_past),
* Calculation of absolute discrepancy and total discrepancy for normalization
p31_abs_discrepancy(t,i) = sum(cell(i,j), f31_land(t,j,"past") - v31_grass_area.l(j,"pastr"));
pc31_scaled_expansion_cost(t,i) = s31_cost_expansion - p31_abs_discrepancy(t,i) * 10;
elseif(ord(t)>card(t_past)),
pc31_scaled_expansion_cost(t,i) = pc31_scaled_expansion_cost(t-1,i)
);
pc31_scaled_expansion_cost(t,i)$(pc31_scaled_expansion_cost(t,i) < 0) = 0;

* Beyond 2010, carrying forward the last historical year adjusted costs
p31_abs_discrepancy_log(t,i) = p31_abs_discrepancy(t,i);
pc31_scaled_expansion_cost_log(t,i) = pc31_scaled_expansion_cost(t,i);
$offtext

*#################### R SECTION START (OUTPUT DEFINITIONS) #####################
ov31_grass_area(t,j,grassland,"marginal") = v31_grass_area.m(j,grassland);
ov31_cost_grass_expansion(t,j,grassland,"marginal") = v31_cost_grass_expansion.m(j,grassland);
Expand Down
15 changes: 10 additions & 5 deletions modules/31_past/grasslands_apr22/preloop.gms
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@


pc31_grass(j,grassland) = f31_LUH2v2("y1995",j,grassland);
*pc31_scaled_expansion_cost(t,j) = s31_cost_expansion;
pc31_scaled_expansion_cost(t,j) = 0;
pc31_scaled_expansion_cost("y1995",j) = 1000;

* calibrating pasture suitability
i31_manpast_suit(t_all,j)$(i31_manpast_suit(t_all,j) = 0) = f31_land("y1995",j,"past");
p31_pastr_suit_sf(j) = (f31_land("y1995",j,"past") / i31_manpast_suit("y1995",j))$(i31_manpast_suit("y1995",j) <> 0);
* This next part calibrates pasture suitability for managed pastures ("pastr") across various
* regions and time periods. It initializes the suitability for regions with no previous data using 1995
* baseline values from the LUH2v2 dataset. A scaling factor, calculated only where there is existing
* data to avoid division by zero, adjusts pasture suitability based on the ratio of estimated pastures to
* manually adjusted pastures from 1995. This factor is then applied to update suitability for all
* regions and periods. Historical data is directly assigned from LUH2v2 for past periods.

i31_manpast_suit(t_all,j)$(i31_manpast_suit(t_all,j) = 0) = f31_LUH2v2("y1995",j,"pastr");
p31_pastr_suit_sf(j) = (f31_LUH2v2("y1995",j,"pastr") / i31_manpast_suit("y1995",j))$(i31_manpast_suit("y1995",j) <> 0);
i31_manpast_suit(t_all,j) = i31_manpast_suit(t_all,j) * p31_pastr_suit_sf(j);
i31_manpast_suit(t_past,j) = f31_land(t_past,j,"past");
i31_manpast_suit(t_past,j) = f31_LUH2v2(t_past,j,"pastr");

***YIELD CORRECTION ACCOUNTING FOR REGIONAL DIFFERENCES IN MANAGEMENT***

Expand Down
9 changes: 1 addition & 8 deletions modules/31_past/grasslands_apr22/sets.gms
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ sets
grassland(f31_luh) Grassland cover types (pastr = managed pastures and range = rangelands)
/ pastr, range /

grass_to31(grassland) pasture management options
/ pastr,range /

grass_from31(grassland) pasture management options
/ pastr,range /

land31 land use types landinitialization
/ crop,past,range,primforest,secdforest,forestry,urban,primother,secdother /

/ crop,past,range,primforest,secdforest,forestry,urban,primother,secdother /
;

0 comments on commit bd76178

Please sign in to comment.