diff --git a/src/ac/ed/lurg/country/AbstractCountryAgent.java b/src/ac/ed/lurg/country/AbstractCountryAgent.java index 25283e15cc991770a59c9ab3ec1559c51968cf5a..c98997abd46cc97ebee975f1f5f1d2af44933e43 100644 --- a/src/ac/ed/lurg/country/AbstractCountryAgent.java +++ b/src/ac/ed/lurg/country/AbstractCountryAgent.java @@ -53,14 +53,14 @@ public abstract class AbstractCountryAgent { currentCountryPrices = countryPrices; } - private void calculateDemand() { + private void calculateDemand(boolean outputGamsDemand) { Map<CommodityType, Double> producerPrices = getProducerCommodityPrices(); - currentProjectedDemand = demandManager.getDemand(country, currentTimestep.getYear(), producerPrices); + currentProjectedDemand = demandManager.getDemand(country, currentTimestep.getYear(), producerPrices, outputGamsDemand); } - protected void calculateCountryPricesAndDemand(Map<CropType, GlobalPrice> worldPrices) { + protected void calculateCountryPricesAndDemand(Map<CropType, GlobalPrice> worldPrices, boolean outputGamsDemand) { calculateCountryPrices(worldPrices); - calculateDemand(); + calculateDemand(outputGamsDemand); } private Map<CommodityType, Double> getProducerCommodityPrices() { diff --git a/src/ac/ed/lurg/country/CountryAgent.java b/src/ac/ed/lurg/country/CountryAgent.java index 6b3ca7a9e618a1244371631bdb3b55aef59dfd4e..4bcb755a5c7e0c3b133004ccd9266bb908050711 100644 --- a/src/ac/ed/lurg/country/CountryAgent.java +++ b/src/ac/ed/lurg/country/CountryAgent.java @@ -121,7 +121,7 @@ public class CountryAgent extends AbstractCountryAgent { Map<CropType, GlobalPrice> worldPrices, double globalGen2EcIncrease) { // project demand - calculateCountryPricesAndDemand(worldPrices); + calculateCountryPricesAndDemand(worldPrices, false); if (saveGamsGdxFiles && ModelConfig.PRICE_ELASTIC_DEMAND) saveGDXFile("demand"); diff --git a/src/ac/ed/lurg/country/CountryAgentManager.java b/src/ac/ed/lurg/country/CountryAgentManager.java index 8fe33be506e30cd31529f95939d51cd3d4bc69c9..8340d27aac125ffbcf442d13ae6d6500d906bb83 100644 --- a/src/ac/ed/lurg/country/CountryAgentManager.java +++ b/src/ac/ed/lurg/country/CountryAgentManager.java @@ -138,7 +138,7 @@ public class CountryAgentManager { public void recalculateDemandForAll() { for (CountryAgent ca : gamsCountryAgents) { ca.shockGDP(); - ca.calculateCountryPricesAndDemand(internationalMarket.getWorldPrices()); + ca.calculateCountryPricesAndDemand(internationalMarket.getWorldPrices(), true); } } diff --git a/src/ac/ed/lurg/country/crafty/CraftyCountryAgent.java b/src/ac/ed/lurg/country/crafty/CraftyCountryAgent.java index 7ab4740c38afd86c010352f50332dd9e4df4e94b..af0145d69d0f6144f229707b472cbf3deee63b95 100644 --- a/src/ac/ed/lurg/country/crafty/CraftyCountryAgent.java +++ b/src/ac/ed/lurg/country/crafty/CraftyCountryAgent.java @@ -29,7 +29,7 @@ public class CraftyCountryAgent extends AbstractCountryAgent { } public void updateProduction(Map<CropType, Double> cropProduction, Map<CropType, GlobalPrice> worldPrices) { - calculateCountryPricesAndDemand(worldPrices); + calculateCountryPricesAndDemand(worldPrices, false); cropUsageData = new HashMap<CropType, CropUsageData>(); for (Entry<CropType, Double> entry : cropProduction.entrySet()) { diff --git a/src/ac/ed/lurg/demand/AbstractDemandManager.java b/src/ac/ed/lurg/demand/AbstractDemandManager.java index 18a176741a436eb1da932173c38cce9b1aac7ba3..81808f06326c4448862fba0597a908cac96cb2b2 100644 --- a/src/ac/ed/lurg/demand/AbstractDemandManager.java +++ b/src/ac/ed/lurg/demand/AbstractDemandManager.java @@ -27,7 +27,7 @@ public abstract class AbstractDemandManager { cerealFractionsManager = new CerealFractionsManager(compositeCountryManager); } - public Map<CommodityType, Double> getDemand(CompositeCountry cc, int year, Map<CommodityType, Double> prices) { + public Map<CommodityType, Double> getDemand(CompositeCountry cc, int year, Map<CommodityType, Double> prices, boolean outputGamsDemand) { if (!ModelConfig.CHANGE_DEMAND_YEAR) year = ModelConfig.BASE_YEAR; @@ -37,7 +37,7 @@ public abstract class AbstractDemandManager { for (SingleCountry c : compositeCountryManager.getAllForCompositeCountry(cc)) { - foodDemandMap = getFoodDemand(c, year, prices); + foodDemandMap = getFoodDemand(c, year, prices, outputGamsDemand); for (CommodityType commodity : CommodityType.getAllFoodItems()) { @@ -60,7 +60,7 @@ public abstract class AbstractDemandManager { return demandMap; } - protected abstract Map<CommodityType, Double> getFoodDemand(SingleCountry c, int year, Map<CommodityType, Double> prices); + protected abstract Map<CommodityType, Double> getFoodDemand(SingleCountry c, int year, Map<CommodityType, Double> prices, boolean outputGamsDemand); public void updateGdpLossesFromShock(CompositeCountry cc, int year, double shockMagnitude) {} diff --git a/src/ac/ed/lurg/demand/AbstractSSPDemandManager.java b/src/ac/ed/lurg/demand/AbstractSSPDemandManager.java index 7781a43a54b997f6e36d607e039c42bfbb054f5b..56da459d243b29d03404694f62d347a9ad460a08 100644 --- a/src/ac/ed/lurg/demand/AbstractSSPDemandManager.java +++ b/src/ac/ed/lurg/demand/AbstractSSPDemandManager.java @@ -48,7 +48,7 @@ public abstract class AbstractSSPDemandManager extends AbstractDemandManager { } @Override - protected Map<CommodityType, Double> getFoodDemand(SingleCountry c, int year, Map<CommodityType, Double> prices) { + protected Map<CommodityType, Double> getFoodDemand(SingleCountry c, int year, Map<CommodityType, Double> prices, boolean outputGamsDemand) { SspData sd = sspManager.get(ssp_scenario, year, c); Map<CommodityType, Double> foodDemandMap = new HashMap<CommodityType, Double>(); @@ -67,7 +67,7 @@ public abstract class AbstractSSPDemandManager extends AbstractDemandManager { SspData usaSd = sspManager.get(ssp_scenario, year, usa); LogWriter.println("Got ssp data for " + c.getCountryName() + " of " + sd); - foodDemandMap = getFoodDemandMap(c, year, gdpPcYear * ModelConfig.SSP_GDP_PC_FACTOR, sd.getPopulation() * ModelConfig.SSP_POPULATION_FACTOR, prices, usaSd.getGdpPc()); + foodDemandMap = getFoodDemandMap(c, year, gdpPcYear * ModelConfig.SSP_GDP_PC_FACTOR, sd.getPopulation() * ModelConfig.SSP_POPULATION_FACTOR, prices, usaSd.getGdpPc(), outputGamsDemand); if(!ModelConfig.SHOCKS_POSSIBLE){ return foodDemandMap; @@ -85,5 +85,5 @@ public abstract class AbstractSSPDemandManager extends AbstractDemandManager { return projectedCpc; } - abstract Map<CommodityType, Double> getFoodDemandMap(SingleCountry c, int year, double gdpPc, double population, Map<CommodityType, Double> prices, double usaGdpPc); + abstract Map<CommodityType, Double> getFoodDemandMap(SingleCountry c, int year, double gdpPc, double population, Map<CommodityType, Double> prices, double usaGdpPc, boolean outputGamsDemand); } diff --git a/src/ac/ed/lurg/demand/DemandManagerFromFile.java b/src/ac/ed/lurg/demand/DemandManagerFromFile.java index 766ea12c09034046b13277188d8072aae2dfbc31..7d084ec548586cb3b3587c43cb54dcdbeaf7c286 100644 --- a/src/ac/ed/lurg/demand/DemandManagerFromFile.java +++ b/src/ac/ed/lurg/demand/DemandManagerFromFile.java @@ -21,7 +21,7 @@ public class DemandManagerFromFile extends AbstractDemandManager { } @Override - protected Map<CommodityType, Double> getFoodDemand(SingleCountry c, int year, Map<CommodityType, Double> prices) { + protected Map<CommodityType, Double> getFoodDemand(SingleCountry c, int year, Map<CommodityType, Double> prices, boolean outputGamsDemand) { Map<CommodityType, Double> foodDemandMap = new HashMap<CommodityType, Double>(); for (CommodityType commodity : CommodityType.getAllFoodItems()) { diff --git a/src/ac/ed/lurg/demand/DemandManagerSSP.java b/src/ac/ed/lurg/demand/DemandManagerSSP.java index 683b00aa1963842b3a770c3e74414aacfdcd8688..c139c239dc86ef66afd46b17c8e0daf571155f75 100644 --- a/src/ac/ed/lurg/demand/DemandManagerSSP.java +++ b/src/ac/ed/lurg/demand/DemandManagerSSP.java @@ -19,7 +19,7 @@ public class DemandManagerSSP extends AbstractSSPDemandManager { } @Override - Map<CommodityType, Double> getFoodDemandMap(SingleCountry c, int year, double gdpPc, double population, Map<CommodityType, Double> prices, double usaGdpPc) { + Map<CommodityType, Double> getFoodDemandMap(SingleCountry c, int year, double gdpPc, double population, Map<CommodityType, Double> prices, double usaGdpPc, boolean outputGamsDemand) { Map<CommodityType, Double> aFoodDemandMap = new HashMap<CommodityType, Double>(); SspData baseSspData = sspManager.get(ssp_scenario, ModelConfig.BASE_YEAR, c); double baseGdpPc = baseSspData.getGdpPc(); diff --git a/src/ac/ed/lurg/demand/ElasticDemandManager.java b/src/ac/ed/lurg/demand/ElasticDemandManager.java index cac5227873136fa7ac6fa83367184f6527ffca25..eca6b8d87f9eebe4719c4bab89d12e2ccff64cba 100755 --- a/src/ac/ed/lurg/demand/ElasticDemandManager.java +++ b/src/ac/ed/lurg/demand/ElasticDemandManager.java @@ -35,7 +35,7 @@ public class ElasticDemandManager extends AbstractSSPDemandManager { } @Override - Map<CommodityType, Double> getFoodDemandMap(SingleCountry c, int year, double gdpPc, double population, Map<CommodityType, Double> producerPrices, double usaGdpPc) { + Map<CommodityType, Double> getFoodDemandMap(SingleCountry c, int year, double gdpPc, double population, Map<CommodityType, Double> producerPrices, double usaGdpPc, boolean outputGamsDemand) { Map<CommodityType, Double> consumerPrices = new HashMap<CommodityType, Double>(); Map<CommodityType, Double> kcalPerT = calorieManager.get(c); @@ -97,7 +97,7 @@ public class ElasticDemandManager extends AbstractSSPDemandManager { foodDemands.put(commodity, d); } - writeGamsDemandOutputs(inputData, gamsOutput, foodDemands, population); + if (outputGamsDemand) writeGamsDemandOutputs(inputData, gamsOutput, foodDemands, population); return foodDemands; }