diff --git a/src/ac/ed/lurg/ModelMain.java b/src/ac/ed/lurg/ModelMain.java index b3d0144271bd9509da89dc889c3c4c14b0d1eec7..3ab05cdf84ca859ee5d491f7946372bbd880bbe3 100644 --- a/src/ac/ed/lurg/ModelMain.java +++ b/src/ac/ed/lurg/ModelMain.java @@ -162,7 +162,7 @@ public class ModelMain { double imports = totalImportCommodities.get(crop); double exports = totalExportCommodities.get(crop) * (1.0-ModelConfig.TRANSPORT_LOSSES); - GlobalPrice adjustedPrice = prevPrice.updateMarketPrices(imports, exports); + GlobalPrice adjustedPrice = prevPrice.createWithUpdatedMarketPrices(imports, exports); LogWriter.println(String.format("Price for %s updated from %s (imports amount %.0f, exports amount %.0f) to %s ", crop.getGamsName(), prevPrice, imports, exports, adjustedPrice)); prevWorldPrices.put(crop, adjustedPrice); } @@ -218,7 +218,7 @@ public class ModelMain { private void writeGlobalMarketFile(Timestep timestep) { try { - StringBuffer sbHeadings = new StringBuffer("Year, Crop, Imports (Mt), Exports (Mt), import price, export price"); + StringBuffer sbHeadings = new StringBuffer("Year, Crop, Imports (Mt), Exports (Mt), New import price, New export price"); BufferedWriter outputFile = getFileWriter(timestep, ModelConfig.PRICES_OUTPUT_FILE, sbHeadings.toString()); for (CropType crop : CropType.getImportedTypes() ) { diff --git a/src/ac/ed/lurg/country/GlobalPrice.java b/src/ac/ed/lurg/country/GlobalPrice.java index 7f5eafaa41c34f905d7c22ba514a0ac574847fbc..61758314219d2ce133469a1a5cc35c9ba2739923 100644 --- a/src/ac/ed/lurg/country/GlobalPrice.java +++ b/src/ac/ed/lurg/country/GlobalPrice.java @@ -35,7 +35,7 @@ public class GlobalPrice { return exportAmount; } - public GlobalPrice updateMarketPrices(double imports, double exports) { + public GlobalPrice createWithUpdatedMarketPrices(double imports, double exports) { if (imports > 0 || exports > 0) { double ratio; diff --git a/src/ac/ed/lurg/country/gams/GamsCountryInput.java b/src/ac/ed/lurg/country/gams/GamsCountryInput.java index eed98aa4b68f050cf873efc1a6dbd3a188897c1e..431a39920a715d1696a216237cafd9b2b0d11433 100644 --- a/src/ac/ed/lurg/country/gams/GamsCountryInput.java +++ b/src/ac/ed/lurg/country/gams/GamsCountryInput.java @@ -44,7 +44,7 @@ public class GamsCountryInput { public static GamsCountryInput createInput(CompositeCountry country, Map<CommodityType, Double> projectedDemand, Map<CropType, GlobalPrice> worldPrices, Map<CropType, Double> baseNetImport, Map<CropType, Double> maxOfProdOrSupply, Map<CropType, Double> cropAdjustments, boolean calibrateToObserved) { - double allowedImportChange = ModelConfig.MAX_IMPORT_CHANGE; + double allowedImportChange = calibrateToObserved ? 0.0 : ModelConfig.MAX_IMPORT_CHANGE; Map<CropType, ImportExportConstraint> importConstraints = new HashMap<CropType, ImportExportConstraint>(); for (Map.Entry<CropType, Double> entry : baseNetImport.entrySet()) { @@ -52,7 +52,7 @@ public class GamsCountryInput { double change = allowedImportChange * maxOfProdOrSupply.get(c); importConstraints.put(c, new ImportExportConstraint(entry.getValue() - change, entry.getValue() + change)); } - + return new GamsCountryInput(country, projectedDemand, worldPrices, importConstraints, cropAdjustments, calibrateToObserved); }