Skip to content
Snippets Groups Projects
Commit 6b64bf62 authored by rhenry2's avatar rhenry2
Browse files

Check to make sure rebased demand is affordable.

parent ce344f9c
No related branches found
No related tags found
No related merge requests found
...@@ -96,6 +96,28 @@ public class ElasticDemandManager extends AbstractSSPDemandManager { ...@@ -96,6 +96,28 @@ public class ElasticDemandManager extends AbstractSSPDemandManager {
double d = cpcAdj * population; double d = cpcAdj * population;
foodDemands.put(commodity, d); foodDemands.put(commodity, d);
} }
double foodSpend = 0;
for (CommodityType commodity : CommodityType.getAllFoodItems()) {
double consumerPrice = consumerPrices.get(commodity);
double rebasedDemand = foodDemands.get(commodity);
double caloriesPerT = kcalPerT.get(commodity);
foodSpend += consumerPrice*rebasedDemand/population/365/2000*caloriesPerT;
}
LogWriter.println("foodSpend " + foodSpend + " budget " + gdpPc*ModelConfig.MAX_INCOME_PROPORTION_FOOD_SPEND);
if(foodSpend > gdpPc*ModelConfig.MAX_INCOME_PROPORTION_FOOD_SPEND) {
double overspend= 1/(foodSpend/(gdpPc*ModelConfig.MAX_INCOME_PROPORTION_FOOD_SPEND));
LogWriter.println("overspend " + overspend);
for (Map.Entry<CommodityType, Double> entry : foodPc.entrySet()) {
CommodityType commodity = entry.getKey();
double rebasedDemand = foodDemands.get(commodity);
double affordableDemand = rebasedDemand*overspend;
foodDemands.put(commodity, affordableDemand);
}
}
if (outputGamsDemand) writeGamsDemandOutputs(inputData, gamsOutput, foodDemands, population); if (outputGamsDemand) writeGamsDemandOutputs(inputData, gamsOutput, foodDemands, population);
......
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