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

Weighed price changes.

parent 14c810d9
No related branches found
No related tags found
No related merge requests found
...@@ -39,19 +39,7 @@ public abstract class AbstractCountryAgent { ...@@ -39,19 +39,7 @@ public abstract class AbstractCountryAgent {
currentMinDemandFract = getMinDemandFraction(); currentMinDemandFract = getMinDemandFraction();
} }
private void calculateCountryPrices(Map<CropType, GlobalPrice> worldPrices){ protected abstract void calculateCountryPrices(Map<CropType, GlobalPrice> worldPrices);
Map<CropType, CountryPrice> countryPrices = new HashMap <CropType, CountryPrice>();
for (CropType c : CropType.getImportedTypes()) {
GlobalPrice worldPrice = worldPrices.get(c);
Double tb = tradeBarriers.get(c);
LogWriter.println(worldPrice + " " + c);
CountryPrice prices = new CountryPrice(worldPrice.getCountryImportPrice(tb==null ? 0 : tb, currentTimestep), worldPrice.getExportPrice());
countryPrices.put(c, prices);
}
currentCountryPrices = countryPrices;
}
private void calculateDemand() { private void calculateDemand() {
Map<CommodityType, Double> producerPrices = getProducerCommodityPrices(); Map<CommodityType, Double> producerPrices = getProducerCommodityPrices();
......
...@@ -59,6 +59,34 @@ public class CountryAgent extends AbstractCountryAgent { ...@@ -59,6 +59,34 @@ public class CountryAgent extends AbstractCountryAgent {
public RasterSet<IntegerRasterItem> getYieldClusters() { public RasterSet<IntegerRasterItem> getYieldClusters() {
return yieldClusters; return yieldClusters;
} }
@Override
protected void calculateCountryPrices(Map<CropType, GlobalPrice> worldPrices) {
Map<CropType, CountryPrice> countryPrices = new HashMap <CropType, CountryPrice>();
Map<CropType, CropUsageData> cropUsageMap = previousGamsRasterOutput.getCropUsageData();
for (CropType c : CropType.getImportedTypes()) {
GlobalPrice worldPrice = worldPrices.get(c);
Double tb = tradeBarriers.get(c);
CropUsageData cropUsageData = cropUsageMap.get(c);
LogWriter.println(worldPrice + " " + c);
double importsPostShock = cropUsageData.getShockedNetImports();
double productionPostShock = cropUsageData.getProductionExpected()-cropUsageData.getProductionShock();
double weighting = importsPostShock/(productionPostShock+importsPostShock);
double importPrice = worldPrice.getCountryImportPrice(tb==null ? 0 : tb, currentTimestep) * weighting;
double exportPrice = worldPrice.getExportPrice() * (1-weighting);
double newImportPrice = importPrice + exportPrice;
CountryPrice prices = new CountryPrice(newImportPrice, worldPrice.getExportPrice());
countryPrices.put(c, prices);
}
currentCountryPrices = countryPrices;
}
private RasterSet<IntegerRasterItem> calcYieldClusters(RasterSet<IrrigationItem> irrigData, YieldRaster countryYieldSurfaces) { private RasterSet<IntegerRasterItem> calcYieldClusters(RasterSet<IrrigationItem> irrigData, YieldRaster countryYieldSurfaces) {
......
...@@ -6,10 +6,14 @@ import java.util.Map.Entry; ...@@ -6,10 +6,14 @@ import java.util.Map.Entry;
import ac.ed.lurg.country.AbstractCountryAgent; import ac.ed.lurg.country.AbstractCountryAgent;
import ac.ed.lurg.country.CompositeCountry; import ac.ed.lurg.country.CompositeCountry;
import ac.ed.lurg.country.CountryPrice;
import ac.ed.lurg.country.GlobalPrice; import ac.ed.lurg.country.GlobalPrice;
import ac.ed.lurg.country.SingleCountry;
import ac.ed.lurg.demand.AbstractDemandManager; import ac.ed.lurg.demand.AbstractDemandManager;
import ac.ed.lurg.landuse.CropUsageData; import ac.ed.lurg.landuse.CropUsageData;
import ac.ed.lurg.types.CommodityType;
import ac.ed.lurg.types.CropType; import ac.ed.lurg.types.CropType;
import ac.ed.lurg.utils.LogWriter;
/** /**
* Country agent that is interface over data transferred to and from CRAFTY. * Country agent that is interface over data transferred to and from CRAFTY.
...@@ -38,4 +42,20 @@ public class CraftyCountryAgent extends AbstractCountryAgent { ...@@ -38,4 +42,20 @@ public class CraftyCountryAgent extends AbstractCountryAgent {
updateNetImportsFromProdAndDemand(currentProjectedDemand, currentMinDemandFract, cropUsageData); updateNetImportsFromProdAndDemand(currentProjectedDemand, currentMinDemandFract, cropUsageData);
} }
@Override
protected void calculateCountryPrices(Map<CropType, GlobalPrice> worldPrices) {
Map<CropType, CountryPrice> countryPrices = new HashMap <CropType, CountryPrice>();
for (CropType c : CropType.getImportedTypes()) {
GlobalPrice worldPrice = worldPrices.get(c);
Double tb = tradeBarriers.get(c);
LogWriter.println(worldPrice + " " + c);
CountryPrice prices = new CountryPrice(worldPrice.getCountryImportPrice(tb==null ? 0 : tb, currentTimestep), worldPrice.getExportPrice());
countryPrices.put(c, prices);
}
currentCountryPrices = countryPrices;
}
} }
\ No newline at end of file
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