From 6d85f0314c2c5753f0b5db4864e75f5abe825b0e Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 10 Aug 2023 16:08:21 +0200 Subject: [PATCH 01/71] model-internal EAT Lancet diet implementation following Isabelles draft --- config/default.cfg | 36 +- main.gms | 20 +- .../15_food/anthro_iso_jun22/declarations.gms | 114 +++-- .../15_food/anthro_iso_jun22/exodietmacro.gms | 189 ++++++-- modules/15_food/anthro_iso_jun22/input.gms | 14 +- modules/15_food/anthro_iso_jun22/preloop.gms | 12 +- .../15_food/anthro_iso_jun22/realization.gms | 2 +- modules/15_food/anthro_iso_jun22/sets.gms | 117 ++++- modules/15_food/input/files | 2 + renv/activate.R | 421 +++++++++++++----- scripts/start/projects/project_EAT2.R | 44 ++ standalone/HOWTO.md | 2 +- 12 files changed, 726 insertions(+), 247 deletions(-) create mode 100644 scripts/start/projects/project_EAT2.R diff --git a/config/default.cfg b/config/default.cfg index f796720c61..028ef4483e 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -397,16 +397,23 @@ cfg$gms$s15_exo_waste <- 0 # def = 0 # * (1.2): corresponds to 20% food waste ~ half waste of HIC cfg$gms$s15_waste_scen <- 1.2 # def = 1.2 -# * switch for transition to exogenous diet scenarios (EAT Lancet and National Institute of Nutrition (NIN)) -# * (2): transition towards exogenous diets (NIN for India and EAT for other regions) -# * Please use this switch in combination with cfg$gms$c15_EAT_scen <- "FLX_hmilk" -# * If only India's diet needs to be changed, then set cfg$gms$scen_countries15 <- "IND" -# * (1): transition towards exogenous diets and food demand -# * (0): regression-based estimation of diets and food demand +# * Switch for transition to exogenous diet scenarios +# * (EAT Lancet and National Institute of Nutrition (NIN)) +# * (3): MAgPIE-specific realization of the EAT-Lancet diet, where model-internal +# * (regression-based) food demand projections are constraint by ranges for +# * intake targets of food groups to ensure healthy and sustainable diets as +# * recommended by the EAT-Lancet Commission +# * (2): transition towards exogenous diets (NIN for India and EAT for other regions) +# * Please use this switch in combination with cfg$gms$c15_EAT_scen <- "FLX_hmilk" +# * If only India's diet needs to be changed, then set cfg$gms$scen_countries15 <- "IND" +# * (1): transition towards exogenous diets and food demand parametrized +# * to a food-specific data set published by the EAT-Lancet Commission +# * (Willett et al., 2019) +# * (0): regression-based estimation of diets and food demand cfg$gms$s15_exo_diet <- 0 # def = 0 # * exogenous calorie scenario (EAT Lancet diet scenarios) -# * only activated if s15_exo_diet is set to 1 +# * only activated if s15_exo_diet is > 0 # * options: healthy_BMI, 2100kcal, 2500kcal, # * endo, no_underweight, no_overweight # * half_overweight, no_underweight_half_overweight @@ -421,7 +428,8 @@ cfg$gms$s15_exo_diet <- 0 # def = 0 cfg$gms$c15_kcal_scen <- "healthy_BMI" # def = healthy_BMI # # * exogenous food-specific diet scenario (EAT Lancet diet scenarios) -# * only activated if s15_exo_diet is set to 1 +# * only activated if s15_exo_diet is > 0 +#******** ISABELLE/BENNI: Or is this only active for s15_exo_diet = 1???? # * options: BMK, FLX, PSC, VEG, VGN, FLX_hmilk, FLX_hredmeat cfg$gms$c15_EAT_scen <- "FLX" # def = FLX @@ -441,9 +449,9 @@ cfg$gms$s15_exo_brans <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet -# * The EAT-Lancet diet only allows for added sugars, but does not include processed food or -# * alcohol. -# * only activated if s15_exo_diet is set to 1 +# * The EAT-Lancet diet only allows for added sugars, +# * but does not include processed food or alcohol. +# * only activated if s15_exo_diet is > 0 cfg$gms$s15_exo_alcohol <- 1 # default: 1 # * Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. # * (0): no alcohol consumption, as in the original version of the EAT-Lancet diet @@ -703,7 +711,7 @@ cfg$gms$c31_grassl_yld_scenario <- "cc" # def = "cc" # * SSP scenario switch for pasture suitability areas (only take effect for realization grasslands_apr22) # * options: ssp126, ssp245, ssp370, ssp460, ssp585 -# * nocc (fixed to values from 1995), +# * nocc (fixed to values from 1995), # * nocc_hist (ssp245 until year defined in sm_fix_cc, fixed thereafter) cfg$gms$c31_past_suit_scen <- "ssp370" # def = "ssp370" @@ -1281,8 +1289,8 @@ cfg$gms$nitrogen <- "rescaled_jan21" # def = rescaled_jan21 cfg$gms$carbon <- "normal_dec17" # def = normal_dec17 # * RCP scenario of land carbon sink adjustment factor, from Grassi et al 2021 -# * options: RCP19, RCP26, RCP34, RCP45, RCP60, RCPBU, -# * nocc (fixed to values from 1995), +# * options: RCP19, RCP26, RCP34, RCP45, RCP60, RCPBU, +# * nocc (fixed to values from 1995), # * nocc_hist (RCPBU until year defined in sm_fix_cc, fixed thereafter) cfg$gms$c52_land_carbon_sink_rcp <- "RCPBU" diff --git a/main.gms b/main.gms index 3595e9c073..374f08fc64 100644 --- a/main.gms +++ b/main.gms @@ -149,24 +149,24 @@ $title magpie *##################### R SECTION START (VERSION INFO) ########################## * * Used data set: rev4.87_h12_magpie.tgz -* md5sum: 658398f1dcbef89198bd85d61b1db9ad -* Repository: /p/projects/rd3mod/inputdata/output +* md5sum: NA +* Repository: https://rse.pik-potsdam.de/data/magpie/public * * Used data set: rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz -* md5sum: 8a1d668acfe66a700eb5da2143b31cb2 -* Repository: /p/projects/rd3mod/inputdata/output +* md5sum: NA +* Repository: https://rse.pik-potsdam.de/data/magpie/public * * Used data set: rev4.87_h12_validation.tgz -* md5sum: d02217d791b58400e6e3be7186527ed5 -* Repository: /p/projects/rd3mod/inputdata/output +* md5sum: NA +* Repository: https://rse.pik-potsdam.de/data/magpie/public * * Used data set: additional_data_rev4.43.tgz * md5sum: NA * Repository: https://rse.pik-potsdam.de/data/magpie/public * -* Used data set: calibration_H12_per_ton_fao_may22_glo_08Jul23.tgz -* md5sum: 7315d0f268d6225805a4c1f1c3c05b13 -* Repository: /p/projects/landuse/data/input/calibration +* Used data set: calibration_H12_per_ton_fao_may22_glo_14Jul23.tgz +* md5sum: NA +* Repository: https://rse.pik-potsdam.de/data/magpie/public * * Low resolution: c200 * High resolution: 0.5 @@ -195,7 +195,7 @@ $title magpie * * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler) * * -* Last modification (input data): Thu Jul 13 10:36:10 2023 +* Last modification (input data): Thu Aug 10 15:24:22 2023 * *###################### R SECTION END (VERSION INFO) ########################### diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index b5f7cd8ef2..10b8d8274e 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -11,14 +11,11 @@ equations ; positive variables - vm_dem_food(i,kall) Food demand (mio. tDM per yr) + vm_dem_food(i,kall) Food demand (mio. tDM per yr) ; *** #### Food Demand Model - - - equations q15_aim Objective function of food demand model (mio. USD05PPP) q15_budget(iso) Household budget constraint (USD05PPP per cap per day) @@ -39,7 +36,6 @@ equations q15_foodtree_kcal_processed(iso,kfo_pf) Demand for processed products (kcal per cap per day) q15_foodtree_kcal_staples(iso,kfo_st) Demand for staple products (kcal per cap per day) q15_foodtree_kcal_vegetables(iso) Demand for vegetable and fruit products (kcal per cap per day) - ; @@ -50,8 +46,8 @@ positive variables v15_income_pc_real_ppp_iso(iso) Real income per cap (USD05PPP per cap) v15_income_balance(iso) Balance variable to balance cases in which reduction in income is larger than the per capita GDP (USD05PPP per cap per yr) v15_kcal_intake_total_regr(iso) Food intake (kcal per cap per day) - v15_regr_overgroups(iso,sex,agegroup15,bmi_tree15) Hierarchical tree parameter regressions (1) - v15_bmi_shr_regr(iso,sex,age,bmi_group15) Uncalibrated share of population groups belonging to a certain BMI group (1) + v15_regr_overgroups(iso,sex,agegroup15,bmi_tree15) Hierarchical tree parameter regressions (1) + v15_bmi_shr_regr(iso,sex,age,bmi_group15) Uncalibrated share of population groups belonging to a certain BMI group (1) v15_bmi_shr_overgroups(iso,sex,agegroup15,bmi_group15) Uncalibrated share of population groups belonging to a certain BMI group (1) ; @@ -71,20 +67,20 @@ parameters p15_iteration_counter(t) Number of iterations required for reaching an equilibrium between food demand model and magpie (1) p15_convergence_measure(t,iter15) Convergence measure to decide for continuation or stop of food_demand - magpie iteration (1) i15_dem_intercept(iso,regr15) Food regression parameters intercept in kcal or as share (X) - i15_dem_saturation(iso,regr15) Food regression parameters saturation in kcal or as share (X) - i15_dem_halfsat(iso,regr15) Food regression parameters halfsaturation (USD05PPP per cap) - i15_dem_nonsat(iso,regr15) Food regression parameters nonsaturation (1) + i15_dem_saturation(iso,regr15) Food regression parameters saturation in kcal or as share (X) + i15_dem_halfsat(iso,regr15) Food regression parameters halfsaturation (USD05PPP per cap) + i15_dem_nonsat(iso,regr15) Food regression parameters nonsaturation (1) *prices p15_prices_kcal(t,iso,kfo,iter15) Prices from MAgPIE after optimization (USD05PPP per kcal) i15_prices_initial_kcal(iso,kfo) Initial prices that capture the approximate level of prices in 1961-2010 (USD05PPP per kcal) * anthropometrics - p15_bodyheight(t,iso,sex,age,estimates15) Body height (cm per cap) - p15_bodyweight(t,iso,sex,age,bmi_group15) Body weight (kg per cap) - p15_bodyheight_calib(t,iso,sex,age_new_estimated15) Calibration factor for regional height differences (cm) - p15_kcal_growth_food(t_all,iso,underaged15) Average per capita demand for body size growth relevant food items in the last three 5-year steps (kcal per capita per day) - p15_physical_activity_level(t,iso,sex,age) Physical activity levels in PAL relative to basic metabolic rate BMR (kcal per kcal) + p15_bodyheight(t,iso,sex,age,estimates15) Body height (cm per cap) + p15_bodyweight(t,iso,sex,age,bmi_group15) Body weight (kg per cap) + p15_bodyheight_calib(t,iso,sex,age_new_estimated15) Calibration factor for regional height differences (cm) + p15_kcal_growth_food(t_all,iso,underaged15) Average per capita demand for body size growth relevant food items in the last three 5-year steps (kcal per capita per day) + p15_physical_activity_level(t,iso,sex,age) Physical activity levels in PAL relative to basic metabolic rate BMR (kcal per kcal) i15_bmi_intercept(sex,agegroup15,bmi_tree15) BMI share regression intercept (1) i15_bmi_saturation(sex,agegroup15,bmi_tree15) BMI share regression saturation (1) @@ -101,20 +97,20 @@ parameters i15_milk_share_fadeout_india(t_all) Temporal fader of milk share in india (applied before food demand model) (1) i15_rum_share_fadeout(t_all,iso) Temporal fader of ruminant meat share (applied before food demand model) (1) - i15_ruminant_fadeout(t,iso) Ruminant fadeout share (1) - i15_fish_fadeout(t,iso) Fish fadeout share (1) - i15_alcohol_fadeout(t,iso) Alcohol fadeout share (1) - i15_livestock_fadeout(t,iso) Livestock fadeout share (1) - i15_rumdairy_fadeout(t,iso) Ruminant meat and dairy fadeout share (1) - i15_rumdairy_scp_fadeout(t,iso) Ruminant meat and dairy fadeout share to be replaced by SCP (1) - i15_livestock_fadeout_threshold(t,iso) Livestock fadeout share for threshold (1) + i15_ruminant_fadeout(t,iso) Ruminant fadeout share (1) + i15_fish_fadeout(t,iso) Fish fadeout share (1) + i15_alcohol_fadeout(t,iso) Alcohol fadeout share (1) + i15_livestock_fadeout(t,iso) Livestock fadeout share (1) + i15_rumdairy_fadeout(t,iso) Ruminant meat and dairy fadeout share (1) + i15_rumdairy_scp_fadeout(t,iso) Ruminant meat and dairy fadeout share to be replaced by SCP (1) + i15_livestock_fadeout_threshold(t,iso) Livestock fadeout share for threshold (1) - i15_protein_to_kcal_ratio(t,kfo) protein-to-kcal ratio (g protein per kcal) + i15_protein_to_kcal_ratio(t,kfo) Protein-to-kcal ratio (g protein per kcal) - i15_staples_kcal_structure_iso(t,iso,kfo_st) Share of single staple products within total staples (1) - i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap) Share of single livestock products within total livestock products (uncorrected for future changes in shares) (1) - i15_livestock_kcal_structure_iso(t,iso,kfo_ap) Share of single livestock products within total livestock products (corrected for future changes in shares) (1) - i15_processed_kcal_structure_iso Share of single processed products within total processed food (1) + i15_staples_kcal_structure_iso(t,iso,kfo_st) Share of single staple products within total staples (1) + i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap) Share of single livestock products within total livestock products (uncorrected for future changes in shares) (1) + i15_livestock_kcal_structure_iso(t,iso,kfo_ap) Share of single livestock products within total livestock products (corrected for future changes in shares) (1) + i15_processed_kcal_structure_iso Share of single processed products within total processed food (1) * diet calibration p15_kcal_calib(t,iso,kfo) Balance flow to diverge from mean calories of regressions (kcal per cap per day) @@ -125,38 +121,58 @@ parameters * before shock o15_kcal_regr_initial(t,iso,kfo) Uncalibrated per capita demand before price shock (kcal per capita per day) - pm_kcal_pc_initial(t,i,kall) Per capita consumption in food demand model before price shock (kcal per capita per day) + pm_kcal_pc_initial(t,i,kall) Per capita consumption in food demand model before price shock (kcal per capita per day) p15_kcal_pc_initial_iso(t,iso,kfo) Per capita consumption in food demand model before price shock on country level (kcal per capita per day) * after price shock - p15_kcal_pc_iso(t,iso,kfo) Per capita consumption in food demand model after price shock on country level (kcal per capita per day) - p15_kcal_pc(t,i,kfo) Per capita consumption in food demand model after price shock on regional level (kcal per capita per day) - p15_kcal_pc_calibrated(t,i,kfo) Calibrated per capita consumption in food demand model after price shock (kcal per capita per day) - p15_kcal_pc_iso_orig(t,iso,kfo) Auxiliary parameter for per capita food consumption - basis for convergence into waste and diet scenarios (kcal per capita per day) - p15_kcal_pc_iso_livestock_orig(t,iso) Auxiliary parameter for per capita livestock consumption - basis for scenarios of livestock food substitution (kcal per capita per day) - p15_kcal_pc_iso_rumdairy_orig(t,iso) Auxiliary parameter for per capita ruminant and dairy consumption - basis for scenarios of ruminant-based food substitution (kcal per capita per day) - p15_kcal_pc_iso_plant_orig(t,iso) Auxiliary parameter for per capita plant-based food consumption - basis for scenarios of livestock food substitution (kcal per capita per day) + p15_kcal_pc_iso(t,iso,kfo) Per capita consumption in food demand model after price shock on country level (kcal per capita per day) + p15_kcal_pc(t,i,kfo) Per capita consumption in food demand model after price shock on regional level (kcal per capita per day) + p15_kcal_pc_calibrated(t,i,kfo) Calibrated per capita consumption in food demand model after price shock (kcal per capita per day) + p15_kcal_pc_iso_orig(t,iso,kfo) Auxiliary parameter for per capita food consumption - basis for convergence into waste and diet scenarios (kcal per capita per day) + p15_kcal_pc_iso_livestock_orig(t,iso) Auxiliary parameter for per capita livestock consumption - basis for scenarios of livestock food substitution (kcal per capita per day) + p15_kcal_pc_iso_rumdairy_orig(t,iso) Auxiliary parameter for per capita ruminant and dairy consumption - basis for scenarios of ruminant-based food substitution (kcal per capita per day) + p15_kcal_pc_iso_plant_orig(t,iso) Auxiliary parameter for per capita plant-based food consumption - basis for scenarios of livestock food substitution (kcal per capita per day) p15_livestock_kcal_structure_orig(t,iso,kfo_lp) Auxiliary parameter for livestock kcal structure - basis for scenarios of livestock food substitution (1) p15_rumdairy_kcal_structure_orig(t,iso,kfo_rd) Auxiliary parameter for ruminant and dairy kcal structure - basis for scenarios of ruminant-based food substitution (1) p15_plant_kcal_structure_orig(t,iso,kfo_pp) Auxiliary parameter for plant-based food kcal structure - basis for scenarios of livestock food substitution (1) - p15_kcal_pc_livestock_supply_target(iso) Target of per capita livestock consumption (kcal per capita per day) + p15_kcal_pc_livestock_supply_target(iso) Target of per capita livestock consumption (kcal per capita per day) - p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) Calibrated estimates of BMI share for population groups (1) - p15_bmi_shr_target(t,iso,sex,age,bmi_group15) Target for BMI shares under exogenous scenarios (1) - p15_intake_total(t,iso) Total food intake in a country (kcal per capita per day) + p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) Calibrated estimates of BMI share for population groups (1) + p15_bmi_shr_target(t,iso,sex,age,bmi_group15) Target for BMI shares under exogenous scenarios (1) + p15_intake_total(t,iso) Total food intake in a country (kcal per capita per day) *food waste - p15_demand2intake_ratio(t,iso) Ratio between food calorie demand and intake (kcal per kcal) - p15_waste_pc(t,iso,kfo) Household waste by food group (kcal per capita per day) - p15_intake_detail(t,iso,kfo) Intake by food group (kcal per capita per day) - p15_demand2intake_ratio_detail(t,iso,kfo) Food waste ratio by food group (kcal per kcal) + p15_demand2intake_ratio(t,iso) Ratio between food calorie demand and intake (kcal per kcal) + p15_waste_pc(t,iso,kfo) Household waste by food group (kcal per capita per day) + p15_intake_detail(t,iso,kfo) Intake by food group (kcal per capita per day) + p15_demand2intake_ratio_detail(t,iso,kfo) Food waste ratio by food group (kcal per kcal) p15_demand2intake_ratio_detail_preexo(t,iso,kfo) Food waste as outcome of regression (kcal per kcal) * transition to exogenous scenario diets - i15_intake_scen_target(t,iso) Target for total per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) - i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) Food-specific per capita calorie intake according to various EAT Lancet diet scenarios (kcal per capita per day) - i15_intake_EATLancet(iso,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) - i15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) + i15_intake_scen_target(t,iso) Target for total per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) + i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) Food-specific per capita calorie intake according to various EAT Lancet diet scenarios (kcal per capita per day) + i15_intake_EATLancet(iso,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) + i15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) + + +*** NEW PARAMETERS IN ISABELLE'S VERSION *** + +* transformed to iso (check whether input data is available like that) + i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) + i15_fruitveg2others_kcal_ratio(t,iso) Ratio of calories from fruits and vegetables within the others food category (1) +* why is the following needed? + i15_fruitveg2others_kcal_ratio_scen(t,iso) Ratio of calories from fruits and vegetables within the others food category for an exogenous diet scenario (1) + p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) + p15_intake_detail_nsothers(t,iso) Auxiliary parameter for the intake of those nuts and seeds included in others (kcal per capita per day) + i15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) + i15_intake_detailed_scen_nsothers(t,iso) Auxiliary scenario target for the intake of those nuts and seeds included in others (kcal per capita per day) + +* are these needed? +p15_demand2intake_ratio_ref(i) Ratio between food calorie demand and intake for the historical time step of EAT Lancet diets (1) +i15_demand2intake_detailed_ref(i,kfo) Historical ratio between food calorie demand and intake for different food commodities (1) + +*** NEW PARAMETERS IN ISABELLE'S VERSION *** + p15_foodwaste_growth(t,iso) Increase in food waste over time relative to the historical time step of EAT Lancet diets (1) i15_kcal_pc_scen_target(t,iso,kfo) Target for per capita food consumption according to an exogenous diet scenario (kcal per capita per day) @@ -171,13 +187,13 @@ parameters ; scalars - s15_year Current year as integer value (yr) /2000/ + s15_year Current year as integer value (yr) / 2000 / ; + *' @code *' The food demand model consists of the following equations, which are not *' part of MAgPIE. - model m15_food_demand / q15_aim, q15_budget, diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index a8a5b23e44..029bb1ca25 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -221,15 +221,12 @@ if (s15_run_diet_postprocessing = 1, *' calculation of food intake and demand according to a predefined speed of *' convergence from `p15_kcal_pc_calibrated(t,iso,kfo)` to the scenario-dependent target *' `i15_kcal_pc_scen_target(t,iso,kfo)` by setting the switch `s15_exo_diet` -*' to 1. - - - if((s15_exo_diet = 1 or s15_exo_diet = 2), +*' to 1, 2 or 3. +if ((s15_exo_diet > 0), *' 1.) In a first step, the exogenous scenario diets are defined by selecting a *' scenario target for total daily per capita food intake - $ifthen "%c15_kcal_scen%" == "healthy_BMI" p15_bmi_shr_target(t,iso,sex,age,bmi_group15)=0; @@ -273,6 +270,7 @@ $elseif "%c15_kcal_scen%" == "no_overweight" im_demography(t,iso,sex,age)*p15_intake(t,iso,sex,age,bmi_group15) ) + i15_kcal_pregnancy(t,iso)) / sum((sex,age), im_demography(t,iso,sex,age)); + $elseif "%c15_kcal_scen%" == "half_overweight" p15_bmi_shr_target(t,iso,sex,age,bmi_group15)=p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15); p15_bmi_shr_target(t,iso,sex,age,"medium")= @@ -288,6 +286,7 @@ $elseif "%c15_kcal_scen%" == "half_overweight" im_demography(t,iso,sex,age)*p15_intake(t,iso,sex,age,bmi_group15) ) + i15_kcal_pregnancy(t,iso)) / sum((sex,age), im_demography(t,iso,sex,age)); + $elseif "%c15_kcal_scen%" == "no_underweight_half_overweight" p15_bmi_shr_target(t,iso,sex,age,bmi_group15)=p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15); p15_bmi_shr_target(t,iso,sex,age,"medium") = @@ -307,28 +306,37 @@ $elseif "%c15_kcal_scen%" == "no_underweight_half_overweight" im_demography(t,iso,sex,age)*p15_intake(t,iso,sex,age,bmi_group15) ) + i15_kcal_pregnancy(t,iso)) / sum((sex,age), im_demography(t,iso,sex,age)); + $elseif "%c15_kcal_scen%" == "endo" i15_intake_scen_target(t,iso) = p15_intake_total(t,iso); p15_bmi_shr_target(t,iso,sex,age,bmi_group15) = p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15); + $else i15_intake_scen_target(t,iso) = sum(kfo,i15_intake_EATLancet_all(iso,"%c15_kcal_scen%","%c15_EAT_scen%",kfo)); p15_bmi_shr_target(t,iso,sex,age,bmi_group15)=0; p15_bmi_shr_target(t,iso,sex,age,"medium")=1; $endif - -*' Intake target is adjusted to meet the calorie target - i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso)>0) = +*' The intake target is adjusted to meet the calorie target + i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) > 0) = p15_intake_detail(t,iso,kfo) / p15_intake_total(t,iso) * i15_intake_scen_target(t,iso); *' 2.) The second step defines the daily per capita intake of different food -*' commodities by filling up the scenario target for total daily per capita food -*' intake according to different scenario assumptions on dietary patterns. Calories -*' for staple crops can be modified in order to meet the total calorie target. +*' commodities. + +*---------------------------------------------------------------------------------------- +if (s15_exo_diet = 1, +*' In case of diet scenarios that are parametrized to a food-specific data set published +*' by the EAT-Lancet Commission (`s15_exo_diet=1`), this calculation step consists of +*' filling up the scenario target for total daily per capita food intake according +*' to the food-specific calorie intake of non-staple crops of this data set based on +*' exogenous food demand projections. +*' In case that the in step 1.) selected total calorie intake is not equal to total intake +*' of the data set, only the calories for staple crops are modified and calories for +*' non-staple food commodities are preserved. *' The EAT lancet target values are the same for non-staples irrespective of the calorie target *' Only non-staples differ - i15_intake_EATLancet(iso,kfo) = i15_intake_EATLancet_all(iso,"2100kcal","%c15_EAT_scen%",kfo); @@ -371,9 +379,133 @@ $endif = s15_alc_scen*i15_intake_scen_target(t,iso); ); - i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))>0) = ( - i15_intake_scen_target(t,iso) - sum(EAT_nonstaples,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)) )*( - i15_intake_EATLancet(iso,EAT_staples)/sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2)) ); + i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2)) > 0) = + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * + (i15_intake_EATLancet(iso,EAT_staples)/sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))) + ; + +* VARTIKA: What about s15_exo_diet = 2? Is there any special treatment needed here? + +*---------------------------------------------------------------------------------------- +elseif s15_exo_diet = 3, +*' In case of a MAgPIE-specific realization of the EAT Lancet diet (`s15_exo_diet=3`), +*' model-internal diet projections are constraint by recommended ranges for intake +*' (`i15_rec_EATLancet`) of different food groups to ensure healthy and sustainable +*' diets according to the EAT-Lancet Commission. After all calorie recommendations +*' for non-staple food groups are satisfied, intake of staple crops is modified such +*' that the in step 1.) selected total calorie intake is met. +* Note: brans is the only food commodity group that will not be affected +* by the following calculations. + +*' Where maximum target is not exceeded, total scenario food intake is assigned +*' to EAT-Lancet recommendation + i15_rec_EATLancet(iso,EAT_targets15,"max")$(i15_rec_EATLancet(iso,EAT_targets15,"max") = 0) = i15_intake_scen_target(t,iso); +*** ISABELLE: Why does the i15_rec_EATLancet have to be overwritten, though? + +*' It is, however, switched off for roots, since they will, as staples, +*' later be treated as balancing post to meet total calorie intake: + i15_rec_EATLancet(iso,"t_roots","max") = i15_intake_scen_target(t,iso); +*** ISABELLE: Why are roots and staples used as balancing post? Roots has a target +*** Also: discuss with Isabelle and Benni about splitting the roots target into potatos and cassav_sp (see Marcos distinction between starchy_fruits and roots) + + +*** ISABELLE/BENNI: I think this is not required anymore (food waste calculations have changed since then) +** Use p15_intake_detail(t,iso,kfo) instead? +* The parameter p15_intake_detailed_regr doesn't exist anymore in this realization. +*p15_intake_detailed_regr(t,i,kfo) = p15_kcal_pc_calibrated(t,i,kfo) +* / (i15_calib_fsupply(i) * i15_demand2intake_detailed_ref(i,kfo) * p15_foodwaste_growth(t,i)); +*i15_intake_detailed_scen_target(t,iso,kfo) = p15_intake_detailed_regr(t,i,kfo); + +*' The intake target is adjusted to meet the EAT-Lancet recommendations +*** Minimum recommendations *** +*' If projected food intake is below minimum, it is increased it to meet +*' the EAT-Lancet recommendations: + i15_intake_detailed_scen_target(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), + sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)) + ) < sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"min")) + ) = + (p15_intake_detail(t,iso,kfo) / sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) + * sum(EATtar_kfo15(EAT_mtargets15,kfo),i15_rec_EATLancet(iso,EAT_mtargets15,"min")) + ; + +*** Maximum recommendations *** +*' If projected food intake is above maximum, it is decreased it to meet +*' the EAT-Lancet recommendations: + i15_intake_detailed_scen_target(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), + sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)) + ) > sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"max")) + ) = + (p15_intake_detail(t,iso,kfo) / sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) + * sum(EATtar_kfo15(EAT_mtargets15,kfo),i15_rec_EATLancet(iso,EAT_mtargets15,"max")) + ; + +*** Special case: Fruits, vegetables and nuts *** +*' In MAgPIE fruits, vegetables and (some) nuts are combined to the 'other' food category. +*' The f15_fruitveg2others_kcal_ratio gives the historical share (fixed into the future based on last historic year) +*' of fruits and vegetables in this aggregate category + if (sum(sameas(t_past,t),1) = 1, + i15_fruitveg2others_kcal_ratio(t,iso) = f15_fruitveg2others_kcal_ratio(t,iso); + else + i15_fruitveg2others_kcal_ratio(t,iso) = f15_fruitveg2others_kcal_ratio(t-1,iso); + ); + +*' This ratio is used to split the 'others' category into fruits plus vegetables +*' and those nuts and seeds that are not included in rapeseed, groundnut and sunflower +*****BENNI/ISABELLE: Are groundnuts nuts or pulses in the end? Or should they be anyway be a separate target (peanuts) + p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso) * p15_intake_detail(t,iso,"others"); + p15_intake_detail_nsothers(t,iso) = (1-i15_fruitveg2others_kcal_ratio(t,iso)) * p15_intake_detail(t,iso,"others"); + i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); + i15_intake_detailed_scen_nsothers(t,iso) = p15_intake_detail_nsothers(t,iso); + +*' Minimum recommendation for fruits and vegetables: + i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) + = i15_rec_EATLancet(iso,"t_fruitveg","min"); + +*' Minimum recommendation for nuts +*' (a) nuts and seeds that are included in "others" + i15_intake_detailed_scen_nsothers(t,iso)$((sum(kfo_ns, p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nsothers(t,iso) + ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) + = (p15_intake_detail_nsothers(t,iso) / (sum(kfo_ns,p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nsothers(t,iso))) + * i15_rec_EATLancet(iso,"t_nutseeds","min") + ; +*' (b) for rapeseed, groundnut, sunflower: +*** BENNI/ISABELLE: where to put groundnuts? separate? + i15_intake_detailed_scen_target(t,iso,kfo_ns)$((sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nsothers(t,iso) + ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) + = (p15_intake_detail(t,iso,kfo_ns) / (sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nsothers(t,iso))) + * i15_rec_EATLancet(iso,"t_nutseeds","min") + ; + +*' The resulting intake of the "others" category is: + i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nsothers(t,iso); +* Update of the ratio of fruits and vegetables within the "others" category: + i15_fruitveg2others_kcal_ratio_scen(t,iso)$(i15_intake_detailed_scen_target(t,iso,"others") > 0) + = i15_intake_detailed_scen_fruitveg(t,iso) / i15_intake_detailed_scen_target(t,iso,"others"); + +* Food commodities that are not included in diet recommendations are set to zero: + i15_intake_detailed_scen_target(t,iso,kfo_norec) = 0; +* Optionally, there is an exception for alcohol: +* Via 's15_alc_scen' a maximum target for alcohol consumption can be defined, e.g. according to Lassen et al., (2020). + if (s15_alc_scen > 0, +* first, reduce projected alcohol consumption by a quarter: + i15_intake_detailed_scen_target(t,iso,"alcohol") = p15_intake_detail(t,iso,"alcohol") * 3/4; +* if still above target, set to maximum: + i15_intake_detailed_scen_target(t,iso,"alcohol")$(i15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen * i15_intake_scen_target(t,iso)) + = s15_alc_scen * i15_intake_scen_target(t,iso); + ); +***** ISABELLE: Why is this done in two steps? +***** BENNI: This is also done in the other EAT implementation (s15_exo_diet = 1). +***** Should it be done the same way in both? (Should it be taken out of the if-condition (applied to both)?) + +*** Balancing calorie requirements *** +*' After all calorie recommendations for non-staple food groups are satisfied, intake of staple crops is +*' now modified such that the in step 1.) selected total calorie intake is met: + i15_intake_detailed_scen_target(t,iso,EAT_staples) = + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) + * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); + +); +*** End of MAgPIE-specific realization of the EAT Lancet diet *' 3.) In the third step, the regression-based calculation of intake *' is faded into the exogenous intake scenario according to a predefined speed of @@ -385,9 +517,8 @@ $endif p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) = p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) * (1-i15_exo_foodscen_fader(t,iso)) + p15_bmi_shr_target(t,iso,sex,age,bmi_group15) * i15_exo_foodscen_fader(t,iso); - ); -*' End of special postprocessing food demand scenarios. +*** End of special postprocessing food demand scenarios. *' 4.) The fourth step estimates the calorie supply at household level by multiplying @@ -395,10 +526,9 @@ $endif *' previously. It assures that if commodities with higher food waste ratio are *' increasingly consumed, food waste increases. p15_kcal_pc_iso(t,iso,kfo) = p15_intake_detail(t,iso,kfo) - *p15_demand2intake_ratio_detail(t,iso,kfo); + * p15_demand2intake_ratio_detail(t,iso,kfo); *' Total waste share and total intake are adapted to new calculations. - p15_intake_total(t,iso) = sum(kfo, p15_intake_detail(t,iso,kfo)); p15_waste_pc(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo) - p15_intake_detail(t,iso,kfo); @@ -408,22 +538,19 @@ $endif * ###### Exogenous food waste scenario - - if(s15_exo_waste = 1, +if (s15_exo_waste = 1, *' "Downwards convergence" of regional calorie oversupply due to food waste to the *' waste reduction target, i.e. only for values that are higher than the target: - p15_demand2intake_ratio(t,iso)$(p15_demand2intake_ratio(t,iso) > s15_waste_scen ) - = p15_demand2intake_ratio(t,iso)*(1-i15_exo_foodscen_fader(t,iso)) - + s15_waste_scen*i15_exo_foodscen_fader(t,iso); + = p15_demand2intake_ratio(t,iso) * (1-i15_exo_foodscen_fader(t,iso)) + + s15_waste_scen * i15_exo_foodscen_fader(t,iso); ); *' waste calculation by crop type - - p15_waste_pc(t,iso,kfo)$(sum(kfo2, p15_waste_pc(t,iso,kfo2))<>0) = p15_waste_pc(t,iso,kfo) / sum(kfo2, p15_waste_pc(t,iso,kfo2))* - (p15_intake_total(t,iso)*p15_demand2intake_ratio(t,iso)-p15_intake_total(t,iso)); + p15_waste_pc(t,iso,kfo)$(sum(kfo2, p15_waste_pc(t,iso,kfo2))<>0) = p15_waste_pc(t,iso,kfo) / sum(kfo2, p15_waste_pc(t,iso,kfo2)) * + (p15_intake_total(t,iso)*p15_demand2intake_ratio(t,iso) - p15_intake_total(t,iso)); *' Waste ratio is applied p15_kcal_pc_iso(t,iso,kfo) = p15_intake_detail(t,iso,kfo) + p15_waste_pc(t,iso,kfo); @@ -462,12 +589,12 @@ $endif ); -*' Finally, we calibrate countries with zero food demand according to FAOSTAT +*' Finally, countries with zero food demand according to FAOSTAT are calibrated *' down to zero to match FAO world totals. *' Values are rounded to avoid path dependencies of MAgPIE solver. - p15_kcal_pc_calibrated(t,i,kfo)=p15_kcal_pc(t,i,kfo)+p15_balanceflow_kcal(t,i,kfo); - p15_kcal_pc_calibrated(t,i,kfo)=round(p15_kcal_pc_calibrated(t,i,kfo),2); - p15_kcal_pc_calibrated(t,i,kfo)$(p15_kcal_pc_calibrated(t,i,kfo)<0)=0; + p15_kcal_pc_calibrated(t,i,kfo) = p15_kcal_pc(t,i,kfo) + p15_balanceflow_kcal(t,i,kfo); + p15_kcal_pc_calibrated(t,i,kfo) = round(p15_kcal_pc_calibrated(t,i,kfo), 2); + p15_kcal_pc_calibrated(t,i,kfo)$(p15_kcal_pc_calibrated(t,i,kfo) < 0) = 0; *' @stop ); diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index 099e6acbfc..c1ed29dede 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -250,9 +250,19 @@ $ondelim $include "./modules/15_food/input/f15_supply2intake_ratio_FAO_iso.cs3" $offdelim; +*** EAT Lancet diet recommendation +table f15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) +$ondelim +$include "./modules/15_food/input/f15_targets_EATLancet_iso.cs3" +$offdelim; + +table f15_fruitveg2others_kcal_ratio(t_all,iso) Ratio of calories from fruits and vegetables within the others food category (1) +$ondelim +$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio_iso.csv" +$offdelim; -**This file contains exogenous dietary recommendations for India and EAT Lancet recommendations for all other regions -**Different set elements for sets "t_scen15", "kcal_scen15" and "EAT_scen15" result in the identical target diet as per f15_intake_EATLancet +* This file contains exogenous dietary recommendations for India and EAT Lancet recommendations for all other regions +* Different set elements for sets "t_scen15", "kcal_scen15" and "EAT_scen15" result in the identical target diet as per f15_intake_EATLancet table f15_intake_NIN(t_scen15,iso,kcal_scen15,EAT_scen15,kfo) NIN scenarios for food-specific intake (kcal per capita per day) $ondelim $include "./modules/15_food/input/f15_intake_NIN_iso.cs3" diff --git a/modules/15_food/anthro_iso_jun22/preloop.gms b/modules/15_food/anthro_iso_jun22/preloop.gms index 0397c55f4b..cc0750210a 100644 --- a/modules/15_food/anthro_iso_jun22/preloop.gms +++ b/modules/15_food/anthro_iso_jun22/preloop.gms @@ -9,7 +9,7 @@ i15_bmi_saturation(sex,agegroup15,bmi_tree15) = f15_bmi_shr_paras(sex,agegroup15,bmi_tree15,"saturation"); i15_bmi_halfsat(sex,agegroup15,bmi_tree15) = f15_bmi_shr_paras(sex,agegroup15,bmi_tree15,"halfsaturation"); -p15_bodyheight(t,iso,sex,age,estimates15) = f15_bodyheight(t,iso,sex,age); + p15_bodyheight(t,iso,sex,age,estimates15) = f15_bodyheight(t,iso,sex,age); * calculating growth food for historical period @@ -55,8 +55,7 @@ Elseif s15_milk_share_fadeout_india = 1, * ###### Exogenous food waste and diet scenarios as well as food substitution scenarios - -* Switch to determine countries for which exogenous food scenarios (EAT Lancet diet and +* Switch to determine countries for which exogenous food scenarios (EAT Lancet diet and * food waste scenarios), and food substitution scenarios shall be applied. * In the default case, the exogenous food scenarios affect all countries. p15_country_dummy(iso) = 0; @@ -81,16 +80,19 @@ i15_exo_foodscen_fader(t,iso) = (1-f15_food_substitution_fader(t,"%c15_exo_foods $ifthen "%c15_exo_foodscen%" == "lin_zero_20_30" i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_EATLancet("y2030",iso,kcal_scen15,EAT_scen15,kfo); *extra condition to see if India diet scenario has been selected - if(s15_exo_diet = 2, + if (s15_exo_diet = 2, i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_NIN("y2030",iso,kcal_scen15,EAT_scen15,kfo); ); $else i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_EATLancet("y2050",iso,kcal_scen15,EAT_scen15,kfo); - if(s15_exo_diet = 2, + if (s15_exo_diet = 2, i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_NIN("y2050",iso,kcal_scen15,EAT_scen15,kfo); ); $endif +* Initialisation of the recommendations for healthy food intake: +i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) = f15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15); + * initial prices in $US per Kcal i15_prices_initial_kcal(iso,kfo)$(fm_nutrition_attributes("y1995",kfo,"kcal")>0) = f15_prices_initial(kfo) / (fm_nutrition_attributes("y1995",kfo,"kcal")*10**6); diff --git a/modules/15_food/anthro_iso_jun22/realization.gms b/modules/15_food/anthro_iso_jun22/realization.gms index 87624010d9..724e75d087 100644 --- a/modules/15_food/anthro_iso_jun22/realization.gms +++ b/modules/15_food/anthro_iso_jun22/realization.gms @@ -45,4 +45,4 @@ $Ifi "%phase%" == "postsolve" $include "./modules/15_food/anthro_iso_jun22/posts *' diet scenarios, most importantly the shift to the Planetary Health diet *' [@willett_food_2019]. *' -*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Jan Philipp Dietrich +*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Jan Philipp Dietrich, Felicitas Beier, Marco Springmann diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 18f196764f..19c01fff13 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -109,6 +109,15 @@ sets kfo_pf(kfo) Processed foods including oils sugar alcohol / oils,alcohol,sugar / + kfo_ns(kfo) Food products that can be counted towards nuts and nuts_seeds + / rapeseed, groundnut, sunflower / +** BENNI/ISABELLE: Where should groundnut be counted towards? + + kfo_norec(kfo) Food products that do not have an EAT-Lancet recommendation + / sugr_cane, sugr_beet, molasses, alcohol, scp / +** Note: To Do: attribute sugr_cane, sugr_bee, molasses to sugar +* ISABELLE: What about brans? + knf(kall) Non-food products in the sectoral version / oilpalm,cottn_pro,foddr, pasture, begr, betr, oilcakes,ethanol,distillers_grain,fibres, @@ -116,7 +125,7 @@ sets wood, woodfuel / nutrition Nutrition attributes - /kcal, protein/ + / kcal, protein/ par15 Parameters for food module / intercept,saturation,halfsaturation,non_saturation / @@ -164,26 +173,97 @@ sets EAT_scen15 Scenario of daily per capita calorie intake / BMK, FLX, PSC, VEG, VGN, FLX_hmilk, FLX_hredmeat / - EAT_monogastrics15(kfo) monogastic products + EAT_monogastrics15(kfo) monogastic products / livst_pig, livst_egg, livst_chick / - EAT_ruminants15(kfo) ruminant products + EAT_ruminants15(kfo) ruminant products / livst_milk, livst_rum / - EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds - /rapeseed,sunflower,others/ - EAT_pulses15(kfo) pulses - /soybean,puls_pro,groundnut/ - EAT_sugar15(kfo) sugar - /sugr_cane,sugr_beet,sugar,molasses/ - - EAT_staples(kfo) All staple food products according to EAT Lancet definition - / tece,maiz,trce,rice_pro,potato,cassav_sp / - EAT_nonstaples(kfo) All non-staple food products according to EAT Lancet definition - / soybean,rapeseed,groundnut,sunflower,puls_pro, - sugr_cane,sugr_beet, - oils,sugar,molasses,alcohol,brans,scp, - livst_rum,livst_pig,livst_chick, livst_egg, livst_milk, fish, + EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds + / rapeseed, sunflower, others / + EAT_pulses15(kfo) pulses + / soybean, puls_pro, groundnut / +** BENNI: are groundnuts nuts or pulses? +** also note: peanuts (=groundnut?) has actually a single target (shouldn't we separate it?) + EAT_sugar15(kfo) sugar + / sugr_cane, sugr_beet, sugar, molasses / + + EAT_staples(kfo) All staple food products according to EAT Lancet definition + / tece, maiz, trce, rice_pro, potato, cassav_sp / +*** ISABELLE/BENNI/MARCO: Should potato and cassav_sp be included in staples (balancing post?) +* Alternatively: +*EAT_starch(kfo) Food group starch as of EAT +* / tece, maiz, trce, rice_pro / + EAT_nonstaples(kfo) All non-staple food products according to EAT Lancet definition + / soybean, rapeseed, groundnut, sunflower, puls_pro, + sugr_cane, sugr_beet, + oils, sugar, molasses, alcohol, brans, scp, + livst_rum, livst_pig, livst_chick, livst_egg, livst_milk, fish, others / +* Food groups for Marco's diet model (my suggestion) +* EAT_starch(kfo) Food group starch as of EAT --> different from EAT_staples (see above) +* / tece, maiz, trce, rice_pro / +* EAT_soybeans(kfo) Soybeans as of EAT --> not new set definition required +* / soybean / +* EAT_nutsseeds(kfo) Food group of nuts and seeds as of EAT +* / rapeseed, groundnut, sunflower / +**** BENNI: Is groundnut nuts or pulses? +* EAT_legumes(kfo) Legumes as of EAT +* / puls_pro / +* EAT_roots(kfo) Food group of roots as of EAT +* / potato, cassav_sp / +* EAT_sugar15(kfo) Sugar as of EAT --> same as in above code, but different from Isabelle's +* / sugr_cane, sugr_beet, sugar, molasses / +* EAT_redmeat(kfo) Food group of red meat as of EAT target +* / livst_rum, livst_pig / +* EAT_poultry(kfo) EAT target food group poultry ---> for 1:1 product, no extra set necessary +* / livst_chick / +* EAT_eggs(kfo) EAT target food group eggs ---> for 1:1 product, no extra set necessary +* / livst_egg / +* EAT_milk(kfo) EAT target food group milk +* / livst_milk / +* EAT_fish(kfo) EAT target food group fish +* / fish / +* EAT_fruits --> common target for fruits and vegetables? (just add up?) +* EAT_vegetables --> common target for fruits and vegetables? (just add up?) +* For others: check how Isabelle solved this (separation of nuts from other (based on FAO)) +* Where should oils, alcohol, brans, scp be attributed to? +* For oils (same problem!): just combine oil_palm and oil_veg to one target? (how did Isabelle solve this?) +* scp -> redmeat? +* for brans -> keep regression value? +* alcohol: 0 or default value (Lassen et al.)? + + +* Isabelle's code: +EAT_targettype15 Minimum or maximum target type of the EAT Lancet recommendations + / min, max / + +EAT_targets15 Food groups as well as individual foods for which EAT Lancet targets are defined + / t_nutseeds, t_fruitveg, + t_roots, t_redmeat, + t_puls_pro, t_soybean, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + +EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible + / t_roots, t_redmeat, + t_puls_pro, t_soybean, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + +EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories +* ISABELLE: Where are groundnuts? (peanuts have separate target. should we add it?) +* + / t_roots . (potato, cassav_sp) +* Note: To Do: split roots target because cassav_sp contains bananas/plantains (see Marco's model: starchy fruits) + t_redmeat . (livst_rum, livst_pig) + t_puls_pro . (puls_pro) + t_soybean . (soybean) + t_fish . (fish) + t_livst_chick . (livst_chick) + t_livst_egg . (livst_egg) + t_livst_milk . (livst_milk) + t_sugar . (sugar) +* Note: To Do: add sugr_cane, sugr_beet, molasses + t_oils . (oils) +* Note: To Do: double check whether the oils target contains oil_palm and oil_veg + / + ; alias(kst,kst2); @@ -192,6 +272,9 @@ alias(kfo,kfo2); alias(kfo_ap,kfo_ap2); alias(kfo_st,kfo_st2); alias(kfo_pf,kfo_pf2); +alias(kfo_ns,kfo_ns2); alias(iso,iso2); alias(reproductive,reproductive2); alias(EAT_staples,EAT_staples2); +alias(EAT_mtargets15,EAT_mtargets15_2); +alias(EATtar_kfo15,EATtar_kfo15_2); diff --git a/modules/15_food/input/files b/modules/15_food/input/files index c71a6ff7c9..1fa6f16081 100644 --- a/modules/15_food/input/files +++ b/modules/15_food/input/files @@ -20,6 +20,8 @@ f15_supply2intake_ratio_bottomup.cs3 f15_supply2intake_ratio_FAO_iso.cs3 f15_intake_EATLancet.cs3 f15_intake_EATLancet_iso.cs3 +f15_targets_EATLancet_iso.cs3 +f15_fruitveg2others_kcal_ratio_iso.csv f15_food_substitution_fader.csv f15_ruminant_fadeout_india.csv f15_milk_fadeout_india.csv diff --git a/renv/activate.R b/renv/activate.R index 019b5a6693..55dae8650e 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -3,6 +3,7 @@ local({ # the requested version of renv version <- "0.16.0" + attr(version, "sha") <- "0e3aab27a928eb261819a3fc45a3ee2b4ba902a5" # the project directory project <- getwd() @@ -60,21 +61,75 @@ local({ # load bootstrap tools `%||%` <- function(x, y) { - if (is.environment(x) || length(x)) x else y + if (is.null(x)) y else x + } + + catf <- function(fmt, ..., appendLF = TRUE) { + + quiet <- getOption("renv.bootstrap.quiet", default = FALSE) + if (quiet) + return(invisible()) + + msg <- sprintf(fmt, ...) + cat(msg, file = stdout(), sep = if (appendLF) "\n" else "") + + invisible(msg) + + } + + header <- function(label, + ..., + prefix = "#", + suffix = "-", + n = min(getOption("width"), 78)) + { + label <- sprintf(label, ...) + n <- max(n - nchar(label) - nchar(prefix) - 2L, 8L) + if (n <= 0) + return(paste(prefix, label)) + + tail <- paste(rep.int(suffix, n), collapse = "") + paste0(prefix, " ", label, " ", tail) + + } + + startswith <- function(string, prefix) { + substring(string, 1, nchar(prefix)) == prefix } bootstrap <- function(version, library) { + friendly <- renv_bootstrap_version_friendly(version) + section <- header(sprintf("Bootstrapping renv %s", friendly)) + catf(section) + # attempt to download renv - tarball <- tryCatch(renv_bootstrap_download(version), error = identity) - if (inherits(tarball, "error")) - stop("failed to download renv ", version) + catf("- Downloading renv ... ", appendLF = FALSE) + withCallingHandlers( + tarball <- renv_bootstrap_download(version), + error = function(err) { + catf("FAILED") + stop("failed to download:\n", conditionMessage(err)) + } + ) + catf("OK") + on.exit(unlink(tarball), add = TRUE) # now attempt to install - status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity) - if (inherits(status, "error")) - stop("failed to install renv ", version) + catf("- Installing renv ... ", appendLF = FALSE) + withCallingHandlers( + status <- renv_bootstrap_install(version, tarball, library), + error = function(err) { + catf("FAILED") + stop("failed to install:\n", conditionMessage(err)) + } + ) + catf("OK") + + # add empty line to break up bootstrapping from normal output + catf("") + return(invisible()) } renv_bootstrap_tests_running <- function() { @@ -83,28 +138,32 @@ local({ renv_bootstrap_repos <- function() { + # get CRAN repository + cran <- getOption("renv.repos.cran", "https://cloud.r-project.org") + # check for repos override repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) - if (!is.na(repos)) + if (!is.na(repos)) { + + # check for RSPM; if set, use a fallback repository for renv + rspm <- Sys.getenv("RSPM", unset = NA) + if (identical(rspm, repos)) + repos <- c(RSPM = rspm, CRAN = cran) + return(repos) + } + # check for lockfile repositories repos <- tryCatch(renv_bootstrap_repos_lockfile(), error = identity) if (!inherits(repos, "error") && length(repos)) return(repos) - # if we're testing, re-use the test repositories - if (renv_bootstrap_tests_running()) - return(getOption("renv.tests.repos")) - # retrieve current repos repos <- getOption("repos") # ensure @CRAN@ entries are resolved - repos[repos == "@CRAN@"] <- getOption( - "renv.repos.cran", - "https://cloud.r-project.org" - ) + repos[repos == "@CRAN@"] <- cran # add in renv.bootstrap.repos if set default <- c(FALLBACK = "https://cloud.r-project.org") @@ -143,33 +202,34 @@ local({ renv_bootstrap_download <- function(version) { - # if the renv version number has 4 components, assume it must - # be retrieved via github - nv <- numeric_version(version) - components <- unclass(nv)[[1]] - - # if this appears to be a development version of 'renv', we'll - # try to restore from github - dev <- length(components) == 4L - - # begin collecting different methods for finding renv - methods <- c( - renv_bootstrap_download_tarball, - if (dev) - renv_bootstrap_download_github - else c( - renv_bootstrap_download_cran_latest, - renv_bootstrap_download_cran_archive + sha <- attr(version, "sha", exact = TRUE) + + methods <- if (!is.null(sha)) { + + # attempting to bootstrap a development version of renv + c( + function() renv_bootstrap_download_tarball(sha), + function() renv_bootstrap_download_github(sha) + ) + + } else { + + # attempting to bootstrap a release version of renv + c( + function() renv_bootstrap_download_tarball(version), + function() renv_bootstrap_download_cran_latest(version), + function() renv_bootstrap_download_cran_archive(version) ) - ) + + } for (method in methods) { - path <- tryCatch(method(version), error = identity) + path <- tryCatch(method(), error = identity) if (is.character(path) && file.exists(path)) return(path) } - stop("failed to download renv ", version) + stop("All download methods failed") } @@ -233,8 +293,6 @@ local({ type <- spec$type repos <- spec$repos - message("* Downloading renv ", version, " ... ", appendLF = FALSE) - baseurl <- utils::contrib.url(repos = repos, type = type) ext <- if (identical(type, "source")) ".tar.gz" @@ -251,13 +309,10 @@ local({ condition = identity ) - if (inherits(status, "condition")) { - message("FAILED") + if (inherits(status, "condition")) return(FALSE) - } # report success and return - message("OK (downloaded ", type, ")") destfile } @@ -314,8 +369,6 @@ local({ urls <- file.path(repos, "src/contrib/Archive/renv", name) destfile <- file.path(tempdir(), name) - message("* Downloading renv ", version, " ... ", appendLF = FALSE) - for (url in urls) { status <- tryCatch( @@ -323,14 +376,11 @@ local({ condition = identity ) - if (identical(status, 0L)) { - message("OK") + if (identical(status, 0L)) return(destfile) - } } - message("FAILED") return(FALSE) } @@ -344,8 +394,7 @@ local({ return() # allow directories - info <- file.info(tarball, extra_cols = FALSE) - if (identical(info$isdir, TRUE)) { + if (dir.exists(tarball)) { name <- sprintf("renv_%s.tar.gz", version) tarball <- file.path(tarball, name) } @@ -354,7 +403,7 @@ local({ if (!file.exists(tarball)) { # let the user know we weren't able to honour their request - fmt <- "* RENV_BOOTSTRAP_TARBALL is set (%s) but does not exist." + fmt <- "- RENV_BOOTSTRAP_TARBALL is set (%s) but does not exist." msg <- sprintf(fmt, tarball) warning(msg) @@ -363,10 +412,7 @@ local({ } - fmt <- "* Bootstrapping with tarball at path '%s'." - msg <- sprintf(fmt, tarball) - message(msg) - + catf("- Using local tarball '%s'.", tarball) tarball } @@ -393,8 +439,6 @@ local({ on.exit(do.call(base::options, saved), add = TRUE) } - message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE) - url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) name <- sprintf("renv_%s.tar.gz", version) destfile <- file.path(tempdir(), name) @@ -404,26 +448,105 @@ local({ condition = identity ) - if (!identical(status, 0L)) { - message("FAILED") + if (!identical(status, 0L)) return(FALSE) - } - message("OK") + renv_bootstrap_download_augment(destfile) + return(destfile) } + # Add Sha to DESCRIPTION. This is stop gap until #890, after which we + # can use renv::install() to fully capture metadata. + renv_bootstrap_download_augment <- function(destfile) { + sha <- renv_bootstrap_git_extract_sha1_tar(destfile) + if (is.null(sha)) { + return() + } + + # Untar + tempdir <- tempfile("renv-github-") + on.exit(unlink(tempdir, recursive = TRUE), add = TRUE) + untar(destfile, exdir = tempdir) + pkgdir <- dir(tempdir, full.names = TRUE)[[1]] + + # Modify description + desc_path <- file.path(pkgdir, "DESCRIPTION") + desc_lines <- readLines(desc_path) + remotes_fields <- c( + "RemoteType: github", + "RemoteHost: api.github.com", + "RemoteRepo: renv", + "RemoteUsername: rstudio", + "RemotePkgRef: rstudio/renv", + paste("RemoteRef: ", sha), + paste("RemoteSha: ", sha) + ) + writeLines(c(desc_lines[desc_lines != ""], remotes_fields), con = desc_path) + + # Re-tar + local({ + old <- setwd(tempdir) + on.exit(setwd(old), add = TRUE) + + tar(destfile, compression = "gzip") + }) + invisible() + } + + # Extract the commit hash from a git archive. Git archives include the SHA1 + # hash as the comment field of the tarball pax extended header + # (see https://www.kernel.org/pub/software/scm/git/docs/git-archive.html) + # For GitHub archives this should be the first header after the default one + # (512 byte) header. + renv_bootstrap_git_extract_sha1_tar <- function(bundle) { + + # open the bundle for reading + # We use gzcon for everything because (from ?gzcon) + # > Reading from a connection which does not supply a ‘gzip’ magic + # > header is equivalent to reading from the original connection + conn <- gzcon(file(bundle, open = "rb", raw = TRUE)) + on.exit(close(conn)) + + # The default pax header is 512 bytes long and the first pax extended header + # with the comment should be 51 bytes long + # `52 comment=` (11 chars) + 40 byte SHA1 hash + len <- 0x200 + 0x33 + res <- rawToChar(readBin(conn, "raw", n = len)[0x201:len]) + + if (grepl("^52 comment=", res)) { + sub("52 comment=", "", res) + } else { + NULL + } + } + renv_bootstrap_install <- function(version, tarball, library) { # attempt to install it into project library - message("* Installing renv ", version, " ... ", appendLF = FALSE) dir.create(library, showWarnings = FALSE, recursive = TRUE) + output <- renv_bootstrap_install_impl(library, tarball) + + # check for successful install + status <- attr(output, "status") + if (is.null(status) || identical(status, 0L)) + return(status) + + # an error occurred; report it + header <- "installation of renv failed" + lines <- paste(rep.int("=", nchar(header)), collapse = "") + text <- paste(c(header, lines, output), collapse = "\n") + stop(text) + + } + + renv_bootstrap_install_impl <- function(library, tarball) { # invoke using system2 so we can capture and report output bin <- R.home("bin") exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" - r <- file.path(bin, exe) + R <- file.path(bin, exe) args <- c( "--vanilla", "CMD", "INSTALL", "--no-multiarch", @@ -431,19 +554,7 @@ local({ shQuote(path.expand(tarball)) ) - output <- system2(r, args, stdout = TRUE, stderr = TRUE) - message("Done!") - - # check for successful install - status <- attr(output, "status") - if (is.numeric(status) && !identical(status, 0L)) { - header <- "Error installing renv:" - lines <- paste(rep.int("=", nchar(header)), collapse = "") - text <- c(header, lines, output) - writeLines(text, con = stderr()) - } - - status + system2(R, args, stdout = TRUE, stderr = TRUE) } @@ -653,34 +764,60 @@ local({ } - renv_bootstrap_validate_version <- function(version) { + renv_bootstrap_validate_version <- function(version, description = NULL) { - loadedversion <- utils::packageDescription("renv", fields = "Version") - if (version == loadedversion) - return(TRUE) + # resolve description file + description <- description %||% { + path <- getNamespaceInfo("renv", "path") + packageDescription("renv", lib.loc = dirname(path)) + } - # assume four-component versions are from GitHub; three-component - # versions are from CRAN - components <- strsplit(loadedversion, "[.-]")[[1]] - remote <- if (length(components) == 4L) - paste("rstudio/renv", loadedversion, sep = "@") + # check whether requested version 'version' matches loaded version of renv + sha <- attr(version, "sha", exact = TRUE) + valid <- if (!is.null(sha)) + renv_bootstrap_validate_version_dev(sha, description) else - paste("renv", loadedversion, sep = "@") + renv_bootstrap_validate_version_release(version, description) + + if (valid) + return(TRUE) + + # the loaded version of renv doesn't match the requested version; + # give the user instructions on how to proceed + remote <- if (!is.null(description[["RemoteSha"]])) { + paste("rstudio/renv", description[["RemoteSha"]], sep = "@") + } else { + paste("renv", description[["Version"]], sep = "@") + } + + # display both loaded version + sha if available + friendly <- renv_bootstrap_version_friendly( + version = description[["Version"]], + sha = description[["RemoteSha"]] + ) fmt <- paste( "renv %1$s was loaded from project library, but this project is configured to use renv %2$s.", - "Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", - "Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", + "- Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", + "- Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", sep = "\n" ) - - msg <- sprintf(fmt, loadedversion, version, remote) - warning(msg, call. = FALSE) + catf(fmt, friendly, renv_bootstrap_version_friendly(version), remote) FALSE } + renv_bootstrap_validate_version_dev <- function(version, description) { + expected <- description[["RemoteSha"]] + is.character(expected) && startswith(expected, version) + } + + renv_bootstrap_validate_version_release <- function(version, description) { + expected <- description[["Version"]] + is.character(expected) && identical(expected, version) + } + renv_bootstrap_hash_text <- function(text) { hashfile <- tempfile("renv-hash-") @@ -700,6 +837,12 @@ local({ # warn if the version of renv loaded does not match renv_bootstrap_validate_version(version) + # execute renv load hooks, if any + hooks <- getHook("renv::autoload") + for (hook in hooks) + if (is.function(hook)) + tryCatch(hook(), error = warning) + # load the project renv::load(project) @@ -839,14 +982,66 @@ local({ } + renv_bootstrap_version_friendly <- function(version, sha = NULL) { + sha <- sha %||% attr(version, "sha", exact = TRUE) + parts <- c(version, sprintf("[sha: %s]", substring(sha, 1L, 7L))) + paste(parts, collapse = " ") + } + + renv_bootstrap_run <- function(version, libpath) { + + # perform bootstrap + bootstrap(version, libpath) + + # exit early if we're just testing bootstrap + if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) + return(TRUE) + + # try again to load + if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + return(renv::load(project = getwd())) + } + + # failed to download or load renv; warn the user + msg <- c( + "Failed to find an renv installation: the project will not be loaded.", + "Use `renv::activate()` to re-initialize the project." + ) + + warning(paste(msg, collapse = "\n"), call. = FALSE) + + } + + + renv_bootstrap_in_rstudio <- function() { + commandArgs()[[1]] == "RStudio" + } renv_json_read <- function(file = NULL, text = NULL) { + jlerr <- NULL + # if jsonlite is loaded, use that instead - if ("jsonlite" %in% loadedNamespaces()) - renv_json_read_jsonlite(file, text) + if ("jsonlite" %in% loadedNamespaces()) { + + json <- catch(renv_json_read_jsonlite(file, text)) + if (!inherits(json, "error")) + return(json) + + jlerr <- json + + } + + # otherwise, fall back to the default JSON reader + json <- catch(renv_json_read_default(file, text)) + if (!inherits(json, "error")) + return(json) + + # report an error + if (!is.null(jlerr)) + stop(jlerr) else - renv_json_read_default(file, text) + stop(json) } @@ -964,31 +1159,23 @@ local({ if (renv_bootstrap_load(project, libpath, version)) return(TRUE) - # load failed; inform user we're about to bootstrap - prefix <- paste("# Bootstrapping renv", version) - postfix <- paste(rep.int("-", 77L - nchar(prefix)), collapse = "") - header <- paste(prefix, postfix) - message(header) - - # perform bootstrap - bootstrap(version, libpath) - - # exit early if we're just testing bootstrap - if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) - return(TRUE) + if (renv_bootstrap_in_rstudio()) { + setHook("rstudio.sessionInit", function(...) { + renv_bootstrap_run(version, libpath) - # try again to load - if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { - message("* Successfully installed and loaded renv ", version, ".") - return(renv::load()) + # Work around buglet in RStudio if hook uses readline + tryCatch( + { + tools <- as.environment("tools:rstudio") + tools$.rs.api.sendToConsole("", echo = FALSE, focus = FALSE) + }, + error = function(cnd) {} + ) + }) + } else { + renv_bootstrap_run(version, libpath) } - # failed to download or load renv; warn the user - msg <- c( - "Failed to find an renv installation: the project will not be loaded.", - "Use `renv::activate()` to re-initialize the project." - ) - - warning(paste(msg, collapse = "\n"), call. = FALSE) + invisible() }) diff --git a/scripts/start/projects/project_EAT2.R b/scripts/start/projects/project_EAT2.R new file mode 100644 index 0000000000..1ef1c567c9 --- /dev/null +++ b/scripts/start/projects/project_EAT2.R @@ -0,0 +1,44 @@ +# | (C) 2008-2023 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: EAT 2.0 simulations +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### +library(gms) +library(lucode2) +library(magclass) + +# load start_function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# laod default configuration +source("config/default.cfg") + +# Set defaults +codeCheck <- FALSE + +################################################# +# Testing of new EAT-Lancet diet implementation # +################################################# +# Current develop default diet +cfg$title <- "default_Diet" +cfg$gms$s15_exo_diet <- 0 # default +start_run(cfg, codeCheck = codeCheck) + +# Previous EAT-Lancet implementation +cfg$title <- "eatLancet_1" +cfg$gms$s15_exo_diet <- 1 +start_run(cfg, codeCheck = codeCheck) + +# New EAT-Lancet implementation +cfg$title <- "eatLancet_2" +cfg$gms$s15_exo_diet <- 3 +start_run(cfg, codeCheck = codeCheck) diff --git a/standalone/HOWTO.md b/standalone/HOWTO.md index 98ec2668e2..6a69274151 100644 --- a/standalone/HOWTO.md +++ b/standalone/HOWTO.md @@ -4,7 +4,7 @@ Standalone models can be used to run simulations which only require a subset of modules coming with the model. It can also be used to run a module isolated from the rest of the code. -A new standalone model is created by copying the template.gms within the standalone folder to a gms file with the name of the new model. The new model file needs to include all modules relevant for the calculation (done by adding a line for each module in the "MODULE SETUP" section) and make sure that all interfaces of the modules are properly adressed. Especially, interfaces to modules not part of that reduced model need to be fed with information coming from that new model file. +A new standalone model is created by copying the template.gms within the standalone folder to a gms file with the name of the new model. The new model file needs to include all modules relevant for the calculation (done by adding a line for each module in the "MODULE SETUP" section) and make sure that all interfaces of the modules are properly addressed. Especially, interfaces to modules not part of that reduced model need to be fed with information coming from that new model file. The standalone model file needs to follow the coding etiquette as any other file, meaning that it is only allowed to interact through interfaces with the modules. This is necessary to allow the reduced model to work with all realizations of a coupled module. From 52afec653b0b16003fa2ef06320eaa67714f4c1b Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 11 Aug 2023 10:35:26 +0200 Subject: [PATCH 02/71] add standalone tests --- .../15_food/anthro_iso_jun22/declarations.gms | 50 ++---- .../15_food/anthro_iso_jun22/exodietmacro.gms | 33 ++-- modules/15_food/anthro_iso_jun22/preloop.gms | 10 +- scripts/start/projects/test_eat2_standalone.R | 23 +++ .../projects/test_fooddemand_standalone.R | 25 +++ standalone/eat2.gms | 156 ++++++++++++++++++ 6 files changed, 239 insertions(+), 58 deletions(-) create mode 100644 scripts/start/projects/test_eat2_standalone.R create mode 100644 scripts/start/projects/test_fooddemand_standalone.R create mode 100644 standalone/eat2.gms diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index 10b8d8274e..28828dfb2f 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -40,12 +40,12 @@ equations positive variables - v15_kcal_regr(iso,kfo) Uncalibrated regression estimates of calorie demand (kcal per cap per day) - v15_kcal_regr_total(iso) Uncalibrated regression estimates of total per cap calories (kcal per cap per day) - v15_demand_regr(iso, regr15) Uncalibrated regression estimates of kcal shares (1) - v15_income_pc_real_ppp_iso(iso) Real income per cap (USD05PPP per cap) - v15_income_balance(iso) Balance variable to balance cases in which reduction in income is larger than the per capita GDP (USD05PPP per cap per yr) - v15_kcal_intake_total_regr(iso) Food intake (kcal per cap per day) + v15_kcal_regr(iso,kfo) Uncalibrated regression estimates of calorie demand (kcal per cap per day) + v15_kcal_regr_total(iso) Uncalibrated regression estimates of total per cap calories (kcal per cap per day) + v15_demand_regr(iso, regr15) Uncalibrated regression estimates of kcal shares (1) + v15_income_pc_real_ppp_iso(iso) Real income per cap (USD05PPP per cap) + v15_income_balance(iso) Balance variable to balance cases in which reduction in income is larger than the per capita GDP (USD05PPP per cap per yr) + v15_kcal_intake_total_regr(iso) Food intake (kcal per cap per day) v15_regr_overgroups(iso,sex,agegroup15,bmi_tree15) Hierarchical tree parameter regressions (1) v15_bmi_shr_regr(iso,sex,age,bmi_group15) Uncalibrated share of population groups belonging to a certain BMI group (1) v15_bmi_shr_overgroups(iso,sex,agegroup15,bmi_group15) Uncalibrated share of population groups belonging to a certain BMI group (1) @@ -86,8 +86,8 @@ parameters i15_bmi_saturation(sex,agegroup15,bmi_tree15) BMI share regression saturation (1) i15_bmi_halfsat(sex,agegroup15,bmi_tree15) BMI share regression halfsaturation (1) - p15_bmi_shr_regr(t,iso,sex,age,bmi_group15) Uncalibrated regression estimates of BMI shares (1) - i15_bmi_shr_calib(t,iso,sex,age,bmi_group15) Calibration parameters to meet historical BMI shares (1) + p15_bmi_shr_regr(t,iso,sex,age,bmi_group15) Uncalibrated regression estimates of BMI shares (1) + i15_bmi_shr_calib(t,iso,sex,age,bmi_group15) Calibration parameters to meet historical BMI shares (1) i15_bmi_shr_calib_lastcalibyear(iso,sex,age,bmi_group15) Calibration parameters of the last year with historical observations (1) * diet structure @@ -154,29 +154,15 @@ parameters i15_intake_EATLancet(iso,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) i15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) + i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) + i15_fruitveg2others_kcal_ratio(t,iso) Ratio of calories from fruits and vegetables within the others food category (1) + i15_fruitveg2others_kcal_ratio_scen(t,iso) Ratio of calories from fruits and vegetables within the others food category for an exogenous diet scenario (1) + p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) + p15_intake_detail_nsothers(t,iso) Auxiliary parameter for the intake of those nuts and seeds included in others (kcal per capita per day) + i15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) + i15_intake_detailed_scen_nsothers(t,iso) Auxiliary scenario target for the intake of those nuts and seeds included in others (kcal per capita per day) -*** NEW PARAMETERS IN ISABELLE'S VERSION *** - -* transformed to iso (check whether input data is available like that) - i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) - i15_fruitveg2others_kcal_ratio(t,iso) Ratio of calories from fruits and vegetables within the others food category (1) -* why is the following needed? - i15_fruitveg2others_kcal_ratio_scen(t,iso) Ratio of calories from fruits and vegetables within the others food category for an exogenous diet scenario (1) - p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) - p15_intake_detail_nsothers(t,iso) Auxiliary parameter for the intake of those nuts and seeds included in others (kcal per capita per day) - i15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) - i15_intake_detailed_scen_nsothers(t,iso) Auxiliary scenario target for the intake of those nuts and seeds included in others (kcal per capita per day) - -* are these needed? -p15_demand2intake_ratio_ref(i) Ratio between food calorie demand and intake for the historical time step of EAT Lancet diets (1) -i15_demand2intake_detailed_ref(i,kfo) Historical ratio between food calorie demand and intake for different food commodities (1) - -*** NEW PARAMETERS IN ISABELLE'S VERSION *** - - - p15_foodwaste_growth(t,iso) Increase in food waste over time relative to the historical time step of EAT Lancet diets (1) - i15_kcal_pc_scen_target(t,iso,kfo) Target for per capita food consumption according to an exogenous diet scenario (kcal per capita per day) - i15_exo_foodscen_fader(t,iso) Fader that converges per capita food consumption to an exogenous diet scenario (1) + i15_exo_foodscen_fader(t,iso) Fader that converges per capita food consumption to an exogenous diet scenario (1) * country-specific scenario switch p15_country_dummy(iso) Dummy parameter indicating whether country is affected by diet scenarios (1) @@ -219,8 +205,6 @@ model m15_food_demand / q15_foodtree_kcal_vegetables /; - - *' In contrast, the equation `q15_food_demand` is part of MAgPIE, but *' not of the food demand model. *' @stop @@ -230,8 +214,6 @@ m15_food_demand.scaleopt = 1 ; m15_food_demand.solprint = 0 ; m15_food_demand.holdfixed = 1 ; - - *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters ov_dem_food(t,i,kall,type) Food demand (mio. tDM per yr) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 029bb1ca25..5b1969680f 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -22,7 +22,7 @@ if (s15_run_diet_postprocessing = 1, v15_kcal_regr.l(iso,kfo) + p15_kcal_calib(t,iso,kfo) * s15_calibrate; *' Negative values that can possibly occur due to calibration are set to zero. - p15_kcal_pc_iso(t,iso,kfo)$(p15_kcal_pc_iso(t,iso,kfo)<0) = 0; + p15_kcal_pc_iso(t,iso,kfo)$(p15_kcal_pc_iso(t,iso,kfo) < 0) = 0; * saving regression outcome for BMI shares p15_bmi_shr_regr(t,iso,sex,age,bmi_group15) = v15_bmi_shr_regr.l(iso,sex,age,bmi_group15); @@ -43,7 +43,6 @@ if (s15_run_diet_postprocessing = 1, *############################################################################### * ###### Food substitution scenarios - * Substitution of ruminant beef with poultry: p15_kcal_pc_iso_orig(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo); p15_kcal_pc_iso(t,iso,"livst_rum") = @@ -107,7 +106,7 @@ if (s15_run_diet_postprocessing = 1, + p15_kcal_pc_iso_rumdairy_orig(t,iso) * (1- i15_rumdairy_fadeout(t,iso))); *** Substitution of ruminant meat and dairy products (kfo_rd) with single-cell protein (SCP) based on protein/cap/day - i15_protein_to_kcal_ratio(t,kfo) = fm_nutrition_attributes(t,kfo,"protein")/fm_nutrition_attributes(t,kfo,"kcal"); + i15_protein_to_kcal_ratio(t,kfo) = fm_nutrition_attributes(t,kfo,"protein") / fm_nutrition_attributes(t,kfo,"kcal"); * Before the substitution, kfo_rd is converted from kcal/cap/day to g protein/cap/day * using i15_protein_to_kcal_ratio(t,kfo_rd). * After the substitution of kfo_rd with SCP (1-i15_rumdairy_scp_fadeout), SCP is converted @@ -170,22 +169,20 @@ if (s15_run_diet_postprocessing = 1, * food waste ratio. * To achieve maximum consistency, this calibration involves three steps. -* first apply FAO waste factors, than rescale intake proportionally to meet total intake +* First, FAO waste factors are applied and then intake is proportionally rescaled to meet total intake * This distributes the differences in waste estimates rather equally over different products - - p15_intake_detail(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo)/f15_overcons_FAOwaste(iso,kfo); + p15_intake_detail(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo) / f15_overcons_FAOwaste(iso,kfo); p15_intake_detail(t,iso,kfo)$(sum(kfo2, p15_intake_detail(t,iso,kfo2))<>0) = p15_intake_detail(t,iso,kfo) / sum(kfo2, p15_intake_detail(t,iso,kfo2))* p15_intake_total(t,iso); -* to avoid negative waste, we reduce intake where it exceed food availabiltiy +* To avoid negative waste, we reduce intake where it exceed food availabiltiy p15_intake_detail(t,iso,kfo)$(p15_intake_detail(t,iso,kfo)>p15_kcal_pc_iso(t,iso,kfo)) = p15_kcal_pc_iso(t,iso,kfo); -* in a second round of calibration, we rescale food waste to meet total food waste. +* In a second round of calibration, we rescale food waste to meet total food waste. * Now, waste is increasing only where there is already waste. - p15_waste_pc(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo) - p15_intake_detail(t,iso,kfo); p15_waste_pc(t,iso,kfo) = 0$(sum(kfo2, p15_waste_pc(t,iso,kfo2))=0) + ( @@ -196,15 +193,14 @@ if (s15_run_diet_postprocessing = 1, p15_intake_detail(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo) - p15_waste_pc(t,iso,kfo); -* the third calibration is only needed for those countries where total intake exceeds calory availabtility -* here we want to have the inconsistency in the waste, not in the intake. - +* The third calibration is only needed for those countries where total intake exceeds calory availabtility. +* Here we want to have the inconsistency in the waste, not in the intake. p15_intake_detail(t,iso,kfo)$(sum(kfo2, p15_intake_detail(t,iso,kfo2))<>0) = p15_intake_detail(t,iso,kfo) / sum(kfo2, p15_intake_detail(t,iso,kfo2))* p15_intake_total(t,iso); p15_waste_pc(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo) - p15_intake_detail(t,iso,kfo); -* we calculate a product specific demand2intake ratio +* We calculate a product specific demand2intake ratio p15_demand2intake_ratio_detail(t,iso,kfo)=1$(p15_intake_detail(t,iso,kfo) = 0) + (p15_kcal_pc_iso(t,iso,kfo) / p15_intake_detail(t,iso,kfo))$(p15_intake_detail(t,iso,kfo) > 0); @@ -216,12 +212,11 @@ if (s15_run_diet_postprocessing = 1, * ###### Exogenous EAT Lancet diet scenario *' @code -*' Transition to exogenous Planetary Health diet scenarios [@willett_food_2019]: +*' Transition to exogenous Planetary Health diet (PHD) scenarios [@willett_food_2019]: *' It is possible to define exogenous diet scenarios that replace the regression-based -*' calculation of food intake and demand according to a predefined speed of -*' convergence from `p15_kcal_pc_calibrated(t,iso,kfo)` to the scenario-dependent target -*' `i15_kcal_pc_scen_target(t,iso,kfo)` by setting the switch `s15_exo_diet` -*' to 1, 2 or 3. +*' calculation of food intake and demand scenario-dependent targets following the +*' exogenous PHDs, India-specific recommendations or model-internal intake estimates +*' that hit the PHD targets by setting the switch `s15_exo_diet` to 1, 2 or 3. if ((s15_exo_diet > 0), @@ -381,7 +376,7 @@ if (s15_exo_diet = 1, i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2)) > 0) = (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * - (i15_intake_EATLancet(iso,EAT_staples)/sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))) + (i15_intake_EATLancet(iso,EAT_staples) / sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))) ; * VARTIKA: What about s15_exo_diet = 2? Is there any special treatment needed here? diff --git a/modules/15_food/anthro_iso_jun22/preloop.gms b/modules/15_food/anthro_iso_jun22/preloop.gms index cc0750210a..b10933b160 100644 --- a/modules/15_food/anthro_iso_jun22/preloop.gms +++ b/modules/15_food/anthro_iso_jun22/preloop.gms @@ -81,12 +81,12 @@ $ifthen "%c15_exo_foodscen%" == "lin_zero_20_30" i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_EATLancet("y2030",iso,kcal_scen15,EAT_scen15,kfo); *extra condition to see if India diet scenario has been selected if (s15_exo_diet = 2, - i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_NIN("y2030",iso,kcal_scen15,EAT_scen15,kfo); + i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_NIN("y2030",iso,kcal_scen15,EAT_scen15,kfo); ); $else i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_EATLancet("y2050",iso,kcal_scen15,EAT_scen15,kfo); if (s15_exo_diet = 2, - i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_NIN("y2050",iso,kcal_scen15,EAT_scen15,kfo); + i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_NIN("y2050",iso,kcal_scen15,EAT_scen15,kfo); ); $endif @@ -95,6 +95,6 @@ i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) = f15_rec_EATLancet(iso,EA * initial prices in $US per Kcal i15_prices_initial_kcal(iso,kfo)$(fm_nutrition_attributes("y1995",kfo,"kcal")>0) = f15_prices_initial(kfo) - / (fm_nutrition_attributes("y1995",kfo,"kcal")*10**6); -p15_prices_kcal(t,iso,kfo,"iter1")=i15_prices_initial_kcal(iso,kfo); -p15_convergence_measure(t,iter15)=NA; + / (fm_nutrition_attributes("y1995",kfo,"kcal")*10**6); +p15_prices_kcal(t,iso,kfo,"iter1") = i15_prices_initial_kcal(iso,kfo); +p15_convergence_measure(t,iter15) = NA; diff --git a/scripts/start/projects/test_eat2_standalone.R b/scripts/start/projects/test_eat2_standalone.R new file mode 100644 index 0000000000..1f0bfa3acb --- /dev/null +++ b/scripts/start/projects/test_eat2_standalone.R @@ -0,0 +1,23 @@ +# | (C) 2008-2023 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: Food Demand Standalone +# ---------------------------------------------------------- + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# start MAgPIE run +source("config/default.cfg") +cfg$model <- "standalone/eat2.gms" +cfg$recalibrate <- FALSE +cfg$gms$c_timesteps <- "1" + +cfg$title <- "test1" +start_run(cfg = cfg) diff --git a/scripts/start/projects/test_fooddemand_standalone.R b/scripts/start/projects/test_fooddemand_standalone.R new file mode 100644 index 0000000000..9a3d3a07dd --- /dev/null +++ b/scripts/start/projects/test_fooddemand_standalone.R @@ -0,0 +1,25 @@ +# | (C) 2008-2023 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: Food Demand Standalone +# ---------------------------------------------------------- + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# start MAgPIE run +source("config/default.cfg") +cfg$model <- "standalone/demand_model.gms" +cfg$recalibrate <- FALSE +cfg$gms$c_timesteps <- "pastandfuture" +cfg$gms$s15_calibrate <- 1 +cfg$gms$s15_elastic_demand <- 0 + +cfg$title <- "test1" +start_run(cfg = cfg) diff --git a/standalone/eat2.gms b/standalone/eat2.gms new file mode 100644 index 0000000000..7d6655d830 --- /dev/null +++ b/standalone/eat2.gms @@ -0,0 +1,156 @@ +*** | (C) 2008-2023 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 + +* This is a standalone skeleton which should be used as template +* if only parts of the model should be run. It contains the basic, +* structural components of the model. +* To use it, please copy this file, give it an explaining name and +* save it in the "models" folder. After that you can modify it based +* on the given requirements. You can add own code, but also delete +* code (e.g. the model statement or the provided loops) if these parts +* are irrelevant for your analysis. + +$title eatLancetDiet2 + +$offupper +$offsymxref +$offsymlist +$offlisting + +$setglobal c_timesteps "1" +$setglobal c_past "till_1995" + +*******************************MODULE SETUP************************************* +$setglobal drivers aug17 +$setglobal food anthro_iso_jun22 + +***************************PREDEFINED MACROS************************************ +$include "./core/macros.gms" + +***************************BASIC SETS INDICES*********************************** +$include "./core/sets.gms" +$batinclude "./modules/include.gms" sets + +***** BENNI: What would I need that for? Isn't it enough to have them defined in the module? +*sets +* exampleset / elem1, elem2, elem3 / +*; + +**********INTRODUCE CALCULATION PARAMETERS, VARIABLES AND EQUATIONS************* +$include "./core/declarations.gms" +$batinclude "./modules/include.gms" declarations + +*parameters +* p_example(exampleset) example parameter (1) +*; + +*variables +* v_example example variable (1) +*; + +*equations +* q_example example equation (1) +*; + +*****************************IMPORT DATA FILES********************************** +$batinclude "./modules/include.gms" input + +********************OBJECTIVE FUNCTION & CONSTRAINTS**************************** +$batinclude "./modules/include.gms" equations + +*q_example .. +* v_example =g= sum(exampleset, p_example(exampleset)); + + +*******************MODEL DEFINITION & SOLVER OPTIONS**************************** +model magpie / all - m15_food_demand /; +magpie.scaleopt = 1 ; +magpie.holdfixed = 1 ; + +option lp = cplex ; +option nlp = conopt4 ; +option iterlim = 1000000 ; +option reslim = 1000000 ; +option sysout = Off ; +option savepoint = 1 ; + +*model example / q_example /; + +*****************************VARIABLE SCALING*********************************** +$batinclude "./modules/include.gms" scaling + +****************************PREPROCESSING START********************************* +* In this section everything is calculated that is not influenced by the +* optimization process. Hence these lines CAN INFLUENCE the optimization process +* but CANNOT BE INFLUENCED by it. + +$batinclude "./modules/include.gms" preloop + +*p_example(exampleset) = 1; + +* create dummy file (this is necessary to be able to use put_utility and it has +* to be done here because a file declaration cannot be inside a loop +file dummy; dummy.pw=2000; put dummy; + +************************OPTIMIZATION PROCESS START****************************** +* This section contains only sourcecode that is directly connected to the +* optimization process. That means that everything on the following lines +* INFLUENCES and IS INFLUENCED by the optimization process (except the +* redefinition on preprocessed data). +* Hence one can describe this section together with the constraints section +* as "model-core". + +* clear ct set +ct(t) = no; + +***************************TIMESTEP LOOP START********************************** +loop (t, + +* set ct to current time period + ct(t) = yes; + display "Year"; + display ct; + +$batinclude "./modules/include.gms" presolve + +* intersolve for food demand model + sm_intersolve = 0; + + while(sm_intersolve = 0, + +*************************SOLVE STATEMENT START********************************** +* #### additional phases ### +* set additional phases which should be detected by +* update_module_embeddings. Most phases will be detected automatically, +* but batincludes used within a module are not detected and therefore +* have to be set manually! (Syntax: "* !add_phase!: ") +* !add_phase!: nl_fix +* !add_phase!: nl_release +* !add_phase!: nl_relax + +$batinclude "./modules/include.gms" solve + +* intersolve for food demand model + sm_intersolve = 1; +* solve example USING lp MINIMIZING v_example; + + +$batinclude "./modules/include.gms" intersolve + + ); + +**************************SOLVE STATEMENT END*********************************** + +$batinclude "./modules/include.gms" postsolve + +**********************WRITE ALL DATA IN 1 GDX FILE****************************** + Execute_Unload "fulldata.gdx"; + +* clear ct set + ct(t) = no; +); +****************************TIMESTEP LOOP END*********************************** From f9a9b55333791bc073c3cf23fc48c5f219aede51 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 15 Aug 2023 16:48:24 +0200 Subject: [PATCH 03/71] bugfixing standalone scripts --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 6 +++--- standalone/demand_model.gms | 4 ++++ standalone/eat2.gms | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 5b1969680f..ff1b4e6e69 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -448,7 +448,7 @@ elseif s15_exo_diet = 3, *' and those nuts and seeds that are not included in rapeseed, groundnut and sunflower *****BENNI/ISABELLE: Are groundnuts nuts or pulses in the end? Or should they be anyway be a separate target (peanuts) p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso) * p15_intake_detail(t,iso,"others"); - p15_intake_detail_nsothers(t,iso) = (1-i15_fruitveg2others_kcal_ratio(t,iso)) * p15_intake_detail(t,iso,"others"); + p15_intake_detail_nsothers(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso)) * p15_intake_detail(t,iso,"others"); i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); i15_intake_detailed_scen_nsothers(t,iso) = p15_intake_detail_nsothers(t,iso); @@ -564,7 +564,7 @@ if (s15_exo_waste = 1, p15_kcal_pc(t,i,kfo)$( sum(i_to_iso(i,iso), im_pop_iso(t,iso) - ) >0 ) = + ) > 0) = sum(i_to_iso(i,iso), p15_kcal_pc_iso(t,iso,kfo) * im_pop_iso(t,iso) @@ -575,7 +575,7 @@ if (s15_exo_waste = 1, p15_balanceflow_kcal(t,i,kfo)$( sum(i_to_iso(i,iso), im_pop_iso(t,iso) - ) >0 ) = + ) > 0) = sum(i_to_iso(i,iso), p15_balanceflow_kcal_iso(t,iso,kfo) * im_pop_iso(t,iso) diff --git a/standalone/demand_model.gms b/standalone/demand_model.gms index 20c44f2abf..81fea54c9e 100644 --- a/standalone/demand_model.gms +++ b/standalone/demand_model.gms @@ -14,7 +14,11 @@ $offlisting $setglobal c_timesteps pastandfuture $setglobal c_past till_1975 +$setglobal c_title default +scalars +s_use_gdx use of gdx files / 0 / +; *******************************MODULE SETUP************************************* $setglobal drivers aug17 diff --git a/standalone/eat2.gms b/standalone/eat2.gms index 7d6655d830..3e22bdf607 100644 --- a/standalone/eat2.gms +++ b/standalone/eat2.gms @@ -23,6 +23,11 @@ $offlisting $setglobal c_timesteps "1" $setglobal c_past "till_1995" +$setglobal c_title default + +scalars +s_use_gdx use of gdx files / 0 / +; *******************************MODULE SETUP************************************* $setglobal drivers aug17 From 346022c65c0390b4fdfcfeebae643ea59e71836b Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 21 Aug 2023 12:11:47 +0200 Subject: [PATCH 04/71] included display statements for checking --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index ff1b4e6e69..7bd203ed57 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -382,7 +382,7 @@ if (s15_exo_diet = 1, * VARTIKA: What about s15_exo_diet = 2? Is there any special treatment needed here? *---------------------------------------------------------------------------------------- -elseif s15_exo_diet = 3, +elseif (s15_exo_diet = 3), *' In case of a MAgPIE-specific realization of the EAT Lancet diet (`s15_exo_diet=3`), *' model-internal diet projections are constraint by recommended ranges for intake *' (`i15_rec_EATLancet`) of different food groups to ensure healthy and sustainable @@ -403,6 +403,7 @@ elseif s15_exo_diet = 3, *** ISABELLE: Why are roots and staples used as balancing post? Roots has a target *** Also: discuss with Isabelle and Benni about splitting the roots target into potatos and cassav_sp (see Marcos distinction between starchy_fruits and roots) +display i15_rec_EATLancet; *** ISABELLE/BENNI: I think this is not required anymore (food waste calculations have changed since then) ** Use p15_intake_detail(t,iso,kfo) instead? @@ -444,6 +445,8 @@ elseif s15_exo_diet = 3, i15_fruitveg2others_kcal_ratio(t,iso) = f15_fruitveg2others_kcal_ratio(t-1,iso); ); +display i15_fruitveg2others_kcal_ratio; + *' This ratio is used to split the 'others' category into fruits plus vegetables *' and those nuts and seeds that are not included in rapeseed, groundnut and sunflower *****BENNI/ISABELLE: Are groundnuts nuts or pulses in the end? Or should they be anyway be a separate target (peanuts) @@ -499,6 +502,8 @@ elseif s15_exo_diet = 3, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); +display i15_intake_detailed_scen_target; + ); *** End of MAgPIE-specific realization of the EAT Lancet diet @@ -512,6 +517,8 @@ elseif s15_exo_diet = 3, p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) = p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) * (1-i15_exo_foodscen_fader(t,iso)) + p15_bmi_shr_target(t,iso,sex,age,bmi_group15) * i15_exo_foodscen_fader(t,iso); +display p15_intake_detail; + ); *** End of special postprocessing food demand scenarios. From 3d58d99cf9f25855d730e5de7074e15e2bad97aa Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 25 Aug 2023 12:27:21 +0200 Subject: [PATCH 05/71] added EAT2p0 start script for scenarios to be reported by MAgPIE --- .../anthropometrics_jan18/intersolve.gms | 4 +- scripts/start/projects/project_EAT2p0.R | 92 +++++++++++++++++++ 2 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 scripts/start/projects/project_EAT2p0.R diff --git a/modules/15_food/anthropometrics_jan18/intersolve.gms b/modules/15_food/anthropometrics_jan18/intersolve.gms index a8326dab0a..a554ed199f 100644 --- a/modules/15_food/anthropometrics_jan18/intersolve.gms +++ b/modules/15_food/anthropometrics_jan18/intersolve.gms @@ -223,12 +223,12 @@ p15_kcal_pc_calibrated(t,i,kfo_pp) = p15_plant_kcal_structure_orig(t,i,kfo_pp) *** Substitution of ruminant meat and dairy products (kfo_rd) with single-cell protein (SCP) based on protein/cap/day i15_protein_to_kcal_ratio(t,kfo) = fm_nutrition_attributes(t,kfo,"protein")/fm_nutrition_attributes(t,kfo,"kcal"); -* Before the substitution, kfo_rd is converted from kcal/cap/day to g protein/cap/day +* Before the substitution, kfo_rd is converted from kcal/cap/day to g protein/cap/day * using i15_protein_to_kcal_ratio(t,kfo_rd). * After the substitution of kfo_rd with SCP (1-i15_rumdairy_scp_fadeout), SCP is converted * back to kcal/cap/day using i15_protein_to_kcal_ratio(t,"scp"). p15_kcal_pc_calibrated(t,i,"scp") = p15_kcal_pc_calibrated(t,i,"scp") + - sum(kfo_rd, p15_kcal_pc_calibrated(t,i,kfo_rd) * (1-i15_rumdairy_scp_fadeout(t,i)) * + sum(kfo_rd, p15_kcal_pc_calibrated(t,i,kfo_rd) * (1-i15_rumdairy_scp_fadeout(t,i)) * i15_protein_to_kcal_ratio(t,kfo_rd)) / i15_protein_to_kcal_ratio(t,"scp"); p15_kcal_pc_calibrated(t,i,kfo_rd) = p15_kcal_pc_calibrated(t,i,kfo_rd) * i15_rumdairy_scp_fadeout(t,i); diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R new file mode 100644 index 0000000000..9783506f18 --- /dev/null +++ b/scripts/start/projects/project_EAT2p0.R @@ -0,0 +1,92 @@ +# | (C) 2008-2023 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: EAT2p0 project simulations 2023 +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(lucode2) +library(magclass) +library(gms) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# start MAgPIE runs +source("config/default.cfg") + +cfg$force_download <- FALSE + +#cfg$results_folder <- "output/:title:" +cfg$results_folder <- "output/:title::date:" + + +######################### +# 1 Baseline BAU_RCP4.5 # +######################### +# SSP: SSP2 +# Diet: BAU-SSP2 +# Waste: BAU-SSP2 +# Crop and Livestock productivity: BAU-SSP2 +# Mitigation policies: current policies +# Land-use policies: current policies +# RCP/GCM: tba +# Trade: BAU-SSP2 +cfg$title <- "BAU_RCP4p5" +cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) +start_run(cfg, codeCheck = FALSE) + +######################### +# 2 Baseline PHD_RCP4.5 # +######################### +# SSP: SSP2 +# Diet: EL2p0 +# Waste: half +# Crop and Livestock productivity: high (SSP1?) +# Mitigation policies: current policies +# Land-use policies: current policies +# RCP/GCM: tba +# Trade: BAU-SSP2 +cfg$title <- "PHD_RCP4p5" +cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) +# Diets: exogenous EATLancet diet +cfg$gms$s15_exo_diet <- 1 # Note: switch to 3 once implementation is ready +cfg$gms$c15_kcal_scen <- "healthy_BMI" +cfg$gms$c15_EAT_scen <- "FLX" +# Waste: half food waste +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_waste_scen <- 1.2 +start_run(cfg, codeCheck = FALSE) + +######################### +# 3 Baseline PHD_MIT1p9 # +######################### +# SSP: SSP2 +# Diet: EL2p0 +# Waste: half +# Crop and Livestock productivity: high (SSP1?) +# Mitigation policies: 1.5 degrees +# Land-use policies: 1.5 degrees +# RCP/GCM: tba +# Trade: BAU-SSP2 +cfg$title <- "PHD_MIT1p9" +cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) +# Diets: exogenous EATLancet diet +cfg$gms$s15_exo_diet <- 1 # Note: switch to 3 once implementation is ready +cfg$gms$c15_kcal_scen <- "healthy_BMI" +cfg$gms$c15_EAT_scen <- "FLX" +# Waste: half food waste +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_waste_scen <- 1.2 +# Mitigation +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg1300" +cfg$gms$c56_emis_policy <- "sdp_all" +start_run(cfg, codeCheck = FALSE) From 36cd9fb0b34d0802dc88a6d74d94092fb9e132df Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 29 Nov 2023 17:59:36 +0100 Subject: [PATCH 06/71] added eat2p0 reporting output script and eat2p0 start script for core and decomposition runs --- scripts/output/projects/eat2p0_report.R | 36 ++++ scripts/start/projects/project_EAT2p0.R | 272 +++++++++++++++++++----- 2 files changed, 258 insertions(+), 50 deletions(-) create mode 100644 scripts/output/projects/eat2p0_report.R diff --git a/scripts/output/projects/eat2p0_report.R b/scripts/output/projects/eat2p0_report.R new file mode 100644 index 0000000000..1e7be72a54 --- /dev/null +++ b/scripts/output/projects/eat2p0_report.R @@ -0,0 +1,36 @@ +# | (C) 2008-2023 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: extract agmip-report in rds format from run +# comparison script: FALSE +# --------------------------------------------------------------- + +library(magclass) +library(magpie4) +library(lucode2) +library(quitte) +library(gms) +options("magclass.verbosity" = 1) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- "/p/projects/landuse/users/miodrag/projects/tests/flexreg/output/H12_setup1_2016-11-23_12.38.56/" + readArgs("outputdir") +} + +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +gdx <- file.path(outputdir, "fulldata.gdx") +mif <- paste0(outputdir, "/eat2p0_report.mif") +rds <- paste0(outputdir, "/eat2p0_report.rds") +############################################################################### + +report <- getReportAgMIP(gdx, scenario = cfg$title) + +### regional aggregation +write.report(report, file = mif) +saveRDS(as.quitte(report), file = rds) diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index 9783506f18..32de97fef6 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -28,65 +28,237 @@ cfg$force_download <- FALSE #cfg$results_folder <- "output/:title:" cfg$results_folder <- "output/:title::date:" +####################### +# SCENARIO DEFINITION # +####################### +cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) -######################### -# 1 Baseline BAU_RCP4.5 # -######################### +### BAU Scenario ### # SSP: SSP2 # Diet: BAU-SSP2 # Waste: BAU-SSP2 # Crop and Livestock productivity: BAU-SSP2 # Mitigation policies: current policies # Land-use policies: current policies -# RCP/GCM: tba -# Trade: BAU-SSP2 -cfg$title <- "BAU_RCP4p5" -cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) +# RCP/GCM: 7p0 shocks on crops, livestock, labor +# Trade: BAU +bau <- function(cfg) { + ### General settings ### + # For impacts of CC on labor: + cfg$gms$factor_costs <- "sticky_labor" # @Alex/Edna/Florian: Should we use this one? + cfg$gms$labor_prod <- "exo" + cfg$gms$c37_labor_rcp <- "rcp585" # @Florian: which one to choose for RCP 7p0? + + ### Components for Decomposition ### + # Diets: exogenous EATLancet diet + cfg$gms$s15_exo_diet <- 0 # default + cfg$gms$c15_kcal_scen <- "healthy_BMI" # default (but not active b/c of s15_exo_diet = 0) + cfg$gms$c15_EAT_scen <- "FLX" # default (but not active b/c of s15_exo_diet = 0) + # Waste: half food waste + cfg$gms$s15_exo_waste <- 0 # default + cfg$gms$s15_waste_scen <- 1.2 # default (but not active b/c of s15_exo_waste = 0) + # Higher endogenous productivity achieved through lower costs + cfg$gms$tc <- "endo_jan22" # default + cfg$gms$c13_tccost <- "medium" # default + # Mitigation: no mitigation beyond NPI (NPI already set in setScenario) + cfg$gms$c56_emis_policy <- "redd+natveg_nosoil" # default # @Florian: should it be "red+natveg_nosoil" or "default" for case of current policies / no additional mitigation + cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" # default + cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" # default + # Climate Change + input['cellular'] <- "rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" + + return(cfg) +} + +### Diet component ## +# Globally achieves EL2 diet by 2050 # To Do: Check implementation +diet <- function(cfg) { + cfg$gms$s15_exo_diet <- 1 # To Do: switch to 3 once implementation is ready + cfg$gms$c15_kcal_scen <- "healthy_BMI" # default: not necessary to set it again (To Do: remove) + cfg$gms$c15_EAT_scen <- "FLX" # default: not necessary to set it again (To Do: remove) + return(cfg) +} + +### Productivity component ## +# High productivity growth rate similar to productivity trends +# associated with SSP1 (e.g., PRD 1 in Stehfest et al.) +prod <- function(cfg) { + # Higher endogenous productivity achieved through lower costs + cfg$gms$tc <- "endo_jan22" # default: not necessary to set it again (To Do: remove) + cfg$gms$c13_tccost <- "low" # Should I set it like this? @Jan? Or how was it done in Stehfest et al. PRD1? + return(cfg) +} + +### Waste component ## +# Reduction (halving) of food loss and waste +waste <- function(cfg) { + # Waste: half food waste + cfg$gms$s15_exo_waste <- 1 + cfg$gms$s15_waste_scen <- 1.2 + return(cfg) +} + +### Mitigation component ## +# Adds mitigation and land-use policies consistent with 1.5C by 2050 to BAU +miti <- function(cfg) { + # Mitigation: consistent with 1.5C + cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg1300" # @Florian: What to choose for 1.5 degrees? + cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-PkBudg1300" # @Florian: What to choose for 1.5 degrees? + cfg$gms$c56_emis_policy <- "sdp_all" # @Florian: Which emissions to price? all? + return(cfg) +} + +### NoCC component ## +# No climate change impacts +noCC <- function(cfg) { + # deactivate climate change impacts + cfg$gms$c59_som_scenario <- "nocc" + cfg$gms$c14_yields_scenario <- "nocc" + cfg$gms$c31_grassl_yld_scenario <- "nocc" # Note: anyway not active in current default. + cfg$gms$c42_watdem_scenario <- "nocc" + cfg$gms$c43_watavail_scenario <- "nocc" + cfg$gms$c52_carbon_scenario <- "nocc" + return(cfg) +} + +### RCP 2.6 ### +# Decomposition Scenario. Apply lower climate impacts based on RCP 2.6 to BAU +rcp26 <- function(cfg) { + cfg$input['cellular'] <- "rev4.94_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz" + return(cfg) +} + + +################# +# SCENARIO RUNS # +################# +# BAU # +# Business as usual scenario based on SSP2 +# with a higher climate impact reflected by RCP 7.0 +cfg$title <- "BAU" +cfg <- bau(cfg = cfg) start_run(cfg, codeCheck = FALSE) -######################### -# 2 Baseline PHD_RCP4.5 # -######################### -# SSP: SSP2 -# Diet: EL2p0 -# Waste: half -# Crop and Livestock productivity: high (SSP1?) -# Mitigation policies: current policies -# Land-use policies: current policies -# RCP/GCM: tba -# Trade: BAU-SSP2 -cfg$title <- "PHD_RCP4p5" -cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) -# Diets: exogenous EATLancet diet -cfg$gms$s15_exo_diet <- 1 # Note: switch to 3 once implementation is ready -cfg$gms$c15_kcal_scen <- "healthy_BMI" -cfg$gms$c15_EAT_scen <- "FLX" -# Waste: half food waste -cfg$gms$s15_exo_waste <- 1 -cfg$gms$s15_waste_scen <- 1.2 +# BAU_DIET # +# Decomposition scenario. Adds EL2.0 Diet to BAU: +# Globally achieves EL2 diet by 2050 # To Do: Check implemention! +cfg$title <- "BAU_DIET" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) start_run(cfg, codeCheck = FALSE) -######################### -# 3 Baseline PHD_MIT1p9 # -######################### -# SSP: SSP2 -# Diet: EL2p0 -# Waste: half -# Crop and Livestock productivity: high (SSP1?) -# Mitigation policies: 1.5 degrees -# Land-use policies: 1.5 degrees -# RCP/GCM: tba -# Trade: BAU-SSP2 -cfg$title <- "PHD_MIT1p9" -cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) -# Diets: exogenous EATLancet diet -cfg$gms$s15_exo_diet <- 1 # Note: switch to 3 once implementation is ready -cfg$gms$c15_kcal_scen <- "healthy_BMI" -cfg$gms$c15_EAT_scen <- "FLX" -# Waste: half food waste -cfg$gms$s15_exo_waste <- 1 -cfg$gms$s15_waste_scen <- 1.2 -# Mitigation -cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg1300" -cfg$gms$c56_emis_policy <- "sdp_all" +# BAU_PROD # +# Decomposition scenario adds high productivity to BAU +cfg$title <- "BAU_PROD" +cfg <- bau(cfg = cfg) +cfg <- prod(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# BAU_WAST # +# Decomposition scenario. Adds a reduction (halving) of food loss and waste +cfg$title <- "BAU_WAST" +cfg <- bau(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# BAU_RCP26 # +# Decomposition Scenario. Apply lower climate impacts based on RCP 2.6 to BAU +cfg$title <- "BAU_RCP26" +cfg <- bau(cfg = cfg) +cfg <- rcp26(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# BAU_NoCC # +# Decomposition scenario. Remove climate impacts (NoCC) from BAU to isolate climate effects +cfg$title <- "BAU_NoCC" +cfg <- bau(cfg = cfg) +cfg <- noCC(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# BAU_MITI # +# Decomposition Scenario. Adds mitigation and land-use policies consistent with 1.5C by 2050 to BAU +cfg$title <- "BAU_MITI" +cfg <- bau(cfg = cfg) +cfg <- miti(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# EL2 # +# Full EAT-Lancet Scenario (diet, productivity, FLW) without mitigation and higher climate impacts based on RCP 7.0 +cfg$title <- "EL2" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM # +# Full EAT-Lancet scenario (diet, productivity, FLW) with mitigation policies consistent with 1.5C. Climate based on a lower climate impacts with RCP 2.6 +cfg$title <- "ELM" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- rcp26(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_Diet # +# Decomposition Scenario. Removes Diet from ELM +cfg$title <- "ELM_DIET" +cfg <- bau(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- rcp26(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_PROD # +# Decomposition Scenario. Removed productivity trend from ELM +cfg$title <- "ELM_PROD" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- waste(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- rcp26(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_WAST # +# Decomposition Scenario. Removes FLW from ELM +cfg$title <- "ELM_WAST" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- rcp26(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_RCP70 # +# Decomposition Scenario. Applies RCP 7.0 climate impacts to ELM +cfg$title <- "ELM_RCP70" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +cfg <- miti(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_NoCC # +# Decomposition Scenario. Removes climate impacts (NoCC) from ELM +cfg$title <- "ELM_NoCC" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- noCC(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_MITI # +# Decomposition Scenario. Removes climate mitigation and LUC policies from ELM +cfg$title <- "ELM_MITI" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +cfg <- rcp26(cfg = cfg) start_run(cfg, codeCheck = FALSE) From bcae77d423e2a05b43a07863c5ecdb163989d079 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 29 Nov 2023 18:35:22 +0100 Subject: [PATCH 07/71] bugfix in eat2p0 start script --- scripts/start/projects/project_EAT2p0.R | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index 32de97fef6..e369ad8849 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -17,21 +17,18 @@ library(lucode2) library(magclass) library(gms) -# Load start_run(cfg) function which is needed to start MAgPIE runs +# Load start function needed to start MAgPIE runs source("scripts/start_functions.R") - -# start MAgPIE runs +# obtain settings from default config source("config/default.cfg") -cfg$force_download <- FALSE - -#cfg$results_folder <- "output/:title:" +# set title and date cfg$results_folder <- "output/:title::date:" ####################### # SCENARIO DEFINITION # ####################### -cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) +cfg <- setScenario(cfg, c("SSP2", "NPI")) ### BAU Scenario ### # SSP: SSP2 @@ -65,7 +62,7 @@ bau <- function(cfg) { cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" # default cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" # default # Climate Change - input['cellular'] <- "rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" + cfg$input['cellular'] <- "rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" return(cfg) } From 924dabd0ac13fb6ed3d0f30d20128e0c7065dedc Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 4 Dec 2023 15:41:25 +0100 Subject: [PATCH 08/71] updated EAT2p0 related start and output scripts --- scripts/output/projects/agmip_merge_report.R | 33 +++++++++------ scripts/output/projects/agmip_report.R | 4 +- scripts/start/projects/project_EAT2p0.R | 42 +++++++++++++++----- 3 files changed, 53 insertions(+), 26 deletions(-) diff --git a/scripts/output/projects/agmip_merge_report.R b/scripts/output/projects/agmip_merge_report.R index d7bf55b10d..19785491cc 100644 --- a/scripts/output/projects/agmip_merge_report.R +++ b/scripts/output/projects/agmip_merge_report.R @@ -30,35 +30,44 @@ cat("\nStarting output generation\n") missing <- NULL -if(file.exists("output/agmip_report_full.csv")) file.rename("output/agmip_report_full.csv","output/agmip_report_full.bak") +if (file.exists("output/agmip_report_full.csv")) { + file.rename("output/agmip_report_full.csv", "output/agmip_report_full.bak") +} for (i in 1:length(outputdir)) { - print(paste("Processing",outputdir[i])) + print(paste("Processing", outputdir[i])) #gdx file - rep<-file.path(outputdir[i],"agmip_report.mif") - if(file.exists(rep)) { + rep <- file.path(outputdir[i],"agmip_report.mif") + if (file.exists(rep)) { #get scenario name cfg <- gms::loadConfig(file.path(outputdir[i], "config.yml")) scen <- cfg$title #Remove prefix starting with "V", like "V2" - scen_parts <- unlist(strsplit(scen,"_")) - remove <- grep("V[0-9]",scen_parts) - if (length(remove)>0) scen <- paste(scen_parts[-remove],collapse = "_") + scen_parts <- unlist(strsplit(scen, "_")) + remove <- grep("V[0-9]", scen_parts) + if (length(remove) > 0) { + scen <- paste(scen_parts[-remove], collapse = "_") + } #read-in reporting file a <- read.report(rep,as.list = FALSE) - getNames(a,dim=1) <- scen + getNames(a, dim = 1) <- scen #add to reporting csv file - write.report(a,file="output/agmip_report_full.csv",append=TRUE,ndigit = 4,skipempty = FALSE) - } else missing <- c(missing,outputdir[i]) + write.report(a, file = "output/agmip_report_full.csv", append = TRUE, + ndigit = 4, skipempty = FALSE) + } else { + missing <- c(missing, outputdir[i]) + } } if (!is.null(missing)) { cat("\nList of folders with missing agmip_report.mif\n") print(missing) } -if(file.exists("output/agmip_report_full.csv")) { +if (file.exists("output/agmip_report_full.csv")) { #saveRDS(read.quitte("output/agmip_report_full.csv"),file = "output/agmip_report_full.rds") #agmip_report_full <- read.report(file="agmip_report_full.csv") - write.reportProject(mif="output/agmip_report_full.csv",mapping = system.file("extdata",mapping="variablemappingAgMIP.csv",package = "magpie4"), file = "output/agmip_report_subset.csv",format="AgMIP") + write.reportProject(mif = "output/agmip_report_full.csv", + mapping = system.file("extdata", mapping = "variablemappingAgMIP.csv", package = "magpie4"), + file = "output/agmip_report_subset.csv", format = "AgMIP") #write.reportProject(mif="output/agmip_report_full.csv",mapping = "mapping_magpie_agmip.csv", file = "agmip_report_subset.csv",format="AgMIP") } diff --git a/scripts/output/projects/agmip_report.R b/scripts/output/projects/agmip_report.R index 23545059d2..f16d59fe75 100644 --- a/scripts/output/projects/agmip_report.R +++ b/scripts/output/projects/agmip_report.R @@ -29,10 +29,8 @@ mif <- paste0(outputdir, "/agmip_report.mif") rds <- paste0(outputdir, "/agmip_report.rds") ############################################################################### - report <- getReportAgMIP(gdx, scenario = cfg$title) -###regional aggregation - +### regional aggregation write.report(report, file = mif) saveRDS(as.quitte(report), file = rds) diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index e369ad8849..016fee17e1 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -44,7 +44,10 @@ bau <- function(cfg) { # For impacts of CC on labor: cfg$gms$factor_costs <- "sticky_labor" # @Alex/Edna/Florian: Should we use this one? cfg$gms$labor_prod <- "exo" - cfg$gms$c37_labor_rcp <- "rcp585" # @Florian: which one to choose for RCP 7p0? + cfg$gms$c37_labor_rcp <- "rcp585" + # Note: the effect of labor impacts is very low in MAgPIE and we don't have the + # Nelson data implemented. We therefore use the existing data from LAMACLIMA + # and the scenarios rcp119 and rcp585. ### Components for Decomposition ### # Diets: exogenous EATLancet diet @@ -54,13 +57,18 @@ bau <- function(cfg) { # Waste: half food waste cfg$gms$s15_exo_waste <- 0 # default cfg$gms$s15_waste_scen <- 1.2 # default (but not active b/c of s15_exo_waste = 0) - # Higher endogenous productivity achieved through lower costs - cfg$gms$tc <- "endo_jan22" # default - cfg$gms$c13_tccost <- "medium" # default + # Default interest rate (for default productivity) + cfg$gms$s12_interest_lic <- 0.1 # default + cfg$gms$s12_interest_hic <- 0.04 # default + # Default livestock productivity + cfg$gms$c70_feed_scen <- "ssp2" # Mitigation: no mitigation beyond NPI (NPI already set in setScenario) - cfg$gms$c56_emis_policy <- "redd+natveg_nosoil" # default # @Florian: should it be "red+natveg_nosoil" or "default" for case of current policies / no additional mitigation + cfg$gms$c56_emis_policy <- "redd+natveg_nosoil" # default + cfg$path_to_report_ghgprices <- NA cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" # default + cfg$path_to_report_bioenergy <- NA cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" # default + # Climate Change cfg$input['cellular'] <- "rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" @@ -80,9 +88,12 @@ diet <- function(cfg) { # High productivity growth rate similar to productivity trends # associated with SSP1 (e.g., PRD 1 in Stehfest et al.) prod <- function(cfg) { - # Higher endogenous productivity achieved through lower costs - cfg$gms$tc <- "endo_jan22" # default: not necessary to set it again (To Do: remove) - cfg$gms$c13_tccost <- "low" # Should I set it like this? @Jan? Or how was it done in Stehfest et al. PRD1? + # Higher endogenous productivity achieved through lower interest rates + # representing more trust and therefore easier investments + cfg$gms$s12_interest_lic <- 0.06 + cfg$gms$s12_interest_hic <- 0.04 + # Livestock productivity follows SSP1 + cfg$gms$c70_feed_scen <- "ssp1" return(cfg) } @@ -97,11 +108,20 @@ waste <- function(cfg) { ### Mitigation component ## # Adds mitigation and land-use policies consistent with 1.5C by 2050 to BAU +# Note on our implementation: +# We use a GHG pricing pathway based on a peak budget of 500 with overshoot +# starting from 2020. +# Please note that with the diet shift, a lower ghg price would be necessary. +# However, to be consistent with the other models and for the decomposition +# scenarios to be "additive", we choose to use the same ghg price for all scenarios +# where miti is active. +# Reference: Humpenöder, F., Popp, A., Merfort, L., Luderer, G., Weindl, I., Bodirsky, B., Stevanović, M., Klein, D., Rodrigues, R., Bauer, N., Dietrich, J., Lotze-Campen, H., & Rockström, J. (2023). Data repository - Dietary shifts increase the feasibility of 1.5°C pathways (Version 1) [Data set]. Zenodo. https://doi.org/10.5281/zenodo.8328217 miti <- function(cfg) { # Mitigation: consistent with 1.5C - cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg1300" # @Florian: What to choose for 1.5 degrees? - cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-PkBudg1300" # @Florian: What to choose for 1.5 degrees? - cfg$gms$c56_emis_policy <- "sdp_all" # @Florian: Which emissions to price? all? + cfg$path_to_report_ghgprices <- "/p/projects/magpie/users/florianh/projects/paper/LandEnergy/modelrunsGrassland7/remind/output/C_SSP2EU-PkBudg500-rem-5/REMIND_generic_C_SSP2EU-PkBudg500-rem-5.mif" + cfg$gms$c56_pollutant_prices <- "coupling" + cfg$path_to_report_bioenergy <- "/p/projects/magpie/users/florianh/projects/paper/LandEnergy/modelrunsGrassland7/remind/output/C_SSP2EU-PkBudg500-rem-5/REMIND_generic_C_SSP2EU-PkBudg500-rem-5.mif" + cfg$gms$c60_2ndgen_biodem <- "coupling" return(cfg) } From 851e1f8dafb4e734590e97f2cc9709d5957f6b8c Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 4 Dec 2023 16:06:08 +0100 Subject: [PATCH 09/71] update agmip output script --- scripts/output/projects/agmip_report.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/output/projects/agmip_report.R b/scripts/output/projects/agmip_report.R index f16d59fe75..6d10cfd725 100644 --- a/scripts/output/projects/agmip_report.R +++ b/scripts/output/projects/agmip_report.R @@ -29,7 +29,7 @@ mif <- paste0(outputdir, "/agmip_report.mif") rds <- paste0(outputdir, "/agmip_report.rds") ############################################################################### -report <- getReportAgMIP(gdx, scenario = cfg$title) +report <- getReportAgMIP(gdx, scenario = cfg$title, detail = TRUE) ### regional aggregation write.report(report, file = mif) From d664588dc470985ae4595a1c7ee29b32e14c4045 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 4 Dec 2023 16:12:36 +0100 Subject: [PATCH 10/71] new sets in standalone food demand model --- standalone/demand_model.gms | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/standalone/demand_model.gms b/standalone/demand_model.gms index 81fea54c9e..9e336aad32 100644 --- a/standalone/demand_model.gms +++ b/standalone/demand_model.gms @@ -41,6 +41,19 @@ sets / livst_rum,livst_pig,livst_chick, livst_egg, livst_milk / + + kli_rd(kap) Ruminant meat and dairy products + / livst_rum,livst_milk / + + kap_to_kfo_ap(kap,kfo_ap) Mapping between animal products and animal food products + /livst_rum . livst_rum + livst_pig . livst_pig + livst_chick . livst_chick + livst_egg . livst_egg + livst_milk . livst_milk + fish . fish + / + ; From 2e8003c3235955cabb335867215f229c23c51709 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 5 Dec 2023 11:43:22 +0100 Subject: [PATCH 11/71] updated preprocessing for EAT runs --- scripts/start/projects/project_EAT2p0.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index 016fee17e1..87554bf481 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -70,7 +70,7 @@ bau <- function(cfg) { cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" # default # Climate Change - cfg$input['cellular'] <- "rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" + cfg$input['cellular'] <- "WARNINGS2_rev4.95_h12_c6a7458f_cellularmagpie_c200_IPSL-CM6A-LR-ssp370_lpjml-8e6c5eb1.tgz" return(cfg) } @@ -141,7 +141,7 @@ noCC <- function(cfg) { ### RCP 2.6 ### # Decomposition Scenario. Apply lower climate impacts based on RCP 2.6 to BAU rcp26 <- function(cfg) { - cfg$input['cellular'] <- "rev4.94_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz" + cfg$input['cellular'] <- "WARNINGS4_rev4.95_h12_5033a1ce_cellularmagpie_c200_IPSL-CM6A-LR-ssp126_lpjml-8e6c5eb1.tgz" return(cfg) } From f11de073438a15bfbd451e36ad7217986cbc1b5c Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 5 Dec 2023 18:21:25 +0100 Subject: [PATCH 12/71] remove TRUE argument from getReportAgMIP as it might cause error --- scripts/output/projects/agmip_report.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/output/projects/agmip_report.R b/scripts/output/projects/agmip_report.R index 6d10cfd725..f16d59fe75 100644 --- a/scripts/output/projects/agmip_report.R +++ b/scripts/output/projects/agmip_report.R @@ -29,7 +29,7 @@ mif <- paste0(outputdir, "/agmip_report.mif") rds <- paste0(outputdir, "/agmip_report.rds") ############################################################################### -report <- getReportAgMIP(gdx, scenario = cfg$title, detail = TRUE) +report <- getReportAgMIP(gdx, scenario = cfg$title) ### regional aggregation write.report(report, file = mif) From f81916680d6d5a54a6aba163a8ac9a7cf32eb72e Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 12 Dec 2023 14:59:54 +0100 Subject: [PATCH 13/71] added small amount to p15_intake_detail where sum over food products would be zero to avoid divison by zero --- config/default.cfg | 2 +- .../15_food/anthro_iso_jun22/exodietmacro.gms | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 4ea83f956d..5304dbeb84 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -424,7 +424,7 @@ cfg$gms$s15_waste_scen <- 1.2 # def = 1.2 # * Switch for transition to exogenous diet scenarios # * (EAT Lancet and National Institute of Nutrition (NIN)) # * (3): MAgPIE-specific realization of the EAT-Lancet diet, where model-internal -# * (regression-based) food demand projections are constraint by ranges for +# * (regression-based) food demand projections are constrained by ranges for # * intake targets of food groups to ensure healthy and sustainable diets as # * recommended by the EAT-Lancet Commission # * (2): transition towards exogenous diets (NIN for India and EAT for other regions) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 7bd203ed57..d838e8afab 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -384,7 +384,7 @@ if (s15_exo_diet = 1, *---------------------------------------------------------------------------------------- elseif (s15_exo_diet = 3), *' In case of a MAgPIE-specific realization of the EAT Lancet diet (`s15_exo_diet=3`), -*' model-internal diet projections are constraint by recommended ranges for intake +*' model-internal diet projections are constrained by recommended ranges for intake *' (`i15_rec_EATLancet`) of different food groups to ensure healthy and sustainable *' diets according to the EAT-Lancet Commission. After all calorie recommendations *' for non-staple food groups are satisfied, intake of staple crops is modified such @@ -400,7 +400,7 @@ elseif (s15_exo_diet = 3), *' It is, however, switched off for roots, since they will, as staples, *' later be treated as balancing post to meet total calorie intake: i15_rec_EATLancet(iso,"t_roots","max") = i15_intake_scen_target(t,iso); -*** ISABELLE: Why are roots and staples used as balancing post? Roots has a target +*** ISABELLE: Why are roots and staples used as balancing post? Roots has a target... *** Also: discuss with Isabelle and Benni about splitting the roots target into potatos and cassav_sp (see Marcos distinction between starchy_fruits and roots) display i15_rec_EATLancet; @@ -412,6 +412,14 @@ display i15_rec_EATLancet; * / (i15_calib_fsupply(i) * i15_demand2intake_detailed_ref(i,kfo) * p15_foodwaste_growth(t,i)); *i15_intake_detailed_scen_target(t,iso,kfo) = p15_intake_detailed_regr(t,i,kfo); +*' For cases where the intake in a EAT-Lancet food group is zero for a country +*' in a particular time step, a small amount is added to ensure no division by +*' zero. This way, all kfo-items in the respective food group are corrected by +*' the same amount. +p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), + sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) = 0) = + p15_intake_detail(t,iso,kfo) + 1e-6; + *' The intake target is adjusted to meet the EAT-Lancet recommendations *** Minimum recommendations *** *' If projected food intake is below minimum, it is increased it to meet @@ -421,7 +429,7 @@ display i15_rec_EATLancet; ) < sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"min")) ) = (p15_intake_detail(t,iso,kfo) / sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) - * sum(EATtar_kfo15(EAT_mtargets15,kfo),i15_rec_EATLancet(iso,EAT_mtargets15,"min")) + * sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"min")) ; *** Maximum recommendations *** @@ -432,7 +440,7 @@ display i15_rec_EATLancet; ) > sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"max")) ) = (p15_intake_detail(t,iso,kfo) / sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) - * sum(EATtar_kfo15(EAT_mtargets15,kfo),i15_rec_EATLancet(iso,EAT_mtargets15,"max")) + * sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"max")) ; *** Special case: Fruits, vegetables and nuts *** From 791c26b3889efba84a98d501dd8b0b4c8c9e8445 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 13 Dec 2023 13:38:58 +0100 Subject: [PATCH 14/71] bugfix of too many ) --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index d838e8afab..4953fb7b1c 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -413,11 +413,11 @@ display i15_rec_EATLancet; *i15_intake_detailed_scen_target(t,iso,kfo) = p15_intake_detailed_regr(t,i,kfo); *' For cases where the intake in a EAT-Lancet food group is zero for a country -*' in a particular time step, a small amount is added to ensure no division by +*' in a particular time step, a small amount is added to ensure no division by *' zero. This way, all kfo-items in the respective food group are corrected by *' the same amount. p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), - sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) = 0) = + sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2))) = 0) = p15_intake_detail(t,iso,kfo) + 1e-6; *' The intake target is adjusted to meet the EAT-Lancet recommendations From 0be1aa211ea89dac40ef9c4dcad405c86349dadf Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 20 Dec 2023 08:49:27 +0100 Subject: [PATCH 15/71] splitting cassav_sp category in starchy fruits and roots --- config/default.cfg | 8 +- .../15_food/anthro_iso_jun22/declarations.gms | 8 +- .../15_food/anthro_iso_jun22/exodietmacro.gms | 89 ++++++++++--------- modules/15_food/anthro_iso_jun22/input.gms | 4 +- modules/15_food/anthro_iso_jun22/presolve.gms | 2 +- modules/15_food/anthro_iso_jun22/sets.gms | 69 +++----------- modules/15_food/input/files | 2 +- scripts/start/projects/project_EAT2p0.R | 1 + 8 files changed, 74 insertions(+), 109 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 5304dbeb84..a115b9e681 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "rev4.95_h12_magpie.tgz", - cellular = "rev4.95_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.95_h12_validation.tgz", +cfg$input <- c(regional = "WARNINGS1_rev4.95EL2__h12_magpie.tgz", + cellular = "rev4.95EL2__h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.95EL2__h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") @@ -1274,7 +1274,7 @@ cfg$gms$c50_scen_neff_noselect <- "baseeff_add3_add5_add10_max65" # def = base # * For pastures, only two scenarios exist: a constant scenario, and one where # * the minimum NUE increases to 55,60 and 65% for 2020,2050 and 2100, to avoid -# * that pastures which dont have a nutrient deficit are fertilized +# * that pastures which do not have a nutrient deficit are fertilized # * (historical NUE may be low despite no fertilization) # * Options: # * constant, constant_min55_min60_min65 diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index 28828dfb2f..3596b74d90 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -155,10 +155,14 @@ parameters i15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) - i15_fruitveg2others_kcal_ratio(t,iso) Ratio of calories from fruits and vegetables within the others food category (1) - i15_fruitveg2others_kcal_ratio_scen(t,iso) Ratio of calories from fruits and vegetables within the others food category for an exogenous diet scenario (1) + i15_fruitveg2others_kcal_ratio(t,iso) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) + i15_fruitveg2others_kcal_ratio_scen(t,iso) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories for an exogenous diet scenario (1) + p15_intake_detail_starchyfruit(t,iso) Auxiliary parameter for the intake of starchy fruits included in cassav_sp (kcal per capita per day) + p15_intake_detail_roots(t,iso) Auxiliary parameter for the intake of roots (kcal per capita per day) p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) p15_intake_detail_nsothers(t,iso) Auxiliary parameter for the intake of those nuts and seeds included in others (kcal per capita per day) + i15_intake_detailed_scen_starchyfruit(t,iso) Auxiliary scenario target for the intake of starchy fruits included in cassav_sp (kcal per capita per day) + i15_intake_detailed_scen_roots(t,iso) Auxiliary scenario target for the intake of roots (kcal per capita per day) i15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) i15_intake_detailed_scen_nsothers(t,iso) Auxiliary scenario target for the intake of those nuts and seeds included in others (kcal per capita per day) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 4953fb7b1c..712109de02 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -174,7 +174,7 @@ if (s15_run_diet_postprocessing = 1, p15_intake_detail(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo) / f15_overcons_FAOwaste(iso,kfo); p15_intake_detail(t,iso,kfo)$(sum(kfo2, p15_intake_detail(t,iso,kfo2))<>0) = - p15_intake_detail(t,iso,kfo) / sum(kfo2, p15_intake_detail(t,iso,kfo2))* + p15_intake_detail(t,iso,kfo) / sum(kfo2, p15_intake_detail(t,iso,kfo2)) * p15_intake_total(t,iso); * To avoid negative waste, we reduce intake where it exceed food availabiltiy @@ -308,8 +308,8 @@ $elseif "%c15_kcal_scen%" == "endo" $else i15_intake_scen_target(t,iso) = sum(kfo,i15_intake_EATLancet_all(iso,"%c15_kcal_scen%","%c15_EAT_scen%",kfo)); - p15_bmi_shr_target(t,iso,sex,age,bmi_group15)=0; - p15_bmi_shr_target(t,iso,sex,age,"medium")=1; + p15_bmi_shr_target(t,iso,sex,age,bmi_group15) = 0; + p15_bmi_shr_target(t,iso,sex,age,"medium") = 1; $endif *' The intake target is adjusted to meet the calorie target @@ -395,27 +395,12 @@ elseif (s15_exo_diet = 3), *' Where maximum target is not exceeded, total scenario food intake is assigned *' to EAT-Lancet recommendation i15_rec_EATLancet(iso,EAT_targets15,"max")$(i15_rec_EATLancet(iso,EAT_targets15,"max") = 0) = i15_intake_scen_target(t,iso); -*** ISABELLE: Why does the i15_rec_EATLancet have to be overwritten, though? - -*' It is, however, switched off for roots, since they will, as staples, -*' later be treated as balancing post to meet total calorie intake: - i15_rec_EATLancet(iso,"t_roots","max") = i15_intake_scen_target(t,iso); -*** ISABELLE: Why are roots and staples used as balancing post? Roots has a target... -*** Also: discuss with Isabelle and Benni about splitting the roots target into potatos and cassav_sp (see Marcos distinction between starchy_fruits and roots) - -display i15_rec_EATLancet; - -*** ISABELLE/BENNI: I think this is not required anymore (food waste calculations have changed since then) -** Use p15_intake_detail(t,iso,kfo) instead? -* The parameter p15_intake_detailed_regr doesn't exist anymore in this realization. -*p15_intake_detailed_regr(t,i,kfo) = p15_kcal_pc_calibrated(t,i,kfo) -* / (i15_calib_fsupply(i) * i15_demand2intake_detailed_ref(i,kfo) * p15_foodwaste_growth(t,i)); -*i15_intake_detailed_scen_target(t,iso,kfo) = p15_intake_detailed_regr(t,i,kfo); - -*' For cases where the intake in a EAT-Lancet food group is zero for a country -*' in a particular time step, a small amount is added to ensure no division by -*' zero. This way, all kfo-items in the respective food group are corrected by -*' the same amount. +*** JAN: Should i15_rec_EATLancet be p15_rec_EATLancet then? + +* For cases where the intake in a EAT-Lancet food group is zero for a country +* in a particular time step, a small amount is added to ensure no division by +* zero. This way, all kfo-items in the respective food group are corrected by +* the same amount. p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2))) = 0) = p15_intake_detail(t,iso,kfo) + 1e-6; @@ -444,28 +429,51 @@ p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), ; *** Special case: Fruits, vegetables and nuts *** -*' In MAgPIE fruits, vegetables and (some) nuts are combined to the 'other' food category. +*' In MAgPIE fruits, vegetables and (some) nuts are combined to the 'other' food category; +*' and bananas and plantains are included in the 'cassav_sp' category. *' The f15_fruitveg2others_kcal_ratio gives the historical share (fixed into the future based on last historic year) -*' of fruits and vegetables in this aggregate category +*' of fruits and vegetables in this aggregate categories. if (sum(sameas(t_past,t),1) = 1, - i15_fruitveg2others_kcal_ratio(t,iso) = f15_fruitveg2others_kcal_ratio(t,iso); + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); else - i15_fruitveg2others_kcal_ratio(t,iso) = f15_fruitveg2others_kcal_ratio(t-1,iso); + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); ); -display i15_fruitveg2others_kcal_ratio; +*' Separation of starchy fruits (bananas and plantains) +*' and roots (cassava, sweet potato, yams) in the cassav_sp food category +p15_intake_detail_starchyfruit(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp") * p15_intake_detail(t,iso,"cassav_sp"); +p15_intake_detail_roots(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); + +*' Maximum recommendation for starchy fruits: +i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > i15_rec_EATLancet(iso,"t_fruitstarch","max")) + = i15_rec_EATLancet(iso,"t_fruitstarch","max"); + +*' Maximum recommendation for roots: +i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) + = i15_rec_EATLancet(iso,"t_roots","max"); + +i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) + = p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail(t,iso,"potato"); + +i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = + p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail_roots(t,iso) - + i15_intake_detailed_scen_target(t,iso,"potato") + + p15_intake_detail_starchyfruit(t,iso); -*' This ratio is used to split the 'others' category into fruits plus vegetables -*' and those nuts and seeds that are not included in rapeseed, groundnut and sunflower -*****BENNI/ISABELLE: Are groundnuts nuts or pulses in the end? Or should they be anyway be a separate target (peanuts) - p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso) * p15_intake_detail(t,iso,"others"); - p15_intake_detail_nsothers(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso)) * p15_intake_detail(t,iso,"others"); +*' Split the 'others' category into fruits plus vegetables +*' and those nuts and seeds that are not included in rapeseed and sunflower + p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + p15_intake_detail_starchyfruit(t,iso); + p15_intake_detail_nsothers(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); i15_intake_detailed_scen_nsothers(t,iso) = p15_intake_detail_nsothers(t,iso); *' Minimum recommendation for fruits and vegetables: i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) = i15_rec_EATLancet(iso,"t_fruitveg","min"); +*' Extract fruits and vegetables that are part of others categroy +* Note that starchy fruits are kept at the previously assigned maximum level +* and their amount has been added to cassav_sp already. + i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - p15_intake_detail_starchyfruit(t,iso); *' Minimum recommendation for nuts *' (a) nuts and seeds that are included in "others" @@ -474,8 +482,7 @@ display i15_fruitveg2others_kcal_ratio; = (p15_intake_detail_nsothers(t,iso) / (sum(kfo_ns,p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nsothers(t,iso))) * i15_rec_EATLancet(iso,"t_nutseeds","min") ; -*' (b) for rapeseed, groundnut, sunflower: -*** BENNI/ISABELLE: where to put groundnuts? separate? +*' (b) for rapeseed, sunflower: i15_intake_detailed_scen_target(t,iso,kfo_ns)$((sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nsothers(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) = (p15_intake_detail(t,iso,kfo_ns) / (sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nsothers(t,iso))) @@ -484,9 +491,6 @@ display i15_fruitveg2others_kcal_ratio; *' The resulting intake of the "others" category is: i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nsothers(t,iso); -* Update of the ratio of fruits and vegetables within the "others" category: - i15_fruitveg2others_kcal_ratio_scen(t,iso)$(i15_intake_detailed_scen_target(t,iso,"others") > 0) - = i15_intake_detailed_scen_fruitveg(t,iso) / i15_intake_detailed_scen_target(t,iso,"others"); * Food commodities that are not included in diet recommendations are set to zero: i15_intake_detailed_scen_target(t,iso,kfo_norec) = 0; @@ -504,8 +508,11 @@ display i15_fruitveg2others_kcal_ratio; ***** Should it be done the same way in both? (Should it be taken out of the if-condition (applied to both)?) *** Balancing calorie requirements *** -*' After all calorie recommendations for non-staple food groups are satisfied, intake of staple crops is -*' now modified such that the in step 1.) selected total calorie intake is met: +*' After all calorie recommendations for non-staple food groups are satisfied, +*' intake of staple crops is now modified such that the +*' in step 1.) selected total calorie intake is met. +*' Note that brans do not have an EAT Lancet target and are kept at their +*' original level. i15_intake_detailed_scen_target(t,iso,EAT_staples) = (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index c1ed29dede..ee21df3034 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -256,9 +256,9 @@ $ondelim $include "./modules/15_food/input/f15_targets_EATLancet_iso.cs3" $offdelim; -table f15_fruitveg2others_kcal_ratio(t_all,iso) Ratio of calories from fruits and vegetables within the others food category (1) +table f15_fruitveg2others_kcal_ratio(t_all,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) $ondelim -$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio_iso.csv" +$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio_iso.cs3" $offdelim; * This file contains exogenous dietary recommendations for India and EAT Lancet recommendations for all other regions diff --git a/modules/15_food/anthro_iso_jun22/presolve.gms b/modules/15_food/anthro_iso_jun22/presolve.gms index 2606232578..8f422f32d7 100644 --- a/modules/15_food/anthro_iso_jun22/presolve.gms +++ b/modules/15_food/anthro_iso_jun22/presolve.gms @@ -317,7 +317,7 @@ $include "./modules/15_food/anthro_iso_jun22/exodietmacro.gms"; * some calculations for postprocessing and other modules p15_kcal_pc_initial_iso(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo); pm_kcal_pc_initial(t,i,kfo) = p15_kcal_pc(t,i,kfo); -o15_kcal_regr_initial(t,iso,kfo)=v15_kcal_regr.l(iso,kfo); +o15_kcal_regr_initial(t,iso,kfo) = v15_kcal_regr.l(iso,kfo); *' @stop diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 19c01fff13..dbcb26bfeb 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -110,13 +110,10 @@ sets / oils,alcohol,sugar / kfo_ns(kfo) Food products that can be counted towards nuts and nuts_seeds - / rapeseed, groundnut, sunflower / -** BENNI/ISABELLE: Where should groundnut be counted towards? + / rapeseed, sunflower / kfo_norec(kfo) Food products that do not have an EAT-Lancet recommendation - / sugr_cane, sugr_beet, molasses, alcohol, scp / -** Note: To Do: attribute sugr_cane, sugr_bee, molasses to sugar -* ISABELLE: What about brans? + / sugr_cane, sugr_beet, molasses, alcohol / knf(kall) Non-food products in the sectoral version / oilpalm,cottn_pro,foddr, pasture, begr, betr, @@ -181,17 +178,11 @@ sets / rapeseed, sunflower, others / EAT_pulses15(kfo) pulses / soybean, puls_pro, groundnut / -** BENNI: are groundnuts nuts or pulses? -** also note: peanuts (=groundnut?) has actually a single target (shouldn't we separate it?) EAT_sugar15(kfo) sugar / sugr_cane, sugr_beet, sugar, molasses / EAT_staples(kfo) All staple food products according to EAT Lancet definition - / tece, maiz, trce, rice_pro, potato, cassav_sp / -*** ISABELLE/BENNI/MARCO: Should potato and cassav_sp be included in staples (balancing post?) -* Alternatively: -*EAT_starch(kfo) Food group starch as of EAT -* / tece, maiz, trce, rice_pro / + / tece, maiz, trce, rice_pro / EAT_nonstaples(kfo) All non-staple food products according to EAT Lancet definition / soybean, rapeseed, groundnut, sunflower, puls_pro, sugr_cane, sugr_beet, @@ -199,69 +190,31 @@ sets livst_rum, livst_pig, livst_chick, livst_egg, livst_milk, fish, others / -* Food groups for Marco's diet model (my suggestion) -* EAT_starch(kfo) Food group starch as of EAT --> different from EAT_staples (see above) -* / tece, maiz, trce, rice_pro / -* EAT_soybeans(kfo) Soybeans as of EAT --> not new set definition required -* / soybean / -* EAT_nutsseeds(kfo) Food group of nuts and seeds as of EAT -* / rapeseed, groundnut, sunflower / -**** BENNI: Is groundnut nuts or pulses? -* EAT_legumes(kfo) Legumes as of EAT -* / puls_pro / -* EAT_roots(kfo) Food group of roots as of EAT -* / potato, cassav_sp / -* EAT_sugar15(kfo) Sugar as of EAT --> same as in above code, but different from Isabelle's -* / sugr_cane, sugr_beet, sugar, molasses / -* EAT_redmeat(kfo) Food group of red meat as of EAT target -* / livst_rum, livst_pig / -* EAT_poultry(kfo) EAT target food group poultry ---> for 1:1 product, no extra set necessary -* / livst_chick / -* EAT_eggs(kfo) EAT target food group eggs ---> for 1:1 product, no extra set necessary -* / livst_egg / -* EAT_milk(kfo) EAT target food group milk -* / livst_milk / -* EAT_fish(kfo) EAT target food group fish -* / fish / -* EAT_fruits --> common target for fruits and vegetables? (just add up?) -* EAT_vegetables --> common target for fruits and vegetables? (just add up?) -* For others: check how Isabelle solved this (separation of nuts from other (based on FAO)) -* Where should oils, alcohol, brans, scp be attributed to? -* For oils (same problem!): just combine oil_palm and oil_veg to one target? (how did Isabelle solve this?) -* scp -> redmeat? -* for brans -> keep regression value? -* alcohol: 0 or default value (Lassen et al.)? - - * Isabelle's code: EAT_targettype15 Minimum or maximum target type of the EAT Lancet recommendations / min, max / EAT_targets15 Food groups as well as individual foods for which EAT Lancet targets are defined - / t_nutseeds, t_fruitveg, + / t_nutseeds, t_fruitveg, t_fruitstarch, t_roots, t_redmeat, - t_puls_pro, t_soybean, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible / t_roots, t_redmeat, - t_puls_pro, t_soybean, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + +EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio + / cassav_sp, others / EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories -* ISABELLE: Where are groundnuts? (peanuts have separate target. should we add it?) -* - / t_roots . (potato, cassav_sp) -* Note: To Do: split roots target because cassav_sp contains bananas/plantains (see Marco's model: starchy fruits) - t_redmeat . (livst_rum, livst_pig) - t_puls_pro . (puls_pro) - t_soybean . (soybean) + / t_redmeat . (livst_rum, livst_pig, scp) + t_legumes . (puls_pro, groundnut, soybean) t_fish . (fish) t_livst_chick . (livst_chick) t_livst_egg . (livst_egg) t_livst_milk . (livst_milk) t_sugar . (sugar) -* Note: To Do: add sugr_cane, sugr_beet, molasses t_oils . (oils) -* Note: To Do: double check whether the oils target contains oil_palm and oil_veg / ; diff --git a/modules/15_food/input/files b/modules/15_food/input/files index 1fa6f16081..3a2b8735ad 100644 --- a/modules/15_food/input/files +++ b/modules/15_food/input/files @@ -21,7 +21,7 @@ f15_supply2intake_ratio_FAO_iso.cs3 f15_intake_EATLancet.cs3 f15_intake_EATLancet_iso.cs3 f15_targets_EATLancet_iso.cs3 -f15_fruitveg2others_kcal_ratio_iso.csv +f15_fruitveg2others_kcal_ratio_iso.cs3 f15_food_substitution_fader.csv f15_ruminant_fadeout_india.csv f15_milk_fadeout_india.csv diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index 016fee17e1..0e3982d443 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -79,6 +79,7 @@ bau <- function(cfg) { # Globally achieves EL2 diet by 2050 # To Do: Check implementation diet <- function(cfg) { cfg$gms$s15_exo_diet <- 1 # To Do: switch to 3 once implementation is ready + cfg$gms$s15_alc_scen <- 0 # No alcohol allowed as in the definition of EATLancet cfg$gms$c15_kcal_scen <- "healthy_BMI" # default: not necessary to set it again (To Do: remove) cfg$gms$c15_EAT_scen <- "FLX" # default: not necessary to set it again (To Do: remove) return(cfg) From 9b30b182099d146594e160b99220dcb414946549 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 20 Dec 2023 09:10:49 +0100 Subject: [PATCH 16/71] bugfix dimension mismatch in fruitveg2others ratio --- modules/15_food/anthro_iso_jun22/declarations.gms | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index 3596b74d90..88122ba32f 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -155,8 +155,7 @@ parameters i15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) - i15_fruitveg2others_kcal_ratio(t,iso) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) - i15_fruitveg2others_kcal_ratio_scen(t,iso) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories for an exogenous diet scenario (1) + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) p15_intake_detail_starchyfruit(t,iso) Auxiliary parameter for the intake of starchy fruits included in cassav_sp (kcal per capita per day) p15_intake_detail_roots(t,iso) Auxiliary parameter for the intake of roots (kcal per capita per day) p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) From 60122c0d573a5a5874bad6e89ac903203f4300e2 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 20 Dec 2023 13:03:19 +0100 Subject: [PATCH 17/71] bugfix of starchyfruit --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 712109de02..1087375229 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -458,11 +458,11 @@ i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail_roots(t,iso) - i15_intake_detailed_scen_target(t,iso,"potato") + - p15_intake_detail_starchyfruit(t,iso); + i15_intake_detailed_scen_starchyfruit(t,iso); *' Split the 'others' category into fruits plus vegetables *' and those nuts and seeds that are not included in rapeseed and sunflower - p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + p15_intake_detail_starchyfruit(t,iso); + p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + i15_intake_detailed_scen_starchyfruit(t,iso); p15_intake_detail_nsothers(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); i15_intake_detailed_scen_nsothers(t,iso) = p15_intake_detail_nsothers(t,iso); @@ -473,7 +473,7 @@ i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,is *' Extract fruits and vegetables that are part of others categroy * Note that starchy fruits are kept at the previously assigned maximum level * and their amount has been added to cassav_sp already. - i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - p15_intake_detail_starchyfruit(t,iso); + i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); *' Minimum recommendation for nuts *' (a) nuts and seeds that are included in "others" From d29556a158cdbefa687b929622db7f993cab6ae0 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 20 Dec 2023 13:30:19 +0100 Subject: [PATCH 18/71] bugfix wrong staples definition with new cassava treatment in new implementation --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 2 +- modules/15_food/anthro_iso_jun22/sets.gms | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 1087375229..763b32f0ca 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -375,7 +375,7 @@ if (s15_exo_diet = 1, ); i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2)) > 0) = - (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old))) * (i15_intake_EATLancet(iso,EAT_staples) / sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))) ; diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index dbcb26bfeb..d04b7c2d73 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -183,12 +183,19 @@ sets EAT_staples(kfo) All staple food products according to EAT Lancet definition / tece, maiz, trce, rice_pro / - EAT_nonstaples(kfo) All non-staple food products according to EAT Lancet definition + + EAT_nonstaples_old(kfo) All non-staple food products according to EAT Lancet definition / soybean, rapeseed, groundnut, sunflower, puls_pro, sugr_cane, sugr_beet, oils, sugar, molasses, alcohol, brans, scp, livst_rum, livst_pig, livst_chick, livst_egg, livst_milk, fish, others / + EAT_nonstaples(kfo) All non-staple food products according to EAT Lancet definition + / soybean, rapeseed, groundnut, sunflower, puls_pro, potato, cassav_sp, + sugr_cane, sugr_beet, + oils, sugar, molasses, alcohol, brans, scp, + livst_rum, livst_pig, livst_chick, livst_egg, livst_milk, fish, + others / * Isabelle's code: EAT_targettype15 Minimum or maximum target type of the EAT Lancet recommendations From 6c130ce3e83657f07305319c1d6fca22b3fdb17d Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 4 Jan 2024 12:10:13 +0100 Subject: [PATCH 19/71] test summation mapping and parentheses --- .../15_food/anthro_iso_jun22/exodietmacro.gms | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 763b32f0ca..c2ed2c6617 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -392,19 +392,30 @@ elseif (s15_exo_diet = 3), * Note: brans is the only food commodity group that will not be affected * by the following calculations. -*' Where maximum target is not exceeded, total scenario food intake is assigned +*' Where no maximum target is assigned, total scenario food intake is assigned *' to EAT-Lancet recommendation i15_rec_EATLancet(iso,EAT_targets15,"max")$(i15_rec_EATLancet(iso,EAT_targets15,"max") = 0) = i15_intake_scen_target(t,iso); *** JAN: Should i15_rec_EATLancet be p15_rec_EATLancet then? +*** BENNI: +*Und assigned wird nicht der total food intake, sondern der (eventuell total-intake korrigierte) endogene intake. +*Ich wĂĽrde ausserdem den wert auf 9999 setzen fĂĽr fälle die man nicht erreichen will, nicht auf 0. +*Vielleicht will man ja einen max target von 0, zum beispiel bei Zucker. Ausserdem brauchst du dann auch keine sonderregel, und du kannst das ganz weglassen. +*** FELI: You mean 9999 in the file that is preprocessed? In the calcEATLancetTargets function, right? * For cases where the intake in a EAT-Lancet food group is zero for a country * in a particular time step, a small amount is added to ensure no division by * zero. This way, all kfo-items in the respective food group are corrected by * the same amount. -p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), + p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2))) = 0) = p15_intake_detail(t,iso,kfo) + 1e-6; +* Test whether sums and parentheses are set correctly +display(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,"puls_pro")))); +display(p15_intake_detail(t,iso,"puls_pro")) +display(p15_intake_detail(t,iso,"groundnut")) +display(p15_intake_detail(t,iso,"soybean")) + *' The intake target is adjusted to meet the EAT-Lancet recommendations *** Minimum recommendations *** *' If projected food intake is below minimum, it is increased it to meet @@ -455,6 +466,11 @@ i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > i15_rec_ i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail(t,iso,"potato"); +* Benni's suggestion: +*i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) +* = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); + + i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail_roots(t,iso) - i15_intake_detailed_scen_target(t,iso,"potato") + From 3ffd65b82adb2e1ee343da22a72339ff7f58f40d Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 4 Jan 2024 12:19:55 +0100 Subject: [PATCH 20/71] bugfix in display statements --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index c2ed2c6617..ebf5e1c9b0 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -412,9 +412,9 @@ elseif (s15_exo_diet = 3), * Test whether sums and parentheses are set correctly display(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,"puls_pro")))); -display(p15_intake_detail(t,iso,"puls_pro")) -display(p15_intake_detail(t,iso,"groundnut")) -display(p15_intake_detail(t,iso,"soybean")) +display(p15_intake_detail(t,iso,"puls_pro")); +display(p15_intake_detail(t,iso,"groundnut")); +display(p15_intake_detail(t,iso,"soybean")); *' The intake target is adjusted to meet the EAT-Lancet recommendations *** Minimum recommendations *** From dcd3300570cc93145f41ad9cbb17e5bdb4ace505 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 4 Jan 2024 12:32:04 +0100 Subject: [PATCH 21/71] bugfix in display statment --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index ebf5e1c9b0..ada52c85c0 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -411,10 +411,10 @@ elseif (s15_exo_diet = 3), p15_intake_detail(t,iso,kfo) + 1e-6; * Test whether sums and parentheses are set correctly -display(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,"puls_pro")))); -display(p15_intake_detail(t,iso,"puls_pro")); -display(p15_intake_detail(t,iso,"groundnut")); -display(p15_intake_detail(t,iso,"soybean")); +display sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,"puls_pro"))); +display p15_intake_detail(t,iso,"puls_pro"); +display p15_intake_detail(t,iso,"groundnut"); +display p15_intake_detail(t,iso,"soybean"); *' The intake target is adjusted to meet the EAT-Lancet recommendations *** Minimum recommendations *** From 22c8d9c07b30eada6bf5b73adc15d9e0b2ae1e82 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 5 Jan 2024 10:25:36 +0100 Subject: [PATCH 22/71] bugfixes after Benni's code review --- .../15_food/anthro_iso_jun22/exodietmacro.gms | 42 ++++++++----------- modules/15_food/anthro_iso_jun22/sets.gms | 3 +- scripts/start/projects/project_EAT2p0.R | 1 + 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index ada52c85c0..b0707c4487 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -316,6 +316,9 @@ $endif i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) > 0) = p15_intake_detail(t,iso,kfo) / p15_intake_total(t,iso) * i15_intake_scen_target(t,iso); +*** BENNI: Is this initiated correctly? (If p15_intake_total = 0, no value is written into i15_intake_detailed_scen_target. Is that a problem?) +* Am Ende fadet ja dann p15_intake_detail zu i15_intake_detailed_scen_target, d.h. wir mĂĽssen sicherstellen, dass in i15_intake_detailed_scen_target auch echt alles richtig drinsteht. + *' 2.) The second step defines the daily per capita intake of different food *' commodities. @@ -410,16 +413,11 @@ elseif (s15_exo_diet = 3), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2))) = 0) = p15_intake_detail(t,iso,kfo) + 1e-6; -* Test whether sums and parentheses are set correctly -display sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,"puls_pro"))); -display p15_intake_detail(t,iso,"puls_pro"); -display p15_intake_detail(t,iso,"groundnut"); -display p15_intake_detail(t,iso,"soybean"); - *' The intake target is adjusted to meet the EAT-Lancet recommendations *** Minimum recommendations *** -*' If projected food intake is below minimum, it is increased it to meet -*' the EAT-Lancet recommendations: +*' For food groups where direct mapping between EATLancet and MAgPIE food groups is possible, +*' projected food intake it is increased to meet the EAT-Lancet recommendations +*' if it is below the minimum recommendation: i15_intake_detailed_scen_target(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)) ) < sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"min")) @@ -429,8 +427,9 @@ display p15_intake_detail(t,iso,"soybean"); ; *** Maximum recommendations *** -*' If projected food intake is above maximum, it is decreased it to meet -*' the EAT-Lancet recommendations: +*' For food groups where direct mapping between EATLancet and MAgPIE food groups is possible, +*' projected food intake it is decreased to meet the EAT-Lancet recommendations +*' if it is above the maximum recommendation: i15_intake_detailed_scen_target(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)) ) > sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"max")) @@ -456,28 +455,24 @@ p15_intake_detail_starchyfruit(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"ca p15_intake_detail_roots(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); *' Maximum recommendation for starchy fruits: +i15_intake_detailed_scen_starchyfruit(t,iso) = p15_intake_detail_starchyfruit(t,iso); i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > i15_rec_EATLancet(iso,"t_fruitstarch","max")) = i15_rec_EATLancet(iso,"t_fruitstarch","max"); *' Maximum recommendation for roots: +i15_intake_detailed_scen_roots(t,iso) = p15_intake_detail_roots(t,iso); i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = i15_rec_EATLancet(iso,"t_roots","max"); i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) - = p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail(t,iso,"potato"); - -* Benni's suggestion: -*i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) -* = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); - + = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = - p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail_roots(t,iso) - + i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail_roots(t,iso) - i15_intake_detailed_scen_target(t,iso,"potato") + i15_intake_detailed_scen_starchyfruit(t,iso); -*' Split the 'others' category into fruits plus vegetables -*' and those nuts and seeds that are not included in rapeseed and sunflower +*' Split the 'others' category into fruits plus vegetables and nuts p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + i15_intake_detailed_scen_starchyfruit(t,iso); p15_intake_detail_nsothers(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); @@ -513,15 +508,9 @@ i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,is * Optionally, there is an exception for alcohol: * Via 's15_alc_scen' a maximum target for alcohol consumption can be defined, e.g. according to Lassen et al., (2020). if (s15_alc_scen > 0, -* first, reduce projected alcohol consumption by a quarter: - i15_intake_detailed_scen_target(t,iso,"alcohol") = p15_intake_detail(t,iso,"alcohol") * 3/4; -* if still above target, set to maximum: i15_intake_detailed_scen_target(t,iso,"alcohol")$(i15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen * i15_intake_scen_target(t,iso)) = s15_alc_scen * i15_intake_scen_target(t,iso); ); -***** ISABELLE: Why is this done in two steps? -***** BENNI: This is also done in the other EAT implementation (s15_exo_diet = 1). -***** Should it be done the same way in both? (Should it be taken out of the if-condition (applied to both)?) *** Balancing calorie requirements *** *' After all calorie recommendations for non-staple food groups are satisfied, @@ -535,6 +524,9 @@ i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,is display i15_intake_detailed_scen_target; +**** FELI: Check whether it gets negative... And come up with solution for fixing this... (Maybe via positive declaration / setting everyting that's negative to 0?) +* BENNI: What if EATLancet leads to too much calories? Just allow higher values? + ); *** End of MAgPIE-specific realization of the EAT Lancet diet diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index d04b7c2d73..b723532739 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -207,8 +207,7 @@ EAT_targets15 Food groups as well as individual foods for which EAT Lancet targe t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible - / t_roots, t_redmeat, - t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + / t_redmeat, t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio / cassav_sp, others / diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index 0e3982d443..80215d589d 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -82,6 +82,7 @@ diet <- function(cfg) { cfg$gms$s15_alc_scen <- 0 # No alcohol allowed as in the definition of EATLancet cfg$gms$c15_kcal_scen <- "healthy_BMI" # default: not necessary to set it again (To Do: remove) cfg$gms$c15_EAT_scen <- "FLX" # default: not necessary to set it again (To Do: remove) + cfg$gms$s15_alc_scen <- 0 # In EATLancet, no calories for alcohol. return(cfg) } From af41e84779283c62f612a332aad9a03cb08d241c Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 5 Jan 2024 16:34:26 +0100 Subject: [PATCH 23/71] decomposing EATLancet diet into single targets --- config/default.cfg | 26 +- .../15_food/anthro_iso_jun22/declarations.gms | 4 +- .../15_food/anthro_iso_jun22/exodietmacro.gms | 236 +++++++++++------- modules/15_food/anthro_iso_jun22/sets.gms | 40 ++- 4 files changed, 183 insertions(+), 123 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index a115b9e681..fd2e43c928 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -453,24 +453,25 @@ cfg$gms$c15_kcal_scen <- "healthy_BMI" # def = healthy_BMI # # * exogenous food-specific diet scenario (EAT Lancet diet scenarios) # * only activated if s15_exo_diet is > 0 -#******** ISABELLE/BENNI: Or is this only active for s15_exo_diet = 1???? # * options: BMK, FLX, PSC, VEG, VGN, FLX_hmilk, FLX_hredmeat cfg$gms$c15_EAT_scen <- "FLX" # def = FLX -# * Subspecifications: Which commodities shall be included in the diet shift +# * Sub-specifications: Which commodities shall be included in the diet shift # * towards cfg$gms$c15_EAT_scen ? Only selected (1) commodities will be # * included, while the others will remain to be endogenous. # * Any shift will be compensated to reach the calorie target by adjusting # * staple calories. -cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_fish <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnut <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_sugar <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_oils <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 1) +cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 1) +cfg$gms$s15_exo_redmeatdairy <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 3) +cfg$gms$s15_exo_poultry <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 3) +cfg$gms$s15_exo_fish <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnut <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_sugar <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_oils <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_brans <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet # * The EAT-Lancet diet only allows for added sugars, @@ -482,6 +483,9 @@ cfg$gms$s15_exo_alcohol <- 1 # default: 1 # * (0.014): maximum target for alcohol consumption is 1.4% of total calorie consumption # * (see Lassen et al., 2020) cfg$gms$s15_alc_scen <- 0.014 # def = 0.014 +# FELI: I would strongly suggest to set it to 0 because otherwise it is not in line with EATLancet, +# but that would be what the user expects! It would be better if the user manually has to set it to 0.014 +# when (s)he wants to divert from the standard EATLancet setting! # # # * Switch and specification of countries for which exogenous food scenarios diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index 88122ba32f..0aac72e28e 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -159,11 +159,11 @@ parameters p15_intake_detail_starchyfruit(t,iso) Auxiliary parameter for the intake of starchy fruits included in cassav_sp (kcal per capita per day) p15_intake_detail_roots(t,iso) Auxiliary parameter for the intake of roots (kcal per capita per day) p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) - p15_intake_detail_nsothers(t,iso) Auxiliary parameter for the intake of those nuts and seeds included in others (kcal per capita per day) + p15_intake_detail_nuts(t,iso) Auxiliary parameter for the intake of nuts included in others (kcal per capita per day) i15_intake_detailed_scen_starchyfruit(t,iso) Auxiliary scenario target for the intake of starchy fruits included in cassav_sp (kcal per capita per day) i15_intake_detailed_scen_roots(t,iso) Auxiliary scenario target for the intake of roots (kcal per capita per day) i15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) - i15_intake_detailed_scen_nsothers(t,iso) Auxiliary scenario target for the intake of those nuts and seeds included in others (kcal per capita per day) + i15_intake_detailed_scen_nuts(t,iso) Auxiliary scenario target for the intake of nuts included in others (kcal per capita per day) i15_exo_foodscen_fader(t,iso) Fader that converges per capita food consumption to an exogenous diet scenario (1) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index b0707c4487..6477237d56 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -338,7 +338,7 @@ if (s15_exo_diet = 1, i15_intake_EATLancet(iso,kfo) = i15_intake_EATLancet_all(iso,"2100kcal","%c15_EAT_scen%",kfo); -*' upper bound for monogastric meat +*' upper bound for monogastric meat and eggs if (s15_exo_monogastric=1, i15_intake_detailed_scen_target(t,iso,EAT_monogastrics15)$(i15_intake_detailed_scen_target(t,iso,EAT_monogastrics15) > i15_intake_EATLancet(iso,EAT_monogastrics15)) = i15_intake_EATLancet(iso,EAT_monogastrics15)); @@ -382,7 +382,9 @@ if (s15_exo_diet = 1, (i15_intake_EATLancet(iso,EAT_staples) / sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))) ; -* VARTIKA: What about s15_exo_diet = 2? Is there any special treatment needed here? +* VARTIKA: What about s15_exo_diet = 2? +* Can this be transformed to the new diet implementation? Did you have target values there? +* (Note: The old EATLancet implementation should be deleted soon.) *---------------------------------------------------------------------------------------- elseif (s15_exo_diet = 3), @@ -395,16 +397,6 @@ elseif (s15_exo_diet = 3), * Note: brans is the only food commodity group that will not be affected * by the following calculations. -*' Where no maximum target is assigned, total scenario food intake is assigned -*' to EAT-Lancet recommendation - i15_rec_EATLancet(iso,EAT_targets15,"max")$(i15_rec_EATLancet(iso,EAT_targets15,"max") = 0) = i15_intake_scen_target(t,iso); -*** JAN: Should i15_rec_EATLancet be p15_rec_EATLancet then? -*** BENNI: -*Und assigned wird nicht der total food intake, sondern der (eventuell total-intake korrigierte) endogene intake. -*Ich wĂĽrde ausserdem den wert auf 9999 setzen fĂĽr fälle die man nicht erreichen will, nicht auf 0. -*Vielleicht will man ja einen max target von 0, zum beispiel bei Zucker. Ausserdem brauchst du dann auch keine sonderregel, und du kannst das ganz weglassen. -*** FELI: You mean 9999 in the file that is preprocessed? In the calcEATLancetTargets function, right? - * For cases where the intake in a EAT-Lancet food group is zero for a country * in a particular time step, a small amount is added to ensure no division by * zero. This way, all kfo-items in the respective food group are corrected by @@ -412,105 +404,176 @@ elseif (s15_exo_diet = 3), p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2))) = 0) = p15_intake_detail(t,iso,kfo) + 1e-6; +* FELI: Check whether this is still necessary when the targets are split + +*' The single targets can also be set manually via switches +*' (e.g., s15_exo_ruminant, s15_exo_fish, etc.). + +*' upper bound for chicken and eggs + if (s15_exo_poultry = 1, +* upper bound for eggs + i15_intake_detailed_scen_target(t,iso,"livst_egg")$(p15_intake_detail(t,iso,"livst_egg") + > i15_rec_EATLancet(iso,"t_livst_egg","max")) + ) = + i15_rec_EATLancet(iso,"t_livst_egg","max"); + +* upper bound for chicken + i15_intake_detailed_scen_target(t,iso,"livst_chick")$(p15_intake_detail(t,iso,"livst_chick") + > i15_rec_EATLancet(iso,"t_livst_chick","max")) + ) = + i15_rec_EATLancet(iso,"t_livst_chick","max"); + ); + +*' upper bound for redmeat and milk + if (s15_exo_redmeatdairy = 1, +* upper bound for redmeat (pig and ruminant) + i15_intake_detailed_scen_target(t,iso,EAT_redmeat15)$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) + > i15_rec_EATLancet(iso,"t_redmeat","max") + ) = + (p15_intake_detail(t,iso,EAT_redmeat15) / sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2))) + * i15_rec_EATLancet(iso,"t_redmeat","max"); +* upper bound for milk + i15_intake_detailed_scen_target(t,iso,"livst_milk")$(p15_intake_detail(t,iso,"livst_milk") + > i15_rec_EATLancet(iso,"t_livst_milk","max")) + ) = + i15_rec_EATLancet(iso,"t_livst_milk","max"); + ); -*' The intake target is adjusted to meet the EAT-Lancet recommendations -*** Minimum recommendations *** -*' For food groups where direct mapping between EATLancet and MAgPIE food groups is possible, -*' projected food intake it is increased to meet the EAT-Lancet recommendations -*' if it is below the minimum recommendation: - i15_intake_detailed_scen_target(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), - sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)) - ) < sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"min")) - ) = - (p15_intake_detail(t,iso,kfo) / sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) - * sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"min")) - ; - -*** Maximum recommendations *** -*' For food groups where direct mapping between EATLancet and MAgPIE food groups is possible, -*' projected food intake it is decreased to meet the EAT-Lancet recommendations -*' if it is above the maximum recommendation: - i15_intake_detailed_scen_target(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), - sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)) - ) > sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"max")) - ) = - (p15_intake_detail(t,iso,kfo) / sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) - * sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"max")) - ; +*' lower bound for fish + if (s15_exo_fish = 1, + i15_intake_detailed_scen_target(t,iso,"fish")$(p15_intake_detail(t,iso,"fish") + < i15_rec_EATLancet(iso,"t_fish","min") + ) = + i15_rec_EATLancet(iso,"t_fish","min"); + ); +*' lower bound for fruits, veggies, nuts and seeds +*' and upper bound for starchy fruits and roots + if (s15_exo_fruitvegnut = 1, *** Special case: Fruits, vegetables and nuts *** -*' In MAgPIE fruits, vegetables and (some) nuts are combined to the 'other' food category; -*' and bananas and plantains are included in the 'cassav_sp' category. +*' In MAgPIE fruits, vegetables and nuts are combined in the 'other' food category; +*' Bananas and plantains are included in the 'cassav_sp' category. *' The f15_fruitveg2others_kcal_ratio gives the historical share (fixed into the future based on last historic year) -*' of fruits and vegetables in this aggregate categories. - if (sum(sameas(t_past,t),1) = 1, - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); - else - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); - ); +*' of fruits and vegetables in these aggregate categories. + if (sum(sameas(t_past,t),1) = 1, + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); + else + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); + ); *' Separation of starchy fruits (bananas and plantains) *' and roots (cassava, sweet potato, yams) in the cassav_sp food category -p15_intake_detail_starchyfruit(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp") * p15_intake_detail(t,iso,"cassav_sp"); -p15_intake_detail_roots(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); + p15_intake_detail_starchyfruit(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp") * p15_intake_detail(t,iso,"cassav_sp"); + p15_intake_detail_roots(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); *' Maximum recommendation for starchy fruits: -i15_intake_detailed_scen_starchyfruit(t,iso) = p15_intake_detail_starchyfruit(t,iso); -i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > i15_rec_EATLancet(iso,"t_fruitstarch","max")) - = i15_rec_EATLancet(iso,"t_fruitstarch","max"); + i15_intake_detailed_scen_starchyfruit(t,iso) = p15_intake_detail_starchyfruit(t,iso); + i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > i15_rec_EATLancet(iso,"t_fruitstarch","max")) + = i15_rec_EATLancet(iso,"t_fruitstarch","max"); *' Maximum recommendation for roots: -i15_intake_detailed_scen_roots(t,iso) = p15_intake_detail_roots(t,iso); -i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) - = i15_rec_EATLancet(iso,"t_roots","max"); + i15_intake_detailed_scen_roots(t,iso) = p15_intake_detail_roots(t,iso); + i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) + = i15_rec_EATLancet(iso,"t_roots","max"); -i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) - = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); + i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) + = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); -i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = - i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail_roots(t,iso) - - i15_intake_detailed_scen_target(t,iso,"potato") + - i15_intake_detailed_scen_starchyfruit(t,iso); + i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = + i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail_roots(t,iso) - + i15_intake_detailed_scen_target(t,iso,"potato") + + i15_intake_detailed_scen_starchyfruit(t,iso); *' Split the 'others' category into fruits plus vegetables and nuts - p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + i15_intake_detailed_scen_starchyfruit(t,iso); - p15_intake_detail_nsothers(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); - i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); - i15_intake_detailed_scen_nsothers(t,iso) = p15_intake_detail_nsothers(t,iso); + p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + i15_intake_detailed_scen_starchyfruit(t,iso); + p15_intake_detail_nuts(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); + i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); + i15_intake_detailed_scen_nuts(t,iso) = p15_intake_detail_nuts(t,iso); *' Minimum recommendation for fruits and vegetables: - i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) - = i15_rec_EATLancet(iso,"t_fruitveg","min"); + i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) + = i15_rec_EATLancet(iso,"t_fruitveg","min"); *' Extract fruits and vegetables that are part of others categroy * Note that starchy fruits are kept at the previously assigned maximum level * and their amount has been added to cassav_sp already. - i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); - -*' Minimum recommendation for nuts -*' (a) nuts and seeds that are included in "others" - i15_intake_detailed_scen_nsothers(t,iso)$((sum(kfo_ns, p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nsothers(t,iso) - ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail_nsothers(t,iso) / (sum(kfo_ns,p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nsothers(t,iso))) - * i15_rec_EATLancet(iso,"t_nutseeds","min") - ; + i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); + +*' Minimum recommendation for nuts & seeds +*' (a) nuts included in "others" + i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_seeds, p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso) + ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) + = (p15_intake_detail_nuts(t,iso) / (sum(kfo_seeds,p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso))) + * i15_rec_EATLancet(iso,"t_nutseeds","min") + ; +*FELI: Check here! I think something is wrong with the set!!! + *' (b) for rapeseed, sunflower: - i15_intake_detailed_scen_target(t,iso,kfo_ns)$((sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nsothers(t,iso) - ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail(t,iso,kfo_ns) / (sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nsothers(t,iso))) - * i15_rec_EATLancet(iso,"t_nutseeds","min") - ; + i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2,p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso) + ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) + = (p15_intake_detail(t,iso,kfo_seeds) / (sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso))) + * i15_rec_EATLancet(iso,"t_nutseeds","min") + ; *' The resulting intake of the "others" category is: - i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nsothers(t,iso); + i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); + ); + +*' lower bound for legumes + if (s15_exo_pulses = 1, + i15_intake_detailed_scen_target(t,iso,EAT_pulses15)$(sum(EAT_pulses15_2, p15_intake_detail(t,iso,EAT_pulses15_2)) + < i15_rec_EATLancet(iso,"t_legumes","min") + ) = + (p15_intake_detail(t,iso,EAT_pulses15) / sum(EAT_pulses15_2, p15_intake_detail(t,iso,EAT_pulses15_2))) + * i15_rec_EATLancet(iso,"t_legumes","min"); + ); + +*' upper bound for sugar + if (s15_exo_sugar = 1, + i15_intake_detailed_scen_target(t,iso,"sugar")$(p15_intake_detail(t,iso,"sugar") + > i15_rec_EATLancet(iso,"t_sugar","max")) + ) = + i15_rec_EATLancet(iso,"t_sugar","max"); + ); + +*' upper and lower bound for oils + if (s15_exo_oils = 1, +* i15_intake_detailed_scen_target(t,iso,"oils") = i15_intake_EATLancet(iso,"oils") +* oil_veg has a minimum and maximum recommendation in EAT + i15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") + < i15_rec_EATLancet(iso,"t_oils","min") + ) = + i15_rec_EATLancet(iso,"t_oils","min"); + +* oil palm has a maximum recommendation in EAT + i15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") + > i15_rec_EATLancet(iso,"t_oils","max")) + ) = + i15_rec_EATLancet(iso,"t_oils","max"); + ); + * Food commodities that are not included in diet recommendations are set to zero: - i15_intake_detailed_scen_target(t,iso,kfo_norec) = 0; -* Optionally, there is an exception for alcohol: -* Via 's15_alc_scen' a maximum target for alcohol consumption can be defined, e.g. according to Lassen et al., (2020). - if (s15_alc_scen > 0, - i15_intake_detailed_scen_target(t,iso,"alcohol")$(i15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen * i15_intake_scen_target(t,iso)) - = s15_alc_scen * i15_intake_scen_target(t,iso); - ); + i15_intake_detailed_scen_target(t,iso,kfo_norec) = 0; + +* Optionally, there is an exception for alcohol if s15_exo_alcohol = 1: +* Even though it would be 0 following the EAT Lancet recommendation, +* an alternative maximum target can be set via 's15_alc_scen' for alcohol consumption, +* e.g. following the recommendation according to Lassen et al., (2020). + if (s15_exo_alcohol = 1, + i15_intake_detailed_scen_target(t,iso,"alcohol")$(i15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen * i15_intake_scen_target(t,iso)) + = s15_alc_scen * i15_intake_scen_target(t,iso); + ); +*' There is no explicit target for brans in the EATLancet recommendations. +*' It is therefore set to 0. +*** BENNI: Why was this decided in the previous implementation? My approach would have been to keep it at the current level / including it as part of staples. + if (s15_exo_brans = 1, + i15_intake_detailed_scen_target(t,iso,"brans") = 0; + ); +*' There is no explicit target for single cell protein in the EATLancet recommendations. +*' It is therefore set to 0. + if (s15_exo_scp = 1, + i15_intake_detailed_scen_target(t,iso,"scp") = 0; + ); *** Balancing calorie requirements *** *' After all calorie recommendations for non-staple food groups are satisfied, @@ -526,6 +589,7 @@ display i15_intake_detailed_scen_target; **** FELI: Check whether it gets negative... And come up with solution for fixing this... (Maybe via positive declaration / setting everyting that's negative to 0?) * BENNI: What if EATLancet leads to too much calories? Just allow higher values? +* JAN: Can a parameter be declared as positive? Or only variables? ); *** End of MAgPIE-specific realization of the EAT Lancet diet diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index b723532739..f2030daa47 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -109,7 +109,7 @@ sets kfo_pf(kfo) Processed foods including oils sugar alcohol / oils,alcohol,sugar / - kfo_ns(kfo) Food products that can be counted towards nuts and nuts_seeds + kfo_seeds(kfo) Food products that are counted towards seeds / rapeseed, sunflower / kfo_norec(kfo) Food products that do not have an EAT-Lancet recommendation @@ -174,6 +174,8 @@ sets / livst_pig, livst_egg, livst_chick / EAT_ruminants15(kfo) ruminant products / livst_milk, livst_rum / + EAT_redmeat15(kfo) + / livest_rum, livst_pig / EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds / rapeseed, sunflower, others / EAT_pulses15(kfo) pulses @@ -212,28 +214,18 @@ EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MA EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio / cassav_sp, others / -EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories - / t_redmeat . (livst_rum, livst_pig, scp) - t_legumes . (puls_pro, groundnut, soybean) - t_fish . (fish) - t_livst_chick . (livst_chick) - t_livst_egg . (livst_egg) - t_livst_milk . (livst_milk) - t_sugar . (sugar) - t_oils . (oils) - / - ; -alias(kst,kst2); -alias(bmi_group15,bmi_group15_2); -alias(kfo,kfo2); -alias(kfo_ap,kfo_ap2); -alias(kfo_st,kfo_st2); -alias(kfo_pf,kfo_pf2); -alias(kfo_ns,kfo_ns2); -alias(iso,iso2); -alias(reproductive,reproductive2); -alias(EAT_staples,EAT_staples2); -alias(EAT_mtargets15,EAT_mtargets15_2); -alias(EATtar_kfo15,EATtar_kfo15_2); +alias(kst, kst2); +alias(bmi_group15, bmi_group15_2); +alias(kfo, kfo2); +alias(kfo_ap, kfo_ap2); +alias(kfo_st, kfo_st2); +alias(kfo_pf, kfo_pf2); +alias(kfo_seeds, kfo_seeds2); +alias(iso, iso2); +alias(reproductive, reproductive2); +alias(EAT_staples, EAT_staples2); +alias(EAT_pulses15, EAT_pulses15_2); +alias(EAT_redmeat15, EAT_redmeat15_2) +alias(EAT_mtargets15, EAT_mtargets15_2); From ddabcecd0894ffa27b530fcbc9652e9d746ba64a Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 5 Jan 2024 17:01:40 +0100 Subject: [PATCH 24/71] correct typo --- modules/15_food/anthro_iso_jun22/sets.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index f2030daa47..eadc741589 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -175,7 +175,7 @@ sets EAT_ruminants15(kfo) ruminant products / livst_milk, livst_rum / EAT_redmeat15(kfo) - / livest_rum, livst_pig / + / livst_rum, livst_pig / EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds / rapeseed, sunflower, others / EAT_pulses15(kfo) pulses From 245c11b73b11d05d30b9d6b8cf13cf2d0996ab61 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 8 Jan 2024 11:44:21 +0100 Subject: [PATCH 25/71] re-introduced mapping between magpie and eat categories for division by zero avoidance constraint --- modules/15_food/anthro_iso_jun22/sets.gms | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index eadc741589..a0dc886c24 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -214,6 +214,18 @@ EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MA EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio / cassav_sp, others / + +EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories + / t_redmeat . (livst_rum, livst_pig, scp) + t_legumes . (puls_pro, groundnut, soybean) + t_fish . (fish) + t_livst_chick . (livst_chick) + t_livst_egg . (livst_egg) + t_livst_milk . (livst_milk) + t_sugar . (sugar) + t_oils . (oils) + / + ; alias(kst, kst2); @@ -227,5 +239,6 @@ alias(iso, iso2); alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); alias(EAT_pulses15, EAT_pulses15_2); -alias(EAT_redmeat15, EAT_redmeat15_2) +alias(EAT_redmeat15, EAT_redmeat15_2); +alias(EATtar_kfo15, EATtar_kfo15_2); alias(EAT_mtargets15, EAT_mtargets15_2); From 3ab7734e9d60307ebe9e7d81edcb8b08d608f3ea Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 8 Jan 2024 14:29:32 +0100 Subject: [PATCH 26/71] updated preprocessing tgzs --- config/default.cfg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index fd2e43c928..f7730e2d51 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "WARNINGS1_rev4.95EL2__h12_magpie.tgz", - cellular = "rev4.95EL2__h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.95EL2__h12_validation.tgz", +cfg$input <- c(regional = "WARNINGS30_rev4.96EAT2p0_h12_magpie.tgz", + cellular = "rev4.96EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.96EAT2p0_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") From ce560c6fdd9372b6f4a12bdc3e604f7a52a4e6bd Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 9 Jan 2024 10:05:34 +0100 Subject: [PATCH 27/71] bugfixes in new DietImplementation with target separation --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 10 +++++----- modules/15_food/anthro_iso_jun22/input.gms | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 6477237d56..46f009ff12 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -413,13 +413,13 @@ elseif (s15_exo_diet = 3), if (s15_exo_poultry = 1, * upper bound for eggs i15_intake_detailed_scen_target(t,iso,"livst_egg")$(p15_intake_detail(t,iso,"livst_egg") - > i15_rec_EATLancet(iso,"t_livst_egg","max")) + > i15_rec_EATLancet(iso,"t_livst_egg","max") ) = i15_rec_EATLancet(iso,"t_livst_egg","max"); * upper bound for chicken i15_intake_detailed_scen_target(t,iso,"livst_chick")$(p15_intake_detail(t,iso,"livst_chick") - > i15_rec_EATLancet(iso,"t_livst_chick","max")) + > i15_rec_EATLancet(iso,"t_livst_chick","max") ) = i15_rec_EATLancet(iso,"t_livst_chick","max"); ); @@ -434,7 +434,7 @@ elseif (s15_exo_diet = 3), * i15_rec_EATLancet(iso,"t_redmeat","max"); * upper bound for milk i15_intake_detailed_scen_target(t,iso,"livst_milk")$(p15_intake_detail(t,iso,"livst_milk") - > i15_rec_EATLancet(iso,"t_livst_milk","max")) + > i15_rec_EATLancet(iso,"t_livst_milk","max") ) = i15_rec_EATLancet(iso,"t_livst_milk","max"); ); @@ -530,7 +530,7 @@ elseif (s15_exo_diet = 3), *' upper bound for sugar if (s15_exo_sugar = 1, i15_intake_detailed_scen_target(t,iso,"sugar")$(p15_intake_detail(t,iso,"sugar") - > i15_rec_EATLancet(iso,"t_sugar","max")) + > i15_rec_EATLancet(iso,"t_sugar","max") ) = i15_rec_EATLancet(iso,"t_sugar","max"); ); @@ -546,7 +546,7 @@ elseif (s15_exo_diet = 3), * oil palm has a maximum recommendation in EAT i15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") - > i15_rec_EATLancet(iso,"t_oils","max")) + > i15_rec_EATLancet(iso,"t_oils","max") ) = i15_rec_EATLancet(iso,"t_oils","max"); ); diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index ee21df3034..ffbc06e32f 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -97,6 +97,8 @@ scalar s15_exo_diet Switch for transition towards exogenous diet scenario (1) / * If the switch is set to 1,the exogenous diets are activated. * For all other settings (!=1), the endogenous estimate is used. * When activating a target, total calories are always preserved via scaling of staples +scalar s15_exo_poultry Exogenous EAT Lancet animal product target on (1) / 1 /; +scalar s15_exo_redmeatdairy Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_monogastric Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_ruminant Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_fish Exogenous EAT Lancet animal product target on (1) / 1 /; From 37e3537162d241db84fe032f25a7d139370725c8 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 9 Jan 2024 18:00:05 +0100 Subject: [PATCH 28/71] groundnuts is allocated to nuts because of dietary target --- .../15_food/anthro_iso_jun22/exodietmacro.gms | 20 ++++++++++++------- modules/15_food/anthro_iso_jun22/sets.gms | 11 +++++----- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 46f009ff12..65a72f38dc 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -406,6 +406,9 @@ elseif (s15_exo_diet = 3), p15_intake_detail(t,iso,kfo) + 1e-6; * FELI: Check whether this is still necessary when the targets are split +* To Do: transform i15_intake_detailed_scen_target and i15_intake_scen_target and p15_intake_detail +* to grams using i15_protein_to_kcal_ratio + *' The single targets can also be set manually via switches *' (e.g., s15_exo_ruminant, s15_exo_fish, etc.). @@ -500,17 +503,16 @@ elseif (s15_exo_diet = 3), *' Minimum recommendation for nuts & seeds *' (a) nuts included in "others" - i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_seeds, p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso) + i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_ns, p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail_nuts(t,iso) / (sum(kfo_seeds,p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso))) + = (p15_intake_detail_nuts(t,iso) / (sum(kfo_ns,p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nuts(t,iso))) * i15_rec_EATLancet(iso,"t_nutseeds","min") ; -*FELI: Check here! I think something is wrong with the set!!! -*' (b) for rapeseed, sunflower: - i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2,p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso) +*' (b) for other nuts (groundnut) and seeds (rapeseed, sunflower): + i15_intake_detailed_scen_target(t,iso,kfo_ns)$((sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail(t,iso,kfo_seeds) / (sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso))) + = (p15_intake_detail(t,iso,kfo_ns) / (sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) * i15_rec_EATLancet(iso,"t_nutseeds","min") ; @@ -565,7 +567,7 @@ elseif (s15_exo_diet = 3), ); *' There is no explicit target for brans in the EATLancet recommendations. *' It is therefore set to 0. -*** BENNI: Why was this decided in the previous implementation? My approach would have been to keep it at the current level / including it as part of staples. +*** BENNI: Why was this decided in the previous implementation? My approach would have been to keep it at the current level or including it as part of staples. if (s15_exo_brans = 1, i15_intake_detailed_scen_target(t,iso,"brans") = 0; ); @@ -575,6 +577,10 @@ elseif (s15_exo_diet = 3), i15_intake_detailed_scen_target(t,iso,"scp") = 0; ); + +* To Do: transform i15_intake_detailed_scen_target and i15_intake_scen_target and p15_intake_detail +* back to kcal using i15_protein_to_kcal_ratio + *** Balancing calorie requirements *** *' After all calorie recommendations for non-staple food groups are satisfied, *' intake of staple crops is now modified such that the diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index a0dc886c24..dda75b79ed 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -109,8 +109,9 @@ sets kfo_pf(kfo) Processed foods including oils sugar alcohol / oils,alcohol,sugar / - kfo_seeds(kfo) Food products that are counted towards seeds - / rapeseed, sunflower / +* Note: From a nutritional perspective, groundnut counts towards nuts + kfo_ns(kfo) Food products that are counted towards nuts and seeds + / rapeseed, sunflower, groundnut/ kfo_norec(kfo) Food products that do not have an EAT-Lancet recommendation / sugr_cane, sugr_beet, molasses, alcohol / @@ -179,7 +180,7 @@ sets EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds / rapeseed, sunflower, others / EAT_pulses15(kfo) pulses - / soybean, puls_pro, groundnut / + / soybean, puls_pro / EAT_sugar15(kfo) sugar / sugr_cane, sugr_beet, sugar, molasses / @@ -217,7 +218,7 @@ EAT_special MAgPIE food groups that need special treatment with respect to fruit EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories / t_redmeat . (livst_rum, livst_pig, scp) - t_legumes . (puls_pro, groundnut, soybean) + t_legumes . (puls_pro, soybean) t_fish . (fish) t_livst_chick . (livst_chick) t_livst_egg . (livst_egg) @@ -234,7 +235,7 @@ alias(kfo, kfo2); alias(kfo_ap, kfo_ap2); alias(kfo_st, kfo_st2); alias(kfo_pf, kfo_pf2); -alias(kfo_seeds, kfo_seeds2); +alias(kfo_ns, kfo_ns2); alias(iso, iso2); alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); From 0099c452c98356532a437873f1924baa1669f41a Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 10 Jan 2024 14:16:06 +0100 Subject: [PATCH 29/71] bugfix in old diet implementation --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 6 ++++-- modules/15_food/anthro_iso_jun22/sets.gms | 4 ++++ scripts/start/projects/project_EAT2.R | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 65a72f38dc..e6dfdbcd0b 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -377,9 +377,9 @@ if (s15_exo_diet = 1, = s15_alc_scen*i15_intake_scen_target(t,iso); ); - i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2)) > 0) = + i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(sum(EAT_staples2_old,i15_intake_EATLancet(iso,EAT_staples2_old)) > 0) = (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old))) * - (i15_intake_EATLancet(iso,EAT_staples) / sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))) + (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old,i15_intake_EATLancet(iso,EAT_staples2_old))) ; * VARTIKA: What about s15_exo_diet = 2? @@ -508,6 +508,8 @@ elseif (s15_exo_diet = 3), = (p15_intake_detail_nuts(t,iso) / (sum(kfo_ns,p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nuts(t,iso))) * i15_rec_EATLancet(iso,"t_nutseeds","min") ; +* 25 for peanuts +* 25 for nuts from other + seeds *' (b) for other nuts (groundnut) and seeds (rapeseed, sunflower): i15_intake_detailed_scen_target(t,iso,kfo_ns)$((sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso) diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index dda75b79ed..7c7d9bb831 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -184,6 +184,9 @@ sets EAT_sugar15(kfo) sugar / sugr_cane, sugr_beet, sugar, molasses / + EAT_staples_old(kfo) All staple food products according to EAT Lancet definition + / tece, maiz, trce, rice_pro, potato, cassav_sp / + EAT_staples(kfo) All staple food products according to EAT Lancet definition / tece, maiz, trce, rice_pro / @@ -239,6 +242,7 @@ alias(kfo_ns, kfo_ns2); alias(iso, iso2); alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); +alias(EAT_staples_old, EAT_staples2_old); alias(EAT_pulses15, EAT_pulses15_2); alias(EAT_redmeat15, EAT_redmeat15_2); alias(EATtar_kfo15, EATtar_kfo15_2); diff --git a/scripts/start/projects/project_EAT2.R b/scripts/start/projects/project_EAT2.R index 1ef1c567c9..63f3526d0a 100644 --- a/scripts/start/projects/project_EAT2.R +++ b/scripts/start/projects/project_EAT2.R @@ -22,6 +22,8 @@ source("scripts/start_functions.R") # laod default configuration source("config/default.cfg") +cfg$force_download <- TRUE + # Set defaults codeCheck <- FALSE From da7cac19771999f19c54de896ec1b8822d1a077d Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 11 Jan 2024 09:50:20 +0100 Subject: [PATCH 30/71] separation of peanuts from nuts --- config/default.cfg | 6 +++--- .../15_food/anthro_iso_jun22/exodietmacro.gms | 21 +++++++++++-------- modules/15_food/anthro_iso_jun22/sets.gms | 10 ++++----- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 6a94fc6104..10c7ea3b35 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "WARNINGS30_rev4.96EAT2p0_h12_magpie.tgz", - cellular = "rev4.96EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.96EAT2p0_h12_validation.tgz", +cfg$input <- c(regional = "WARNINGS30_rev4.97EAT2p0_h12_magpie.tgz", + cellular = "rev4.97EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.97EAT2p0_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index e6dfdbcd0b..623215c770 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -502,21 +502,24 @@ elseif (s15_exo_diet = 3), i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); *' Minimum recommendation for nuts & seeds -*' (a) nuts included in "others" - i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_ns, p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nuts(t,iso) +*' (a) nuts included in "others" counted towards EAT nuts & seeds category + i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_seeds, p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail_nuts(t,iso) / (sum(kfo_ns,p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nuts(t,iso))) + = (p15_intake_detail_nuts(t,iso) / (sum(kfo_seeds,p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso))) * i15_rec_EATLancet(iso,"t_nutseeds","min") ; -* 25 for peanuts -* 25 for nuts from other + seeds - -*' (b) for other nuts (groundnut) and seeds (rapeseed, sunflower): - i15_intake_detailed_scen_target(t,iso,kfo_ns)$((sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso) +*' (b) seeds (rapeseed, sunflower): + i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2,p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail(t,iso,kfo_ns) / (sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) + = (p15_intake_detail(t,iso,kfo_seeds) / (sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso))) * i15_rec_EATLancet(iso,"t_nutseeds","min") ; +*' (c) For model-internal reasons, MAgPIE considers the peanuts target separate from the other nuts & seeds +*** BENNI: Can you replace "model-internal reasons" with a short explanation why we went for the solution to separate peanuts from nuts? + i15_intake_detailed_scen_target(t,iso,"groundnut")$(p15_intake_detail(t,iso,"groundnut") + < i15_rec_EATLancet(iso,"t_peanuts","min") + ) = + i15_rec_EATLancet(iso,"t_peanuts","min"); *' The resulting intake of the "others" category is: i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 7c7d9bb831..52cad210c4 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -109,9 +109,8 @@ sets kfo_pf(kfo) Processed foods including oils sugar alcohol / oils,alcohol,sugar / -* Note: From a nutritional perspective, groundnut counts towards nuts - kfo_ns(kfo) Food products that are counted towards nuts and seeds - / rapeseed, sunflower, groundnut/ + kfo_seeds(kfo) Food products that are counted towards seeds + / rapeseed, sunflower/ kfo_norec(kfo) Food products that do not have an EAT-Lancet recommendation / sugr_cane, sugr_beet, molasses, alcohol / @@ -213,7 +212,7 @@ EAT_targets15 Food groups as well as individual foods for which EAT Lancet targe t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible - / t_redmeat, t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + / t_redmeat, t_legumes, t_peanuts, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio / cassav_sp, others / @@ -222,6 +221,7 @@ EAT_special MAgPIE food groups that need special treatment with respect to fruit EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories / t_redmeat . (livst_rum, livst_pig, scp) t_legumes . (puls_pro, soybean) + t_peanuts . (groundnut) t_fish . (fish) t_livst_chick . (livst_chick) t_livst_egg . (livst_egg) @@ -238,7 +238,7 @@ alias(kfo, kfo2); alias(kfo_ap, kfo_ap2); alias(kfo_st, kfo_st2); alias(kfo_pf, kfo_pf2); -alias(kfo_ns, kfo_ns2); +alias(kfo_seeds, kfo_seeds2); alias(iso, iso2); alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); From 4960920888a942eb5768ab19ddbdb72e0dc2198d Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 11 Jan 2024 11:05:55 +0100 Subject: [PATCH 31/71] bugfix in peanuts implementation and in eat1 as it diverged from develop --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 4 ++-- modules/15_food/anthro_iso_jun22/sets.gms | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 623215c770..708e36b642 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -355,8 +355,8 @@ if (s15_exo_diet = 1, = i15_intake_EATLancet(iso,EAT_fruitvegnutseed15)); *' lower bound for pulses if (s15_exo_pulses=1, - i15_intake_detailed_scen_target(t,iso,EAT_pulses15)$(i15_intake_detailed_scen_target(t,iso,EAT_pulses15) < i15_intake_EATLancet(iso,EAT_pulses15)) - = i15_intake_EATLancet(iso,EAT_pulses15)); + i15_intake_detailed_scen_target(t,iso,EAT_pulses15_old)$(i15_intake_detailed_scen_target(t,iso,EAT_pulses15_old) < i15_intake_EATLancet(iso,EAT_pulses15_old)) + = i15_intake_EATLancet(iso,EAT_pulses15_old)); *' upper bound for sugar if (s15_exo_sugar=1, i15_intake_detailed_scen_target(t,iso,EAT_sugar15)$(i15_intake_detailed_scen_target(t,iso,EAT_sugar15) > i15_intake_EATLancet(iso,EAT_sugar15)) diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 52cad210c4..35fdb73429 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -178,6 +178,8 @@ sets / livst_rum, livst_pig / EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds / rapeseed, sunflower, others / + EAT_pulses15_old(kfo) pulses + / soybean, puls_pro, groundnut / EAT_pulses15(kfo) pulses / soybean, puls_pro / EAT_sugar15(kfo) sugar @@ -209,7 +211,7 @@ EAT_targettype15 Minimum or maximum target type of the EAT Lancet recommendation EAT_targets15 Food groups as well as individual foods for which EAT Lancet targets are defined / t_nutseeds, t_fruitveg, t_fruitstarch, t_roots, t_redmeat, - t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + t_legumes, t_peanuts, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible / t_redmeat, t_legumes, t_peanuts, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / @@ -244,6 +246,7 @@ alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); alias(EAT_staples_old, EAT_staples2_old); alias(EAT_pulses15, EAT_pulses15_2); +alias(EAT_pulses15_old, EAT_pulses15_2_old); alias(EAT_redmeat15, EAT_redmeat15_2); alias(EATtar_kfo15, EATtar_kfo15_2); alias(EAT_mtargets15, EAT_mtargets15_2); From dc9f7d582149ce21500c4b7487649c5afa279354 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 12 Jan 2024 13:49:18 +0100 Subject: [PATCH 32/71] changed iso-level fruitveg ratio to regional level --- config/default.cfg | 2 +- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 9 +++++---- modules/15_food/anthro_iso_jun22/input.gms | 4 ++-- modules/15_food/input/files | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 10c7ea3b35..e2d5cb9d8c 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -483,7 +483,7 @@ cfg$gms$s15_exo_alcohol <- 1 # default: 1 # * (0.014): maximum target for alcohol consumption is 1.4% of total calorie consumption # * (see Lassen et al., 2020) cfg$gms$s15_alc_scen <- 0.014 # def = 0.014 -# FELI: I would strongly suggest to set it to 0 because otherwise it is not in line with EATLancet, +# BENNI: I (Feli) would suggest to set it to 0 because otherwise it is not in line with EATLancet, # but that would be what the user expects! It would be better if the user manually has to set it to 0.014 # when (s)he wants to divert from the standard EATLancet setting! # diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 708e36b642..e6b92954f1 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -407,7 +407,7 @@ elseif (s15_exo_diet = 3), * FELI: Check whether this is still necessary when the targets are split * To Do: transform i15_intake_detailed_scen_target and i15_intake_scen_target and p15_intake_detail -* to grams using i15_protein_to_kcal_ratio +* to grams using *' The single targets can also be set manually via switches *' (e.g., s15_exo_ruminant, s15_exo_fish, etc.). @@ -456,12 +456,13 @@ elseif (s15_exo_diet = 3), *** Special case: Fruits, vegetables and nuts *** *' In MAgPIE fruits, vegetables and nuts are combined in the 'other' food category; *' Bananas and plantains are included in the 'cassav_sp' category. -*' The f15_fruitveg2others_kcal_ratio gives the historical share (fixed into the future based on last historic year) +*' The f15_fruitveg2others_kcal_ratio gives the regional average historical share +*' (fixed into the future based on last historic year) *' of fruits and vegetables in these aggregate categories. if (sum(sameas(t_past,t),1) = 1, - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = sum(i_to_iso(i,iso), f15_fruitveg2others_kcal_ratio(t,i,EAT_special)); else - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = sum(i_to_iso(i,iso), f15_fruitveg2others_kcal_ratio(t-1,i,EAT_special)); ); *' Separation of starchy fruits (bananas and plantains) diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index ffbc06e32f..5960190762 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -258,9 +258,9 @@ $ondelim $include "./modules/15_food/input/f15_targets_EATLancet_iso.cs3" $offdelim; -table f15_fruitveg2others_kcal_ratio(t_all,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) +table f15_fruitveg2others_kcal_ratio(t_all,i,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) $ondelim -$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio_iso.cs3" +$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio.cs3" $offdelim; * This file contains exogenous dietary recommendations for India and EAT Lancet recommendations for all other regions diff --git a/modules/15_food/input/files b/modules/15_food/input/files index 3a2b8735ad..46b2d569ee 100644 --- a/modules/15_food/input/files +++ b/modules/15_food/input/files @@ -21,7 +21,7 @@ f15_supply2intake_ratio_FAO_iso.cs3 f15_intake_EATLancet.cs3 f15_intake_EATLancet_iso.cs3 f15_targets_EATLancet_iso.cs3 -f15_fruitveg2others_kcal_ratio_iso.cs3 +f15_fruitveg2others_kcal_ratio.cs3 f15_food_substitution_fader.csv f15_ruminant_fadeout_india.csv f15_milk_fadeout_india.csv From 207de3e713d2e0ae98c4d605bc169571710539cd Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 15 Jan 2024 14:41:27 +0100 Subject: [PATCH 33/71] bugfix in way fruitveg2other parameter is written into the future --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index e6b92954f1..90e5dd239f 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -462,7 +462,7 @@ elseif (s15_exo_diet = 3), if (sum(sameas(t_past,t),1) = 1, i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = sum(i_to_iso(i,iso), f15_fruitveg2others_kcal_ratio(t,i,EAT_special)); else - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = sum(i_to_iso(i,iso), f15_fruitveg2others_kcal_ratio(t-1,i,EAT_special)); + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = i15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); ); *' Separation of starchy fruits (bananas and plantains) From a200ed486c2fc4f2dff623b9c5f299bf11227b84 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 17 Jan 2024 15:06:59 +0100 Subject: [PATCH 34/71] bugfix balancing equation --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 90e5dd239f..d95482cbcc 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -387,7 +387,7 @@ if (s15_exo_diet = 1, * (Note: The old EATLancet implementation should be deleted soon.) *---------------------------------------------------------------------------------------- -elseif (s15_exo_diet = 3), +elseif s15_exo_diet = 3, *' In case of a MAgPIE-specific realization of the EAT Lancet diet (`s15_exo_diet=3`), *' model-internal diet projections are constrained by recommended ranges for intake *' (`i15_rec_EATLancet`) of different food groups to ensure healthy and sustainable @@ -593,7 +593,7 @@ elseif (s15_exo_diet = 3), *' in step 1.) selected total calorie intake is met. *' Note that brans do not have an EAT Lancet target and are kept at their *' original level. - i15_intake_detailed_scen_target(t,iso,EAT_staples) = + i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2)) > 0) = (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); From 9195bccf342bc7ea74846626f8d0d2eb9bef43b0 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 17 Jan 2024 16:02:19 +0100 Subject: [PATCH 35/71] separation of targets is now the same as before (monogastric and ruminant) rather than redmeat and poultry --- config/default.cfg | 6 +-- .../15_food/anthro_iso_jun22/exodietmacro.gms | 43 ++++++++----------- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index e2d5cb9d8c..dd7829c9db 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -461,10 +461,8 @@ cfg$gms$c15_EAT_scen <- "FLX" # def = FLX # * included, while the others will remain to be endogenous. # * Any shift will be compensated to reach the calorie target by adjusting # * staple calories. -cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 1) -cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 1) -cfg$gms$s15_exo_redmeatdairy <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 3) -cfg$gms$s15_exo_poultry <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 3) +cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_fish <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_fruitvegnut <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index d95482cbcc..2ed0b672bf 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -404,36 +404,37 @@ elseif s15_exo_diet = 3, p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2))) = 0) = p15_intake_detail(t,iso,kfo) + 1e-6; -* FELI: Check whether this is still necessary when the targets are split -* To Do: transform i15_intake_detailed_scen_target and i15_intake_scen_target and p15_intake_detail -* to grams using - -*' The single targets can also be set manually via switches +*' The single targets can be set manually via switches *' (e.g., s15_exo_ruminant, s15_exo_fish, etc.). -*' upper bound for chicken and eggs - if (s15_exo_poultry = 1, +*' upper bound for monogastric products + if (s15_exo_monogastric = 1, * upper bound for eggs i15_intake_detailed_scen_target(t,iso,"livst_egg")$(p15_intake_detail(t,iso,"livst_egg") > i15_rec_EATLancet(iso,"t_livst_egg","max") ) = i15_rec_EATLancet(iso,"t_livst_egg","max"); - * upper bound for chicken i15_intake_detailed_scen_target(t,iso,"livst_chick")$(p15_intake_detail(t,iso,"livst_chick") - > i15_rec_EATLancet(iso,"t_livst_chick","max") + > i15_rec_EATLancet(iso,"t_livst_chick","max") + ) = + i15_rec_EATLancet(iso,"t_livst_chick","max"); +* upper bound for redmeat (share of pigs in redmeat) + i15_intake_detailed_scen_target(t,iso,"livst_pig")$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) + > i15_rec_EATLancet(iso,"t_redmeat","max") ) = - i15_rec_EATLancet(iso,"t_livst_chick","max"); + (p15_intake_detail(t,iso,"livst_pig") / sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2))) + * i15_rec_EATLancet(iso,"t_redmeat","max"); ); -*' upper bound for redmeat and milk - if (s15_exo_redmeatdairy = 1, +*' upper bound for ruminant products + if (s15_exo_ruminant = 1, * upper bound for redmeat (pig and ruminant) - i15_intake_detailed_scen_target(t,iso,EAT_redmeat15)$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) + i15_intake_detailed_scen_target(t,iso,"livst_rum")$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) > i15_rec_EATLancet(iso,"t_redmeat","max") ) = - (p15_intake_detail(t,iso,EAT_redmeat15) / sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2))) + (p15_intake_detail(t,iso,"livst_rum") / sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2))) * i15_rec_EATLancet(iso,"t_redmeat","max"); * upper bound for milk i15_intake_detailed_scen_target(t,iso,"livst_milk")$(p15_intake_detail(t,iso,"livst_milk") @@ -574,6 +575,7 @@ elseif s15_exo_diet = 3, *' There is no explicit target for brans in the EATLancet recommendations. *' It is therefore set to 0. *** BENNI: Why was this decided in the previous implementation? My approach would have been to keep it at the current level or including it as part of staples. +*** To Do: exclude from both old and new (as last step when approval for the rest of the implementation by Benni/Isabelle) if (s15_exo_brans = 1, i15_intake_detailed_scen_target(t,iso,"brans") = 0; ); @@ -583,10 +585,6 @@ elseif s15_exo_diet = 3, i15_intake_detailed_scen_target(t,iso,"scp") = 0; ); - -* To Do: transform i15_intake_detailed_scen_target and i15_intake_scen_target and p15_intake_detail -* back to kcal using i15_protein_to_kcal_ratio - *** Balancing calorie requirements *** *' After all calorie recommendations for non-staple food groups are satisfied, *' intake of staple crops is now modified such that the @@ -597,11 +595,8 @@ elseif s15_exo_diet = 3, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); -display i15_intake_detailed_scen_target; - -**** FELI: Check whether it gets negative... And come up with solution for fixing this... (Maybe via positive declaration / setting everyting that's negative to 0?) -* BENNI: What if EATLancet leads to too much calories? Just allow higher values? -* JAN: Can a parameter be declared as positive? Or only variables? + if (i15_intake_detailed_scen_target(t,iso,EAT_staples) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing.", i15_intake_detailed_scen_target(t,iso,EAT_staples);); +* JAN: Is there if(any(x)) in GAMS? Or does this above check for each individual and therefore is a if any? ); *** End of MAgPIE-specific realization of the EAT Lancet diet @@ -616,8 +611,6 @@ display i15_intake_detailed_scen_target; p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) = p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) * (1-i15_exo_foodscen_fader(t,iso)) + p15_bmi_shr_target(t,iso,sex,age,bmi_group15) * i15_exo_foodscen_fader(t,iso); -display p15_intake_detail; - ); *** End of special postprocessing food demand scenarios. From 400eb2d02946b0fb37c25bb95542d9b6de123cb4 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 18 Jan 2024 13:07:26 +0100 Subject: [PATCH 36/71] abort statement if intake_detail_scen_target is negative --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 2ed0b672bf..d2b6437ec3 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -595,8 +595,10 @@ elseif s15_exo_diet = 3, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); - if (i15_intake_detailed_scen_target(t,iso,EAT_staples) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing.", i15_intake_detailed_scen_target(t,iso,EAT_staples);); -* JAN: Is there if(any(x)) in GAMS? Or does this above check for each individual and therefore is a if any? + if (smin((iso,EAT_staples), i15_intake_detailed_scen_target(t,iso,EAT_staples)) < 0, + abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; + ); + ); *** End of MAgPIE-specific realization of the EAT Lancet diet From c121a679a8552d3e5a75f9ffa0456ddb62018dc1 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 18 Jan 2024 15:47:36 +0100 Subject: [PATCH 37/71] clean-up --- CHANGELOG.md | 4 +- config/default.cfg | 4 +- .../15_food/anthro_iso_jun22/realization.gms | 2 +- modules/15_food/anthro_iso_jun22/sets.gms | 1 - scripts/start/projects/test_eat2_standalone.R | 23 --- .../projects/test_fooddemand_standalone.R | 25 --- standalone/eat2.gms | 161 ------------------ 7 files changed, 5 insertions(+), 215 deletions(-) delete mode 100644 scripts/start/projects/test_eat2_standalone.R delete mode 100644 scripts/start/projects/test_fooddemand_standalone.R delete mode 100644 standalone/eat2.gms diff --git a/CHANGELOG.md b/CHANGELOG.md index c07daa02d0..41f6ac6a44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### changed -- **15_food** Added new EAT Lancet diet implementation +- **15_food** Added improved EAT Lancet diet implementation - **start_functions** Check if cfg$recalibrate is consistent with cfg$gms$s14_use_yield_calib - **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations. - **default.cfg** Default for cfg$gms$peatland changed from `on` to `v2` @@ -17,7 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **scenario_config.csv** settings for cfg$gms$s35_secdf_distribution in `ForestryEndo` and `ForestryExo` changed from `2` to `0` - **scenario_config.csv** removed erroneous setting `cc` from column `input` - **default.cfg** update default `cfg$gms$c56_pollutant_prices` and `cfg$gms$c60_2ndgen_biodem` to `R32M46-SSP2EU-NPi` -- **default.cfg** update input data to rev 4.96 +- **default.cfg** update input data to rev 4.97 ### added - **32_forestry** new interfaces `vm_land_forestry`, `pcm_land_forestry` `vm_landexpansion_forestry` and `vm_landreduction_forestry` diff --git a/config/default.cfg b/config/default.cfg index dd7829c9db..c5c3857bfc 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -474,14 +474,14 @@ cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet # * The EAT-Lancet diet only allows for added sugars, # * but does not include processed food or alcohol. -# * only activated if s15_exo_diet is > 0 +# * only activated if s15_exo_diet is set to 1 cfg$gms$s15_exo_alcohol <- 1 # default: 1 # * Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. # * (0): no alcohol consumption, as in the original version of the EAT-Lancet diet # * (0.014): maximum target for alcohol consumption is 1.4% of total calorie consumption # * (see Lassen et al., 2020) cfg$gms$s15_alc_scen <- 0.014 # def = 0.014 -# BENNI: I (Feli) would suggest to set it to 0 because otherwise it is not in line with EATLancet, +# BENNI: I (Feli) would suggest to set s15_exo_alcohol to 0 in default because otherwise it is not in line with EATLancet, # but that would be what the user expects! It would be better if the user manually has to set it to 0.014 # when (s)he wants to divert from the standard EATLancet setting! # diff --git a/modules/15_food/anthro_iso_jun22/realization.gms b/modules/15_food/anthro_iso_jun22/realization.gms index 724e75d087..e2c4c14760 100644 --- a/modules/15_food/anthro_iso_jun22/realization.gms +++ b/modules/15_food/anthro_iso_jun22/realization.gms @@ -45,4 +45,4 @@ $Ifi "%phase%" == "postsolve" $include "./modules/15_food/anthro_iso_jun22/posts *' diet scenarios, most importantly the shift to the Planetary Health diet *' [@willett_food_2019]. *' -*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Jan Philipp Dietrich, Felicitas Beier, Marco Springmann +*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Jan Philipp Dietrich, Felicitas Beier diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 35fdb73429..c8a241c6e9 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -204,7 +204,6 @@ sets livst_rum, livst_pig, livst_chick, livst_egg, livst_milk, fish, others / -* Isabelle's code: EAT_targettype15 Minimum or maximum target type of the EAT Lancet recommendations / min, max / diff --git a/scripts/start/projects/test_eat2_standalone.R b/scripts/start/projects/test_eat2_standalone.R deleted file mode 100644 index 1f0bfa3acb..0000000000 --- a/scripts/start/projects/test_eat2_standalone.R +++ /dev/null @@ -1,23 +0,0 @@ -# | (C) 2008-2023 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: Food Demand Standalone -# ---------------------------------------------------------- - -# Load start_run(cfg) function which is needed to start MAgPIE runs -source("scripts/start_functions.R") - -# start MAgPIE run -source("config/default.cfg") -cfg$model <- "standalone/eat2.gms" -cfg$recalibrate <- FALSE -cfg$gms$c_timesteps <- "1" - -cfg$title <- "test1" -start_run(cfg = cfg) diff --git a/scripts/start/projects/test_fooddemand_standalone.R b/scripts/start/projects/test_fooddemand_standalone.R deleted file mode 100644 index 9a3d3a07dd..0000000000 --- a/scripts/start/projects/test_fooddemand_standalone.R +++ /dev/null @@ -1,25 +0,0 @@ -# | (C) 2008-2023 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: Food Demand Standalone -# ---------------------------------------------------------- - -# Load start_run(cfg) function which is needed to start MAgPIE runs -source("scripts/start_functions.R") - -# start MAgPIE run -source("config/default.cfg") -cfg$model <- "standalone/demand_model.gms" -cfg$recalibrate <- FALSE -cfg$gms$c_timesteps <- "pastandfuture" -cfg$gms$s15_calibrate <- 1 -cfg$gms$s15_elastic_demand <- 0 - -cfg$title <- "test1" -start_run(cfg = cfg) diff --git a/standalone/eat2.gms b/standalone/eat2.gms deleted file mode 100644 index 3e22bdf607..0000000000 --- a/standalone/eat2.gms +++ /dev/null @@ -1,161 +0,0 @@ -*** | (C) 2008-2023 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 - -* This is a standalone skeleton which should be used as template -* if only parts of the model should be run. It contains the basic, -* structural components of the model. -* To use it, please copy this file, give it an explaining name and -* save it in the "models" folder. After that you can modify it based -* on the given requirements. You can add own code, but also delete -* code (e.g. the model statement or the provided loops) if these parts -* are irrelevant for your analysis. - -$title eatLancetDiet2 - -$offupper -$offsymxref -$offsymlist -$offlisting - -$setglobal c_timesteps "1" -$setglobal c_past "till_1995" -$setglobal c_title default - -scalars -s_use_gdx use of gdx files / 0 / -; - -*******************************MODULE SETUP************************************* -$setglobal drivers aug17 -$setglobal food anthro_iso_jun22 - -***************************PREDEFINED MACROS************************************ -$include "./core/macros.gms" - -***************************BASIC SETS INDICES*********************************** -$include "./core/sets.gms" -$batinclude "./modules/include.gms" sets - -***** BENNI: What would I need that for? Isn't it enough to have them defined in the module? -*sets -* exampleset / elem1, elem2, elem3 / -*; - -**********INTRODUCE CALCULATION PARAMETERS, VARIABLES AND EQUATIONS************* -$include "./core/declarations.gms" -$batinclude "./modules/include.gms" declarations - -*parameters -* p_example(exampleset) example parameter (1) -*; - -*variables -* v_example example variable (1) -*; - -*equations -* q_example example equation (1) -*; - -*****************************IMPORT DATA FILES********************************** -$batinclude "./modules/include.gms" input - -********************OBJECTIVE FUNCTION & CONSTRAINTS**************************** -$batinclude "./modules/include.gms" equations - -*q_example .. -* v_example =g= sum(exampleset, p_example(exampleset)); - - -*******************MODEL DEFINITION & SOLVER OPTIONS**************************** -model magpie / all - m15_food_demand /; -magpie.scaleopt = 1 ; -magpie.holdfixed = 1 ; - -option lp = cplex ; -option nlp = conopt4 ; -option iterlim = 1000000 ; -option reslim = 1000000 ; -option sysout = Off ; -option savepoint = 1 ; - -*model example / q_example /; - -*****************************VARIABLE SCALING*********************************** -$batinclude "./modules/include.gms" scaling - -****************************PREPROCESSING START********************************* -* In this section everything is calculated that is not influenced by the -* optimization process. Hence these lines CAN INFLUENCE the optimization process -* but CANNOT BE INFLUENCED by it. - -$batinclude "./modules/include.gms" preloop - -*p_example(exampleset) = 1; - -* create dummy file (this is necessary to be able to use put_utility and it has -* to be done here because a file declaration cannot be inside a loop -file dummy; dummy.pw=2000; put dummy; - -************************OPTIMIZATION PROCESS START****************************** -* This section contains only sourcecode that is directly connected to the -* optimization process. That means that everything on the following lines -* INFLUENCES and IS INFLUENCED by the optimization process (except the -* redefinition on preprocessed data). -* Hence one can describe this section together with the constraints section -* as "model-core". - -* clear ct set -ct(t) = no; - -***************************TIMESTEP LOOP START********************************** -loop (t, - -* set ct to current time period - ct(t) = yes; - display "Year"; - display ct; - -$batinclude "./modules/include.gms" presolve - -* intersolve for food demand model - sm_intersolve = 0; - - while(sm_intersolve = 0, - -*************************SOLVE STATEMENT START********************************** -* #### additional phases ### -* set additional phases which should be detected by -* update_module_embeddings. Most phases will be detected automatically, -* but batincludes used within a module are not detected and therefore -* have to be set manually! (Syntax: "* !add_phase!: ") -* !add_phase!: nl_fix -* !add_phase!: nl_release -* !add_phase!: nl_relax - -$batinclude "./modules/include.gms" solve - -* intersolve for food demand model - sm_intersolve = 1; -* solve example USING lp MINIMIZING v_example; - - -$batinclude "./modules/include.gms" intersolve - - ); - -**************************SOLVE STATEMENT END*********************************** - -$batinclude "./modules/include.gms" postsolve - -**********************WRITE ALL DATA IN 1 GDX FILE****************************** - Execute_Unload "fulldata.gdx"; - -* clear ct set - ct(t) = no; -); -****************************TIMESTEP LOOP END*********************************** From 0f666a3bc3627a25443a76712ba18406f95ae62e Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 18 Jan 2024 16:06:47 +0100 Subject: [PATCH 38/71] clean up after check worflow run failed --- scripts/output/extra/disaggregation_LUH2.R | 12 ++++++------ scripts/start/projects/project_EAT2p0.R | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/output/extra/disaggregation_LUH2.R b/scripts/output/extra/disaggregation_LUH2.R index b5f18049b8..461d98e197 100644 --- a/scripts/output/extra/disaggregation_LUH2.R +++ b/scripts/output/extra/disaggregation_LUH2.R @@ -226,10 +226,10 @@ gc() #check for dynamic foresty if(!is.null(harvested_area_timber(gdx,level = "cell"))) { message("Start forestry / timber reporting") - + #### Wood land_lr <- madrat::toolAggregate(dimSums(land_hr,dim=3), map_file, from = "cell",to = "cluster") - + ### Wood: Harvested Area a <- harvested_area_timber(gdx,level = "cell") b <- a / land_lr @@ -249,12 +249,12 @@ if(!is.null(harvested_area_timber(gdx,level = "cell"))) { rm(a,b) gc() } - + #### Wood: Yields a <- ForestYield(gdx,level="cell") a_fix<- new.magpie(cells_and_regions=getCells(a),years=getYears(a), names=getNames(a)) - + # BugFix in the mean time. Strange jump from ForestYield a_fix[,1,]<-0 a_fix[,-1,]<-setYears(a[,2100,,invert=TRUE],getYears(a_fix[,-1,])) @@ -275,7 +275,7 @@ if(!is.null(harvested_area_timber(gdx,level = "cell"))) { rm(a,b) gc() } - + #### Wood: Harvested Biomass Product Split b <- TimberProductionVolumetric(gdx,level = "cell",sumSource = FALSE,sumProduct = FALSE) b <- dimSums(b,dim=3.1) @@ -490,4 +490,4 @@ gc() write.magpie(a, paste0(out_dir, "/LUH2_Yield_Nr.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,yield_kr,yield_kr_su) gc() -} \ No newline at end of file +} diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index eb6d8e594f..321ef40d12 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -82,7 +82,7 @@ diet <- function(cfg) { cfg$gms$s15_alc_scen <- 0 # No alcohol allowed as in the definition of EATLancet cfg$gms$c15_kcal_scen <- "healthy_BMI" # default: not necessary to set it again (To Do: remove) cfg$gms$c15_EAT_scen <- "FLX" # default: not necessary to set it again (To Do: remove) - cfg$gms$s15_alc_scen <- 0 # In EATLancet, no calories for alcohol. + cfg$gms$s15_alc_scen <- 0 # In EATLancet, no calories for alcohol. return(cfg) } @@ -232,7 +232,7 @@ cfg <- rcp26(cfg = cfg) start_run(cfg, codeCheck = FALSE) # ELM_PROD # -# Decomposition Scenario. Removed productivity trend from ELM +# Decomposition Scenario. Removed productivity trend from ELM cfg$title <- "ELM_PROD" cfg <- bau(cfg = cfg) cfg <- diet(cfg = cfg) @@ -242,7 +242,7 @@ cfg <- rcp26(cfg = cfg) start_run(cfg, codeCheck = FALSE) # ELM_WAST # -# Decomposition Scenario. Removes FLW from ELM +# Decomposition Scenario. Removes FLW from ELM cfg$title <- "ELM_WAST" cfg <- bau(cfg = cfg) cfg <- diet(cfg = cfg) @@ -262,7 +262,7 @@ cfg <- miti(cfg = cfg) start_run(cfg, codeCheck = FALSE) # ELM_NoCC # -# Decomposition Scenario. Removes climate impacts (NoCC) from ELM +# Decomposition Scenario. Removes climate impacts (NoCC) from ELM cfg$title <- "ELM_NoCC" cfg <- bau(cfg = cfg) cfg <- diet(cfg = cfg) @@ -273,7 +273,7 @@ cfg <- noCC(cfg = cfg) start_run(cfg, codeCheck = FALSE) # ELM_MITI # -# Decomposition Scenario. Removes climate mitigation and LUC policies from ELM +# Decomposition Scenario. Removes climate mitigation and LUC policies from ELM cfg$title <- "ELM_MITI" cfg <- bau(cfg = cfg) cfg <- diet(cfg = cfg) From 2b67fe563b80712ee1b3b9944c9c716b24fd2be4 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 18 Jan 2024 16:11:10 +0100 Subject: [PATCH 39/71] added missing description --- modules/15_food/anthro_iso_jun22/sets.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index c8a241c6e9..c210001afd 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -174,7 +174,7 @@ sets / livst_pig, livst_egg, livst_chick / EAT_ruminants15(kfo) ruminant products / livst_milk, livst_rum / - EAT_redmeat15(kfo) + EAT_redmeat15(kfo) livstock products that are categorized as red meat / livst_rum, livst_pig / EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds / rapeseed, sunflower, others / From 8bc839d97e57c3b132fb8a9ebf2210cab696e18e Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 22 Jan 2024 18:11:03 +0100 Subject: [PATCH 40/71] nuts in others are scaled by the same amount as fruits and vegetables and seeds are used to fill up to meet the nuts target AND fruit ratio in others at country level --- config/default.cfg | 6 +-- .../15_food/anthro_iso_jun22/exodietmacro.gms | 38 ++++++++++++------- modules/15_food/anthro_iso_jun22/input.gms | 4 +- modules/15_food/input/files | 2 +- scripts/start/projects/project_EAT2p0.R | 3 ++ 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index c5c3857bfc..7cee9a5bbb 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "WARNINGS30_rev4.97EAT2p0_h12_magpie.tgz", - cellular = "rev4.97EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.97EAT2p0_h12_validation.tgz", +cfg$input <- c(regional = "WARNINGS30_rev4.96EAT2p0_h12_magpie.tgz", + cellular = "rev4.96EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.96EAT2p0_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index d2b6437ec3..23e9b53fbf 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -457,11 +457,11 @@ elseif s15_exo_diet = 3, *** Special case: Fruits, vegetables and nuts *** *' In MAgPIE fruits, vegetables and nuts are combined in the 'other' food category; *' Bananas and plantains are included in the 'cassav_sp' category. -*' The f15_fruitveg2others_kcal_ratio gives the regional average historical share +*' The f15_fruitveg2others_kcal_ratio gives the country-level historical share *' (fixed into the future based on last historic year) *' of fruits and vegetables in these aggregate categories. if (sum(sameas(t_past,t),1) = 1, - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = sum(i_to_iso(i,iso), f15_fruitveg2others_kcal_ratio(t,i,EAT_special)); + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); else i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = i15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); ); @@ -498,24 +498,28 @@ elseif s15_exo_diet = 3, *' Minimum recommendation for fruits and vegetables: i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) = i15_rec_EATLancet(iso,"t_fruitveg","min"); -*' Extract fruits and vegetables that are part of others categroy -* Note that starchy fruits are kept at the previously assigned maximum level -* and their amount has been added to cassav_sp already. - i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); *' Minimum recommendation for nuts & seeds -*' (a) nuts included in "others" counted towards EAT nuts & seeds category +*' (a) nuts included in "others" count towards nuts & seeds EAT target, +*' but they are scaled by the same amount as vegetables +*' because in MAgPIE, they are represented by a uniform category. i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_seeds, p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail_nuts(t,iso) / (sum(kfo_seeds,p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso))) - * i15_rec_EATLancet(iso,"t_nutseeds","min") + = p15_intake_detail_nuts(t,iso) * (i15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso)) ; -*' (b) seeds (rapeseed, sunflower): - i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2,p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso) +*** BENNI: It is not scaled up if the nuts target is fulfilled. Is this correct? That way we lose the 1:1 connection of nuts and fruits&vegetables, but otherwise we would potentially overfulfill nuts. +*** Note: It could even already be overfulfilled by this method, right? I would ensure that we don't overfulfill by this equation: (Makes sense to you?) + i15_intake_detailed_scen_nuts(t,iso)$(i15_intake_detailed_scen_nuts(t,iso) > i15_rec_EATLancet(iso,"t_nutseeds","min")) + = i15_rec_EATLancet(iso,"t_nutseeds","min"); + +*' (b) seeds (rapeseed, sunflower) are scaled up towards the EAT target if scaling +*' of nuts in others was not sufficient to meet the nuts target. + i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + i15_intake_detailed_scen_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail(t,iso,kfo_seeds) / (sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso))) - * i15_rec_EATLancet(iso,"t_nutseeds","min") - ; + = p15_intake_detail(t,iso,kfo_seeds) / (sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2))) + * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts) + ; + *' (c) For model-internal reasons, MAgPIE considers the peanuts target separate from the other nuts & seeds *** BENNI: Can you replace "model-internal reasons" with a short explanation why we went for the solution to separate peanuts from nuts? i15_intake_detailed_scen_target(t,iso,"groundnut")$(p15_intake_detail(t,iso,"groundnut") @@ -523,6 +527,12 @@ elseif s15_exo_diet = 3, ) = i15_rec_EATLancet(iso,"t_peanuts","min"); +*' Extract fruits and vegetables that are part of others categroy +* Note that starchy fruits are kept at the previously assigned maximum level +* and their amount has been added to cassav_sp already. + i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); +*** BENNI: Please double check whether the starchyfruit should be subtracted here or before the nut treatment happens. + *' The resulting intake of the "others" category is: i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); ); diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index 5960190762..39709fc156 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -258,9 +258,9 @@ $ondelim $include "./modules/15_food/input/f15_targets_EATLancet_iso.cs3" $offdelim; -table f15_fruitveg2others_kcal_ratio(t_all,i,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) +table f15_fruitveg2others_kcal_ratio(t_all,iso,EAT_special) Country-specific ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) $ondelim -$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio.cs3" +$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio_iso.cs3" $offdelim; * This file contains exogenous dietary recommendations for India and EAT Lancet recommendations for all other regions diff --git a/modules/15_food/input/files b/modules/15_food/input/files index 46b2d569ee..3a2b8735ad 100644 --- a/modules/15_food/input/files +++ b/modules/15_food/input/files @@ -21,7 +21,7 @@ f15_supply2intake_ratio_FAO_iso.cs3 f15_intake_EATLancet.cs3 f15_intake_EATLancet_iso.cs3 f15_targets_EATLancet_iso.cs3 -f15_fruitveg2others_kcal_ratio.cs3 +f15_fruitveg2others_kcal_ratio_iso.cs3 f15_food_substitution_fader.csv f15_ruminant_fadeout_india.csv f15_milk_fadeout_india.csv diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index 321ef40d12..a7acf1ab9e 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -124,6 +124,9 @@ miti <- function(cfg) { cfg$gms$c56_pollutant_prices <- "coupling" cfg$path_to_report_bioenergy <- "/p/projects/magpie/users/florianh/projects/paper/LandEnergy/modelrunsGrassland7/remind/output/C_SSP2EU-PkBudg500-rem-5/REMIND_generic_C_SSP2EU-PkBudg500-rem-5.mif" cfg$gms$c60_2ndgen_biodem <- "coupling" + +# Switch on NDCs? + return(cfg) } From 77e0f6324f6a3f5f8c4801d3919d53c2537485ef Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 29 Jan 2024 11:47:51 +0100 Subject: [PATCH 41/71] scaling of nuts together with fruits and veggies and abort statement for old implementation --- config/default.cfg | 6 +++--- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 7cee9a5bbb..c5c3857bfc 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "WARNINGS30_rev4.96EAT2p0_h12_magpie.tgz", - cellular = "rev4.96EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.96EAT2p0_h12_validation.tgz", +cfg$input <- c(regional = "WARNINGS30_rev4.97EAT2p0_h12_magpie.tgz", + cellular = "rev4.97EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.97EAT2p0_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 23e9b53fbf..c84d03b10d 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -316,8 +316,7 @@ $endif i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) > 0) = p15_intake_detail(t,iso,kfo) / p15_intake_total(t,iso) * i15_intake_scen_target(t,iso); -*** BENNI: Is this initiated correctly? (If p15_intake_total = 0, no value is written into i15_intake_detailed_scen_target. Is that a problem?) -* Am Ende fadet ja dann p15_intake_detail zu i15_intake_detailed_scen_target, d.h. wir mĂĽssen sicherstellen, dass in i15_intake_detailed_scen_target auch echt alles richtig drinsteht. + i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) = 0) = 0; *' 2.) The second step defines the daily per capita intake of different food *' commodities. @@ -382,6 +381,10 @@ if (s15_exo_diet = 1, (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old,i15_intake_EATLancet(iso,EAT_staples2_old))) ; + if (smin((iso,EAT_staples_old), i15_intake_detailed_scen_target(t,iso,EAT_staples_old)) < 0, + abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; + ); + * VARTIKA: What about s15_exo_diet = 2? * Can this be transformed to the new diet implementation? Did you have target values there? * (Note: The old EATLancet implementation should be deleted soon.) @@ -505,7 +508,7 @@ elseif s15_exo_diet = 3, *' because in MAgPIE, they are represented by a uniform category. i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_seeds, p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = p15_intake_detail_nuts(t,iso) * (i15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso)) + = p15_intake_detail_nuts(t,iso) * i15_intake_detailed_scen_fruitveg(t,iso) / p15_intake_detail_fruitveg(t,iso) ; *** BENNI: It is not scaled up if the nuts target is fulfilled. Is this correct? That way we lose the 1:1 connection of nuts and fruits&vegetables, but otherwise we would potentially overfulfill nuts. *** Note: It could even already be overfulfilled by this method, right? I would ensure that we don't overfulfill by this equation: (Makes sense to you?) @@ -516,8 +519,8 @@ elseif s15_exo_diet = 3, *' of nuts in others was not sufficient to meet the nuts target. i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + i15_intake_detailed_scen_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = p15_intake_detail(t,iso,kfo_seeds) / (sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2))) - * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts) + = p15_intake_detail(t,iso,kfo_seeds) / sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) ; *' (c) For model-internal reasons, MAgPIE considers the peanuts target separate from the other nuts & seeds From bc3eea9e3d3dbf7287e2a9327ae51d8505a006d7 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 29 Jan 2024 14:37:41 +0100 Subject: [PATCH 42/71] code improvements following Bennis suggestions and correction of calorie balancing when negative --- .../15_food/anthro_iso_jun22/exodietmacro.gms | 87 ++++++++++++------- 1 file changed, 54 insertions(+), 33 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index c84d03b10d..1abb4f1008 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -376,14 +376,24 @@ if (s15_exo_diet = 1, = s15_alc_scen*i15_intake_scen_target(t,iso); ); - i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(sum(EAT_staples2_old,i15_intake_EATLancet(iso,EAT_staples2_old)) > 0) = - (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old))) * - (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old,i15_intake_EATLancet(iso,EAT_staples2_old))) + i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old)) > 0) = + smax(0 , (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)))) * + (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old))) ; - if (smin((iso,EAT_staples_old), i15_intake_detailed_scen_target(t,iso,EAT_staples_old)) < 0, +* Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values + i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)) < 0) = + i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)) + ; +*** BENNI / JAN: Please double check: The correction is the same as above commented out code +* The purpose is to correct cases where the EATLancet diet lead to more consumption than allowed by calorie target and staple balancing not sufficient to bring it down. +* i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)) < 0) = +* i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old))) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) +* ; + + if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; - ); + ); * VARTIKA: What about s15_exo_diet = 2? * Can this be transformed to the new diet implementation? Did you have target values there? @@ -502,42 +512,50 @@ elseif s15_exo_diet = 3, i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) = i15_rec_EATLancet(iso,"t_fruitveg","min"); +*' Extract fruits and vegetables that are part of others categroy +* Note that starchy fruits are kept at the previously assigned maximum level +* and their amount has been added to cassav_sp already. + i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); + *' Minimum recommendation for nuts & seeds -*' (a) nuts included in "others" count towards nuts & seeds EAT target, -*' but they are scaled by the same amount as vegetables -*' because in MAgPIE, they are represented by a uniform category. - i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_seeds, p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso) - ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = p15_intake_detail_nuts(t,iso) * i15_intake_detailed_scen_fruitveg(t,iso) / p15_intake_detail_fruitveg(t,iso) +*' (a) nuts included in "others" +*' are scaled by the same amount as fruits and vegetables +*' because the food group "others" is treated as homogenous food category + i15_intake_detailed_scen_nuts(t,iso) + = p15_intake_detail_nuts(t,iso) * i15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso)) ; -*** BENNI: It is not scaled up if the nuts target is fulfilled. Is this correct? That way we lose the 1:1 connection of nuts and fruits&vegetables, but otherwise we would potentially overfulfill nuts. -*** Note: It could even already be overfulfilled by this method, right? I would ensure that we don't overfulfill by this equation: (Makes sense to you?) - i15_intake_detailed_scen_nuts(t,iso)$(i15_intake_detailed_scen_nuts(t,iso) > i15_rec_EATLancet(iso,"t_nutseeds","min")) - = i15_rec_EATLancet(iso,"t_nutseeds","min"); - -*' (b) seeds (rapeseed, sunflower) are scaled up towards the EAT target if scaling -*' of nuts in others was not sufficient to meet the nuts target. - i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + i15_intake_detailed_scen_nuts(t,iso) - ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) + +*' The resulting intake of the "others" category is: + i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); + +* Check (temporarily for testing) +display i15_intake_detailed_scen_target; +*' (b) seeds (rapeseed, sunflower) are scaled up or down towards the EAT target +*' considering scaling of nuts in others. +*' Note that the nuts in others count towards the EAT target + i15_intake_detailed_scen_target(t,iso,kfo_seeds) = p15_intake_detail(t,iso,kfo_seeds) / sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) ; +* Check (temporarily for testing) +display i15_intake_detailed_scen_target; + +* If seeds have been corrected downwards because nuts target already overfulfilled with nuts in others, +* seed consumption is reduced to zero. + i15_intake_detailed_scen_target(t,iso,kfo_seeds)$(i15_intake_detailed_scen_target(t,iso,kfo_seeds) < 0) = 0; + +* Just to make sure. Can probably be deleted after testing (Just included because I removed the if conditions above as suggested by Benni) + if ((sum(kfo_seeds, i15_intake_detailed_scen_target(t,iso,kfo_seeds)) + i15_intake_detailed_scen_nuts(t,iso)) < i15_rec_EATLancet(iso,"t_nutseeds","min"), + abort "The nuts target is not fulfilled. Please make sure enough nuts and seeds are consumed"; + ); *' (c) For model-internal reasons, MAgPIE considers the peanuts target separate from the other nuts & seeds -*** BENNI: Can you replace "model-internal reasons" with a short explanation why we went for the solution to separate peanuts from nuts? +*** BENNI: Can you replace "model-internal reasons" with a short explanation why we went for the solution to separate peanuts from nuts even though the EATLancet 2 recommendation is having it as one nuts target? i15_intake_detailed_scen_target(t,iso,"groundnut")$(p15_intake_detail(t,iso,"groundnut") < i15_rec_EATLancet(iso,"t_peanuts","min") ) = i15_rec_EATLancet(iso,"t_peanuts","min"); -*' Extract fruits and vegetables that are part of others categroy -* Note that starchy fruits are kept at the previously assigned maximum level -* and their amount has been added to cassav_sp already. - i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); -*** BENNI: Please double check whether the starchyfruit should be subtracted here or before the nut treatment happens. - -*' The resulting intake of the "others" category is: - i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); ); *' lower bound for legumes @@ -605,14 +623,17 @@ elseif s15_exo_diet = 3, *' Note that brans do not have an EAT Lancet target and are kept at their *' original level. i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2)) > 0) = - (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) - * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); + smax(0, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)))) + * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); + +* Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values + i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)) < 0) = + i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)); - if (smin((iso,EAT_staples), i15_intake_detailed_scen_target(t,iso,EAT_staples)) < 0, + if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; ); - ); *** End of MAgPIE-specific realization of the EAT Lancet diet From 1d12ac654c4245277557e474b959ed4b80b96771 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 29 Jan 2024 15:36:43 +0100 Subject: [PATCH 43/71] set already under control fix --- .../15_food/anthro_iso_jun22/exodietmacro.gms | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 1abb4f1008..f44c69c0b7 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -377,13 +377,15 @@ if (s15_exo_diet = 1, ); i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old)) > 0) = - smax(0 , (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)))) * + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old))) * (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old))) ; * Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values - i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)) < 0) = - i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)) + i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = + 0; + i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = + i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) ; *** BENNI / JAN: Please double check: The correction is the same as above commented out code * The purpose is to correct cases where the EATLancet diet lead to more consumption than allowed by calorie target and staple balancing not sufficient to bring it down. @@ -623,12 +625,14 @@ display i15_intake_detailed_scen_target; *' Note that brans do not have an EAT Lancet target and are kept at their *' original level. i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2)) > 0) = - smax(0, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)))) + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); * Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values - i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)) < 0) = - i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)); + i15_intake_detailed_scen_target(t,iso,EAT_staples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = + 0; + i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = + i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)); if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; From 7e9cd64d529c67b841b7e4b7443f9319812ed3d3 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 29 Jan 2024 15:56:31 +0100 Subject: [PATCH 44/71] small bufix --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 6 +++--- modules/15_food/anthro_iso_jun22/sets.gms | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index f44c69c0b7..900e11abff 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -547,9 +547,9 @@ display i15_intake_detailed_scen_target; i15_intake_detailed_scen_target(t,iso,kfo_seeds)$(i15_intake_detailed_scen_target(t,iso,kfo_seeds) < 0) = 0; * Just to make sure. Can probably be deleted after testing (Just included because I removed the if conditions above as suggested by Benni) - if ((sum(kfo_seeds, i15_intake_detailed_scen_target(t,iso,kfo_seeds)) + i15_intake_detailed_scen_nuts(t,iso)) < i15_rec_EATLancet(iso,"t_nutseeds","min"), - abort "The nuts target is not fulfilled. Please make sure enough nuts and seeds are consumed"; - ); +* if ((sum(kfo_seeds, i15_intake_detailed_scen_target(t,iso,kfo_seeds)) + i15_intake_detailed_scen_nuts(t,iso)) < i15_rec_EATLancet(iso,"t_nutseeds","min"), +* abort "The nuts target is not fulfilled. Please make sure enough nuts and seeds are consumed"; +* ); *' (c) For model-internal reasons, MAgPIE considers the peanuts target separate from the other nuts & seeds *** BENNI: Can you replace "model-internal reasons" with a short explanation why we went for the solution to separate peanuts from nuts even though the EATLancet 2 recommendation is having it as one nuts target? diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index c210001afd..c340a6b096 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -243,7 +243,9 @@ alias(kfo_seeds, kfo_seeds2); alias(iso, iso2); alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); +alias(EAT_nonstaples, EAT_nonstaples2); alias(EAT_staples_old, EAT_staples2_old); +alias(EAT_nonstaples_old, EAT_nonstaples2_old); alias(EAT_pulses15, EAT_pulses15_2); alias(EAT_pulses15_old, EAT_pulses15_2_old); alias(EAT_redmeat15, EAT_redmeat15_2); From 8f1f0accf15b5efeea52e258245e1bb3ac9cb233 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 30 Jan 2024 17:58:07 +0100 Subject: [PATCH 45/71] cleanup --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 14 +++----------- scripts/start/projects/project_EAT2p0.R | 5 +++-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 900e11abff..09b26247b6 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -218,7 +218,7 @@ if (s15_run_diet_postprocessing = 1, *' exogenous PHDs, India-specific recommendations or model-internal intake estimates *' that hit the PHD targets by setting the switch `s15_exo_diet` to 1, 2 or 3. -if ((s15_exo_diet > 0), +if (s15_exo_diet > 0, *' 1.) In a first step, the exogenous scenario diets are defined by selecting a *' scenario target for total daily per capita food intake @@ -387,11 +387,6 @@ if (s15_exo_diet = 1, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) ; -*** BENNI / JAN: Please double check: The correction is the same as above commented out code -* The purpose is to correct cases where the EATLancet diet lead to more consumption than allowed by calorie target and staple balancing not sufficient to bring it down. -* i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)) < 0) = -* i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old))) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) -* ; if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; @@ -530,8 +525,6 @@ elseif s15_exo_diet = 3, *' The resulting intake of the "others" category is: i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); -* Check (temporarily for testing) -display i15_intake_detailed_scen_target; *' (b) seeds (rapeseed, sunflower) are scaled up or down towards the EAT target *' considering scaling of nuts in others. *' Note that the nuts in others count towards the EAT target @@ -539,8 +532,6 @@ display i15_intake_detailed_scen_target; = p15_intake_detail(t,iso,kfo_seeds) / sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) ; -* Check (temporarily for testing) -display i15_intake_detailed_scen_target; * If seeds have been corrected downwards because nuts target already overfulfilled with nuts in others, * seed consumption is reduced to zero. @@ -632,7 +623,8 @@ display i15_intake_detailed_scen_target; i15_intake_detailed_scen_target(t,iso,EAT_staples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = 0; i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = - i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)); + i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / + sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)); if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index a7acf1ab9e..ccf51dbfed 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -119,14 +119,15 @@ waste <- function(cfg) { # where miti is active. # Reference: Humpenöder, F., Popp, A., Merfort, L., Luderer, G., Weindl, I., Bodirsky, B., Stevanović, M., Klein, D., Rodrigues, R., Bauer, N., Dietrich, J., Lotze-Campen, H., & Rockström, J. (2023). Data repository - Dietary shifts increase the feasibility of 1.5°C pathways (Version 1) [Data set]. Zenodo. https://doi.org/10.5281/zenodo.8328217 miti <- function(cfg) { + # NDCs + cfg <- setScenario(cfg, c("SSP2", "NDC")) + # Mitigation: consistent with 1.5C cfg$path_to_report_ghgprices <- "/p/projects/magpie/users/florianh/projects/paper/LandEnergy/modelrunsGrassland7/remind/output/C_SSP2EU-PkBudg500-rem-5/REMIND_generic_C_SSP2EU-PkBudg500-rem-5.mif" cfg$gms$c56_pollutant_prices <- "coupling" cfg$path_to_report_bioenergy <- "/p/projects/magpie/users/florianh/projects/paper/LandEnergy/modelrunsGrassland7/remind/output/C_SSP2EU-PkBudg500-rem-5/REMIND_generic_C_SSP2EU-PkBudg500-rem-5.mif" cfg$gms$c60_2ndgen_biodem <- "coupling" -# Switch on NDCs? - return(cfg) } From e6f66de52dd9b022e89591cf23f3905702882c24 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 1 Feb 2024 10:26:11 +0100 Subject: [PATCH 46/71] re-introduced combined target for nuts (seeds and groundnut) --- config/default.cfg | 6 ++-- .../15_food/anthro_iso_jun22/exodietmacro.gms | 29 +++++++------------ modules/15_food/anthro_iso_jun22/sets.gms | 13 ++++----- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index c5c3857bfc..6f544eb120 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "WARNINGS30_rev4.97EAT2p0_h12_magpie.tgz", - cellular = "rev4.97EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.97EAT2p0_h12_validation.tgz", +cfg$input <- c(regional = "rev4.98_h12_magpie.tgz", + cellular = "rev4.98_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.98_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 09b26247b6..550095f245 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -525,29 +525,22 @@ elseif s15_exo_diet = 3, *' The resulting intake of the "others" category is: i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); -*' (b) seeds (rapeseed, sunflower) are scaled up or down towards the EAT target +*' (b) remaining nuts (groundnut) and seeds (rapeseed, sunflower) are scaled +*' up or down towards the EAT nuts target *' considering scaling of nuts in others. -*' Note that the nuts in others count towards the EAT target - i15_intake_detailed_scen_target(t,iso,kfo_seeds) - = p15_intake_detail(t,iso,kfo_seeds) / sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + i15_intake_detailed_scen_target(t,iso,kfo_ns) + = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) ; +*** ISABELLE: Please double-check whether I can remove the if condition here +*** ($((sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) +*** Benni and my reasoning was that if the nuts in others (i15_intake_detailed_scen_nuts already over-fulfill the nuts and seeds target, +*** it would be ok to correct the seeds and groundnuts down, too...) + * If seeds have been corrected downwards because nuts target already overfulfilled with nuts in others, -* seed consumption is reduced to zero. - i15_intake_detailed_scen_target(t,iso,kfo_seeds)$(i15_intake_detailed_scen_target(t,iso,kfo_seeds) < 0) = 0; - -* Just to make sure. Can probably be deleted after testing (Just included because I removed the if conditions above as suggested by Benni) -* if ((sum(kfo_seeds, i15_intake_detailed_scen_target(t,iso,kfo_seeds)) + i15_intake_detailed_scen_nuts(t,iso)) < i15_rec_EATLancet(iso,"t_nutseeds","min"), -* abort "The nuts target is not fulfilled. Please make sure enough nuts and seeds are consumed"; -* ); - -*' (c) For model-internal reasons, MAgPIE considers the peanuts target separate from the other nuts & seeds -*** BENNI: Can you replace "model-internal reasons" with a short explanation why we went for the solution to separate peanuts from nuts even though the EATLancet 2 recommendation is having it as one nuts target? - i15_intake_detailed_scen_target(t,iso,"groundnut")$(p15_intake_detail(t,iso,"groundnut") - < i15_rec_EATLancet(iso,"t_peanuts","min") - ) = - i15_rec_EATLancet(iso,"t_peanuts","min"); +* seed and groundnut consumption is reduced to zero. + i15_intake_detailed_scen_target(t,iso,kfo_ns)$(i15_intake_detailed_scen_target(t,iso,kfo_ns) < 0) = 0; ); diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index c340a6b096..8b4735624d 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -109,8 +109,8 @@ sets kfo_pf(kfo) Processed foods including oils sugar alcohol / oils,alcohol,sugar / - kfo_seeds(kfo) Food products that are counted towards seeds - / rapeseed, sunflower/ + kfo_ns(kfo) Food products that are counted towards seeds and nuts other than those included in others + / rapeseed, sunflower, groundnut / kfo_norec(kfo) Food products that do not have an EAT-Lancet recommendation / sugr_cane, sugr_beet, molasses, alcohol / @@ -210,10 +210,10 @@ EAT_targettype15 Minimum or maximum target type of the EAT Lancet recommendation EAT_targets15 Food groups as well as individual foods for which EAT Lancet targets are defined / t_nutseeds, t_fruitveg, t_fruitstarch, t_roots, t_redmeat, - t_legumes, t_peanuts, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible - / t_redmeat, t_legumes, t_peanuts, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + / t_redmeat, t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio / cassav_sp, others / @@ -221,8 +221,7 @@ EAT_special MAgPIE food groups that need special treatment with respect to fruit EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories / t_redmeat . (livst_rum, livst_pig, scp) - t_legumes . (puls_pro, soybean) - t_peanuts . (groundnut) + t_legumes . (puls_pro, soybean, groundnut) t_fish . (fish) t_livst_chick . (livst_chick) t_livst_egg . (livst_egg) @@ -239,7 +238,7 @@ alias(kfo, kfo2); alias(kfo_ap, kfo_ap2); alias(kfo_st, kfo_st2); alias(kfo_pf, kfo_pf2); -alias(kfo_seeds, kfo_seeds2); +alias(kfo_ns, kfo_ns2); alias(iso, iso2); alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); From 511181a3607db6b6689ba0bf74ae7420ce437891 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 1 Feb 2024 15:23:39 +0100 Subject: [PATCH 47/71] bugfixes and update of brans and alcohol default --- config/default.cfg | 28 ++++----- .../15_food/anthro_iso_jun22/exodietmacro.gms | 18 +++--- modules/15_food/anthro_iso_jun22/input.gms | 2 +- modules/15_food/anthro_iso_jun22/sets.gms | 27 +++++---- scripts/start/projects/project_EAT2.R | 59 ++++++++++++++++++- scripts/start/test_runs.R | 2 - 6 files changed, 94 insertions(+), 42 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 91996d84a5..f2419153eb 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -432,7 +432,9 @@ cfg$gms$s15_waste_scen <- 1.2 # def = 1.2 # * If only India's diet needs to be changed, then set cfg$gms$scen_countries15 <- "IND" # * (1): transition towards exogenous diets and food demand parametrized # * to a food-specific data set published by the EAT-Lancet Commission -# * (Willett et al., 2019) +# * (Willett et al., 2019). This EATLancet implementation is deprecated. +# * Please use MAgPIE-specific realization of the EAT-Lancet diet (3) +# * for EATLancet diet. # * (0): regression-based estimation of diets and food demand cfg$gms$s15_exo_diet <- 0 # def = 0 @@ -464,26 +466,24 @@ cfg$gms$c15_EAT_scen <- "FLX" # def = FLX cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_fish <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnut <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnutroots <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_sugar <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_oils <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet # * The EAT-Lancet diet only allows for added sugars, # * but does not include processed food or alcohol. # * only activated if s15_exo_diet is set to 1 -cfg$gms$s15_exo_alcohol <- 1 # default: 1 +cfg$gms$s15_exo_alcohol <- 0 # def = 1 (as in EATLancet definition), options: 0,1 # * Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. +# * Only activated if s15_exo_alcohol = 1 # * (0): no alcohol consumption, as in the original version of the EAT-Lancet diet # * (0.014): maximum target for alcohol consumption is 1.4% of total calorie consumption # * (see Lassen et al., 2020) cfg$gms$s15_alc_scen <- 0.014 # def = 0.014 -# BENNI: I (Feli) would suggest to set s15_exo_alcohol to 0 in default because otherwise it is not in line with EATLancet, -# but that would be what the user expects! It would be better if the user manually has to set it to 0.014 -# when (s)he wants to divert from the standard EATLancet setting! # # # * Switch and specification of countries for which exogenous food scenarios @@ -782,11 +782,11 @@ cfg$gms$s32_max_aff_area <- Inf # def = Inf # Protection of afforested areas (endogenous CO2 price driven) # 0=until end of planning horizon (see s32_planing_horizon) # 1=forever -# Note: Without a price on CO2 emissions from land-use change in module 32_forestry, -# which is the current default (c56_emis_policy <- "reddnatveg_nosoil"), -# the recommended setting for s32_aff_prot is 1. -# Otherwise, the model can do re/afforestation on existing re/afforestation areas -# after the end of planning horizon without penalty for CO2 emissions. +# Note: Without a price on CO2 emissions from land-use change in module 32_forestry, +# which is the current default (c56_emis_policy <- "reddnatveg_nosoil"), +# the recommended setting for s32_aff_prot is 1. +# Otherwise, the model can do re/afforestation on existing re/afforestation areas +# after the end of planning horizon without penalty for CO2 emissions. cfg$gms$s32_aff_prot <- 1 # def = 1 # Type of afforestation constraint @@ -1473,9 +1473,9 @@ cfg$gms$c56_cprice_aff <- "secdforest_vegc" # def = secdforest_vegc # * should not be higher than s32_planing_horizon cfg$gms$s56_c_price_exp_aff <- 50 # def = 50 -# * Share of carbon credits for re/afforestation projects set aside in a buffer to +# * Share of carbon credits for re/afforestation projects set aside in a buffer to # * account for potential failure of permanent carbon storage. -# * Alternatively, this parameter can be interpreted as a reduction factor +# * Alternatively, this parameter can be interpreted as a reduction factor # * of the carbon price for non-permanent CDR. # * Values > 0 will reduce the incentive for c-price-induced re/afforestation cfg$gms$s56_buffer_aff <- 0.5 # def = 0.5 diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 550095f245..3f66ae702e 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -349,7 +349,7 @@ if (s15_exo_diet = 1, if (s15_exo_fish=1, i15_intake_detailed_scen_target(t,iso,"fish") = i15_intake_EATLancet(iso,"fish")); *' lower bound for fruits, veggies, nuts and seeds - if (s15_exo_fruitvegnut=1, + if (s15_exo_fruitvegnutroots=1, i15_intake_detailed_scen_target(t,iso,EAT_fruitvegnutseed15)$(i15_intake_detailed_scen_target(t,iso,EAT_fruitvegnutseed15) < i15_intake_EATLancet(iso,EAT_fruitvegnutseed15)) = i15_intake_EATLancet(iso,EAT_fruitvegnutseed15)); *' lower bound for pulses @@ -463,7 +463,7 @@ elseif s15_exo_diet = 3, *' lower bound for fruits, veggies, nuts and seeds *' and upper bound for starchy fruits and roots - if (s15_exo_fruitvegnut = 1, + if (s15_exo_fruitvegnutroots = 1, *** Special case: Fruits, vegetables and nuts *** *' In MAgPIE fruits, vegetables and nuts are combined in the 'other' food category; *' Bananas and plantains are included in the 'cassav_sp' category. @@ -518,7 +518,7 @@ elseif s15_exo_diet = 3, *' (a) nuts included in "others" *' are scaled by the same amount as fruits and vegetables *' because the food group "others" is treated as homogenous food category - i15_intake_detailed_scen_nuts(t,iso) + i15_intake_detailed_scen_nuts(t,iso)$(p15_intake_detail_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso) > 0) = p15_intake_detail_nuts(t,iso) * i15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso)) ; @@ -528,17 +528,17 @@ elseif s15_exo_diet = 3, *' (b) remaining nuts (groundnut) and seeds (rapeseed, sunflower) are scaled *' up or down towards the EAT nuts target *' considering scaling of nuts in others. - i15_intake_detailed_scen_target(t,iso,kfo_ns) - = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + i15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) > 0) + = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) ; -*** ISABELLE: Please double-check whether I can remove the if condition here +*** ISABELLE: Please double-check whether I can remove the if condition from the nuts target equations *** ($((sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) *** Benni and my reasoning was that if the nuts in others (i15_intake_detailed_scen_nuts already over-fulfill the nuts and seeds target, *** it would be ok to correct the seeds and groundnuts down, too...) -* If seeds have been corrected downwards because nuts target already overfulfilled with nuts in others, +* If seeds have been corrected downwards below zero because nuts target already overfulfilled with nuts in others, * seed and groundnut consumption is reduced to zero. i15_intake_detailed_scen_target(t,iso,kfo_ns)$(i15_intake_detailed_scen_target(t,iso,kfo_ns) < 0) = 0; @@ -590,9 +590,7 @@ elseif s15_exo_diet = 3, = s15_alc_scen * i15_intake_scen_target(t,iso); ); *' There is no explicit target for brans in the EATLancet recommendations. -*' It is therefore set to 0. -*** BENNI: Why was this decided in the previous implementation? My approach would have been to keep it at the current level or including it as part of staples. -*** To Do: exclude from both old and new (as last step when approval for the rest of the implementation by Benni/Isabelle) +*' It is set to 0 when s15_exo_brans is activated. if (s15_exo_brans = 1, i15_intake_detailed_scen_target(t,iso,"brans") = 0; ); diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index 39709fc156..dc19c5132d 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -102,7 +102,7 @@ scalar s15_exo_redmeatdairy Exogenous EAT Lancet animal product target on (1) / scalar s15_exo_monogastric Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_ruminant Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_fish Exogenous EAT Lancet animal product target on (1) / 1 /; -scalar s15_exo_fruitvegnut Exogenous EAT Lancet fruit vegetable nut seeds target on (1) / 1 /; +scalar s15_exo_fruitvegnutroots Exogenous EAT Lancet fruit vegetable nut seeds target on (1) / 1 /; scalar s15_exo_pulses Exogenous pulses target on (1) / 1 /; scalar s15_exo_sugar Exogenous sugar target on (1) / 1 /; scalar s15_exo_oils Exogenous oils (1) / 1 /; diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 8b4735624d..9eaae22c18 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -212,23 +212,26 @@ EAT_targets15 Food groups as well as individual foods for which EAT Lancet targe t_roots, t_redmeat, t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / -EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible - / t_redmeat, t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / +EAT_mtargets15(EAT_targets15) EAT Lancet food targets mapping to MAgPIE categories + / t_redmeat, t_legumes, t_nutseeds, t_roots, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio / cassav_sp, others / - +* Note: It is not a 1 to 1 mapping. For certain groups (e.g., others, cassav_sp, +* there are special rules in exodietmacro.gms) EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories - / t_redmeat . (livst_rum, livst_pig, scp) - t_legumes . (puls_pro, soybean, groundnut) - t_fish . (fish) - t_livst_chick . (livst_chick) - t_livst_egg . (livst_egg) - t_livst_milk . (livst_milk) - t_sugar . (sugar) - t_oils . (oils) - / + / t_redmeat . (livst_rum, livst_pig) + t_legumes . (puls_pro, soybean) + t_nutseeds . (rapeseed, sunflower, groundnut) + t_roots . (cassav_sp, potato) + t_fish . (fish) + t_livst_chick . (livst_chick) + t_livst_egg . (livst_egg) + t_livst_milk . (livst_milk) + t_sugar . (sugar) + t_oils . (oils) + / ; diff --git a/scripts/start/projects/project_EAT2.R b/scripts/start/projects/project_EAT2.R index 63f3526d0a..c1fd5fa9c8 100644 --- a/scripts/start/projects/project_EAT2.R +++ b/scripts/start/projects/project_EAT2.R @@ -31,16 +31,69 @@ codeCheck <- FALSE # Testing of new EAT-Lancet diet implementation # ################################################# # Current develop default diet -cfg$title <- "default_Diet" +cfg$title <- "default_Diet_update" cfg$gms$s15_exo_diet <- 0 # default start_run(cfg, codeCheck = codeCheck) # Previous EAT-Lancet implementation -cfg$title <- "eatLancet_1" +cfg$title <- "eatLancet_1_update" cfg$gms$s15_exo_diet <- 1 start_run(cfg, codeCheck = codeCheck) # New EAT-Lancet implementation -cfg$title <- "eatLancet_2" +cfg$title <- "eatLancet_2_update" cfg$gms$s15_exo_diet <- 3 start_run(cfg, codeCheck = codeCheck) + +# Single measures on or off +cfg$title <- "eatLancet_2_ruminants" +cfg$gms$s15_exo_diet <- 3 +cfg$gms$s15_exo_monogastric <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnutroots <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_pulses <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 +cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 +start_run(cfg, codeCheck = codeCheck) + +cfg$title <- "eatLancet_2_monogastrics" +cfg$gms$s15_exo_diet <- 3 +cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_ruminant <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnutroots <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_pulses <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 +cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 +start_run(cfg, codeCheck = codeCheck) + +cfg$title <- "eatLancet_2_fruits" +cfg$gms$s15_exo_diet <- 3 +cfg$gms$s15_exo_monogastric <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_ruminant <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnutroots <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_pulses <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 +cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 +start_run(cfg, codeCheck = codeCheck) + +cfg$title <- "eatLancet_2_legumes" +cfg$gms$s15_exo_diet <- 3 +cfg$gms$s15_exo_monogastric <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_ruminant <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnutroots <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 +cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 +start_run(cfg, codeCheck = codeCheck) diff --git a/scripts/start/test_runs.R b/scripts/start/test_runs.R index 2dff4f7ac9..0a5f8c9204 100644 --- a/scripts/start/test_runs.R +++ b/scripts/start/test_runs.R @@ -54,7 +54,6 @@ for(ssp in c("SSP1","SSP2EU","SSP5")) { cfg$title <- .title(cfg, paste(ssp,"NDC",sep="-")) cfg <- setScenario(cfg,c(ssp,"NDC","rcp4p5")) cfg$gms$c56_mute_ghgprices_until <- "y2150" -# Input for NDC from R32M46 is not available, therefore NPi is used. cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ssp,"-NDC") cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ssp,"-NDC") start_run(cfg, codeCheck = FALSE) @@ -84,4 +83,3 @@ start_run(cfg = cfg, codeCheck = codeCheck) cfg <- fsecScenario(scenario = "e_FSDP") cfg$results_folder_highres <- "output" start_run(cfg = cfg, codeCheck = codeCheck) - From c4607157fedd4e679fb8838d56a6eacded5d877f Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 1 Feb 2024 17:33:19 +0100 Subject: [PATCH 48/71] updated config and included test --- config/default.cfg | 6 +++--- config/scenario_config.csv | 1 + config/scenario_fsec.csv | 1 + modules/15_food/anthro_iso_jun22/exodietmacro.gms | 4 ++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index f2419153eb..8745f97157 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -476,14 +476,14 @@ cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet # * The EAT-Lancet diet only allows for added sugars, # * but does not include processed food or alcohol. -# * only activated if s15_exo_diet is set to 1 -cfg$gms$s15_exo_alcohol <- 0 # def = 1 (as in EATLancet definition), options: 0,1 +# * Only activated if s15_exo_diet is set to 1 +cfg$gms$s15_exo_alcohol <- 1 # def = 1, options: 0,1 # * Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. # * Only activated if s15_exo_alcohol = 1 # * (0): no alcohol consumption, as in the original version of the EAT-Lancet diet # * (0.014): maximum target for alcohol consumption is 1.4% of total calorie consumption # * (see Lassen et al., 2020) -cfg$gms$s15_alc_scen <- 0.014 # def = 0.014 +cfg$gms$s15_alc_scen <- 0 # def = 0 # # # * Switch and specification of countries for which exogenous food scenarios diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 167b6c5696..6368478075 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -23,6 +23,7 @@ gms$s15_exo_oils;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_brans;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_scp;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_alcohol;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_alc_scen;0.014;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c21_trade_liberalization;;;;l908080r807070;l909090r808080;l909090r808080;l909595r809090;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l909595r809090;l908080r807070;;;;;;;;;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l908080r807070;;;;;;;;;;;;;;;;;;; gms$c22_protect_scenario;;;;none;none;none;none;none;none;BH;none;BH_IFL;BH;;;;;;;BH;;BH_IFL;BH_IFL;BH_IFL;BH_IFL;BH_IFL;;;;;;;;;;;;;;;;;;; gms$c22_protect_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;none;none;BH_IFL;none;BH_IFL;;;;;;;;;;;;;;;;;;; diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 384a29f5aa..928dc548e8 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -19,6 +19,7 @@ gms$s15_exo_sugar;;;;;;;;0;0;0;0;0;0;1;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_oils;;;;;;;;0;0;0;0;0;0;1;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_scp;;;;;;;;0;0;0;0;0;0;1;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_alcohol;;;;;;;;0;0;0;0;0;0;1;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; +gms$s15_alc_scen;0.014;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c15_food_scenario;;;SSP1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c21_trade_liberalization;;;;;;;;;;;;;;;;;;;;;;;l908080r807070;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c22_protect_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BH_IFL;;;;;;;;;;;;;;;;;;;; diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 3f66ae702e..6aa32ba567 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -381,6 +381,8 @@ if (s15_exo_diet = 1, (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old))) ; +display i15_intake_detailed_scen_target; + * Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = 0; @@ -610,6 +612,8 @@ elseif s15_exo_diet = 3, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); +display i15_intake_detailed_scen_target; + * Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values i15_intake_detailed_scen_target(t,iso,EAT_staples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = 0; From ef4fd1e8085d9601f69aff8264dcffacf0df2c4f Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 5 Feb 2024 18:03:33 +0100 Subject: [PATCH 49/71] updated preprocessing revision to 4.99 --- CHANGELOG.md | 2 +- config/default.cfg | 6 +++--- config/scenario_fsec.csv | 6 +++--- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 4 ---- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8296b1c137..3566c4a1e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### changed - **15_food** Added improved EAT Lancet diet implementation (EAT 2p0) -- **default.cfg** update input data to rev 4.98 +- **default.cfg** update input data to rev 4.99 (new validation data, new EATLancet recommendations, new semi-natural vegtation cropland data) - **start_functions** Check if cfg$recalibrate is consistent with cfg$gms$s14_use_yield_calib - **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations. - **default.cfg** Default for cfg$gms$peatland changed from `on` to `v2` diff --git a/config/default.cfg b/config/default.cfg index 8745f97157..a120182de7 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "rev4.98_h12_magpie.tgz", - cellular = "rev4.98_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.98_h12_validation.tgz", +cfg$input <- c(regional = "rev4.99_h12_magpie.tgz", + cellular = "rev4.99_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.99_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 928dc548e8..9069268243 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -66,9 +66,9 @@ gms$s62_max_dem_bioplastic;0;;;;400;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c70_fac_req_regr;reg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c70_feed_scen;;;;;;;;;;;;;;;;;;ssp1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c73_build_demand;;;;;;;;;;;;;;;;;;;;;;;;50pc;;;;;;;;;;;;;;;;;;;;;;;;; -input['cellular'];rev4.96_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.96_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.96_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.96_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.96_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.96_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.96_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; -input['regional'];rev4.96_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['validation'];rev4.96_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['cellular'];rev4.99_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.99_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.99_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.99_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.99_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.99_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.99_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +input['regional'];rev4.99_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['validation'];rev4.99_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input['additional'];additional_data_rev4.47.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input['calibration'];calibration_FSEC_24Mar23.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; magicc_emis_scen;bjoernAR6_C_SSP2-NDC.mif;;;bjoernAR6_C_SSP2-PkBudg900.mif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;bjoernAR6_C_SSP1-NDC.mif;;;;;;;;;;;;bjoernAR6_C_SSP1-PkBudg900.mif diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 6aa32ba567..cb8be4c701 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -394,10 +394,6 @@ display i15_intake_detailed_scen_target; abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; ); -* VARTIKA: What about s15_exo_diet = 2? -* Can this be transformed to the new diet implementation? Did you have target values there? -* (Note: The old EATLancet implementation should be deleted soon.) - *---------------------------------------------------------------------------------------- elseif s15_exo_diet = 3, *' In case of a MAgPIE-specific realization of the EAT Lancet diet (`s15_exo_diet=3`), From 3e4b0a8c7f1608f795b20b48c3fe7826b81639b3 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 5 Feb 2024 18:11:40 +0100 Subject: [PATCH 50/71] delte testing script --- scripts/start/projects/project_EAT2.R | 99 --------------------------- 1 file changed, 99 deletions(-) delete mode 100644 scripts/start/projects/project_EAT2.R diff --git a/scripts/start/projects/project_EAT2.R b/scripts/start/projects/project_EAT2.R deleted file mode 100644 index c1fd5fa9c8..0000000000 --- a/scripts/start/projects/project_EAT2.R +++ /dev/null @@ -1,99 +0,0 @@ -# | (C) 2008-2023 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: EAT 2.0 simulations -# ---------------------------------------------------------- - -###################################### -#### Script to start a MAgPIE run #### -###################################### -library(gms) -library(lucode2) -library(magclass) - -# load start_function which is needed to start MAgPIE runs -source("scripts/start_functions.R") - -# laod default configuration -source("config/default.cfg") - -cfg$force_download <- TRUE - -# Set defaults -codeCheck <- FALSE - -################################################# -# Testing of new EAT-Lancet diet implementation # -################################################# -# Current develop default diet -cfg$title <- "default_Diet_update" -cfg$gms$s15_exo_diet <- 0 # default -start_run(cfg, codeCheck = codeCheck) - -# Previous EAT-Lancet implementation -cfg$title <- "eatLancet_1_update" -cfg$gms$s15_exo_diet <- 1 -start_run(cfg, codeCheck = codeCheck) - -# New EAT-Lancet implementation -cfg$title <- "eatLancet_2_update" -cfg$gms$s15_exo_diet <- 3 -start_run(cfg, codeCheck = codeCheck) - -# Single measures on or off -cfg$title <- "eatLancet_2_ruminants" -cfg$gms$s15_exo_diet <- 3 -cfg$gms$s15_exo_monogastric <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnutroots <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_pulses <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 -cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 -start_run(cfg, codeCheck = codeCheck) - -cfg$title <- "eatLancet_2_monogastrics" -cfg$gms$s15_exo_diet <- 3 -cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_ruminant <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnutroots <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_pulses <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 -cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 -start_run(cfg, codeCheck = codeCheck) - -cfg$title <- "eatLancet_2_fruits" -cfg$gms$s15_exo_diet <- 3 -cfg$gms$s15_exo_monogastric <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_ruminant <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnutroots <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_pulses <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 -cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 -start_run(cfg, codeCheck = codeCheck) - -cfg$title <- "eatLancet_2_legumes" -cfg$gms$s15_exo_diet <- 3 -cfg$gms$s15_exo_monogastric <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_ruminant <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnutroots <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 -cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 -start_run(cfg, codeCheck = codeCheck) From 89eb6135fe05c405d183578fb411f3a2802db517 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 7 Feb 2024 15:39:57 +0100 Subject: [PATCH 51/71] updated renv setting --- config/default.cfg | 2 +- core/sets.gms | 48 +++--- main.gms | 46 ++--- renv/activate.R | 421 +++++++++++++-------------------------------- 4 files changed, 165 insertions(+), 352 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index a120182de7..71fcaca7d0 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -25,7 +25,7 @@ cfg$model <- "main.gms" #def = "main.gms" cfg$input <- c(regional = "rev4.99_h12_magpie.tgz", cellular = "rev4.99_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", validation = "rev4.99_h12_validation.tgz", - additional = "additional_data_rev4.46.tgz", + additional = "additional_data_rev4.47.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") # NOTE: It is recommended to recalibrate the model when changing cellular input data diff --git a/core/sets.gms b/core/sets.gms index e49a577fe4..4e35a355a6 100644 --- a/core/sets.gms +++ b/core/sets.gms @@ -55,32 +55,32 @@ sets VEN, VGB, VIR, VNM, VUT, WLF, WSM, YEM, ZAF, ZMB, ZWE / j number of LPJ cells - / CAZ_1*CAZ_5, - CHA_6*CHA_21, - EUR_22*EUR_29, - IND_30*IND_36, - JPN_37*JPN_38, - LAM_39*LAM_79, - MEA_80*MEA_109, - NEU_110*NEU_117, - OAS_118*OAS_128, - REF_129*REF_140, - SSA_141*SSA_179, - USA_180*USA_200 / + / CAZ_1*CAZ_14, + CHA_15*CHA_37, + EUR_38*EUR_47, + IND_48*IND_54, + JPN_55*JPN_58, + LAM_59*LAM_84, + MEA_85*MEA_105, + NEU_106*NEU_114, + OAS_115*OAS_130, + REF_131*REF_153, + SSA_154*SSA_185, + USA_186*USA_200 / cell(i,j) number of LPJ cells per region i - / CAZ . (CAZ_1*CAZ_5) - CHA . (CHA_6*CHA_21) - EUR . (EUR_22*EUR_29) - IND . (IND_30*IND_36) - JPN . (JPN_37*JPN_38) - LAM . (LAM_39*LAM_79) - MEA . (MEA_80*MEA_109) - NEU . (NEU_110*NEU_117) - OAS . (OAS_118*OAS_128) - REF . (REF_129*REF_140) - SSA . (SSA_141*SSA_179) - USA . (USA_180*USA_200) / + / CAZ . (CAZ_1*CAZ_14) + CHA . (CHA_15*CHA_37) + EUR . (EUR_38*EUR_47) + IND . (IND_48*IND_54) + JPN . (JPN_55*JPN_58) + LAM . (LAM_59*LAM_84) + MEA . (MEA_85*MEA_105) + NEU . (NEU_106*NEU_114) + OAS . (OAS_115*OAS_130) + REF . (REF_131*REF_153) + SSA . (SSA_154*SSA_185) + USA . (USA_186*USA_200) / i_to_iso(i,iso) mapping regions to iso countries / CAZ . (AUS, CAN, HMD, NZL, SPM) diff --git a/main.gms b/main.gms index bc9b0bacfc..20ea421f75 100644 --- a/main.gms +++ b/main.gms @@ -147,56 +147,56 @@ $title magpie *' * Always try to access model outputs through the corresponding magpie package instead of accessing them directly with readGDX. It cannot be guaranteed that your script will work in the future if you do otherwise (as only the corresponding magpie package will be continuously adapted to changes in the GAMS code). *##################### R SECTION START (VERSION INFO) ########################## -* -* Used data set: rev4.96_h12_magpie.tgz +* +* Used data set: rev4.99_h12_magpie.tgz * md5sum: NA * Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output -* -* Used data set: rev4.96_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz +* +* Used data set: rev4.99_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz * md5sum: NA * Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output -* -* Used data set: rev4.96_h12_validation.tgz +* +* Used data set: rev4.99_h12_validation.tgz * md5sum: NA * Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output -* +* * Used data set: additional_data_rev4.47.tgz * md5sum: NA * Repository: scp://cluster.pik-potsdam.de/p/projects/landuse/data/input/archive -* +* * Used data set: calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz * md5sum: NA * Repository: https://rse.pik-potsdam.de/data/magpie/public -* +* * Low resolution: c200 * High resolution: 0.5 -* +* * Total number of cells: 200 -* +* * Number of cells per region: * CAZ CHA EUR IND JPN LAM MEA NEU OAS REF SSA USA -* 5 16 8 7 2 41 30 8 11 12 39 21 -* +* 14 23 10 7 4 26 21 9 16 23 32 15 +* * Regionscode: 62eff8f7 -* -* Regions data revision: 4.96 -* +* +* Regions data revision: 4.99 +* * lpj2magpie settings: * * LPJmL data: MRI-ESM2-0:ssp370 -* * Revision: 4.96 -* +* * Revision: 4.99 +* * aggregation settings: * * Input resolution: 0.5 * * Output resolution: c200 * * Regionscode: 62eff8f7 * * Number of clusters per region: * CAZ CHA EUR IND JPN LAM MEA NEU OAS REF SSA USA -* 5 16 8 7 2 41 30 8 11 12 39 21 +* 14 23 10 7 4 26 21 9 16 23 32 15 * * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler) -* -* -* Last modification (input data): Fri Dec 22 16:58:47 2023 -* +* +* +* Last modification (input data): Wed Feb 7 15:35:14 2024 +* *###################### R SECTION END (VERSION INFO) ########################### $offupper diff --git a/renv/activate.R b/renv/activate.R index 55dae8650e..019b5a6693 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -3,7 +3,6 @@ local({ # the requested version of renv version <- "0.16.0" - attr(version, "sha") <- "0e3aab27a928eb261819a3fc45a3ee2b4ba902a5" # the project directory project <- getwd() @@ -61,75 +60,21 @@ local({ # load bootstrap tools `%||%` <- function(x, y) { - if (is.null(x)) y else x - } - - catf <- function(fmt, ..., appendLF = TRUE) { - - quiet <- getOption("renv.bootstrap.quiet", default = FALSE) - if (quiet) - return(invisible()) - - msg <- sprintf(fmt, ...) - cat(msg, file = stdout(), sep = if (appendLF) "\n" else "") - - invisible(msg) - - } - - header <- function(label, - ..., - prefix = "#", - suffix = "-", - n = min(getOption("width"), 78)) - { - label <- sprintf(label, ...) - n <- max(n - nchar(label) - nchar(prefix) - 2L, 8L) - if (n <= 0) - return(paste(prefix, label)) - - tail <- paste(rep.int(suffix, n), collapse = "") - paste0(prefix, " ", label, " ", tail) - - } - - startswith <- function(string, prefix) { - substring(string, 1, nchar(prefix)) == prefix + if (is.environment(x) || length(x)) x else y } bootstrap <- function(version, library) { - friendly <- renv_bootstrap_version_friendly(version) - section <- header(sprintf("Bootstrapping renv %s", friendly)) - catf(section) - # attempt to download renv - catf("- Downloading renv ... ", appendLF = FALSE) - withCallingHandlers( - tarball <- renv_bootstrap_download(version), - error = function(err) { - catf("FAILED") - stop("failed to download:\n", conditionMessage(err)) - } - ) - catf("OK") - on.exit(unlink(tarball), add = TRUE) + tarball <- tryCatch(renv_bootstrap_download(version), error = identity) + if (inherits(tarball, "error")) + stop("failed to download renv ", version) # now attempt to install - catf("- Installing renv ... ", appendLF = FALSE) - withCallingHandlers( - status <- renv_bootstrap_install(version, tarball, library), - error = function(err) { - catf("FAILED") - stop("failed to install:\n", conditionMessage(err)) - } - ) - catf("OK") - - # add empty line to break up bootstrapping from normal output - catf("") + status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity) + if (inherits(status, "error")) + stop("failed to install renv ", version) - return(invisible()) } renv_bootstrap_tests_running <- function() { @@ -138,32 +83,28 @@ local({ renv_bootstrap_repos <- function() { - # get CRAN repository - cran <- getOption("renv.repos.cran", "https://cloud.r-project.org") - # check for repos override repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) - if (!is.na(repos)) { - - # check for RSPM; if set, use a fallback repository for renv - rspm <- Sys.getenv("RSPM", unset = NA) - if (identical(rspm, repos)) - repos <- c(RSPM = rspm, CRAN = cran) - + if (!is.na(repos)) return(repos) - } - # check for lockfile repositories repos <- tryCatch(renv_bootstrap_repos_lockfile(), error = identity) if (!inherits(repos, "error") && length(repos)) return(repos) + # if we're testing, re-use the test repositories + if (renv_bootstrap_tests_running()) + return(getOption("renv.tests.repos")) + # retrieve current repos repos <- getOption("repos") # ensure @CRAN@ entries are resolved - repos[repos == "@CRAN@"] <- cran + repos[repos == "@CRAN@"] <- getOption( + "renv.repos.cran", + "https://cloud.r-project.org" + ) # add in renv.bootstrap.repos if set default <- c(FALLBACK = "https://cloud.r-project.org") @@ -202,34 +143,33 @@ local({ renv_bootstrap_download <- function(version) { - sha <- attr(version, "sha", exact = TRUE) - - methods <- if (!is.null(sha)) { - - # attempting to bootstrap a development version of renv - c( - function() renv_bootstrap_download_tarball(sha), - function() renv_bootstrap_download_github(sha) + # if the renv version number has 4 components, assume it must + # be retrieved via github + nv <- numeric_version(version) + components <- unclass(nv)[[1]] + + # if this appears to be a development version of 'renv', we'll + # try to restore from github + dev <- length(components) == 4L + + # begin collecting different methods for finding renv + methods <- c( + renv_bootstrap_download_tarball, + if (dev) + renv_bootstrap_download_github + else c( + renv_bootstrap_download_cran_latest, + renv_bootstrap_download_cran_archive ) - - } else { - - # attempting to bootstrap a release version of renv - c( - function() renv_bootstrap_download_tarball(version), - function() renv_bootstrap_download_cran_latest(version), - function() renv_bootstrap_download_cran_archive(version) - ) - - } + ) for (method in methods) { - path <- tryCatch(method(), error = identity) + path <- tryCatch(method(version), error = identity) if (is.character(path) && file.exists(path)) return(path) } - stop("All download methods failed") + stop("failed to download renv ", version) } @@ -293,6 +233,8 @@ local({ type <- spec$type repos <- spec$repos + message("* Downloading renv ", version, " ... ", appendLF = FALSE) + baseurl <- utils::contrib.url(repos = repos, type = type) ext <- if (identical(type, "source")) ".tar.gz" @@ -309,10 +251,13 @@ local({ condition = identity ) - if (inherits(status, "condition")) + if (inherits(status, "condition")) { + message("FAILED") return(FALSE) + } # report success and return + message("OK (downloaded ", type, ")") destfile } @@ -369,6 +314,8 @@ local({ urls <- file.path(repos, "src/contrib/Archive/renv", name) destfile <- file.path(tempdir(), name) + message("* Downloading renv ", version, " ... ", appendLF = FALSE) + for (url in urls) { status <- tryCatch( @@ -376,11 +323,14 @@ local({ condition = identity ) - if (identical(status, 0L)) + if (identical(status, 0L)) { + message("OK") return(destfile) + } } + message("FAILED") return(FALSE) } @@ -394,7 +344,8 @@ local({ return() # allow directories - if (dir.exists(tarball)) { + info <- file.info(tarball, extra_cols = FALSE) + if (identical(info$isdir, TRUE)) { name <- sprintf("renv_%s.tar.gz", version) tarball <- file.path(tarball, name) } @@ -403,7 +354,7 @@ local({ if (!file.exists(tarball)) { # let the user know we weren't able to honour their request - fmt <- "- RENV_BOOTSTRAP_TARBALL is set (%s) but does not exist." + fmt <- "* RENV_BOOTSTRAP_TARBALL is set (%s) but does not exist." msg <- sprintf(fmt, tarball) warning(msg) @@ -412,7 +363,10 @@ local({ } - catf("- Using local tarball '%s'.", tarball) + fmt <- "* Bootstrapping with tarball at path '%s'." + msg <- sprintf(fmt, tarball) + message(msg) + tarball } @@ -439,6 +393,8 @@ local({ on.exit(do.call(base::options, saved), add = TRUE) } + message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE) + url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) name <- sprintf("renv_%s.tar.gz", version) destfile <- file.path(tempdir(), name) @@ -448,105 +404,26 @@ local({ condition = identity ) - if (!identical(status, 0L)) + if (!identical(status, 0L)) { + message("FAILED") return(FALSE) - - renv_bootstrap_download_augment(destfile) - - return(destfile) - - } - - # Add Sha to DESCRIPTION. This is stop gap until #890, after which we - # can use renv::install() to fully capture metadata. - renv_bootstrap_download_augment <- function(destfile) { - sha <- renv_bootstrap_git_extract_sha1_tar(destfile) - if (is.null(sha)) { - return() } - # Untar - tempdir <- tempfile("renv-github-") - on.exit(unlink(tempdir, recursive = TRUE), add = TRUE) - untar(destfile, exdir = tempdir) - pkgdir <- dir(tempdir, full.names = TRUE)[[1]] - - # Modify description - desc_path <- file.path(pkgdir, "DESCRIPTION") - desc_lines <- readLines(desc_path) - remotes_fields <- c( - "RemoteType: github", - "RemoteHost: api.github.com", - "RemoteRepo: renv", - "RemoteUsername: rstudio", - "RemotePkgRef: rstudio/renv", - paste("RemoteRef: ", sha), - paste("RemoteSha: ", sha) - ) - writeLines(c(desc_lines[desc_lines != ""], remotes_fields), con = desc_path) - - # Re-tar - local({ - old <- setwd(tempdir) - on.exit(setwd(old), add = TRUE) - - tar(destfile, compression = "gzip") - }) - invisible() - } + message("OK") + return(destfile) - # Extract the commit hash from a git archive. Git archives include the SHA1 - # hash as the comment field of the tarball pax extended header - # (see https://www.kernel.org/pub/software/scm/git/docs/git-archive.html) - # For GitHub archives this should be the first header after the default one - # (512 byte) header. - renv_bootstrap_git_extract_sha1_tar <- function(bundle) { - - # open the bundle for reading - # We use gzcon for everything because (from ?gzcon) - # > Reading from a connection which does not supply a ‘gzip’ magic - # > header is equivalent to reading from the original connection - conn <- gzcon(file(bundle, open = "rb", raw = TRUE)) - on.exit(close(conn)) - - # The default pax header is 512 bytes long and the first pax extended header - # with the comment should be 51 bytes long - # `52 comment=` (11 chars) + 40 byte SHA1 hash - len <- 0x200 + 0x33 - res <- rawToChar(readBin(conn, "raw", n = len)[0x201:len]) - - if (grepl("^52 comment=", res)) { - sub("52 comment=", "", res) - } else { - NULL - } } renv_bootstrap_install <- function(version, tarball, library) { # attempt to install it into project library + message("* Installing renv ", version, " ... ", appendLF = FALSE) dir.create(library, showWarnings = FALSE, recursive = TRUE) - output <- renv_bootstrap_install_impl(library, tarball) - - # check for successful install - status <- attr(output, "status") - if (is.null(status) || identical(status, 0L)) - return(status) - - # an error occurred; report it - header <- "installation of renv failed" - lines <- paste(rep.int("=", nchar(header)), collapse = "") - text <- paste(c(header, lines, output), collapse = "\n") - stop(text) - - } - - renv_bootstrap_install_impl <- function(library, tarball) { # invoke using system2 so we can capture and report output bin <- R.home("bin") exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" - R <- file.path(bin, exe) + r <- file.path(bin, exe) args <- c( "--vanilla", "CMD", "INSTALL", "--no-multiarch", @@ -554,7 +431,19 @@ local({ shQuote(path.expand(tarball)) ) - system2(R, args, stdout = TRUE, stderr = TRUE) + output <- system2(r, args, stdout = TRUE, stderr = TRUE) + message("Done!") + + # check for successful install + status <- attr(output, "status") + if (is.numeric(status) && !identical(status, 0L)) { + header <- "Error installing renv:" + lines <- paste(rep.int("=", nchar(header)), collapse = "") + text <- c(header, lines, output) + writeLines(text, con = stderr()) + } + + status } @@ -764,58 +653,32 @@ local({ } - renv_bootstrap_validate_version <- function(version, description = NULL) { - - # resolve description file - description <- description %||% { - path <- getNamespaceInfo("renv", "path") - packageDescription("renv", lib.loc = dirname(path)) - } - - # check whether requested version 'version' matches loaded version of renv - sha <- attr(version, "sha", exact = TRUE) - valid <- if (!is.null(sha)) - renv_bootstrap_validate_version_dev(sha, description) - else - renv_bootstrap_validate_version_release(version, description) + renv_bootstrap_validate_version <- function(version) { - if (valid) + loadedversion <- utils::packageDescription("renv", fields = "Version") + if (version == loadedversion) return(TRUE) - # the loaded version of renv doesn't match the requested version; - # give the user instructions on how to proceed - remote <- if (!is.null(description[["RemoteSha"]])) { - paste("rstudio/renv", description[["RemoteSha"]], sep = "@") - } else { - paste("renv", description[["Version"]], sep = "@") - } - - # display both loaded version + sha if available - friendly <- renv_bootstrap_version_friendly( - version = description[["Version"]], - sha = description[["RemoteSha"]] - ) + # assume four-component versions are from GitHub; three-component + # versions are from CRAN + components <- strsplit(loadedversion, "[.-]")[[1]] + remote <- if (length(components) == 4L) + paste("rstudio/renv", loadedversion, sep = "@") + else + paste("renv", loadedversion, sep = "@") fmt <- paste( "renv %1$s was loaded from project library, but this project is configured to use renv %2$s.", - "- Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", - "- Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", + "Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", + "Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", sep = "\n" ) - catf(fmt, friendly, renv_bootstrap_version_friendly(version), remote) - FALSE + msg <- sprintf(fmt, loadedversion, version, remote) + warning(msg, call. = FALSE) - } - - renv_bootstrap_validate_version_dev <- function(version, description) { - expected <- description[["RemoteSha"]] - is.character(expected) && startswith(expected, version) - } + FALSE - renv_bootstrap_validate_version_release <- function(version, description) { - expected <- description[["Version"]] - is.character(expected) && identical(expected, version) } renv_bootstrap_hash_text <- function(text) { @@ -837,12 +700,6 @@ local({ # warn if the version of renv loaded does not match renv_bootstrap_validate_version(version) - # execute renv load hooks, if any - hooks <- getHook("renv::autoload") - for (hook in hooks) - if (is.function(hook)) - tryCatch(hook(), error = warning) - # load the project renv::load(project) @@ -982,66 +839,14 @@ local({ } - renv_bootstrap_version_friendly <- function(version, sha = NULL) { - sha <- sha %||% attr(version, "sha", exact = TRUE) - parts <- c(version, sprintf("[sha: %s]", substring(sha, 1L, 7L))) - paste(parts, collapse = " ") - } - - renv_bootstrap_run <- function(version, libpath) { - - # perform bootstrap - bootstrap(version, libpath) - - # exit early if we're just testing bootstrap - if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) - return(TRUE) - - # try again to load - if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { - return(renv::load(project = getwd())) - } - - # failed to download or load renv; warn the user - msg <- c( - "Failed to find an renv installation: the project will not be loaded.", - "Use `renv::activate()` to re-initialize the project." - ) - - warning(paste(msg, collapse = "\n"), call. = FALSE) - - } - - - renv_bootstrap_in_rstudio <- function() { - commandArgs()[[1]] == "RStudio" - } renv_json_read <- function(file = NULL, text = NULL) { - jlerr <- NULL - # if jsonlite is loaded, use that instead - if ("jsonlite" %in% loadedNamespaces()) { - - json <- catch(renv_json_read_jsonlite(file, text)) - if (!inherits(json, "error")) - return(json) - - jlerr <- json - - } - - # otherwise, fall back to the default JSON reader - json <- catch(renv_json_read_default(file, text)) - if (!inherits(json, "error")) - return(json) - - # report an error - if (!is.null(jlerr)) - stop(jlerr) + if ("jsonlite" %in% loadedNamespaces()) + renv_json_read_jsonlite(file, text) else - stop(json) + renv_json_read_default(file, text) } @@ -1159,23 +964,31 @@ local({ if (renv_bootstrap_load(project, libpath, version)) return(TRUE) - if (renv_bootstrap_in_rstudio()) { - setHook("rstudio.sessionInit", function(...) { - renv_bootstrap_run(version, libpath) + # load failed; inform user we're about to bootstrap + prefix <- paste("# Bootstrapping renv", version) + postfix <- paste(rep.int("-", 77L - nchar(prefix)), collapse = "") + header <- paste(prefix, postfix) + message(header) - # Work around buglet in RStudio if hook uses readline - tryCatch( - { - tools <- as.environment("tools:rstudio") - tools$.rs.api.sendToConsole("", echo = FALSE, focus = FALSE) - }, - error = function(cnd) {} - ) - }) - } else { - renv_bootstrap_run(version, libpath) + # perform bootstrap + bootstrap(version, libpath) + + # exit early if we're just testing bootstrap + if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) + return(TRUE) + + # try again to load + if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + message("* Successfully installed and loaded renv ", version, ".") + return(renv::load()) } - invisible() + # failed to download or load renv; warn the user + msg <- c( + "Failed to find an renv installation: the project will not be loaded.", + "Use `renv::activate()` to re-initialize the project." + ) + + warning(paste(msg, collapse = "\n"), call. = FALSE) }) From adbbca6e61b95475d1a7e298276381a47eb8d360 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:48:24 +0100 Subject: [PATCH 52/71] Shuffled authors in food module --- modules/15_food/anthro_iso_jun22/realization.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/realization.gms b/modules/15_food/anthro_iso_jun22/realization.gms index e2c4c14760..10726a83ea 100644 --- a/modules/15_food/anthro_iso_jun22/realization.gms +++ b/modules/15_food/anthro_iso_jun22/realization.gms @@ -45,4 +45,4 @@ $Ifi "%phase%" == "postsolve" $include "./modules/15_food/anthro_iso_jun22/posts *' diet scenarios, most importantly the shift to the Planetary Health diet *' [@willett_food_2019]. *' -*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Jan Philipp Dietrich, Felicitas Beier +*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Felicitas Beier, Jan Philipp Dietrich From e14238471d3c18e9829f79158d3d8ea62651ca42 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 7 Feb 2024 16:47:50 +0100 Subject: [PATCH 53/71] removed unnecessary display statements --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 3 --- modules/15_food/anthropometrics_jan18/preloop.gms | 5 ----- 2 files changed, 8 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index cb8be4c701..2b0582432a 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -381,8 +381,6 @@ if (s15_exo_diet = 1, (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old))) ; -display i15_intake_detailed_scen_target; - * Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = 0; @@ -608,7 +606,6 @@ elseif s15_exo_diet = 3, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); -display i15_intake_detailed_scen_target; * Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values i15_intake_detailed_scen_target(t,iso,EAT_staples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = diff --git a/modules/15_food/anthropometrics_jan18/preloop.gms b/modules/15_food/anthropometrics_jan18/preloop.gms index 8d84dcd7c6..f8c9a123fa 100644 --- a/modules/15_food/anthropometrics_jan18/preloop.gms +++ b/modules/15_food/anthropometrics_jan18/preloop.gms @@ -52,11 +52,6 @@ Elseif s15_milk_share_fadeout_india = 1, i15_milk_share_fadeout_india(t) = f15_milk_share_fadeout_india(t); ); -display i15_milk_share_fadeout_india; - - - - * ###### Exogenous food waste and diet scenarios as well as food substitution scenarios From 89854b60232982168bf0b38cbe1cd37d4524f5d1 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 9 Feb 2024 14:28:54 +0100 Subject: [PATCH 54/71] improvements recommended by Bennis review --- config/default.cfg | 5 +- .../15_food/anthro_iso_jun22/declarations.gms | 3 +- .../15_food/anthro_iso_jun22/exodietmacro.gms | 202 +++++++++--------- modules/15_food/anthro_iso_jun22/input.gms | 3 +- modules/15_food/anthro_iso_jun22/preloop.gms | 3 - .../anthropometrics_jan18/declarations.gms | 2 +- .../anthropometrics_jan18/intersolve.gms | 8 +- .../anthropometrics_jan18/presolve.gms | 10 +- 8 files changed, 121 insertions(+), 115 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 71fcaca7d0..183f0dbb0b 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -466,11 +466,12 @@ cfg$gms$c15_EAT_scen <- "FLX" # def = FLX cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_fish <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnutroots <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnut <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_roots <- 1 # def = 1, options: 0,1 (only relevant for new EATLancet realization s15_exo_diet=3) cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_sugar <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_oils <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet, they are kept at their historical value, unless switch activated (1), then brans are set to 0), options: 0,1 cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index 0aac72e28e..c87cd37652 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -152,9 +152,8 @@ parameters i15_intake_scen_target(t,iso) Target for total per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) Food-specific per capita calorie intake according to various EAT Lancet diet scenarios (kcal per capita per day) i15_intake_EATLancet(iso,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) - i15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) + p15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) - i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) p15_intake_detail_starchyfruit(t,iso) Auxiliary parameter for the intake of starchy fruits included in cassav_sp (kcal per capita per day) p15_intake_detail_roots(t,iso) Auxiliary parameter for the intake of roots (kcal per capita per day) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 2b0582432a..e56b2ef099 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -313,10 +313,10 @@ $else $endif *' The intake target is adjusted to meet the calorie target - i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) > 0) = + p15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) > 0) = p15_intake_detail(t,iso,kfo) / p15_intake_total(t,iso) * i15_intake_scen_target(t,iso); - i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) = 0) = 0; + p15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) = 0) = 0; *' 2.) The second step defines the daily per capita intake of different food *' commodities. @@ -339,64 +339,64 @@ if (s15_exo_diet = 1, *' upper bound for monogastric meat and eggs if (s15_exo_monogastric=1, - i15_intake_detailed_scen_target(t,iso,EAT_monogastrics15)$(i15_intake_detailed_scen_target(t,iso,EAT_monogastrics15) > i15_intake_EATLancet(iso,EAT_monogastrics15)) + p15_intake_detailed_scen_target(t,iso,EAT_monogastrics15)$(p15_intake_detailed_scen_target(t,iso,EAT_monogastrics15) > i15_intake_EATLancet(iso,EAT_monogastrics15)) = i15_intake_EATLancet(iso,EAT_monogastrics15)); *' upper bound for ruminant products if (s15_exo_ruminant=1, - i15_intake_detailed_scen_target(t,iso,EAT_ruminants15)$(i15_intake_detailed_scen_target(t,iso,EAT_ruminants15) > i15_intake_EATLancet(iso,EAT_ruminants15)) + p15_intake_detailed_scen_target(t,iso,EAT_ruminants15)$(p15_intake_detailed_scen_target(t,iso,EAT_ruminants15) > i15_intake_EATLancet(iso,EAT_ruminants15)) = i15_intake_EATLancet(iso,EAT_ruminants15)); *' target value for fish if (s15_exo_fish=1, - i15_intake_detailed_scen_target(t,iso,"fish") = i15_intake_EATLancet(iso,"fish")); + p15_intake_detailed_scen_target(t,iso,"fish") = i15_intake_EATLancet(iso,"fish")); *' lower bound for fruits, veggies, nuts and seeds - if (s15_exo_fruitvegnutroots=1, - i15_intake_detailed_scen_target(t,iso,EAT_fruitvegnutseed15)$(i15_intake_detailed_scen_target(t,iso,EAT_fruitvegnutseed15) < i15_intake_EATLancet(iso,EAT_fruitvegnutseed15)) + if (s15_exo_fruitvegnut=1, + p15_intake_detailed_scen_target(t,iso,EAT_fruitvegnutseed15)$(p15_intake_detailed_scen_target(t,iso,EAT_fruitvegnutseed15) < i15_intake_EATLancet(iso,EAT_fruitvegnutseed15)) = i15_intake_EATLancet(iso,EAT_fruitvegnutseed15)); *' lower bound for pulses if (s15_exo_pulses=1, - i15_intake_detailed_scen_target(t,iso,EAT_pulses15_old)$(i15_intake_detailed_scen_target(t,iso,EAT_pulses15_old) < i15_intake_EATLancet(iso,EAT_pulses15_old)) + p15_intake_detailed_scen_target(t,iso,EAT_pulses15_old)$(p15_intake_detailed_scen_target(t,iso,EAT_pulses15_old) < i15_intake_EATLancet(iso,EAT_pulses15_old)) = i15_intake_EATLancet(iso,EAT_pulses15_old)); *' upper bound for sugar if (s15_exo_sugar=1, - i15_intake_detailed_scen_target(t,iso,EAT_sugar15)$(i15_intake_detailed_scen_target(t,iso,EAT_sugar15) > i15_intake_EATLancet(iso,EAT_sugar15)) + p15_intake_detailed_scen_target(t,iso,EAT_sugar15)$(p15_intake_detailed_scen_target(t,iso,EAT_sugar15) > i15_intake_EATLancet(iso,EAT_sugar15)) = i15_intake_EATLancet(iso,EAT_sugar15)); *' target value for oils if (s15_exo_oils=1, - i15_intake_detailed_scen_target(t,iso,"oils") = i15_intake_EATLancet(iso,"oils")); + p15_intake_detailed_scen_target(t,iso,"oils") = i15_intake_EATLancet(iso,"oils")); *' target value for brans if (s15_exo_brans=1, - i15_intake_detailed_scen_target(t,iso,"brans") = i15_intake_EATLancet(iso,"brans")); + p15_intake_detailed_scen_target(t,iso,"brans") = i15_intake_EATLancet(iso,"brans")); *' target value for single cell protein if (s15_exo_scp=1, - i15_intake_detailed_scen_target(t,iso,"scp") = i15_intake_EATLancet(iso,"scp")); + p15_intake_detailed_scen_target(t,iso,"scp") = i15_intake_EATLancet(iso,"scp")); *' upper bound for alcohol * alcohol target is not part of EAT Lancet recommendation. Upper boundary is therefore included as specific switch s15_alc_scen if (s15_exo_alcohol=1, - i15_intake_detailed_scen_target(t,iso,"alcohol")$(i15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen*i15_intake_scen_target(t,iso)) + p15_intake_detailed_scen_target(t,iso,"alcohol")$(p15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen*i15_intake_scen_target(t,iso)) = s15_alc_scen*i15_intake_scen_target(t,iso); ); - i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old)) > 0) = - (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old))) * + p15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old)) > 0) = + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old))) * (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old))) ; -* Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values - i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = +* Correction where calorie balancing would lead to negative p15_intake_detailed_scen_target values + p15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = 0; - i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = - i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) + p15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = + i15_intake_scen_target(t,iso) * p15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples2_old, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) ; - if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, - abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; + if (smin((iso,kfo), p15_intake_detailed_scen_target(t,iso,kfo)) < 0, + abort "The parameter p15_intake_detailed_scen_target became negative after calorie balancing."; ); *---------------------------------------------------------------------------------------- elseif s15_exo_diet = 3, *' In case of a MAgPIE-specific realization of the EAT Lancet diet (`s15_exo_diet=3`), *' model-internal diet projections are constrained by recommended ranges for intake -*' (`i15_rec_EATLancet`) of different food groups to ensure healthy and sustainable +*' (`f15_rec_EATLancet`) of different food groups to ensure healthy and sustainable *' diets according to the EAT-Lancet Commission. After all calorie recommendations *' for non-staple food groups are satisfied, intake of staple crops is modified such *' that the in step 1.) selected total calorie intake is met. @@ -417,52 +417,50 @@ elseif s15_exo_diet = 3, *' upper bound for monogastric products if (s15_exo_monogastric = 1, * upper bound for eggs - i15_intake_detailed_scen_target(t,iso,"livst_egg")$(p15_intake_detail(t,iso,"livst_egg") - > i15_rec_EATLancet(iso,"t_livst_egg","max") + p15_intake_detailed_scen_target(t,iso,"livst_egg")$(p15_intake_detail(t,iso,"livst_egg") + > f15_rec_EATLancet(iso,"t_livst_egg","max") ) = - i15_rec_EATLancet(iso,"t_livst_egg","max"); + f15_rec_EATLancet(iso,"t_livst_egg","max"); * upper bound for chicken - i15_intake_detailed_scen_target(t,iso,"livst_chick")$(p15_intake_detail(t,iso,"livst_chick") - > i15_rec_EATLancet(iso,"t_livst_chick","max") + p15_intake_detailed_scen_target(t,iso,"livst_chick")$(p15_intake_detail(t,iso,"livst_chick") + > f15_rec_EATLancet(iso,"t_livst_chick","max") ) = - i15_rec_EATLancet(iso,"t_livst_chick","max"); + f15_rec_EATLancet(iso,"t_livst_chick","max"); * upper bound for redmeat (share of pigs in redmeat) - i15_intake_detailed_scen_target(t,iso,"livst_pig")$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) - > i15_rec_EATLancet(iso,"t_redmeat","max") + p15_intake_detailed_scen_target(t,iso,"livst_pig")$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) + > f15_rec_EATLancet(iso,"t_redmeat","max") ) = (p15_intake_detail(t,iso,"livst_pig") / sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2))) - * i15_rec_EATLancet(iso,"t_redmeat","max"); + * f15_rec_EATLancet(iso,"t_redmeat","max"); ); *' upper bound for ruminant products if (s15_exo_ruminant = 1, * upper bound for redmeat (pig and ruminant) - i15_intake_detailed_scen_target(t,iso,"livst_rum")$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) - > i15_rec_EATLancet(iso,"t_redmeat","max") + p15_intake_detailed_scen_target(t,iso,"livst_rum")$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) + > f15_rec_EATLancet(iso,"t_redmeat","max") ) = (p15_intake_detail(t,iso,"livst_rum") / sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2))) - * i15_rec_EATLancet(iso,"t_redmeat","max"); + * f15_rec_EATLancet(iso,"t_redmeat","max"); * upper bound for milk - i15_intake_detailed_scen_target(t,iso,"livst_milk")$(p15_intake_detail(t,iso,"livst_milk") - > i15_rec_EATLancet(iso,"t_livst_milk","max") + p15_intake_detailed_scen_target(t,iso,"livst_milk")$(p15_intake_detail(t,iso,"livst_milk") + > f15_rec_EATLancet(iso,"t_livst_milk","max") ) = - i15_rec_EATLancet(iso,"t_livst_milk","max"); + f15_rec_EATLancet(iso,"t_livst_milk","max"); ); *' lower bound for fish if (s15_exo_fish = 1, - i15_intake_detailed_scen_target(t,iso,"fish")$(p15_intake_detail(t,iso,"fish") - < i15_rec_EATLancet(iso,"t_fish","min") + p15_intake_detailed_scen_target(t,iso,"fish")$(p15_intake_detail(t,iso,"fish") + < f15_rec_EATLancet(iso,"t_fish","min") ) = - i15_rec_EATLancet(iso,"t_fish","min"); + f15_rec_EATLancet(iso,"t_fish","min"); ); -*' lower bound for fruits, veggies, nuts and seeds -*' and upper bound for starchy fruits and roots - if (s15_exo_fruitvegnutroots = 1, -*** Special case: Fruits, vegetables and nuts *** + +*** Special case: Fruits, vegetables, nuts, and roots *** *' In MAgPIE fruits, vegetables and nuts are combined in the 'other' food category; -*' Bananas and plantains are included in the 'cassav_sp' category. +*' Starchy fruits (bananas and plantains) are included in the 'cassav_sp' category. *' The f15_fruitveg2others_kcal_ratio gives the country-level historical share *' (fixed into the future based on last historic year) *' of fruits and vegetables in these aggregate categories. @@ -477,23 +475,17 @@ elseif s15_exo_diet = 3, p15_intake_detail_starchyfruit(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp") * p15_intake_detail(t,iso,"cassav_sp"); p15_intake_detail_roots(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); -*' Maximum recommendation for starchy fruits: +* Initialize scenario target for case that switch is not active i15_intake_detailed_scen_starchyfruit(t,iso) = p15_intake_detail_starchyfruit(t,iso); - i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > i15_rec_EATLancet(iso,"t_fruitstarch","max")) - = i15_rec_EATLancet(iso,"t_fruitstarch","max"); - -*' Maximum recommendation for roots: i15_intake_detailed_scen_roots(t,iso) = p15_intake_detail_roots(t,iso); - i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) - = i15_rec_EATLancet(iso,"t_roots","max"); + p15_intake_detailed_scen_target(t,iso,"potato") = p15_intake_detail(t,iso,"potato"); - i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) - = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); +*' lower bound for fruits, veggies, nuts and seeds + if (s15_exo_fruitvegnut = 1, - i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = - i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail_roots(t,iso) - - i15_intake_detailed_scen_target(t,iso,"potato") + - i15_intake_detailed_scen_starchyfruit(t,iso); +*' Maximum recommendation for starchy fruits: + i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > f15_rec_EATLancet(iso,"t_fruitstarch","max")) + = f15_rec_EATLancet(iso,"t_fruitstarch","max"); *' Split the 'others' category into fruits plus vegetables and nuts p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + i15_intake_detailed_scen_starchyfruit(t,iso); @@ -502,10 +494,10 @@ elseif s15_exo_diet = 3, i15_intake_detailed_scen_nuts(t,iso) = p15_intake_detail_nuts(t,iso); *' Minimum recommendation for fruits and vegetables: - i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) - = i15_rec_EATLancet(iso,"t_fruitveg","min"); + i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < f15_rec_EATLancet(iso,"t_fruitveg","min")) + = f15_rec_EATLancet(iso,"t_fruitveg","min"); -*' Extract fruits and vegetables that are part of others categroy +*' Extract fruits and vegetables that are part of others category * Note that starchy fruits are kept at the previously assigned maximum level * and their amount has been added to cassav_sp already. i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); @@ -519,103 +511,119 @@ elseif s15_exo_diet = 3, ; *' The resulting intake of the "others" category is: - i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); + p15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); *' (b) remaining nuts (groundnut) and seeds (rapeseed, sunflower) are scaled *' up or down towards the EAT nuts target *' considering scaling of nuts in others. - i15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) > 0) + p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) > 0) = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) + * (f15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) ; *** ISABELLE: Please double-check whether I can remove the if condition from the nuts target equations *** ($((sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) *** Benni and my reasoning was that if the nuts in others (i15_intake_detailed_scen_nuts already over-fulfill the nuts and seeds target, -*** it would be ok to correct the seeds and groundnuts down, too...) +*** it would be ok to correct the seeds and groundnuts down...) * If seeds have been corrected downwards below zero because nuts target already overfulfilled with nuts in others, * seed and groundnut consumption is reduced to zero. - i15_intake_detailed_scen_target(t,iso,kfo_ns)$(i15_intake_detailed_scen_target(t,iso,kfo_ns) < 0) = 0; + p15_intake_detailed_scen_target(t,iso,kfo_ns)$(p15_intake_detailed_scen_target(t,iso,kfo_ns) < 0) = 0; ); +*' upper bound for roots + if (s15_exo_roots = 1, + +*' Maximum recommendation for roots: + i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) + = f15_rec_EATLancet(iso,"t_roots","max"); + + p15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) + = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); + + ); + +* Assign starchy fruit and cassava roots back to cassava_sp scenario target + p15_intake_detailed_scen_target(t,iso,"cassav_sp") = + i15_intake_detailed_scen_roots(t,iso) - + p15_intake_detailed_scen_target(t,iso,"potato") + + i15_intake_detailed_scen_starchyfruit(t,iso); + *' lower bound for legumes if (s15_exo_pulses = 1, - i15_intake_detailed_scen_target(t,iso,EAT_pulses15)$(sum(EAT_pulses15_2, p15_intake_detail(t,iso,EAT_pulses15_2)) - < i15_rec_EATLancet(iso,"t_legumes","min") + p15_intake_detailed_scen_target(t,iso,EAT_pulses15)$(sum(EAT_pulses15_2, p15_intake_detail(t,iso,EAT_pulses15_2)) + < f15_rec_EATLancet(iso,"t_legumes","min") ) = (p15_intake_detail(t,iso,EAT_pulses15) / sum(EAT_pulses15_2, p15_intake_detail(t,iso,EAT_pulses15_2))) - * i15_rec_EATLancet(iso,"t_legumes","min"); + * f15_rec_EATLancet(iso,"t_legumes","min"); ); *' upper bound for sugar if (s15_exo_sugar = 1, - i15_intake_detailed_scen_target(t,iso,"sugar")$(p15_intake_detail(t,iso,"sugar") - > i15_rec_EATLancet(iso,"t_sugar","max") + p15_intake_detailed_scen_target(t,iso,"sugar")$(p15_intake_detail(t,iso,"sugar") + > f15_rec_EATLancet(iso,"t_sugar","max") ) = - i15_rec_EATLancet(iso,"t_sugar","max"); + f15_rec_EATLancet(iso,"t_sugar","max"); ); *' upper and lower bound for oils if (s15_exo_oils = 1, -* i15_intake_detailed_scen_target(t,iso,"oils") = i15_intake_EATLancet(iso,"oils") +* p15_intake_detailed_scen_target(t,iso,"oils") = i15_intake_EATLancet(iso,"oils") * oil_veg has a minimum and maximum recommendation in EAT - i15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") - < i15_rec_EATLancet(iso,"t_oils","min") + p15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") + < f15_rec_EATLancet(iso,"t_oils","min") ) = - i15_rec_EATLancet(iso,"t_oils","min"); + f15_rec_EATLancet(iso,"t_oils","min"); * oil palm has a maximum recommendation in EAT - i15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") - > i15_rec_EATLancet(iso,"t_oils","max") + p15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") + > f15_rec_EATLancet(iso,"t_oils","max") ) = - i15_rec_EATLancet(iso,"t_oils","max"); + f15_rec_EATLancet(iso,"t_oils","max"); ); * Food commodities that are not included in diet recommendations are set to zero: - i15_intake_detailed_scen_target(t,iso,kfo_norec) = 0; + p15_intake_detailed_scen_target(t,iso,kfo_norec) = 0; * Optionally, there is an exception for alcohol if s15_exo_alcohol = 1: * Even though it would be 0 following the EAT Lancet recommendation, * an alternative maximum target can be set via 's15_alc_scen' for alcohol consumption, * e.g. following the recommendation according to Lassen et al., (2020). if (s15_exo_alcohol = 1, - i15_intake_detailed_scen_target(t,iso,"alcohol")$(i15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen * i15_intake_scen_target(t,iso)) + p15_intake_detailed_scen_target(t,iso,"alcohol")$(p15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen * i15_intake_scen_target(t,iso)) = s15_alc_scen * i15_intake_scen_target(t,iso); ); *' There is no explicit target for brans in the EATLancet recommendations. *' It is set to 0 when s15_exo_brans is activated. if (s15_exo_brans = 1, - i15_intake_detailed_scen_target(t,iso,"brans") = 0; + p15_intake_detailed_scen_target(t,iso,"brans") = 0; ); *' There is no explicit target for single cell protein in the EATLancet recommendations. *' It is therefore set to 0. if (s15_exo_scp = 1, - i15_intake_detailed_scen_target(t,iso,"scp") = 0; + p15_intake_detailed_scen_target(t,iso,"scp") = 0; ); *** Balancing calorie requirements *** *' After all calorie recommendations for non-staple food groups are satisfied, -*' intake of staple crops is now modified such that the -*' in step 1.) selected total calorie intake is met. -*' Note that brans do not have an EAT Lancet target and are kept at their -*' original level. - i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2)) > 0) = - (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2))) +*' intake of staple crops is now modified such that +*' the above-selected total calorie intake is met. + p15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2)) > 0) = + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); -* Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values - i15_intake_detailed_scen_target(t,iso,EAT_staples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = +* Correction where calorie balancing would lead to negative p15_intake_detailed_scen_target values + p15_intake_detailed_scen_target(t,iso,EAT_staples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = 0; - i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = - i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)); + p15_intake_detailed_scen_target(t,iso,EAT_nonstaples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = + i15_intake_scen_target(t,iso) * p15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / + sum(EAT_nonstaples2, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)); - if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, - abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; + if (smin((iso,kfo), p15_intake_detailed_scen_target(t,iso,kfo)) < 0, + abort "The parameter p15_intake_detailed_scen_target became negative after calorie balancing."; ); ); @@ -626,7 +634,7 @@ elseif s15_exo_diet = 3, *' convergence (note that fading should start after the historical time slice of *' the EAT Lancet diet scenarios (y2010) as defined in `i15_exo_foodscen_fader(t,iso)`): p15_intake_detail(t,iso,kfo) = p15_intake_detail(t,iso,kfo) * (1-i15_exo_foodscen_fader(t,iso)) - + i15_intake_detailed_scen_target(t,iso,kfo) * i15_exo_foodscen_fader(t,iso); + + p15_intake_detailed_scen_target(t,iso,kfo) * i15_exo_foodscen_fader(t,iso); p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) = p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) * (1-i15_exo_foodscen_fader(t,iso)) + p15_bmi_shr_target(t,iso,sex,age,bmi_group15) * i15_exo_foodscen_fader(t,iso); diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index dc19c5132d..4df838948e 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -102,7 +102,8 @@ scalar s15_exo_redmeatdairy Exogenous EAT Lancet animal product target on (1) / scalar s15_exo_monogastric Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_ruminant Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_fish Exogenous EAT Lancet animal product target on (1) / 1 /; -scalar s15_exo_fruitvegnutroots Exogenous EAT Lancet fruit vegetable nut seeds target on (1) / 1 /; +scalar s15_exo_fruitvegnut Exogenous EAT Lancet fruit vegetable nut seeds target on (1) / 1 /; +scalar s15_exo_roots Exogenous EAT Lancet root target on (1) / 1 /; scalar s15_exo_pulses Exogenous pulses target on (1) / 1 /; scalar s15_exo_sugar Exogenous sugar target on (1) / 1 /; scalar s15_exo_oils Exogenous oils (1) / 1 /; diff --git a/modules/15_food/anthro_iso_jun22/preloop.gms b/modules/15_food/anthro_iso_jun22/preloop.gms index b10933b160..6d2b9fba94 100644 --- a/modules/15_food/anthro_iso_jun22/preloop.gms +++ b/modules/15_food/anthro_iso_jun22/preloop.gms @@ -90,9 +90,6 @@ $else ); $endif -* Initialisation of the recommendations for healthy food intake: -i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) = f15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15); - * initial prices in $US per Kcal i15_prices_initial_kcal(iso,kfo)$(fm_nutrition_attributes("y1995",kfo,"kcal")>0) = f15_prices_initial(kfo) / (fm_nutrition_attributes("y1995",kfo,"kcal")*10**6); diff --git a/modules/15_food/anthropometrics_jan18/declarations.gms b/modules/15_food/anthropometrics_jan18/declarations.gms index 072a935f0c..b945726f5f 100644 --- a/modules/15_food/anthropometrics_jan18/declarations.gms +++ b/modules/15_food/anthropometrics_jan18/declarations.gms @@ -154,7 +154,7 @@ parameters i15_intake_scen_target(t,i) Target for total per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) i15_intake_EATLancet_all(i,kcal_scen15,EAT_scen15,kfo) Food-specific per capita calorie intake according to various EAT Lancet diet scenarios (kcal per capita per day) i15_intake_EATLancet(i,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) - i15_intake_detailed_scen_target(t,i,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) + p15_intake_detailed_scen_target(t,i,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) p15_intake_detailed_regr(t,i,kfo) Food-specific per capita calorie intake according to regression-based projections (kcal per capita per day) p15_demand2intake_ratio_ref(i) Ratio between food calorie demand and intake for the historical time step of EAT Lancet diets (1) diff --git a/modules/15_food/anthropometrics_jan18/intersolve.gms b/modules/15_food/anthropometrics_jan18/intersolve.gms index a554ed199f..49e85612ff 100644 --- a/modules/15_food/anthropometrics_jan18/intersolve.gms +++ b/modules/15_food/anthropometrics_jan18/intersolve.gms @@ -352,12 +352,12 @@ if(s15_exo_diet = 1, * Via 's15_alc_scen' a maximum target for alcohol consumption is defined. if(s15_alc_scen>0, - i15_intake_detailed_scen_target(t,i,"alcohol") = p15_intake_detailed_regr(t,i,"alcohol"); - i15_intake_detailed_scen_target(t,i,"alcohol")$(i15_intake_detailed_scen_target(t,i,"alcohol") > s15_alc_scen*i15_intake_scen_target(t,i)) + p15_intake_detailed_scen_target(t,i,"alcohol") = p15_intake_detailed_regr(t,i,"alcohol"); + p15_intake_detailed_scen_target(t,i,"alcohol")$(p15_intake_detailed_scen_target(t,i,"alcohol") > s15_alc_scen*i15_intake_scen_target(t,i)) = s15_alc_scen*i15_intake_scen_target(t,i); ); - i15_intake_detailed_scen_target(t,i,EAT_staples) = ( + p15_intake_detailed_scen_target(t,i,EAT_staples) = ( i15_intake_scen_target(t,i) - sum(EAT_nonstaples,i15_intake_EATLancet(i,EAT_nonstaples)) )*( i15_intake_EATLancet(i,EAT_staples)/sum(EAT_staples2,i15_intake_EATLancet(i,EAT_staples2)) ); @@ -374,7 +374,7 @@ if(s15_exo_diet = 1, i15_kcal_pc_scen_target(t,i,kfo) = (f15_calib_fsupply(i)*f15_overcons_FAOwaste(i,kfo) - *i15_intake_detailed_scen_target(t,i,kfo)) + *p15_intake_detailed_scen_target(t,i,kfo)) *p15_foodwaste_growth(t,i); *' In the last step, the regression-based calculation of daily per capita food demand diff --git a/modules/15_food/anthropometrics_jan18/presolve.gms b/modules/15_food/anthropometrics_jan18/presolve.gms index 64ed7f2fe4..d293c2348c 100644 --- a/modules/15_food/anthropometrics_jan18/presolve.gms +++ b/modules/15_food/anthropometrics_jan18/presolve.gms @@ -597,17 +597,17 @@ p15_intake_detailed_regr(t,i,kfo) = p15_kcal_pc_calibrated(t,i,kfo) /(f15_calib_fsupply(i)*f15_overcons_FAOwaste(i,kfo)*p15_foodwaste_growth(t,i)); -i15_intake_detailed_scen_target(t,i,EAT_nonstaples) = i15_intake_EATLancet(i,EAT_nonstaples); +p15_intake_detailed_scen_target(t,i,EAT_nonstaples) = i15_intake_EATLancet(i,EAT_nonstaples); * The EAT-Lancet diet only allows for added sugars, but does not include processed food or * alcohol. Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. if(s15_alc_scen>0, -i15_intake_detailed_scen_target(t,i,"alcohol") = p15_intake_detailed_regr(t,i,"alcohol"); -i15_intake_detailed_scen_target(t,i,"alcohol")$(i15_intake_detailed_scen_target(t,i,"alcohol") > s15_alc_scen*i15_intake_scen_target(t,i)) +p15_intake_detailed_scen_target(t,i,"alcohol") = p15_intake_detailed_regr(t,i,"alcohol"); +p15_intake_detailed_scen_target(t,i,"alcohol")$(p15_intake_detailed_scen_target(t,i,"alcohol") > s15_alc_scen*i15_intake_scen_target(t,i)) = s15_alc_scen*i15_intake_scen_target(t,i); ); -i15_intake_detailed_scen_target(t,i,EAT_staples) = ( +p15_intake_detailed_scen_target(t,i,EAT_staples) = ( i15_intake_scen_target(t,i) - sum(EAT_nonstaples,i15_intake_EATLancet(i,EAT_nonstaples)) )*( i15_intake_EATLancet(i,EAT_staples)/sum(EAT_staples2,i15_intake_EATLancet(i,EAT_staples2)) ); @@ -624,7 +624,7 @@ i15_intake_detailed_scen_target(t,i,EAT_staples) = ( *' of the EAT Lancet diet scenarios, according to the regression-based approach. i15_kcal_pc_scen_target(t,i,kfo) = (f15_calib_fsupply(i)*f15_overcons_FAOwaste(i,kfo) - *i15_intake_detailed_scen_target(t,i,kfo)) + *p15_intake_detailed_scen_target(t,i,kfo)) *p15_foodwaste_growth(t,i); *' 4.) In the last step, the regression-based calculation of daily per capita food demand From c95f929b0ad91dfe705df54c3e8a1d8d959bbaed Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 12 Feb 2024 11:40:33 +0100 Subject: [PATCH 55/71] added roots switch to scenario config files --- config/scenario_config.csv | 1 + config/scenario_fsec.csv | 1 + 2 files changed, 2 insertions(+) diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 6368478075..3e06cb6c78 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -17,6 +17,7 @@ gms$s15_exo_monogastric;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_ruminant;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_fish;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_fruitvegnut;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_roots;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_pulses;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_sugar;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_oils;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 9069268243..41d3fe24e0 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -14,6 +14,7 @@ gms$s15_exo_monogastric;;;;;;;;0;0;0;1;0;0;0;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;; gms$s15_exo_ruminant;;;;;;;;0;0;0;0;1;0;0;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_fish;;;;;;;;0;0;0;0;0;0;0;1;0;;;;;;;;;;;;;;;;;0;0;;;;;;;;;;;;;;; gms$s15_exo_fruitvegnut;;;;;;;;0;0;1;0;0;0;0;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; +gms$s15_exo_roots;;;;;;;;0;0;1;0;0;0;0;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_pulses;;;;;;;;0;0;0;0;0;1;0;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_sugar;;;;;;;;0;0;0;0;0;0;1;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_oils;;;;;;;;0;0;0;0;0;0;1;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; From c81d11154fff9c3b32b7c2c96f846b27aa58e867 Mon Sep 17 00:00:00 2001 From: Felicitas Beier Date: Mon, 12 Feb 2024 12:21:32 +0100 Subject: [PATCH 56/71] added new column with EATLancet 2 diet for coupled runs in magpie scenario config --- config/scenario_config.csv | 174 ++++++++++++++++++------------------- 1 file changed, 87 insertions(+), 87 deletions(-) mode change 100644 => 100755 config/scenario_config.csv diff --git a/config/scenario_config.csv b/config/scenario_config.csv old mode 100644 new mode 100755 index 3e06cb6c78..f01fc4c2f2 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -1,87 +1,87 @@ -;cc;nocc;nocc_hist;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SDP;SDP-EI;SDP-RC;SDP-MC;BASE;NPI;NDC;coupling;emulator;input;Tland;eat_lancet_diet;LAMA_Inequal;LAMA_Inequal-SustDemand;LAMA_Inequal-EnvirProt;LAMA_Inequal-GHGPrice;LAMA_Sustainability;NAVIGATE_AllOff;NAVIGATE_LandSup;NAVIGATE_LandDem;NAVIGATE_AllOn;ForestryEndo;ForestryExo;ForestryOff;frst_shock_none;frst_shock_002lin2030;frst_shock_004lin2030;frst_shock_008lin2030;frst_shock_016lin2030;rcp1p9;rcp2p6;rcp4p5;rcp6p0;rcp7p0;rcp8p5;NGFS_o_lowdem -gms$c09_pop_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP1;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; -gms$c09_gdp_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SDP_EI;SDP_RC;SDP_MC;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; -gms$c09_pal_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; -gms$c15_food_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 -gms$c15_food_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 -gms$s15_elastic_demand;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;0;0;0;0;0;0;;;;;;;;;;;;;;;;;;; -gms$c15_rumdairy_scp_scen;;;;constant;constant;constant;constant;constant;constant;constant;sigmoid_50pc_20_50;constant;constant;;;;;;;constant;;;;;;;;;;;;;;;;;;;;;;;;; -gms$kfo_rd;;;;;;;;;;;livst_rum;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c15_exo_foodscen;;;;;;;;;;lin_zero_20_50;lin_zero_20_50;lin_zero_20_50;lin_zero_20_70;;;;;;;lin_zero_20_50;lin_zero_20_50;;lin_zero_20_50;;;lin_zero_20_50;;;;;;;;;;;;;;;;;;;lin_zero_20_50 -gms$s15_exo_waste;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;0;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;;;1 -gms$s15_waste_scen;;;;;;;;;;1.2;1.3;1.2;1.25;;;;;;;1.2;1.2;;1.2;;;1.2;;;;;;;;;;;;;;;;;;;1.2 -gms$s15_exo_diet;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;1;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;;;1 -gms$c15_kcal_scen;;;;;;;;;;healthy_BMI;no_underweight;healthy_BMI;healthy_BMI;;;;;;;healthy_BMI;healthy_BMI;;healthy_BMI;;;healthy_BMI;;;;;;;;;;;;;;;;;;;healthy_BMI -gms$c15_EAT_scen;;;;;;;;;;FLX;;FLX;FLX;;;;;;;FLX;FLX;;FLX;;;FLX;;;;;;;;;;;;;;;;;;; -gms$s15_exo_monogastric;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_ruminant;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_fish;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_fruitvegnut;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_roots;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_pulses;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_sugar;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_oils;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_brans;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_scp;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_alcohol;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_alc_scen;0.014;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c21_trade_liberalization;;;;l908080r807070;l909090r808080;l909090r808080;l909595r809090;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l909595r809090;l908080r807070;;;;;;;;;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l908080r807070;;;;;;;;;;;;;;;;;;; -gms$c22_protect_scenario;;;;none;none;none;none;none;none;BH;none;BH_IFL;BH;;;;;;;BH;;BH_IFL;BH_IFL;BH_IFL;BH_IFL;BH_IFL;;;;;;;;;;;;;;;;;;; -gms$c22_protect_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;none;none;BH_IFL;none;BH_IFL;;;;;;;;;;;;;;;;;;; -gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;all;rainfed;rainfed;;;;;;;rainfed;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;;; -gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;; -gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; -gms$c31_grassl_yld_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s32_max_aff_area;;;;Inf;Inf;Inf;Inf;Inf;Inf;500;350;0;700;;;;;;;500;;Inf;Inf;Inf;500;500;;;;;;;;;;;;;;;;;;; -gms$c32_aff_mask;;;;noboreal;noboreal;noboreal;noboreal;noboreal;noboreal;onlytropical;onlytropical;onlytropical;onlytropical;;;;;;;onlytropical;;noboreal;noboreal;noboreal;noboreal;noboreal;;;;;;;;;;;;;;;;;;; -gms$c34_urban_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP1;SSP2;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; -gms$c32_aff_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; -gms$s32_planing_horizon;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c35_ad_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; -gms$c35_aolc_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; -gms$s35_forest_damage_end;;;;2030;2050;2050;2050;2050;2030;2030;2030;2030;2030;;;;;;;2030;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; -gms$s42_watdem_nonagr_scenario;;;;1;2;2;3;2;1;1;1;3;1;;;;;;;;;2;1;2;2;1;;;;;;;;;;;;;;;;;;; -gms$s42_irrig_eff_scenario;;;;2;2;2;2;2;2;3;3;3;3;;;;;;;3;;3;3;3;3;3;;;;;;;;;;;;;;;;;;; -gms$c42_env_flow_policy;;;;on;off;off;off;mixed;on;on;on;on;on;;;;;;;on;;on;on;on;on;on;;;;;;;;;;;;;;;;;;; -gms$s42_efp_targetyear;;;;2040;2040;2040;2040;2040;2040;2040;2050;2070;2050;;;;;;;2040;;2040;2040;2040;2040;2040;;;;;;;;;;;;;;;;;;; -gms$s44_target_price;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c50_scen_neff;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;;;;;;;;;;;;;;;;;;; -gms$c50_scen_neff_noselect;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;;;;;;;;;;;;;;;;;;; -gms$c55_scen_conf;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;ssp1;ssp1;ssp1;ssp1;ssp1;;;;;;;;;;;;;;;;;;; -gms$c55_scen_conf_noselect;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;ssp4;ssp4;ssp1;ssp4;ssp1;;;;;;;;;;;;;;;;;;; -gms$c56_pollutant_prices;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; -gms$c56_pollutant_prices_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; -gms$s56_c_price_exp_aff;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s56_buffer_aff;;;;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.2;0.3;;;;;;;0.5;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c56_emis_policy;;;;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;redd_nosoil;all_nosoil;;;;;;;reddnatveg_nosoil;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s56_minimum_cprice;;;;;;;;;;;;;;0;0;18;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$maccs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c60_2ndgen_biodem;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; -gms$c60_2ndgen_biodem_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; -gms$c60_1stgen_biodem;;;;phaseout2020;const2020;const2020;const2030;const2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;phaseout2020;;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;;;;;;;;;;;;; -gms$c60_biodem_level;;;;;;;;;;;;;;;;;1;0;;;;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$c60_bioenergy_subsidy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c60_res_2ndgenBE_dem;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;sdp;ssp2;sdp;sdp;;;;;;;sdp;;ssp4;sdp;ssp4;ssp4;sdp;;;;;;;;;;;;;;;;;;; -gms$c70_feed_scen;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;;;;;;;ssp1;;ssp4;ssp1;ssp4;ssp4;ssp1;;;;;;;;;;;;;;;;;;; -gms$c_timesteps;;;;;;;;;;;;;;;;;less_TS;less_TS;;;;5year;5year;5year;5year;5year;;;;;;;;;;;;;;;;;;; -gms$c14_yields_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; -gms$c42_watdem_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; -gms$c43_watavail_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; -gms$c52_carbon_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; -gms$c59_som_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; -gms$s32_initial_distribution;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;4;4;0;;;;;;;;;;;; -gms$s32_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;1;0;;;;;;;;;;;; -gms$s35_secdf_distribution;;;;;;;;;;;;;;;;;;;;;;0;0;0;0;0;;;;;0;0;0;;;;;;;;;;;; -gms$s35_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;;; -gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;1;1;1;1;1;;;;;1;1;0;;;;;;;;;;;; -gms$s35_forest_damage;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;;; -gms$c32_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; -gms$c35_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; -input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.96_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.96_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.96_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.96_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.96_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.96_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; -gms$c52_land_carbon_sink_rcp;;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU; -gms$c57_macc_version;;;;;;;;;;;;;;;;;;;;;;;;;;;PBL_2022;PBL_2022;PBL_2022;PBL_2022;;;;;;;;;;;;;;; -gms$c57_macc_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;Default;Optimistic;Default;Optimistic;;;;;;;;;;;;;;; -gms$s58_rewetting_switch;;;;;;;;;;;;;;;;;;;;;;;;;;;0;1;0;1;;;;;;;;;;;;;;; +;cc;nocc;nocc_hist;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SDP;SDP-EI;SDP-RC;SDP-MC;BASE;NPI;NDC;coupling;emulator;input;Tland;eat_lancet_diet;EL2_Diet;LAMA_Inequal;LAMA_Inequal-SustDemand;LAMA_Inequal-EnvirProt;LAMA_Inequal-GHGPrice;LAMA_Sustainability;NAVIGATE_AllOff;NAVIGATE_LandSup;NAVIGATE_LandDem;NAVIGATE_AllOn;ForestryEndo;ForestryExo;ForestryOff;frst_shock_none;frst_shock_002lin2030;frst_shock_004lin2030;frst_shock_008lin2030;frst_shock_016lin2030;rcp1p9;rcp2p6;rcp4p5;rcp6p0;rcp7p0;rcp8p5;NGFS_o_lowdem +gms$c09_pop_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP1;SSP1;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c09_gdp_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SDP_EI;SDP_RC;SDP_MC;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c09_pal_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c15_food_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 +gms$c15_food_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 +gms$s15_elastic_demand;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;0;0;0;0;0;0;0;;;;;;;;;;;;;;;;;;; +gms$c15_rumdairy_scp_scen;;;;constant;constant;constant;constant;constant;constant;constant;sigmoid_50pc_20_50;constant;constant;;;;;;;constant;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$kfo_rd;;;;;;;;;;;livst_rum;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c15_exo_foodscen;;;;;;;;;;lin_zero_20_50;lin_zero_20_50;lin_zero_20_50;lin_zero_20_70;;;;;;;lin_zero_20_50;lin_zero_20_50;lin_zero_20_50;;lin_zero_20_50;;;lin_zero_20_50;;;;;;;;;;;;;;;;;;;lin_zero_20_50 +gms$s15_exo_waste;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;0;1;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;;;1 +gms$s15_waste_scen;;;;;;;;;;1.2;1.3;1.2;1.25;;;;;;;1.2;1.2;1.2;;1.2;;;1.2;;;;;;;;;;;;;;;;;;;1.2 +gms$s15_exo_diet;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;1;3;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;;;1 +gms$c15_kcal_scen;;;;;;;;;;healthy_BMI;no_underweight;healthy_BMI;healthy_BMI;;;;;;;healthy_BMI;healthy_BMI;healthy_BMI;;healthy_BMI;;;healthy_BMI;;;;;;;;;;;;;;;;;;;healthy_BMI +gms$c15_EAT_scen;;;;;;;;;;FLX;;FLX;FLX;;;;;;;FLX;FLX;FLX;;FLX;;;FLX;;;;;;;;;;;;;;;;;;; +gms$s15_exo_monogastric;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_ruminant;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_fish;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_fruitvegnut;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_roots;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_pulses;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_sugar;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_oils;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_brans;;;;;;;;;;1;0;1;1;;;;;;;1;1;0;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_scp;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_alcohol;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_alc_scen;0.014;;;;;;;;;;;;;;;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;; +gms$c21_trade_liberalization;;;;l908080r807070;l909090r808080;l909090r808080;l909595r809090;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l909595r809090;l908080r807070;;;;;;;;;;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l908080r807070;;;;;;;;;;;;;;;;;;; +gms$c22_protect_scenario;;;;none;none;none;none;none;none;BH;none;BH_IFL;BH;;;;;;;BH;;;BH_IFL;BH_IFL;BH_IFL;BH_IFL;BH_IFL;;;;;;;;;;;;;;;;;;; +gms$c22_protect_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;;none;none;BH_IFL;none;BH_IFL;;;;;;;;;;;;;;;;;;; +gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;all;rainfed;rainfed;;;;;;;rainfed;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;;; +gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;; +gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; +gms$c31_grassl_yld_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s32_max_aff_area;;;;Inf;Inf;Inf;Inf;Inf;Inf;500;350;0;700;;;;;;;500;;;Inf;Inf;Inf;500;500;;;;;;;;;;;;;;;;;;; +gms$c32_aff_mask;;;;noboreal;noboreal;noboreal;noboreal;noboreal;noboreal;onlytropical;onlytropical;onlytropical;onlytropical;;;;;;;onlytropical;;;noboreal;noboreal;noboreal;noboreal;noboreal;;;;;;;;;;;;;;;;;;; +gms$c34_urban_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP1;SSP2;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c32_aff_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; +gms$s32_planing_horizon;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c35_ad_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; +gms$c35_aolc_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; +gms$s35_forest_damage_end;;;;2030;2050;2050;2050;2050;2030;2030;2030;2030;2030;;;;;;;2030;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; +gms$s42_watdem_nonagr_scenario;;;;1;2;2;3;2;1;1;1;3;1;;;;;;;;;;2;1;2;2;1;;;;;;;;;;;;;;;;;;; +gms$s42_irrig_eff_scenario;;;;2;2;2;2;2;2;3;3;3;3;;;;;;;3;;;3;3;3;3;3;;;;;;;;;;;;;;;;;;; +gms$c42_env_flow_policy;;;;on;off;off;off;mixed;on;on;on;on;on;;;;;;;on;;;on;on;on;on;on;;;;;;;;;;;;;;;;;;; +gms$s42_efp_targetyear;;;;2040;2040;2040;2040;2040;2040;2040;2050;2070;2050;;;;;;;2040;;;2040;2040;2040;2040;2040;;;;;;;;;;;;;;;;;;; +gms$s44_target_price;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c50_scen_neff;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;;;;;;;;;;;;;;;;;;; +gms$c50_scen_neff_noselect;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;;;;;;;;;;;;;;;;;;; +gms$c55_scen_conf;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;;ssp1;ssp1;ssp1;ssp1;ssp1;;;;;;;;;;;;;;;;;;; +gms$c55_scen_conf_noselect;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;;ssp4;ssp4;ssp1;ssp4;ssp1;;;;;;;;;;;;;;;;;;; +gms$c56_pollutant_prices;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$c56_pollutant_prices_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$s56_c_price_exp_aff;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s56_buffer_aff;;;;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.2;0.3;;;;;;;0.5;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c56_emis_policy;;;;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;redd_nosoil;all_nosoil;;;;;;;reddnatveg_nosoil;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s56_minimum_cprice;;;;;;;;;;;;;;0;0;18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$maccs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c60_2ndgen_biodem;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$c60_2ndgen_biodem_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$c60_1stgen_biodem;;;;phaseout2020;const2020;const2020;const2030;const2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;phaseout2020;;;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;;;;;;;;;;;;; +gms$c60_biodem_level;;;;;;;;;;;;;;;;;1;0;;;;;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$c60_bioenergy_subsidy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c60_res_2ndgenBE_dem;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;sdp;ssp2;sdp;sdp;;;;;;;sdp;;;ssp4;sdp;ssp4;ssp4;sdp;;;;;;;;;;;;;;;;;;; +gms$c70_feed_scen;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;;;;;;;ssp1;;;ssp4;ssp1;ssp4;ssp4;ssp1;;;;;;;;;;;;;;;;;;; +gms$c_timesteps;;;;;;;;;;;;;;;;;less_TS;less_TS;;;;;5year;5year;5year;5year;5year;;;;;;;;;;;;;;;;;;; +gms$c14_yields_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c42_watdem_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c43_watavail_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c52_carbon_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c59_som_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$s32_initial_distribution;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;4;4;0;;;;;;;;;;;; +gms$s32_hvarea;;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;1;0;;;;;;;;;;;; +gms$s35_secdf_distribution;;;;;;;;;;;;;;;;;;;;;;;0;0;0;0;0;;;;;0;0;0;;;;;;;;;;;; +gms$s35_hvarea;;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;;; +gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;;1;1;1;1;1;;;;;1;1;0;;;;;;;;;;;; +gms$s35_forest_damage;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;;; +gms$c32_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; +gms$c35_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; +input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.96_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.96_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.96_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.96_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.96_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.96_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +gms$c52_land_carbon_sink_rcp;;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU; +gms$c57_macc_version;;;;;;;;;;;;;;;;;;;;;;;;;;;;PBL_2022;PBL_2022;PBL_2022;PBL_2022;;;;;;;;;;;;;;; +gms$c57_macc_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;Default;Optimistic;Default;Optimistic;;;;;;;;;;;;;;; +gms$s58_rewetting_switch;;;;;;;;;;;;;;;;;;;;;;;;;;;;0;1;0;1;;;;;;;;;;;;;;; From 0fc7724d04d9a20f2a94e46596b10043ad37dab4 Mon Sep 17 00:00:00 2001 From: Felicitas Beier Date: Mon, 12 Feb 2024 14:16:43 +0100 Subject: [PATCH 57/71] added productivity increase in EATLancet 2 diet scenario --- config/scenario_config.csv | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/scenario_config.csv b/config/scenario_config.csv index f01fc4c2f2..bf6c7bed6a 100755 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -2,6 +2,8 @@ gms$c09_pop_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP1;SSP1;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; gms$c09_gdp_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SDP_EI;SDP_RC;SDP_MC;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; gms$c09_pal_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$s12_interest_lic;;;;;;;;;;;;;;;;;;;;;;0.06;;;;;;;;;;;;;;;;;;;;;;;; +gms$s12_interest_hic;;;;;;;;;;;;;;;;;;;;;;0.04;;;;;;;;;;;;;;;;;;;;;;;; gms$c15_food_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 gms$c15_food_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 gms$s15_elastic_demand;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;0;0;0;0;0;0;0;;;;;;;;;;;;;;;;;;; @@ -65,7 +67,7 @@ gms$c60_1stgen_biodem;;;;phaseout2020;const2020;const2020;const2030;const2020;ph gms$c60_biodem_level;;;;;;;;;;;;;;;;;1;0;;;;;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$c60_bioenergy_subsidy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c60_res_2ndgenBE_dem;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;sdp;ssp2;sdp;sdp;;;;;;;sdp;;;ssp4;sdp;ssp4;ssp4;sdp;;;;;;;;;;;;;;;;;;; -gms$c70_feed_scen;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;;;;;;;ssp1;;;ssp4;ssp1;ssp4;ssp4;ssp1;;;;;;;;;;;;;;;;;;; +gms$c70_feed_scen;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;;;;;;;ssp1;;ssp1;ssp4;ssp1;ssp4;ssp4;ssp1;;;;;;;;;;;;;;;;;;; gms$c_timesteps;;;;;;;;;;;;;;;;;less_TS;less_TS;;;;;5year;5year;5year;5year;5year;;;;;;;;;;;;;;;;;;; gms$c14_yields_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; gms$c42_watdem_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; From 28393d0bbab7b0058851d38656370c6c821ecdc5 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:35:56 +0100 Subject: [PATCH 58/71] Update CHANGELOG.md Update changelog --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3566c4a1e9..9daf4f1a9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **scenario_config.csv** settings for cfg$gms$s35_secdf_distribution in `ForestryEndo` and `ForestryExo` changed from `2` to `0` - **scenario_config.csv** removed erroneous setting `cc` from column `input` - **default.cfg** update default `cfg$gms$c56_pollutant_prices` and `cfg$gms$c60_2ndgen_biodem` to `R32M46-SSP2EU-NPi` -- **default.cfg** update input data to rev 4.96 - **default.cfg** changed default for `cfg$gms$s56_buffer_aff` from 0.2 to 0.5 - **default.cfg** changed default for `cfg$gms$s32_aff_prot` from 0 to 1 - **21_trade** s21_trade_bal_damper for roundwood changed from 0.75 to 0.65 From af7249dcd3077ab40937f95b97d761291afa515a Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:38:38 +0100 Subject: [PATCH 59/71] Update default.cfg Added reference to Springmann et al. 2018 --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 183f0dbb0b..1b4c193dde 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -426,7 +426,7 @@ cfg$gms$s15_waste_scen <- 1.2 # def = 1.2 # * (3): MAgPIE-specific realization of the EAT-Lancet diet, where model-internal # * (regression-based) food demand projections are constrained by ranges for # * intake targets of food groups to ensure healthy and sustainable diets as -# * recommended by the EAT-Lancet Commission +# * recommended by the EAT-Lancet Commission (following Springmann et al. 2018 and Willett et al. 2019) # * (2): transition towards exogenous diets (NIN for India and EAT for other regions) # * Please use this switch in combination with cfg$gms$c15_EAT_scen <- "FLX_hmilk" # * If only India's diet needs to be changed, then set cfg$gms$scen_countries15 <- "IND" From 003c3e72e93ec23e81f5c60d938bbcba6e664a5d Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:54:14 +0100 Subject: [PATCH 60/71] Update literature.bib added springmann reference --- literature.bib | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/literature.bib b/literature.bib index 697d7d6b71..adb1364d84 100644 --- a/literature.bib +++ b/literature.bib @@ -43,6 +43,19 @@ @article{willett_food_2019 year = {2019}, } +@article{springmann_options_2018, + title = {Options for Keeping the Food System within Environmental Limits}, + doi = {https://doi.org/10.1038/s41586-018-0594-0}, + language = {en}, + journal = {Nature}, + volume = "562", + number = "7728", + pages = "519 - 525", + author = {Springmann, Marco, Michael Clark, Daniel Mason-D’Croz, Keith Wiebe, Benjamin Leon Bodirsky, Luis Lassaletta, Wim de Vries, Sonja J. Vermeulen, Mario Herrero, Kimberly M. Carlson, Malin Jonell, Max Troell, Fabrice DeClerck, Line J. Gordon, Rami Zurayk, Peter Scarborough, Mike Rayner, Brent Loken, Jess Franzo, H. Charles J. Godfray, David Tilman, Johan Rockström, Walter Willett}, + month = oct, + year = {2018}, +} + @misc{FAOSTAT, author = {FAOSTAT}, title = {{FAOSTAT Database}}, From 156bed07635953f78417b88e0cb1b77cc3f67ed4 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:57:52 +0100 Subject: [PATCH 61/71] Update default.cfg --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 1b4c193dde..37cb67d9f0 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -459,7 +459,7 @@ cfg$gms$c15_kcal_scen <- "healthy_BMI" # def = healthy_BMI cfg$gms$c15_EAT_scen <- "FLX" # def = FLX # * Sub-specifications: Which commodities shall be included in the diet shift -# * towards cfg$gms$c15_EAT_scen ? Only selected (1) commodities will be +# * towards the selected scenario diet? Only selected (1) commodities will be # * included, while the others will remain to be endogenous. # * Any shift will be compensated to reach the calorie target by adjusting # * staple calories. From 1f2f9690a90cdc817a6eb48040cd44cca079aeaf Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:50:50 +0100 Subject: [PATCH 62/71] Update default.cfg updated additional data --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 37cb67d9f0..38efa6659e 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -25,7 +25,7 @@ cfg$model <- "main.gms" #def = "main.gms" cfg$input <- c(regional = "rev4.99_h12_magpie.tgz", cellular = "rev4.99_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", validation = "rev4.99_h12_validation.tgz", - additional = "additional_data_rev4.47.tgz", + additional = "additional_data_rev4.48.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") # NOTE: It is recommended to recalibrate the model when changing cellular input data From 9a673b989ff54b5ae1fa9446533f70eb9c8f84d3 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:52:04 +0100 Subject: [PATCH 63/71] Update default.cfg --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 38efa6659e..07c68713b6 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -471,7 +471,7 @@ cfg$gms$s15_exo_roots <- 1 # def = 1, options: 0,1 (only relevant for n cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_sugar <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_oils <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet, they are kept at their historical value, unless switch activated (1), then brans are set to 0), options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet, they are kept at their projected level, unless switch activated (1), then brans are set to 0), options: 0,1 cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet From 34b9621129de9597837049e19c15aae4e10cce5e Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 19 Feb 2024 09:41:16 +0100 Subject: [PATCH 64/71] updated EAT2p0 start script --- scripts/start/projects/project_EAT2p0.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index ccf51dbfed..cbc789fbc5 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -78,11 +78,10 @@ bau <- function(cfg) { ### Diet component ## # Globally achieves EL2 diet by 2050 # To Do: Check implementation diet <- function(cfg) { - cfg$gms$s15_exo_diet <- 1 # To Do: switch to 3 once implementation is ready + cfg$gms$s15_exo_diet <- 3 cfg$gms$s15_alc_scen <- 0 # No alcohol allowed as in the definition of EATLancet cfg$gms$c15_kcal_scen <- "healthy_BMI" # default: not necessary to set it again (To Do: remove) cfg$gms$c15_EAT_scen <- "FLX" # default: not necessary to set it again (To Do: remove) - cfg$gms$s15_alc_scen <- 0 # In EATLancet, no calories for alcohol. return(cfg) } From 1f4add998d1ba40ea5b72eb492338bfc19f2ba1c Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Mon, 19 Feb 2024 09:44:15 +0100 Subject: [PATCH 65/71] Update default.cfg --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 07c68713b6..c2f42ff6dc 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -477,7 +477,7 @@ cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet # * The EAT-Lancet diet only allows for added sugars, # * but does not include processed food or alcohol. -# * Only activated if s15_exo_diet is set to 1 +# * Only activated if s15_exo_diet is set to 1 or 3 cfg$gms$s15_exo_alcohol <- 1 # def = 1, options: 0,1 # * Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. # * Only activated if s15_exo_alcohol = 1 From efefb22ad2e88fbbace45c5c2fa1a071d46b5ac5 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 19 Feb 2024 14:21:13 +0100 Subject: [PATCH 66/71] small fixed requested in the review from Isabelle and renaming to stick to the coding etiquette --- .../15_food/anthro_iso_jun22/declarations.gms | 10 ++-- .../15_food/anthro_iso_jun22/exodietmacro.gms | 49 +++++++++---------- modules/15_food/anthro_iso_jun22/input.gms | 2 +- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index c87cd37652..48ed9d52de 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -154,15 +154,15 @@ parameters i15_intake_EATLancet(iso,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) p15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) + i15_fruit_ratio(t,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) p15_intake_detail_starchyfruit(t,iso) Auxiliary parameter for the intake of starchy fruits included in cassav_sp (kcal per capita per day) p15_intake_detail_roots(t,iso) Auxiliary parameter for the intake of roots (kcal per capita per day) p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) p15_intake_detail_nuts(t,iso) Auxiliary parameter for the intake of nuts included in others (kcal per capita per day) - i15_intake_detailed_scen_starchyfruit(t,iso) Auxiliary scenario target for the intake of starchy fruits included in cassav_sp (kcal per capita per day) - i15_intake_detailed_scen_roots(t,iso) Auxiliary scenario target for the intake of roots (kcal per capita per day) - i15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) - i15_intake_detailed_scen_nuts(t,iso) Auxiliary scenario target for the intake of nuts included in others (kcal per capita per day) + p15_intake_detailed_scen_starchyfruit(t,iso) Auxiliary scenario target for the intake of starchy fruits included in cassav_sp (kcal per capita per day) + p15_intake_detailed_scen_roots(t,iso) Auxiliary scenario target for the intake of roots (kcal per capita per day) + p15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) + p15_intake_detailed_scen_nuts(t,iso) Auxiliary scenario target for the intake of nuts included in others (kcal per capita per day) i15_exo_foodscen_fader(t,iso) Fader that converges per capita food consumption to an exogenous diet scenario (1) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index e56b2ef099..aa5d22e61f 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -322,7 +322,7 @@ $endif *' commodities. *---------------------------------------------------------------------------------------- -if (s15_exo_diet = 1, +if ((s15_exo_diet = 1 or s15_exo_diet = 2), *' In case of diet scenarios that are parametrized to a food-specific data set published *' by the EAT-Lancet Commission (`s15_exo_diet=1`), this calculation step consists of *' filling up the scenario target for total daily per capita food intake according @@ -459,71 +459,71 @@ elseif s15_exo_diet = 3, *** Special case: Fruits, vegetables, nuts, and roots *** -*' In MAgPIE fruits, vegetables and nuts are combined in the 'other' food category; +*' In MAgPIE fruits, vegetables and certain nuts are combined in the 'other' food category; *' Starchy fruits (bananas and plantains) are included in the 'cassav_sp' category. *' The f15_fruitveg2others_kcal_ratio gives the country-level historical share *' (fixed into the future based on last historic year) *' of fruits and vegetables in these aggregate categories. if (sum(sameas(t_past,t),1) = 1, - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); + i15_fruit_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); else - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = i15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); + i15_fruit_ratio(t,iso,EAT_special) = i15_fruit_ratio(t-1,iso,EAT_special); ); *' Separation of starchy fruits (bananas and plantains) *' and roots (cassava, sweet potato, yams) in the cassav_sp food category - p15_intake_detail_starchyfruit(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp") * p15_intake_detail(t,iso,"cassav_sp"); - p15_intake_detail_roots(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); + p15_intake_detail_starchyfruit(t,iso) = i15_fruit_ratio(t,iso,"cassav_sp") * p15_intake_detail(t,iso,"cassav_sp"); + p15_intake_detail_roots(t,iso) = (1 - i15_fruit_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); * Initialize scenario target for case that switch is not active - i15_intake_detailed_scen_starchyfruit(t,iso) = p15_intake_detail_starchyfruit(t,iso); - i15_intake_detailed_scen_roots(t,iso) = p15_intake_detail_roots(t,iso); + p15_intake_detailed_scen_starchyfruit(t,iso) = p15_intake_detail_starchyfruit(t,iso); + p15_intake_detailed_scen_roots(t,iso) = p15_intake_detail_roots(t,iso); p15_intake_detailed_scen_target(t,iso,"potato") = p15_intake_detail(t,iso,"potato"); *' lower bound for fruits, veggies, nuts and seeds if (s15_exo_fruitvegnut = 1, *' Maximum recommendation for starchy fruits: - i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > f15_rec_EATLancet(iso,"t_fruitstarch","max")) + p15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > f15_rec_EATLancet(iso,"t_fruitstarch","max")) = f15_rec_EATLancet(iso,"t_fruitstarch","max"); *' Split the 'others' category into fruits plus vegetables and nuts - p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + i15_intake_detailed_scen_starchyfruit(t,iso); - p15_intake_detail_nuts(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); - i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); - i15_intake_detailed_scen_nuts(t,iso) = p15_intake_detail_nuts(t,iso); + p15_intake_detail_fruitveg(t,iso) = i15_fruit_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + p15_intake_detailed_scen_starchyfruit(t,iso); + p15_intake_detail_nuts(t,iso) = (1 - i15_fruit_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); + p15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); + p15_intake_detailed_scen_nuts(t,iso) = p15_intake_detail_nuts(t,iso); *' Minimum recommendation for fruits and vegetables: - i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < f15_rec_EATLancet(iso,"t_fruitveg","min")) + p15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < f15_rec_EATLancet(iso,"t_fruitveg","min")) = f15_rec_EATLancet(iso,"t_fruitveg","min"); *' Extract fruits and vegetables that are part of others category * Note that starchy fruits are kept at the previously assigned maximum level * and their amount has been added to cassav_sp already. - i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); + p15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detailed_scen_fruitveg(t,iso) - p15_intake_detailed_scen_starchyfruit(t,iso); *' Minimum recommendation for nuts & seeds *' (a) nuts included in "others" *' are scaled by the same amount as fruits and vegetables *' because the food group "others" is treated as homogenous food category - i15_intake_detailed_scen_nuts(t,iso)$(p15_intake_detail_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso) > 0) - = p15_intake_detail_nuts(t,iso) * i15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso)) + p15_intake_detailed_scen_nuts(t,iso)$(p15_intake_detail_fruitveg(t,iso) - p15_intake_detailed_scen_starchyfruit(t,iso) > 0) + = p15_intake_detail_nuts(t,iso) * p15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso) - p15_intake_detail_starchyfruit(t,iso)) ; *' The resulting intake of the "others" category is: - p15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); + p15_intake_detailed_scen_target(t,iso,"others") = p15_intake_detailed_scen_fruitveg(t,iso) + p15_intake_detailed_scen_nuts(t,iso); *' (b) remaining nuts (groundnut) and seeds (rapeseed, sunflower) are scaled *' up or down towards the EAT nuts target *' considering scaling of nuts in others. p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) > 0) = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - * (f15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) + * (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso)) ; *** ISABELLE: Please double-check whether I can remove the if condition from the nuts target equations *** ($((sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) -*** Benni and my reasoning was that if the nuts in others (i15_intake_detailed_scen_nuts already over-fulfill the nuts and seeds target, +*** Benni and my reasoning was that if the nuts in others (p15_intake_detailed_scen_nuts already over-fulfill the nuts and seeds target, *** it would be ok to correct the seeds and groundnuts down...) * If seeds have been corrected downwards below zero because nuts target already overfulfilled with nuts in others, @@ -536,19 +536,19 @@ elseif s15_exo_diet = 3, if (s15_exo_roots = 1, *' Maximum recommendation for roots: - i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) + p15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) = f15_rec_EATLancet(iso,"t_roots","max"); p15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) - = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); + = p15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); ); * Assign starchy fruit and cassava roots back to cassava_sp scenario target p15_intake_detailed_scen_target(t,iso,"cassav_sp") = - i15_intake_detailed_scen_roots(t,iso) - + p15_intake_detailed_scen_roots(t,iso) - p15_intake_detailed_scen_target(t,iso,"potato") + - i15_intake_detailed_scen_starchyfruit(t,iso); + p15_intake_detailed_scen_starchyfruit(t,iso); *' lower bound for legumes if (s15_exo_pulses = 1, @@ -569,7 +569,6 @@ elseif s15_exo_diet = 3, *' upper and lower bound for oils if (s15_exo_oils = 1, -* p15_intake_detailed_scen_target(t,iso,"oils") = i15_intake_EATLancet(iso,"oils") * oil_veg has a minimum and maximum recommendation in EAT p15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") < f15_rec_EATLancet(iso,"t_oils","min") diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index 4df838948e..4d9328f4cf 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -107,7 +107,7 @@ scalar s15_exo_roots Exogenous EAT Lancet root target on (1) / 1 /; scalar s15_exo_pulses Exogenous pulses target on (1) / 1 /; scalar s15_exo_sugar Exogenous sugar target on (1) / 1 /; scalar s15_exo_oils Exogenous oils (1) / 1 /; -scalar s15_exo_brans Exogenous brans (1) / 1 /; +scalar s15_exo_brans Exogenous brans (1) / 0 /; scalar s15_exo_scp Exogenous microbial protein target on (1) / 1 /; * The EAT-Lancet diet only allows for added sugars, but does not include processed food or * alcohol. Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. From fa1c114498141a491433d6eff3b280f6c297a8cd Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 19 Feb 2024 17:06:44 +0100 Subject: [PATCH 67/71] update nuts correction based on Isabelles review --- literature.bib | 2 +- .../15_food/anthro_iso_jun22/declarations.gms | 4 ++-- .../15_food/anthro_iso_jun22/exodietmacro.gms | 22 +++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/literature.bib b/literature.bib index adb1364d84..6f31716a32 100644 --- a/literature.bib +++ b/literature.bib @@ -51,7 +51,7 @@ @article{springmann_options_2018 volume = "562", number = "7728", pages = "519 - 525", - author = {Springmann, Marco, Michael Clark, Daniel Mason-D’Croz, Keith Wiebe, Benjamin Leon Bodirsky, Luis Lassaletta, Wim de Vries, Sonja J. Vermeulen, Mario Herrero, Kimberly M. Carlson, Malin Jonell, Max Troell, Fabrice DeClerck, Line J. Gordon, Rami Zurayk, Peter Scarborough, Mike Rayner, Brent Loken, Jess Franzo, H. Charles J. Godfray, David Tilman, Johan Rockström, Walter Willett}, + author = {Springmann, Marco, Michael Clark, Daniel Mason-D'Croz, Keith Wiebe, Benjamin Leon Bodirsky, Luis Lassaletta, Wim de Vries, Sonja J. Vermeulen, Mario Herrero, Kimberly M. Carlson, Malin Jonell, Max Troell, Fabrice DeClerck, Line J. Gordon, Rami Zurayk, Peter Scarborough, Mike Rayner, Brent Loken, Jess Franzo, H. Charles J. Godfray, David Tilman, Johan Rockström, Walter Willett}, month = oct, year = {2018}, } diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index 48ed9d52de..f56cb86e72 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -154,7 +154,7 @@ parameters i15_intake_EATLancet(iso,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) p15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) - i15_fruit_ratio(t,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) + i15_fruit_ratio(t,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) p15_intake_detail_starchyfruit(t,iso) Auxiliary parameter for the intake of starchy fruits included in cassav_sp (kcal per capita per day) p15_intake_detail_roots(t,iso) Auxiliary parameter for the intake of roots (kcal per capita per day) p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) @@ -162,7 +162,7 @@ parameters p15_intake_detailed_scen_starchyfruit(t,iso) Auxiliary scenario target for the intake of starchy fruits included in cassav_sp (kcal per capita per day) p15_intake_detailed_scen_roots(t,iso) Auxiliary scenario target for the intake of roots (kcal per capita per day) p15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) - p15_intake_detailed_scen_nuts(t,iso) Auxiliary scenario target for the intake of nuts included in others (kcal per capita per day) + p15_intake_detailed_scen_nuts(t,iso) Auxiliary scenario target for the intake of nuts included in others (kcal per capita per day) i15_exo_foodscen_fader(t,iso) Fader that converges per capita food consumption to an exogenous diet scenario (1) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index aa5d22e61f..4c2e891364 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -517,14 +517,14 @@ elseif s15_exo_diet = 3, *' up or down towards the EAT nuts target *' considering scaling of nuts in others. p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) > 0) - = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - * (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso)) - ; + = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + * (sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - p15_intake_detailed_scen_nuts(t,iso)) + ; -*** ISABELLE: Please double-check whether I can remove the if condition from the nuts target equations -*** ($((sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) -*** Benni and my reasoning was that if the nuts in others (p15_intake_detailed_scen_nuts already over-fulfill the nuts and seeds target, -*** it would be ok to correct the seeds and groundnuts down...) + p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detailed_scen_target,iso,kfo_ns2) < (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso))) + = p15_intake_detailed_scen_target(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detailed_scen_target(t,iso,kfo_ns2)) + * (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso)) + ; * If seeds have been corrected downwards below zero because nuts target already overfulfilled with nuts in others, * seed and groundnut consumption is reduced to zero. @@ -536,11 +536,11 @@ elseif s15_exo_diet = 3, if (s15_exo_roots = 1, *' Maximum recommendation for roots: - p15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) - = f15_rec_EATLancet(iso,"t_roots","max"); + p15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) = + f15_rec_EATLancet(iso,"t_roots","max"); - p15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) - = p15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); + p15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) = + p15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); ); From fb8fad1e04859eeddec167f3f6508e3d56e93f96 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 19 Feb 2024 17:17:59 +0100 Subject: [PATCH 68/71] bugfixes --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 4c2e891364..e4a54e2623 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -521,7 +521,7 @@ elseif s15_exo_diet = 3, * (sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - p15_intake_detailed_scen_nuts(t,iso)) ; - p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detailed_scen_target,iso,kfo_ns2) < (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso))) + p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detailed_scen_target(t,iso,kfo_ns2)) < (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso))) = p15_intake_detailed_scen_target(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detailed_scen_target(t,iso,kfo_ns2)) * (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso)) ; From 9917c46d31fab03aa37a155bacbb7e3c4af96fb0 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 20 Feb 2024 16:11:01 +0100 Subject: [PATCH 69/71] bugfixes --- .../15_food/anthro_iso_jun22/exodietmacro.gms | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index e4a54e2623..b4627e8844 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -464,11 +464,11 @@ elseif s15_exo_diet = 3, *' The f15_fruitveg2others_kcal_ratio gives the country-level historical share *' (fixed into the future based on last historic year) *' of fruits and vegetables in these aggregate categories. - if (sum(sameas(t_past,t),1) = 1, - i15_fruit_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); - else - i15_fruit_ratio(t,iso,EAT_special) = i15_fruit_ratio(t-1,iso,EAT_special); - ); + if (sum(sameas(t_past,t),1) = 1, + i15_fruit_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); + else + i15_fruit_ratio(t,iso,EAT_special) = i15_fruit_ratio(t-1,iso,EAT_special); + ); *' Separation of starchy fruits (bananas and plantains) *' and roots (cassava, sweet potato, yams) in the cassav_sp food category @@ -499,7 +499,7 @@ elseif s15_exo_diet = 3, *' Extract fruits and vegetables that are part of others category * Note that starchy fruits are kept at the previously assigned maximum level -* and their amount has been added to cassav_sp already. +* and their amount will be added to cassav_sp. p15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detailed_scen_fruitveg(t,iso) - p15_intake_detailed_scen_starchyfruit(t,iso); *' Minimum recommendation for nuts & seeds @@ -507,7 +507,7 @@ elseif s15_exo_diet = 3, *' are scaled by the same amount as fruits and vegetables *' because the food group "others" is treated as homogenous food category p15_intake_detailed_scen_nuts(t,iso)$(p15_intake_detail_fruitveg(t,iso) - p15_intake_detailed_scen_starchyfruit(t,iso) > 0) - = p15_intake_detail_nuts(t,iso) * p15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso) - p15_intake_detail_starchyfruit(t,iso)) + = p15_intake_detail_nuts(t,iso) * p15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso) - p15_intake_detailed_scen_starchyfruit(t,iso)) ; *' The resulting intake of the "others" category is: @@ -517,14 +517,9 @@ elseif s15_exo_diet = 3, *' up or down towards the EAT nuts target *' considering scaling of nuts in others. p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) > 0) - = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - * (sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - p15_intake_detailed_scen_nuts(t,iso)) - ; + = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + * (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso)); - p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detailed_scen_target(t,iso,kfo_ns2)) < (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso))) - = p15_intake_detailed_scen_target(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detailed_scen_target(t,iso,kfo_ns2)) - * (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso)) - ; * If seeds have been corrected downwards below zero because nuts target already overfulfilled with nuts in others, * seed and groundnut consumption is reduced to zero. @@ -622,6 +617,7 @@ elseif s15_exo_diet = 3, sum(EAT_nonstaples2, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)); if (smin((iso,kfo), p15_intake_detailed_scen_target(t,iso,kfo)) < 0, + display p15_intake_detailed_scen_target; abort "The parameter p15_intake_detailed_scen_target became negative after calorie balancing."; ); From 42ce67cd8bde96acdd6c56ff34de0744f4bd6fa1 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 21 Feb 2024 17:56:57 +0100 Subject: [PATCH 70/71] code cleanup: remove unused scalars --- modules/15_food/anthro_iso_jun22/input.gms | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index 4d9328f4cf..79e10b5d87 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -97,8 +97,6 @@ scalar s15_exo_diet Switch for transition towards exogenous diet scenario (1) / * If the switch is set to 1,the exogenous diets are activated. * For all other settings (!=1), the endogenous estimate is used. * When activating a target, total calories are always preserved via scaling of staples -scalar s15_exo_poultry Exogenous EAT Lancet animal product target on (1) / 1 /; -scalar s15_exo_redmeatdairy Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_monogastric Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_ruminant Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_fish Exogenous EAT Lancet animal product target on (1) / 1 /; From 4b4c75b1c998a9b44c62f2f6fdfb3a3bedea29f9 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 23 Feb 2024 11:43:36 +0100 Subject: [PATCH 71/71] updated comment in default.cfg --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index c2f42ff6dc..81d263859b 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -454,7 +454,7 @@ cfg$gms$s15_exo_diet <- 0 # def = 0 cfg$gms$c15_kcal_scen <- "healthy_BMI" # def = healthy_BMI # # * exogenous food-specific diet scenario (EAT Lancet diet scenarios) -# * only activated if s15_exo_diet is > 0 +# * only activated if s15_exo_diet is 1 or 2 # * options: BMK, FLX, PSC, VEG, VGN, FLX_hmilk, FLX_hredmeat cfg$gms$c15_EAT_scen <- "FLX" # def = FLX