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

Tidy financial speculation shock. Adjustment to read in tradebarriers file

parent e69ca9ce
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
...@@ -95,7 +95,7 @@ public class InternationalMarket { ...@@ -95,7 +95,7 @@ public class InternationalMarket {
GlobalPrice priceQuantity = worldPrices.get(crop); GlobalPrice priceQuantity = worldPrices.get(crop);
sbData.append(String.format("%d,%s", timestep.getYear(), crop.getGamsName())); sbData.append(String.format("%d,%s", timestep.getYear(), crop.getGamsName()));
sbData.append(String.format(",%.1f,%.1f", priceQuantity.getImportAmount(), priceQuantity.getExportsAfterTransportLosses())); sbData.append(String.format(",%.1f,%.1f", priceQuantity.getImportAmount(), priceQuantity.getExportsAfterTransportLosses()));
sbData.append(String.format(",%.3f,%.3f", priceQuantity.getExportPrice(timestep), stockLevel.get(crop))); sbData.append(String.format(",%.3f,%.3f", priceQuantity.getExportPrice(), stockLevel.get(crop)));
outputFile.write(sbData.toString()); outputFile.write(sbData.toString());
outputFile.newLine(); outputFile.newLine();
......
...@@ -328,7 +328,7 @@ public class ModelConfig { ...@@ -328,7 +328,7 @@ public class ModelConfig {
public static final double TRANSPORT_COST = getDoubleProperty("TRANSPORT_COST", 0.1); // 100 $/t see Wheat Transportation Profile - USDA public static final double TRANSPORT_COST = getDoubleProperty("TRANSPORT_COST", 0.1); // 100 $/t see Wheat Transportation Profile - USDA
public static final double TRADE_BARRIER_FACTOR_DEFAULT = getDoubleProperty("TRADE_BARRIER_FACTOR_DEFAULT", 0.2); // price factor in international trade, transport cost and real trade barriers public static final double TRADE_BARRIER_FACTOR_DEFAULT = getDoubleProperty("TRADE_BARRIER_FACTOR_DEFAULT", 0.2); // price factor in international trade, transport cost and real trade barriers
public static final double TRADE_BARRIER_MULTIPLIER = getDoubleProperty("TRADE_BARRIER_MULTIPLIER", 1.0); public static final double TRADE_BARRIER_MULTIPLIER = getDoubleProperty("TRADE_BARRIER_MULTIPLIER", 1.0);
public static final boolean ACTIVE_TRADE_BARRIERS = getBooleanProperty("ACTIVE_TRADE_BARRIERS", false); // if set to true read in barrier information from file, otherwise use default as above public static final boolean ACTIVE_TRADE_BARRIERS = getBooleanProperty("ACTIVE_TRADE_BARRIERS", true); // if set to true read in barrier information from file, otherwise use default as above
public static final boolean SHOCKS_POSSIBLE = getBooleanProperty("SHOCKS_POSSIBLE", false); public static final boolean SHOCKS_POSSIBLE = getBooleanProperty("SHOCKS_POSSIBLE", false);
......
...@@ -289,7 +289,7 @@ public class CountryAgent { ...@@ -289,7 +289,7 @@ public class CountryAgent {
for (CropType c : CropType.getImportedTypes()) { for (CropType c : CropType.getImportedTypes()) {
GlobalPrice worldPrice = worldPrices.get(c); GlobalPrice worldPrice = worldPrices.get(c);
CountryPrice prices = new CountryPrice(worldPrice.getCountryImportPrice(tradeBarriers.get(c), currentTimestep), worldPrice.getExportPrice(currentTimestep)); CountryPrice prices = new CountryPrice(worldPrice.getCountryImportPrice(tradeBarriers.get(c), currentTimestep), worldPrice.getExportPrice());
countryPrices.put(c, prices); countryPrices.put(c, prices);
} }
......
...@@ -22,11 +22,9 @@ public class GlobalPrice { ...@@ -22,11 +22,9 @@ public class GlobalPrice {
return new GlobalPrice(exportPrice, Double.NaN, Double.NaN, Double.NaN); return new GlobalPrice(exportPrice, Double.NaN, Double.NaN, Double.NaN);
} }
public double getExportPrice(Timestep timestep) { public double getExportPrice() {
double financialSpeculationMultiplier = (!ModelConfig.SHOCKS_POSSIBLE)? 1.0 : ModelConfig.getParameter(Parameter.FINANCIAL_SPECULATION_MULTIPLIER,timestep.getYear()); return exportPrice;
return exportPrice * financialSpeculationMultiplier;
} }
public double getCountryImportPrice(double countryTradeBarrier, Timestep timestep) { public double getCountryImportPrice(double countryTradeBarrier, Timestep timestep) {
...@@ -37,7 +35,7 @@ public class GlobalPrice { ...@@ -37,7 +35,7 @@ public class GlobalPrice {
double transportLosses =(!ModelConfig.SHOCKS_POSSIBLE) ? ModelConfig.TRANSPORT_LOSSES : ModelConfig.getParameter(Parameter.TRANSPORT_LOSSES, currentYear); double transportLosses =(!ModelConfig.SHOCKS_POSSIBLE) ? ModelConfig.TRANSPORT_LOSSES : ModelConfig.getParameter(Parameter.TRANSPORT_LOSSES, currentYear);
double transportCosts = (!ModelConfig.SHOCKS_POSSIBLE) ? ModelConfig.TRANSPORT_COST : ModelConfig.getParameter(Parameter.TRANSPORT_COST, currentYear); double transportCosts = (!ModelConfig.SHOCKS_POSSIBLE) ? ModelConfig.TRANSPORT_COST : ModelConfig.getParameter(Parameter.TRANSPORT_COST, currentYear);
double importPrice = (getExportPrice(timestep) * (1.0 + countryTradeBarrier*tradeBarrierMultiplier) double importPrice = (getExportPrice() * (1.0 + countryTradeBarrier*tradeBarrierMultiplier)
/ (1.0 - transportLosses)) + transportCosts; / (1.0 - transportLosses)) + transportCosts;
return importPrice; return importPrice;
} }
...@@ -71,10 +69,18 @@ public class GlobalPrice { ...@@ -71,10 +69,18 @@ public class GlobalPrice {
double adjustment = adjustPrice ? Math.exp(ratio * ModelConfig.MARKET_LAMBA) : 1.0; double adjustment = adjustPrice ? Math.exp(ratio * ModelConfig.MARKET_LAMBA) : 1.0;
//adjustment = Math.min(adjustment, 2.0); // can only double in a time step //adjustment = Math.min(adjustment, 2.0); // can only double in a time step
//adjustment = Math.max(adjustment, 0.5); // can only half in a time step //adjustment = Math.max(adjustment, 0.5); // can only half in a time step
return new GlobalPrice(getExportPrice(timestep) * adjustment, imports, exportsBeforeTransportLosses, transportLosses);
if(getExportPrice() == 0 ){
LogWriter.println("Price is zero: adjustment " + adjustment + " ratio " + ratio + " imports " + imports + " exportsAfterTransportLosses " + exportsAfterTransportLosses);
}
double financialSpeculationMultiplier = (!ModelConfig.SHOCKS_POSSIBLE)? 1.0 : ModelConfig.getParameter(Parameter.FINANCIAL_SPECULATION_MULTIPLIER,timestep.getYear());
return new GlobalPrice(getExportPrice() * adjustment *financialSpeculationMultiplier, imports, exportsBeforeTransportLosses, transportLosses);
} }
else { else {
LogWriter.printlnError(String.format("Price for not updated (still %s), as no imports and no exports for it", getExportPrice(timestep))); LogWriter.printlnError(String.format("Price for not updated (still %s), as no imports and no exports for it", getExportPrice()));
return this; return this;
} }
} }
......
...@@ -38,6 +38,9 @@ public class TradeManager { ...@@ -38,6 +38,9 @@ public class TradeManager {
tradeMap.put(cc, tradeBarriers); tradeMap.put(cc, tradeBarriers);
} }
else{
tradeMap.get(cc).put(CropType.ENERGY_CROPS, ModelConfig.TRADE_BARRIER_FACTOR_DEFAULT);
}
return tradeMap.get(cc); return tradeMap.get(cc);
} }
...@@ -64,6 +67,8 @@ public class TradeManager { ...@@ -64,6 +67,8 @@ public class TradeManager {
itemName = tokens[ITEM_COL]; itemName = tokens[ITEM_COL];
barrierValue = Double.parseDouble(tokens[TRADE_BARRIER_COL]); barrierValue = Double.parseDouble(tokens[TRADE_BARRIER_COL]);
SingleCountry country = CountryManager.getForName(countryName); SingleCountry country = CountryManager.getForName(countryName);
CropType crop = CropType.getForFaoName(itemName); CropType crop = CropType.getForFaoName(itemName);
...@@ -95,9 +100,6 @@ public class TradeManager { ...@@ -95,9 +100,6 @@ public class TradeManager {
for (Entry<CompositeCountry, CropToDoubleMap> entry : tradeMap.entrySet()) { for (Entry<CompositeCountry, CropToDoubleMap> entry : tradeMap.entrySet()) {
// LogWriter.println("country name " + entry.getKey());
// LogWriter.println("crops " + entry.getValue());
entry.getValue().divideBy(compositeCountryManager.getAllForCompositeCountry(entry.getKey()).size()); entry.getValue().divideBy(compositeCountryManager.getAllForCompositeCountry(entry.getKey()).size());
// LogWriter.println("number of countries " + compositeCountryManager.getAllForCompositeCountry(entry.getKey()).size()); // LogWriter.println("number of countries " + compositeCountryManager.getAllForCompositeCountry(entry.getKey()).size());
......
...@@ -75,7 +75,6 @@ public abstract class AbstractDemandManager { ...@@ -75,7 +75,6 @@ public abstract class AbstractDemandManager {
double monoDemandAdj = (!ModelConfig.SHOCKS_POSSIBLE) ? 0.0 : ModelConfig.getParameter(Parameter.MONOGASTRIC_CHANGE_ANNUAL_RATE, year); double monoDemandAdj = (!ModelConfig.SHOCKS_POSSIBLE) ? 0.0 : ModelConfig.getParameter(Parameter.MONOGASTRIC_CHANGE_ANNUAL_RATE, year);
double rumDemandAdj = (!ModelConfig.SHOCKS_POSSIBLE) ? 0.0 : ModelConfig.getParameter(Parameter.RUMINANT_CHANGE_ANNUAL_RATE, year); double rumDemandAdj = (!ModelConfig.SHOCKS_POSSIBLE) ? 0.0 : ModelConfig.getParameter(Parameter.RUMINANT_CHANGE_ANNUAL_RATE, year);
Double monogastricDemand = originalFoodDemandMap.get(CommodityType.MONOGASTRICS); Double monogastricDemand = originalFoodDemandMap.get(CommodityType.MONOGASTRICS);
double monogastricEnergyShortfall = (monogastricDemand != null) double monogastricEnergyShortfall = (monogastricDemand != null)
......
...@@ -3,6 +3,7 @@ package ac.ed.lurg.demand; ...@@ -3,6 +3,7 @@ package ac.ed.lurg.demand;
import ac.ed.lurg.ModelConfig; import ac.ed.lurg.ModelConfig;
import ac.ed.lurg.types.CommodityType; import ac.ed.lurg.types.CommodityType;
import ac.ed.lurg.types.ModelFitType; import ac.ed.lurg.types.ModelFitType;
import ac.ed.lurg.utils.LogWriter;
public class DemandCurve { public class DemandCurve {
......
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