diff --git a/src/ac/ed/lurg/country/AbstractCountryAgent.java b/src/ac/ed/lurg/country/AbstractCountryAgent.java index 2fee1dab8b8961817677f0a26e9ea11ab58e31fb..895a60e66ad95f5dc02b57c4feff98e22b5ce8ac 100644 --- a/src/ac/ed/lurg/country/AbstractCountryAgent.java +++ b/src/ac/ed/lurg/country/AbstractCountryAgent.java @@ -22,7 +22,7 @@ public abstract class AbstractCountryAgent { protected Timestep currentTimestep; protected Map<CommodityType, Map<CropType, Double>> currentMinDemandFract; protected double currentGen2EcDemand; - private double exportTax; + private double exportTaxRate; private Map<CropType, Double> previousProducerCropPrices; protected Map<CropType, Double> currentProducerCropPrices; @@ -51,7 +51,7 @@ public abstract class AbstractCountryAgent { Double tb = tradeBarriers.get(c); LogWriter.println(worldPrice + " " + c); double exportPrice = worldPrice.getExportPrice(); - exportPrice *= (1 - exportTax); + exportPrice /= (1 + exportTaxRate); CountryPrice prices = new CountryPrice(worldPrice.getCountryImportPrice(tb==null ? 0 : tb, currentTimestep), exportPrice); countryPrices.put(c, prices); @@ -65,30 +65,29 @@ public abstract class AbstractCountryAgent { } protected void calculateProducerCropPrices() { - LogWriter.println("calculateProducerCropPrices " + country + " " + currentTimestep); currentProducerCropPrices = getProducerCropPrices(); LogWriter.println("calculateProducerCropPrices " + country + " " + currentTimestep + " prices now " + currentProducerCropPrices); } protected void calculateExportTax() { - exportTax = 0; + exportTaxRate = 0; if (previousProducerCropPrices != null) { for (CropType crop : CommodityType.CEREALS.getCropTypes()) { double newPrice = currentProducerCropPrices.get(crop); double oldPrice = previousProducerCropPrices.get(crop); - if ((newPrice - oldPrice)/ oldPrice > ModelConfig.EXPORT_TAX_THRESHOLD) { - exportTax = ModelConfig.EXPORT_TAX_RATE; - LogWriter.println(String.format("calculateExportTax: Price Spike: %s: Price increased beyond threshold for %s, newPrice=%.4f, oldPrice=%.4f", country, crop, newPrice, oldPrice)); + double priceChangeRate = (newPrice - oldPrice)/ oldPrice; + if (priceChangeRate > ModelConfig.EXPORT_TAX_THRESHOLD) { + exportTaxRate = ModelConfig.EXPORT_TAX_RATE; + LogWriter.println(String.format("calculateExportTax: Price Spike, %s, %d, %s, %.2f, %.6f, %.6f", country, currentTimestep.getTimestep(), crop, priceChangeRate*100, newPrice, oldPrice)); break; } - else { - LogWriter.println(String.format("calculateExportTax: %s: Price change below threshold for %s, newPrice=%.4f, oldPrice=%.4f", country, crop, newPrice, oldPrice)); - } + else + LogWriter.println(String.format("calculateExportTax: Price change below threshold, %s, %d, %s, %.2f, %.6f, %.6f", country, currentTimestep.getTimestep(), crop, priceChangeRate*100, newPrice, oldPrice)); } } - LogWriter.println(String.format("calculateExportTax %s: exportTax is now %s", country, exportTax)); + LogWriter.println(String.format("calculateExportTax %s: exportTax is now %s", country, exportTaxRate)); } protected abstract Map<CropType, Double> getProducerCropPrices();