diff --git a/GAMS/IntExtOpt.gms b/GAMS/IntExtOpt.gms index 1383000ce9ec6f08641500706afc387615704ca8..b7566b86dbc9ead4a976b9c496285cb79f8beae8 100644 --- a/GAMS/IntExtOpt.gms +++ b/GAMS/IntExtOpt.gms @@ -123,7 +123,7 @@ $gdxin MIN_NET_IMPORT_CONSTRAINT(import_crop) constraint on min net imports PASTURE_IMPORT_CONSTRAINT constraint to not import pasture PASTURE_EXPORT_CONSTRAINT - IRRIGATION_CONSTRAINT constraint no water usage + IRRIGATION_CONSTRAINT(location) constraint no water usage NET_SUPPLY_EQ(crop) calc net supply for crops AGRI_LAND_EXPANSION_CALC(location) calc agriLandExpansion CROP_INCREASE_CALC(location) @@ -180,8 +180,8 @@ $gdxin PASTURE_IMPORT_CONSTRAINT .. importAmount('pasture') =E= 0; PASTURE_EXPORT_CONSTRAINT .. exportAmount('pasture') =E= 0; - IRRIGATION_CONSTRAINT .. sum(location, irrigConstraint(location) * suitableLandArea(location)) =G= sum((crop, location), irrigMaxRate(crop, location) * irrigI(crop, location) * area(crop, location)); - + IRRIGATION_CONSTRAINT(location) .. irrigConstraint(location) * suitableLandArea(location) =G= sum(crop, irrigMaxRate(crop, location) * irrigI(crop, location) * area(crop, location)); + AGRI_LAND_EXPANSION_CALC(location) .. agriLandExpansion(location) =G= sum(crop, area(crop, location) - previousArea(crop, location)); CROP_INCREASE_CALC(location) .. cropIncrease(location) =G= sum(crop_less_pasture, area(crop_less_pasture, location) - previousArea(crop_less_pasture, location)); diff --git a/src/ac/ed/lurg/ModelConfig.java b/src/ac/ed/lurg/ModelConfig.java index d61bc11410f59f461bc83b6f912554d4fde3cabd..2ad2f69d19306cced2dd187552369c5c4b62217e 100644 --- a/src/ac/ed/lurg/ModelConfig.java +++ b/src/ac/ed/lurg/ModelConfig.java @@ -242,6 +242,7 @@ public class ModelConfig { public static final boolean PROTECTED_AREAS_ENABLED = getBooleanProperty("PROTECTED_AREAS_ENABLED", true); public static final double MIN_NATURAL_RATE = getDoubleProperty("MIN_NATURAL_RATE", 0.10); + public static final boolean DEBUG_JUST_DEMAND_OUTPUT = getBooleanProperty("DEBUG_JUST_DEMAND_OUTPUT", false); public static final boolean DEBUG_LIMIT_COUNTRIES = getBooleanProperty("DEBUG_LIMIT_COUNTRIES", false); public static final String DEBUG_COUNTRY_NAME = getProperty("DEBUG_COUNTRY_NAME", "United States of America"); public static final double PASTURE_MAX_IRRIGATION_RATE = getDoubleProperty("DEFAULT_MAX_IRRIGATION_RATE", 50.0); // shouldn't need this but some areas crops don't have a value, but was causing them to be selected diff --git a/src/ac/ed/lurg/ModelMain.java b/src/ac/ed/lurg/ModelMain.java index 8d79bfee8928d69cee993b01fd4952c77e5ab805..d85fdd4aef6d78e41fa4325ef2cfab3e99e914ae 100644 --- a/src/ac/ed/lurg/ModelMain.java +++ b/src/ac/ed/lurg/ModelMain.java @@ -299,12 +299,16 @@ public class ModelMain { for (CountryAgent country : countryAgents) { Double d = country.getCurrentProjectedDemand().get(comm); - if (d != null) + if (d != null) { demandAmount += d.doubleValue(); + LogWriter.println(String.format("%s,%s,%.4f", country.getCountry(), comm.getGamsName(), d)); + } } StringBuffer sbData = new StringBuffer(); sbData.append(String.format("%d,%s", timestep.getYear(), comm.getGamsName())); sbData.append(String.format(",%.1f", demandAmount)); + + LogWriter.println("Global demand " + timestep.getYear() + " " + comm.getGamsName() + " " + demandAmount + "\n"); outputFile.write(sbData.toString()); outputFile.newLine(); diff --git a/src/ac/ed/lurg/country/CountryAgent.java b/src/ac/ed/lurg/country/CountryAgent.java index 3b014a51ab4f44a6bd0f952a239be861b6ef2beb..f22938871e78835b8cedc20ee0fc83c6af7e39c1 100644 --- a/src/ac/ed/lurg/country/CountryAgent.java +++ b/src/ac/ed/lurg/country/CountryAgent.java @@ -110,7 +110,9 @@ public class CountryAgent { else if (countryYieldSurfaces.size() == 0 ) { LogWriter.printlnError("No yield values for " + country + " so skipping it"); } - else { + else if (ModelConfig.DEBUG_JUST_DEMAND_OUTPUT) { // if this debug flag is set we don't do the optimisation + } + else { if (yieldClusters==null) yieldClusters = calcYieldClusters(countryYieldSurfaces); // this should only be on the first timestep diff --git a/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java b/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java index fcb27e8a6f68d7365f09e7f340789cbeff28f4be..21d113de0046ef7cf785c617a57f95c9d944052a 100644 --- a/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java +++ b/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java @@ -158,7 +158,7 @@ public class GamsLocationOptimiser { setGamsParamValue(irrigConstraintP.addRecord(Integer.toString(locationId)), irrigConstraint, 3); } - if (DEBUG) LogWriter.println("\nDemand"); + if (DEBUG) LogWriter.println("\nDemand: " + inputData.getCountryInput().getCountry() + " " + inputData.getTimestep().getYear()); GamsCountryInput countryInput = inputData.getCountryInput(); addCommodityMapParm(inDB.addParameter("demand", 1), countryInput.getProjectedDemand(), 4);