diff --git a/src/ac/ed/lurg/InternationalMarket.java b/src/ac/ed/lurg/InternationalMarket.java index d8e529197609f625248707c988a972098b063f70..e2c4d25933363c8013050af2168cb0599b02b3ea 100644 --- a/src/ac/ed/lurg/InternationalMarket.java +++ b/src/ac/ed/lurg/InternationalMarket.java @@ -72,6 +72,9 @@ public class InternationalMarket { LogWriter.println(timestep.getYear() + " Updating " + crop.getGamsName() + " prices"); GlobalPrice adjustedPrice = prevPrice.createWithUpdatedMarketPrices(imports, exportsBeforeTransportLosses, timestep, totalProduction.get(crop)); LogWriter.println( String.format("Price for %s updated from %s to %s \n", crop.getGamsName(), prevPrice, adjustedPrice)); + if (adjustedPrice.getStockLevel() < 0) + LogWriter.println("Global stocks are below zero" + crop.getGamsName() + ", " + timestep.getYear()); + worldPrices.put(crop, adjustedPrice); } } diff --git a/src/ac/ed/lurg/ModelConfig.java b/src/ac/ed/lurg/ModelConfig.java index 749ccce1f90611d29da187b2171c75433c585389..a78765efbf9efbb3f8a500e93ae35ebf677c95d7 100755 --- a/src/ac/ed/lurg/ModelConfig.java +++ b/src/ac/ed/lurg/ModelConfig.java @@ -209,7 +209,7 @@ public class ModelConfig { public static final double INITAL_PRICE_MONOGASTRICS = getDoubleProperty("INITAL_PRICE_MONOGASTRICS", 0.4 * 0.5 * ModelConfig.INITIAL_PRICE_SHIFT); // quantities is in feed equivalent term (0.4 is weighted average price per feed, and 0.5 accounts for mark-up for additional processing) public static final double INITAL_PRICE_RUMINANTS = getDoubleProperty("INITAL_PRICE_RUMINANTS", 0.1 * 0.6 * ModelConfig.INITIAL_PRICE_SHIFT); // quantities is in feed equivalent term public static final double INITAL_PRICE_ENERGYCROPS = getDoubleProperty("INITAL_PRICE_ENERGYCROPS", 0.04 * ModelConfig.INITIAL_PRICE_SHIFT); - public static final double INITAL_PRICE_FRUITVEG = getDoubleProperty("INITAL_PRICE_FRUITVEG", 0.3 * ModelConfig.INITIAL_PRICE_SHIFT); + public static final double INITAL_PRICE_FRUITVEG = getDoubleProperty("INITAL_PRICE_FRUITVEG", 0.1 * ModelConfig.INITIAL_PRICE_SHIFT); public static final double INITAL_PRICE_SUGAR = getDoubleProperty("INITAL_PRICE_SUGAR", 0.02 * ModelConfig.INITIAL_PRICE_SHIFT); // These are initial demand system prices in 2000 kcal terms @@ -268,7 +268,7 @@ public class ModelConfig { public static final int BASE_YEAR = getIntProperty("BASE_YEAR", 2010); // Import export limits - public static final double ANNUAL_MAX_IMPORT_CHANGE = IS_CALIBRATION_RUN ? 0.0 : getDoubleProperty("ANNUAL_MAX_IMPORT_CHANGE", 0.02); + public static final double ANNUAL_MAX_IMPORT_CHANGE = IS_CALIBRATION_RUN ? 0.0 : getDoubleProperty("ANNUAL_MAX_IMPORT_CHANGE", 0.05); public static final double MAX_IMPORT_CHANGE = IS_CALIBRATION_RUN ? 0.0 : getDoubleProperty("MAX_IMPORT_CHANGE", ANNUAL_MAX_IMPORT_CHANGE*TIMESTEP_SIZE); // Fertiliser application rates in kg/ha @@ -345,7 +345,6 @@ public class ModelConfig { public static final boolean PRICE_UPDATE_BY_MARKET_IMBALANCE = getBooleanProperty("PRICE_UPDATE_BY_MARKET_IMBALANCE", false);; public static final double MAX_PRICE_INCREASE = getDoubleProperty("MAX_PRICE_INCREASE", 1.5); public static final double MAX_PRICE_DECREASE = getDoubleProperty("MAX_PRICE_DECREASE", .75); - public static final double STOCK_TARGET_RATE = getDoubleProperty("STOCK_TARGET_RATE", 0.05); public static final int DEMAND_RECALC_MAX_ITERATIONS = getIntProperty("DEMAND_RECALC_MAX_ITERATIONS", 0); // 0 is original behaviour public static final double POPULATION_AGGREG_LIMIT = getDoubleProperty("POPULATION_AGGREG_LIMIT", 30.0); // in millions, smaller countries are aggregated on a regional basis diff --git a/src/ac/ed/lurg/country/GlobalPrice.java b/src/ac/ed/lurg/country/GlobalPrice.java index 310b1e4cd0b6fcdd7e6e48c7efcb1e34b9e774f3..181320b5c295a15ceb9ff95a39651e45e296c69c 100644 --- a/src/ac/ed/lurg/country/GlobalPrice.java +++ b/src/ac/ed/lurg/country/GlobalPrice.java @@ -12,20 +12,18 @@ public class GlobalPrice { private double exportAmountBeforeLoss; private double transportLosses; private double stockLevel; - private double stockTarget; - private GlobalPrice(int timestepId, double exportPrice, double stockLevel, double stockTarget, double importAmount, double exportAmountBeforeLoss, double transportLosses) { + private GlobalPrice(int timestepId, double exportPrice, double stockLevel, double importAmount, double exportAmountBeforeLoss, double transportLosses) { this.timestepId = timestepId; this.exportPrice = exportPrice; this.stockLevel = stockLevel; - this.stockTarget = stockTarget; this.importAmount = importAmount; this.exportAmountBeforeLoss = exportAmountBeforeLoss; this.transportLosses = transportLosses; } public static GlobalPrice createInitial(double exportPrice, double intitalStock) { - return new GlobalPrice(ModelConfig.START_TIMESTEP-1, exportPrice, intitalStock, intitalStock, Double.NaN, Double.NaN, Double.NaN); + return new GlobalPrice(ModelConfig.START_TIMESTEP-1, exportPrice, intitalStock, Double.NaN, Double.NaN, Double.NaN); } public double getExportPrice(){ @@ -39,13 +37,11 @@ public class GlobalPrice { public double getCountryImportPrice(double countryTradeBarrier, Timestep timestep) { int currentYear = timestep.getYear(); - double tradeBarrierMultiplier = (!ModelConfig.SHOCKS_POSSIBLE)? ModelConfig.TRADE_BARRIER_MULTIPLIER: ModelConfig.getParameter(Parameter.TRADE_BARRIER_MULTIPLIER, currentYear); double transportLossesRate =(!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 importPrice = exportPrice * (1 + transportCosts) * (1.0 + countryTradeBarrier*tradeBarrierMultiplier) - / (1.0 - transportLossesRate); + double importPrice = exportPrice * (1 + transportCosts) * (1.0 + countryTradeBarrier*tradeBarrierMultiplier) / (1.0 - transportLossesRate); return importPrice; } @@ -76,8 +72,6 @@ public class GlobalPrice { LogWriter.println(String.format(" imports %.2f, exports %.2f", newImports, newExportAmountBeforeLoss - newTransportLosses)); LogWriter.println(String.format(" updatedStock %.2f, previous %.2f (last timestep %.2f), stockChange %.2f, oldDiff %.2f", updatedStock, stockLevel, stockLevel-oldDiff, stockChange, oldDiff)); - if (updatedStock < 0) - LogWriter.println(String.format("Global stocks are below zero")); double adjustment; double financialSpeculationMultiplier = (!ModelConfig.SHOCKS_POSSIBLE)? 1.0 : ModelConfig.getParameter(Parameter.FINANCIAL_SPECULATION_MULTIPLIER,timestep.getYear()); @@ -108,7 +102,7 @@ public class GlobalPrice { LogWriter.println(String.format(", after limit %.4f", adjustment)); double newPrice = exportPrice * adjustment * financialSpeculationMultiplier; - return new GlobalPrice(timestep.getTimestep(), newPrice, updatedStock, stockTarget, newImports, newExportAmountBeforeLoss, newTransportLosses); + return new GlobalPrice(timestep.getTimestep(), newPrice, updatedStock, newImports, newExportAmountBeforeLoss, newTransportLosses); } else { LogWriter.printlnError(String.format("Price for not updated (still %s), as no imports and no exports for it", exportPrice));