Skip to content
Snippets Groups Projects
Commit 71c31a11 authored by R0slyn's avatar R0slyn
Browse files

country agents hold their info about trade barriers for each crop

parent 04b5ba71
No related branches found
No related tags found
No related merge requests found
...@@ -29,13 +29,15 @@ public class CountryAgent { ...@@ -29,13 +29,15 @@ public class CountryAgent {
private Timestep currentTimestep; private Timestep currentTimestep;
private YieldRaster countryYieldSurfaces; private YieldRaster countryYieldSurfaces;
private Map<CommodityType, Double> currentProjectedDemand; private Map<CommodityType, Double> currentProjectedDemand;
private Map<CropType, Double> tradeBarriers;
public CountryAgent(DemandManager demandManager, CompositeCountry country, RasterSet<LandCoverItem> initialLC, public CountryAgent(DemandManager demandManager,CompositeCountry country, RasterSet<LandCoverItem> initialLC,
Map<CropType, CropUsageData> cropUsageData) { Map<CropType, CropUsageData> cropUsageData, Map<CropType, Double> tradeBarriers) {
this.demandManager = demandManager; this.demandManager = demandManager;
this.country = country; this.country = country;
RasterSet<LandUseItem> cropAreaRaster = convertInitialLC(initialLC); RasterSet<LandUseItem> cropAreaRaster = convertInitialLC(initialLC);
this.tradeBarriers = tradeBarriers;
GamsRasterOutput initialData = new GamsRasterOutput(cropAreaRaster, cropUsageData); GamsRasterOutput initialData = new GamsRasterOutput(cropAreaRaster, cropUsageData);
resultsTimeseries.put(new Timestep(0), initialData); resultsTimeseries.put(new Timestep(0), initialData);
...@@ -50,6 +52,7 @@ public class CountryAgent { ...@@ -50,6 +52,7 @@ public class CountryAgent {
areasItem.setLandCoverAreas(entry.getValue()); 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.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.setCropFraction(CropType.MAIZE, 0.5);
areasItem.setProtectedArea(entry.getValue());
landUseRaster.put(key, areasItem); landUseRaster.put(key, areasItem);
} }
...@@ -75,7 +78,7 @@ public class CountryAgent { ...@@ -75,7 +78,7 @@ public class CountryAgent {
} }
else { else {
// optimize areas and intensity // optimize areas and intensity
GamsRasterInput input = getGamsRasterInput(currentProjectedDemand, worldPrices, irrigData); GamsRasterInput input = getGamsRasterInput(currentProjectedDemand, tradeBarriers, worldPrices, irrigData);
GamsRasterOptimiser opti = new GamsRasterOptimiser(input); GamsRasterOptimiser opti = new GamsRasterOptimiser(input);
LogWriter.println("Running " + country.getName() + ", currentTimestep " + currentTimestep); LogWriter.println("Running " + country.getName() + ", currentTimestep " + currentTimestep);
...@@ -91,8 +94,8 @@ public class CountryAgent { ...@@ -91,8 +94,8 @@ public class CountryAgent {
return currentProjectedDemand; 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; GamsRasterOutput prevOutput;
Map<CropType, Double> cropAdjs; Map<CropType, Double> cropAdjs;
boolean calibrate; boolean calibrate;
...@@ -118,7 +121,7 @@ public class CountryAgent { ...@@ -118,7 +121,7 @@ public class CountryAgent {
maxOfProdOrSupply.put(entry.getKey(), cropUsage.getProduction() + Math.max(netImports, 0)); 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); GamsRasterInput input = new GamsRasterInput(currentTimestep, countryYieldSurfaces, prevOutput.getLandUses(), irrigData, countryLevelInputs);
return input; return input;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment