diff --git a/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java b/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java index ae3f487b6554d11e1d967a73edebb975f18b4afe..bd0125eac253a0ba99a0e8b709350da652ad486c 100644 --- a/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java +++ b/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java @@ -376,7 +376,12 @@ public class GamsRasterOptimiser { IrrigationItem irrigItem = irrigRaster.get(key); - int clusterId = mapping.get(key).getInt(); + IntegerRasterItem clusterItem = mapping.get(key); + if (clusterItem == null) { + LogWriter.printlnError("Warning: GamsRasterOptimiser no cluster for key" + key); + continue; + } + int clusterId = clusterItem.getInt(); YieldResponsesItem aggYResp = aggregatedYields.lazyGet(clusterId); LandUseItem aggLandUse = aggregatedAreas.lazyGet(clusterId); diff --git a/src/ac/ed/lurg/demand/AbstractDemandManager.java b/src/ac/ed/lurg/demand/AbstractDemandManager.java index 20d9c9a8d20c34c1afdf2ce4d192db410668c74d..755c4f2c48fd46f38cf65136b96e5f50b8d4c02f 100644 --- a/src/ac/ed/lurg/demand/AbstractDemandManager.java +++ b/src/ac/ed/lurg/demand/AbstractDemandManager.java @@ -41,8 +41,14 @@ public abstract class AbstractDemandManager implements Serializable { for (SingleCountry c : compositeCountryManager.getAllForCompositeCountry(cc)) { - foodDemandMap = getFoodDemand(c, year, prices, outputGamsDemand); - + try { + foodDemandMap = getFoodDemand(c, year, prices, outputGamsDemand); + } catch (Exception e) { + LogWriter.printlnError("Error: AbstractDemandManager not including " + c + " due to exception"); + LogWriter.print(e); + continue; + } + for (CommodityType commodity : CommodityType.getAllFoodItems()) { Double food = foodDemandMap.get(commodity);