diff --git a/src/ac/ed/lurg/ModelConfig.java b/src/ac/ed/lurg/ModelConfig.java index 36aa223181ef454282031e3eee58f84cc04b58de..da78268c2fff4984bed2b8d9b79e60a958927c29 100644 --- a/src/ac/ed/lurg/ModelConfig.java +++ b/src/ac/ed/lurg/ModelConfig.java @@ -158,14 +158,14 @@ public class ModelConfig { public static final double PASTURE_HARVEST_FRACTION = getDoubleProperty("PASTURE_HARVEST_FRACTION", 0.25); public static final double MEAT_EFFICIENCY = getDoubleProperty("MEAT_EFFICIENCY", 1.0); // 'meat' is includes feed conversion ratio already, this is tech. change or similar public static final double IRRIGIATION_EFFICIENCY = getDoubleProperty("IRRIGIATION_EFFICIENCY", 0.5); - public static final double LAND_CHANGE_COST = getDoubleProperty("LAND_CHANGE_COST", 0.4); + public static final double LAND_CHANGE_COST = getDoubleProperty("LAND_CHANGE_COST", 0.6); public static final double MIN_FEED_RATE = getDoubleProperty("MIN_FEED_RATE", 0.15); public static final double SEED_AND_WASTE_FRACTION = getDoubleProperty("SEED_AND_WASTE_FRACTION", 0.15); - public static final double TECHNOLOGY_CHANGE_ANNUAL_RATE = getDoubleProperty("TECHNOLOGY_CHANGE_ANNUAL_RATE", 0.0); + public static final double TECHNOLOGY_CHANGE_ANNUAL_RATE = IS_CALIBRATION_RUN ? 0.0 : getDoubleProperty("TECHNOLOGY_CHANGE_ANNUAL_RATE", 0.0); public static final int TECHNOLOGY_CHANGE_START_STEP = getIntProperty("TECHNOLOGY_CHANGE_START_STEP", 0); - public static final double BIOENERGY_CHANGE_ANNUAL_RATE = getDoubleProperty("BIOENERGY_CHANGE_ANNUAL_RATE", 0.0); + public static final double BIOENERGY_CHANGE_ANNUAL_RATE = IS_CALIBRATION_RUN ? 0.0 : getDoubleProperty("BIOENERGY_CHANGE_ANNUAL_RATE", 0.0); public static final int BIOENERGY_CHANGE_START_YEAR = getIntProperty("BIOENERGY_CHANGE_START_YEAR", 2010); public static final double MARKET_LAMBA = getDoubleProperty("MARKET_LAMBA", 0.5); // controls international market price adjustment rate @@ -188,8 +188,8 @@ public class ModelConfig { public static final boolean PROTECTED_AREAS_ENABLED = getBooleanProperty("PROTECTED_AREAS_ENABLED", true); - public static final int NUM_CEREAL_CATEGORIES = getIntProperty("NUM_CEREAL_CATEGORIES", 6); - public static final int NUM_PASTURE_CATEGORIES = getIntProperty("NUM_PASTURE_CATEGORIES", 6); + public static final int NUM_CEREAL_CATEGORIES = getIntProperty("NUM_CEREAL_CATEGORIES", 12); + public static final int NUM_PASTURE_CATEGORIES = getIntProperty("NUM_PASTURE_CATEGORIES", 3); public static final boolean DEBUG_LIMIT_COUNTRIES = getBooleanProperty("DEBUG_LIMIT_COUNTRIES", false); public static final Object DEBUG_COUNTRY_NAME = getProperty("DEBUG_COUNTRY_NAME", "United States of America"); diff --git a/src/ac/ed/lurg/country/CountryAgent.java b/src/ac/ed/lurg/country/CountryAgent.java index 5d2773c19468273a9cd0a127c982ea38605b7a23..1ff5b891e942d9daf7c078b546cc12bfab1695cd 100644 --- a/src/ac/ed/lurg/country/CountryAgent.java +++ b/src/ac/ed/lurg/country/CountryAgent.java @@ -63,7 +63,7 @@ public class CountryAgent { } else { // optimize areas and intensity - GamsRasterInput input = getGamsRasterInput(currentProjectedDemand, currentCountryPrices, irrigData); + GamsRasterInput input = getGamsRasterInput(irrigData); GamsRasterOptimiser opti = new GamsRasterOptimiser(input); LogWriter.println("Running " + country.getName() + ", currentTimestep " + currentTimestep); @@ -79,18 +79,19 @@ public class CountryAgent { return currentProjectedDemand; } - private GamsRasterInput getGamsRasterInput(Map<CommodityType, Double> projectedDemand, Map<CropType, CountryPrice> countryPrices, RasterSet<IrrigationItem> irrigData) { -//TODO why pass in projectedDemand when currentProjectedDemand belongs to CountryAgent class already? + private GamsRasterInput getGamsRasterInput(RasterSet<IrrigationItem> irrigData) { GamsRasterOutput prevOutput; + double allowedImportChange; if (currentTimestep.isInitialTimestep()) { // initialisation time-step prevOutput = resultsTimeseries.get(currentTimestep); + allowedImportChange = 0.0; } else { // normal (not the initial) time-step prevOutput = resultsTimeseries.get(currentTimestep.getPreviousTimestep()); + allowedImportChange = ModelConfig.MAX_IMPORT_CHANGE; // when running is calibration model calibrate (ModelConfig.IS_CALIBRATION_RUN==true) MAX_IMPORT_CHANGE is already 0. } - Map<CropType, Double> baseNetImport = new HashMap<CropType, Double>(); Map<CropType, Double> maxOfProdOrSupply = new HashMap<CropType, Double>(); @@ -101,15 +102,13 @@ public class CountryAgent { maxOfProdOrSupply.put(entry.getKey(), cropUsage.getProduction() + Math.max(netImports, 0)); } - GamsCountryInput countryLevelInputs = GamsCountryInput.createInput(country, projectedDemand, countryPrices, baseNetImport, maxOfProdOrSupply); + GamsCountryInput countryLevelInputs = GamsCountryInput.createInput(country, currentProjectedDemand, currentCountryPrices, baseNetImport, maxOfProdOrSupply, allowedImportChange); GamsRasterInput input = new GamsRasterInput(currentTimestep, countryYieldSurfaces, prevOutput.getLandUses(), irrigData, countryLevelInputs); return input; } - Map<CropType, CountryPrice> calculateCountryPrices(Map<CropType, GlobalPrice> worldPrices){ - Map<CropType, CountryPrice> countryPrices = new HashMap <CropType, CountryPrice>(); for (CropType c : CropType.getImportedTypes()) { @@ -118,7 +117,6 @@ public class CountryAgent { countryPrices.put(c, prices); } - return countryPrices; - + return countryPrices; } } diff --git a/src/ac/ed/lurg/country/gams/GamsCountryInput.java b/src/ac/ed/lurg/country/gams/GamsCountryInput.java index 93e8fdff35a6920b64989fb1dfd56d0805d63c09..5ef32d26327754c6f71c7ca0baf785764bdd2a3f 100644 --- a/src/ac/ed/lurg/country/gams/GamsCountryInput.java +++ b/src/ac/ed/lurg/country/gams/GamsCountryInput.java @@ -31,9 +31,8 @@ public class GamsCountryInput { } public static GamsCountryInput createInput(CompositeCountry country, Map<CommodityType, Double> projectedDemand, Map<CropType, CountryPrice> countryPrices, - Map<CropType, Double> baseNetImport, Map<CropType, Double> maxOfProdOrSupply) { + Map<CropType, Double> baseNetImport, Map<CropType, Double> maxOfProdOrSupply, double allowedImportChange) { - double allowedImportChange = ModelConfig.MAX_IMPORT_CHANGE; Map<CropType, ImportExportConstraint> importConstraints = new HashMap<CropType, ImportExportConstraint>(); for (Map.Entry<CropType, Double> entry : baseNetImport.entrySet()) { diff --git a/src/ac/ed/lurg/country/gams/GamsLocationTest.java b/src/ac/ed/lurg/country/gams/GamsLocationTest.java index 9dafdbcb9bafa3363a3332cfdb43f64a497acbd2..add210efda015135a2c686d497f36aa76f8c0995 100644 --- a/src/ac/ed/lurg/country/gams/GamsLocationTest.java +++ b/src/ac/ed/lurg/country/gams/GamsLocationTest.java @@ -23,7 +23,7 @@ public class GamsLocationTest { } private void run() { - GamsCountryInput countryLevelInputs = GamsCountryInput.createInput(new CompositeCountry("Test"), getProjectedDemand(), getCountryPrices(), null, null); + GamsCountryInput countryLevelInputs = GamsCountryInput.createInput(new CompositeCountry("Test"), getProjectedDemand(), getCountryPrices(), null, null, 0.1); GamsLocationInput gamsInput = new GamsLocationInput(new Timestep(0), getYields(), getPreviousArea(), getIrrigationCosts(), countryLevelInputs); GamsLocationOptimiser opti = new GamsLocationOptimiser(gamsInput); diff --git a/src/ac/ed/lurg/country/gams/GamsRasterTest.java b/src/ac/ed/lurg/country/gams/GamsRasterTest.java index 995abdebaa27e8adabbd699eb9874eb5f29467e4..1e991c27b1823f221d0be3ef93b33c2ddfeb9dc3 100644 --- a/src/ac/ed/lurg/country/gams/GamsRasterTest.java +++ b/src/ac/ed/lurg/country/gams/GamsRasterTest.java @@ -18,7 +18,7 @@ public class GamsRasterTest extends GamsLocationTest { } private void run() { - GamsCountryInput countryLevelInputs = GamsCountryInput.createInput(new CompositeCountry("Test"), getProjectedDemand(), getCountryPrices(), null, null); + GamsCountryInput countryLevelInputs = GamsCountryInput.createInput(new CompositeCountry("Test"), getProjectedDemand(), getCountryPrices(), null, null, 0.1); GamsRasterInput input = new GamsRasterInput(new Timestep(0), getYieldRaster(), getPreviousAreaRaster(), getIrrigationCost(), countryLevelInputs); GamsRasterOptimiser opti = new GamsRasterOptimiser(input);