diff --git a/src/ac/ed/lurg/country/CountryAgent.java b/src/ac/ed/lurg/country/CountryAgent.java index cfbb34c761c1649443506e864a9ac0715c3e1d16..9b3f00cf0380d72e50d9893e01bb49a0368aff7c 100644 --- a/src/ac/ed/lurg/country/CountryAgent.java +++ b/src/ac/ed/lurg/country/CountryAgent.java @@ -29,13 +29,15 @@ public class CountryAgent { private Timestep currentTimestep; private YieldRaster countryYieldSurfaces; private Map<CommodityType, Double> currentProjectedDemand; + private Map<CropType, Double> tradeBarriers; - public CountryAgent(DemandManager demandManager, CompositeCountry country, RasterSet<LandCoverItem> initialLC, - Map<CropType, CropUsageData> cropUsageData) { + public CountryAgent(DemandManager demandManager,CompositeCountry country, RasterSet<LandCoverItem> initialLC, + Map<CropType, CropUsageData> cropUsageData, Map<CropType, Double> tradeBarriers) { this.demandManager = demandManager; this.country = country; RasterSet<LandUseItem> cropAreaRaster = convertInitialLC(initialLC); + this.tradeBarriers = tradeBarriers; GamsRasterOutput initialData = new GamsRasterOutput(cropAreaRaster, cropUsageData); resultsTimeseries.put(new Timestep(0), initialData); @@ -50,6 +52,7 @@ public class CountryAgent { areasItem.setLandCoverAreas(entry.getValue()); areasItem.setCropFraction(CropType.WHEAT, 0.5); // random start, better if we could get data, but free substitution between crops so not critical areasItem.setCropFraction(CropType.MAIZE, 0.5); + areasItem.setProtectedArea(entry.getValue()); landUseRaster.put(key, areasItem); } @@ -75,7 +78,7 @@ public class CountryAgent { } else { // optimize areas and intensity - GamsRasterInput input = getGamsRasterInput(currentProjectedDemand, worldPrices, irrigData); + GamsRasterInput input = getGamsRasterInput(currentProjectedDemand, tradeBarriers, worldPrices, irrigData); GamsRasterOptimiser opti = new GamsRasterOptimiser(input); LogWriter.println("Running " + country.getName() + ", currentTimestep " + currentTimestep); @@ -91,8 +94,8 @@ public class CountryAgent { return currentProjectedDemand; } - private GamsRasterInput getGamsRasterInput(Map<CommodityType, Double> projectedDemand, Map<CropType, GlobalPrice> worldPrices, RasterSet<IrrigationItem> irrigData) { - + private GamsRasterInput getGamsRasterInput(Map<CommodityType, Double> projectedDemand, Map<CropType, Double> tradeBarriers, Map<CropType, GlobalPrice> worldPrices, RasterSet<IrrigationItem> irrigData) { +//TODO why pass in projectedDemand when currentProjectedDemand belongs to CountryAgent class already? GamsRasterOutput prevOutput; Map<CropType, Double> cropAdjs; boolean calibrate; @@ -118,7 +121,7 @@ public class CountryAgent { maxOfProdOrSupply.put(entry.getKey(), cropUsage.getProduction() + Math.max(netImports, 0)); } - GamsCountryInput countryLevelInputs = GamsCountryInput.createInput(country, projectedDemand, worldPrices, baseNetImport, maxOfProdOrSupply, cropAdjs, calibrate); + GamsCountryInput countryLevelInputs = GamsCountryInput.createInput(country, projectedDemand, tradeBarriers, worldPrices, baseNetImport, maxOfProdOrSupply, cropAdjs, calibrate); GamsRasterInput input = new GamsRasterInput(currentTimestep, countryYieldSurfaces, prevOutput.getLandUses(), irrigData, countryLevelInputs); return input;