Skip to content
Snippets Groups Projects
Commit 3f954699 authored by Peter Alexander's avatar Peter Alexander
Browse files

Exception handling, minCerealDemand and logging changes

parent 44d4d1d9
No related branches found
No related tags found
No related merge requests found
...@@ -52,9 +52,9 @@ $load fertParam, irrigParam, otherIParam, exportPrices, importPrices, maxNetImpo ...@@ -52,9 +52,9 @@ $load fertParam, irrigParam, otherIParam, exportPrices, importPrices, maxNetImpo
$load meatEfficency, otherICost, irrigCost, irrigMaxRate, irrigConstraint, fertiliserUnitCost, domesticPriceMarkup $load meatEfficency, otherICost, irrigCost, irrigMaxRate, irrigConstraint, fertiliserUnitCost, domesticPriceMarkup
$gdxin $gdxin
SCALAR delta use to smooth power function see 7.5 www.gams.com dd docs solversconopt.pdf / 0.00000000001 / SCALAR delta use to smooth power function see 7.5 www.gams.com dd docs solversconopt.pdf / 0.00000000001 /;
SCALAR minDemandPerCereal / 0.1 /; SCALAR minDemandPerCereal / 0.0 /;
previousArea(crop_less_pasture, location) = previousArea(crop_less_pasture, location) * (1.0 - unhandledCropArea); previousArea(crop_less_pasture, location) = previousArea(crop_less_pasture, location) * (1.0 - unhandledCropArea);
......
MODEL,SCENARIO,REGION,Variable,Unit,Year,value
...@@ -2,30 +2,40 @@ BASE_DIR=/Users/peteralexander/Documents/R_Workspace/UNPLUM/hind1970 ...@@ -2,30 +2,40 @@ BASE_DIR=/Users/peteralexander/Documents/R_Workspace/UNPLUM/hind1970
INITAL_LAND_COVER_FILENAME=hurtt_1970.txt INITAL_LAND_COVER_FILENAME=hurtt_1970.txt
BASE_YEAR=1970 BASE_YEAR=1970
SSP_SCENARIO=HINDCAST SSP_SCENARIO=HINDCAST
YIELD_DIR=/Users/peteralexander/Documents/LURG/LPJ/19Jan2017/LPJG_PLUM_expt1.1_1971-2005_forED YIELD_DIR=/Users/peteralexander/Documents/LURG/LPJ/29May2017/LPJG_PLUM_expt1.1_1961-2015_ipsl_LUfixes_10patchesFrom5patches_forED_20170528170903
#YIELD_DIR=/Users/peteralexander/Documents/LURG/LPJ/19Jan2017/LPJG_PLUM_expt1.1_1971-2005_forED
#YIELD_DIR=/Users/peteralexander/Documents/LURG/LPJ/IPSL/LPJG_PLUM_expt1.1_1966-2005_ipsl_lessIO_forED #YIELD_DIR=/Users/peteralexander/Documents/LURG/LPJ/IPSL/LPJG_PLUM_expt1.1_1966-2005_ipsl_lessIO_forED
# irritatingly the gams file is also found under the BASE_DIR, and don't want to duplicate so need to specify exactly # irritatingly the gams file is also found under the BASE_DIR, and don't want to duplicate so need to specify exactly
GAMS_MODEL=/Users/peteralexander/Documents/R_Workspace/UNPLUM/GAMS/IntExtOpt.gms GAMS_MODEL=/Users/peteralexander/Documents/R_Workspace/UNPLUM/GAMS/IntExtOpt.gms
DEBUG_LIMIT_COUNTRIES=false DEBUG_LIMIT_COUNTRIES=true
DEBUG_COUNTRY_NAME=China DEBUG_COUNTRY_NAME=Germany
#Europe & Central Asia_other #Europe & Central Asia_other
#Russian Federation #Russian Federation
#Europe & Central Asia_other #Europe & Central Asia_other
IS_CALIBRATION_RUN = false IS_CALIBRATION_RUN = true
END_TIMESTEP=20 END_TIMESTEP=0
TIMESTEP_SIZE=2 TIMESTEP_SIZE=2
INTERPOLATE_OUTPUT_YEARS = false INTERPOLATE_OUTPUT_YEARS = false
BIOENERGY_CHANGE_START_YEAR=1970 BIOENERGY_CHANGE_START_YEAR=1970
BIOENERGY_CHANGE_END_YEAR=2010 BIOENERGY_CHANGE_END_YEAR=2010
BIOENERGY_CHANGE_ANNUAL_RATE=0.35
BIOENERGY_CHANGE_ANNUAL_RATE=0.35
PASTURE_INCREASE_COST=0.01 PASTURE_INCREASE_COST=0.01
AGRI_EXPANSION_COST_BASE=0.01 AGRI_EXPANSION_COST_BASE=0.01
AGRI_EXPANSION_COST_BASE_MANAGED_FOREST=0.1 AGRI_EXPANSION_COST_BASE_MANAGED_FOREST=0.1
#Yields too high by factor of 10
#CALIB_FACTOR_WHEAT = 0.0986
#CALIB_FACTOR_MAIZE = 0.0625
#CALIB_FACTOR_RICE = 0.1105
#CALIB_FACTOR_OILCROPS = 0.0554
#CALIB_FACTOR_PULSES = 0.0615
#CALIB_FACTOR_STARCHY_ROOTS = 0.6211
NUM_YIELD_CLUSTERS=500
...@@ -91,11 +91,6 @@ public class GamsLocationOptimiser { ...@@ -91,11 +91,6 @@ public class GamsLocationOptimiser {
GAMSParameter landP = inDB.addParameter("suitableLandArea", 1); GAMSParameter landP = inDB.addParameter("suitableLandArea", 1);
GAMSParameter agriExpansionCostP = inDB.addParameter("agriExpansionCost", 1); GAMSParameter agriExpansionCostP = inDB.addParameter("agriExpansionCost", 1);
addScalar(inDB, "cropIncCost", ModelConfig.CROP_INCREASE_COST, 3);
addScalar(inDB, "cropDecCost", ModelConfig.CROP_DECREASE_COST, 3);
addScalar(inDB, "pastureDecCost", ModelConfig.PASTURE_DECREASE_COST, 3);
addScalar(inDB, "pastureIncCost", ModelConfig.PASTURE_INCREASE_COST, 3);
double totalAgriLand = 0; double totalAgriLand = 0;
for (Map.Entry<Integer, ? extends LandUseItem> entry : inputData.getPreviousLandUse().entrySet()) { for (Map.Entry<Integer, ? extends LandUseItem> entry : inputData.getPreviousLandUse().entrySet()) {
...@@ -225,6 +220,10 @@ public class GamsLocationOptimiser { ...@@ -225,6 +220,10 @@ public class GamsLocationOptimiser {
} }
LogWriter.print("\n"); LogWriter.print("\n");
addScalar(inDB, "cropIncCost", ModelConfig.CROP_INCREASE_COST, 3);
addScalar(inDB, "cropDecCost", ModelConfig.CROP_DECREASE_COST, 3);
addScalar(inDB, "pastureDecCost", ModelConfig.PASTURE_DECREASE_COST, 3);
addScalar(inDB, "pastureIncCost", ModelConfig.PASTURE_INCREASE_COST, 3);
addScalar(inDB, "meatEfficency", countryInput.getMeatEfficiency(), 3); addScalar(inDB, "meatEfficency", countryInput.getMeatEfficiency(), 3);
addScalar(inDB, "fertiliserUnitCost", ModelConfig.FERTILISER_MAX_COST, 3); addScalar(inDB, "fertiliserUnitCost", ModelConfig.FERTILISER_MAX_COST, 3);
addScalar(inDB, "otherICost",ModelConfig.OTHER_INTENSITY_COST, 3); addScalar(inDB, "otherICost",ModelConfig.OTHER_INTENSITY_COST, 3);
......
...@@ -40,16 +40,15 @@ public class DemandManager { ...@@ -40,16 +40,15 @@ public class DemandManager {
for (SingleCountry c : compositeCountryManager.getAllForCompositeCountry(cc)) { for (SingleCountry c : compositeCountryManager.getAllForCompositeCountry(cc)) {
SspData baseSspData = sspManager.get(ssp_scenario, ModelConfig.BASE_YEAR, c); SspData baseSspData = sspManager.get(ssp_scenario, ModelConfig.BASE_YEAR, c);
SspData sd = sspManager.get(ssp_scenario, year, c); SspData sd = sspManager.get(ssp_scenario, year, c);
LogWriter.println("Got ssp data for " + c.getCountryName() + " of " + sd); if (baseSspData == null || sd == null) {
LogWriter.printlnError(String.format("No baseSspData or ssp for %s, baseYr:%d, year:%d, %s, base:%s, sd:%s. Skipping", ssp_scenario, ModelConfig.BASE_YEAR, year, c.getCountryName(), baseSspData, sd));
if (sd == null) {
LogWriter.printlnError("No ssp data for " + ssp_scenario + ", " + year + ", " + c.getCountryName());
continue; continue;
} }
LogWriter.println("Got ssp data for " + c.getCountryName() + " of " + sd);
for (CommodityType commodity : CommodityType.getAllItems()) { for (CommodityType commodity : CommodityType.getAllItems()) {
ModelFitType fitType = commodity.isAnimalProduct() ? ModelFitType.LOGISTIC : ModelFitType.LOGLINEAR; ModelFitType fitType = commodity.isAnimalProduct() ? ModelFitType.LOGISTIC : ModelFitType.LOGLINEAR;
......
...@@ -81,7 +81,7 @@ public abstract class AbstractTabularRasterReader<D extends RasterItem> { ...@@ -81,7 +81,7 @@ public abstract class AbstractTabularRasterReader<D extends RasterItem> {
rowValues.put(dataColNames[i], d); rowValues.put(dataColNames[i], d);
} }
catch (Exception e) { catch (Exception e) {
LogWriter.print("Problem getting col: " + i + " for x: " + x + ", y: " + y + " - " + e.getMessage()); LogWriter.println("Problem getting col: " + i + " for x: " + x + ", y: " + y + " - " + e.getMessage());
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment