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

Corrected changes to weighted producer prices.

parent 62079dda
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ public abstract class AbstractCountryAgent { ...@@ -18,7 +18,7 @@ public abstract class AbstractCountryAgent {
protected Map<CropType, Double> tradeBarriers; protected Map<CropType, Double> tradeBarriers;
protected Map<CommodityType, Double> currentProjectedDemand; protected Map<CommodityType, Double> currentProjectedDemand;
protected Map<CropType, CountryPrice> currentCountryPrices; protected Map<CropType, CountryPrice> currentCountryPrices;
private Map<CommodityType, Map<CropType, Double>> baseDemandFact; protected Map<CommodityType, Map<CropType, Double>> baseDemandFact;
protected Timestep currentTimestep; protected Timestep currentTimestep;
protected Map<CommodityType, Map<CropType, Double>> currentMinDemandFract; protected Map<CommodityType, Map<CropType, Double>> currentMinDemandFract;
...@@ -78,15 +78,7 @@ public abstract class AbstractCountryAgent { ...@@ -78,15 +78,7 @@ public abstract class AbstractCountryAgent {
return prices; return prices;
} }
private double getCommPriceFromCropPrice(CommodityType commodity) { protected abstract double getCommPriceFromCropPrice(CommodityType commodity);
double commPricePlum = 0;
Map<CropType, Double> demandFract = baseDemandFact.get(commodity);
for (CropType crop : commodity.getCropTypes()) {
commPricePlum += currentCountryPrices.get(crop).getImportPrice() * demandFract.get(crop); // weight price by base demand of each cereal crop
}
return commPricePlum;
}
public Map<CommodityType, Double> getCurrentProjectedDemand() { public Map<CommodityType, Double> getCurrentProjectedDemand() {
return currentProjectedDemand; return currentProjectedDemand;
......
...@@ -207,6 +207,24 @@ public class CountryAgent extends AbstractCountryAgent { ...@@ -207,6 +207,24 @@ public class CountryAgent extends AbstractCountryAgent {
return input; return input;
} }
@Override
protected double getCommPriceFromCropPrice(CommodityType commodity) {
double commPricePlum = 0;
Map<CropType, Double> demandFract = baseDemandFact.get(commodity);
Map<CropType, CropUsageData> cropUsageMap = previousGamsRasterOutput.getCropUsageData();
for (CropType crop : commodity.getCropTypes()) {
CropUsageData cropUsageData = cropUsageMap.get(crop);
double weighting = Math.max(0, cropUsageData.getShockedNetImports()/(cropUsageData.getProductionExpected()+cropUsageData.getNetImportsExpected()));
double newImportPrice = currentCountryPrices.get(crop).getImportPrice()*weighting + currentCountryPrices.get(crop).getExportPrice()*(1-weighting);
commPricePlum += newImportPrice * demandFract.get(crop); // weight price by base demand of each cereal crop
}
return commPricePlum;
}
public RasterSet<LandUseItem> getLandUses() { public RasterSet<LandUseItem> getLandUses() {
return previousGamsRasterOutput.getLandUses(); return previousGamsRasterOutput.getLandUses();
......
...@@ -9,14 +9,15 @@ import ac.ed.lurg.country.CompositeCountry; ...@@ -9,14 +9,15 @@ import ac.ed.lurg.country.CompositeCountry;
import ac.ed.lurg.country.GlobalPrice; import ac.ed.lurg.country.GlobalPrice;
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;
/** /**
* Country agent that is interface over data transferred to and from CRAFTY. * Country agent that is interface over data transferred to and from CRAFTY.
* Need to configure country mapping to that there is * Need to configure country mapping to that there is
* */ * */
public class CraftyCountryAgent extends AbstractCountryAgent { public class CraftyCountryAgent extends AbstractCountryAgent {
private Map<CropType, CropUsageData> cropUsageData; private Map<CropType, CropUsageData> cropUsageData;
public CraftyCountryAgent(AbstractDemandManager demandManager,CompositeCountry country, Map<CropType, Double> tradeBarriers) { public CraftyCountryAgent(AbstractDemandManager demandManager,CompositeCountry country, Map<CropType, Double> tradeBarriers) {
...@@ -35,7 +36,18 @@ public class CraftyCountryAgent extends AbstractCountryAgent { ...@@ -35,7 +36,18 @@ public class CraftyCountryAgent extends AbstractCountryAgent {
CropUsageData cropusage = new CropUsageData(entry.getValue()); CropUsageData cropusage = new CropUsageData(entry.getValue());
cropUsageData.put(entry.getKey(), cropusage); cropUsageData.put(entry.getKey(), cropusage);
} }
updateNetImportsFromProdAndDemand(currentProjectedDemand, currentMinDemandFract, cropUsageData); updateNetImportsFromProdAndDemand(currentProjectedDemand, currentMinDemandFract, cropUsageData);
} }
@Override
protected double getCommPriceFromCropPrice(CommodityType commodity) {
double commPricePlum = 0;
Map<CropType, Double> demandFract = baseDemandFact.get(commodity);
for (CropType crop : commodity.getCropTypes()) {
commPricePlum += currentCountryPrices.get(crop).getImportPrice() * demandFract.get(crop); // weight price by base demand of each cereal crop
}
return commPricePlum;
}
} }
\ 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