diff --git a/src/ac/ed/lurg/country/CountryAgent.java b/src/ac/ed/lurg/country/CountryAgent.java index ef7f7e6afe148bf06a3c10f03cc3df454ccdf6de..7eaca36eacdd2fcca2a59723815c727ce85fe849 100644 --- a/src/ac/ed/lurg/country/CountryAgent.java +++ b/src/ac/ed/lurg/country/CountryAgent.java @@ -251,13 +251,13 @@ public class CountryAgent extends AbstractCountryAgent { double totalProduction = getTotalProduction(); double shockMagnitude = 0.0; - Map<CropType, CropUsageData> cropUsages = previousGamsRasterOutput.getCropUsageData(); - for (CropType crop : CropType.getImportedTypes()) { - - if(cropUsages.get(crop).getProductionExpected() != 0) - shockMagnitude += (cropUsages.get(crop).getProductionShock() /cropUsages.get(crop).getProductionExpected()) * (cropUsages.get(crop).getProductionExpected()/totalProduction); - } + for (Map.Entry<CropType, CropUsageData> entry : previousGamsRasterOutput.getCropUsageData().entrySet()) { + CropUsageData cropUsage = entry.getValue(); + CropType crop = entry.getKey(); + if(crop.isImportedCrop() && cropUsage.getProductionExpected() != 0) + shockMagnitude += (cropUsage.getProductionShock() /cropUsage.getProductionExpected()) * (cropUsage.getProductionExpected()/totalProduction); + } demandManager.updateGdpLossesFromShock(country, currentTimestep.getYear(), shockMagnitude); } @@ -271,9 +271,13 @@ public class CountryAgent extends AbstractCountryAgent { public double getTotalProduction() { double totalProduction = 0; - for (CropType crop : CropType.getImportedTypes()) { //assuming pasture and set aside not part of agricultural value, valid or not? - totalProduction += previousGamsRasterOutput.getCropUsageData().get(crop).getProductionExpected(); - } + + for (Map.Entry<CropType, CropUsageData> entry : previousGamsRasterOutput.getCropUsageData().entrySet()) { + CropUsageData cropUsage = entry.getValue(); + CropType crop = entry.getKey(); + if(crop.isImportedCrop()) //assuming pasture and set aside not part of agricultural value, valid or not? + totalProduction += cropUsage.getProductionExpected(); + } return totalProduction; }