From daf857ef8ea54a40ea89c19140b527702753a2fd Mon Sep 17 00:00:00 2001 From: Peter Alexander <> Date: Wed, 26 Jan 2022 11:44:07 +0000 Subject: [PATCH] Silly bug in with changes to timestep in GlobalPrice --- src/ac/ed/lurg/country/GlobalPrice.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ac/ed/lurg/country/GlobalPrice.java b/src/ac/ed/lurg/country/GlobalPrice.java index fa0fc1a3..f0c96121 100644 --- a/src/ac/ed/lurg/country/GlobalPrice.java +++ b/src/ac/ed/lurg/country/GlobalPrice.java @@ -68,16 +68,16 @@ public class GlobalPrice implements Serializable { return transportLosses; } - public GlobalPrice createWithUpdatedMarketPrices(double newImports, double newExportAmountBeforeLoss, Timestep timestep, double production) { + public GlobalPrice createWithUpdatedMarketPrices(double newImports, double newExportAmountBeforeLoss, Timestep thisTimeStep, double production) { if (newImports > 0 || newExportAmountBeforeLoss > 0) { - double oldDiff = !timestep.equals(timestep) ? 0.0 : exportAmountBeforeLoss - transportLosses - importAmount; // if recomputing for same year need to back our previous adjustment - double transportLossRate = ModelConfig.updateParameterForShocks(timestep.getYear(), "TRANSPORT_LOSSES"); + double oldDiff = timestep.equals(thisTimeStep) ? exportAmountBeforeLoss - transportLosses - importAmount : 0.0; // if recomputing for same year need to back our previous adjustment + double transportLossRate = ModelConfig.updateParameterForShocks(thisTimeStep.getYear(), "TRANSPORT_LOSSES"); double newTransportLosses = newExportAmountBeforeLoss * transportLossRate; double stockChange = newExportAmountBeforeLoss - newTransportLosses - newImports - oldDiff; double updatedStock; - if (ModelConfig.IS_CALIBRATION_RUN && timestep.getTimestep() <= ModelConfig.END_FIRST_STAGE_CALIBRATION) + if (ModelConfig.IS_CALIBRATION_RUN && thisTimeStep.getTimestep() <= ModelConfig.END_FIRST_STAGE_CALIBRATION) updatedStock = stockLevel; // don't update stock in inital stage of calibration else updatedStock = stockLevel + stockChange; @@ -87,7 +87,7 @@ public class GlobalPrice implements Serializable { double adjustment; - if (!ModelConfig.MARKET_ADJ_PRICE || (ModelConfig.IS_CALIBRATION_RUN && timestep.getTimestep() <= ModelConfig.END_FIRST_STAGE_CALIBRATION)) { + if (!ModelConfig.MARKET_ADJ_PRICE || (ModelConfig.IS_CALIBRATION_RUN && thisTimeStep.getTimestep() <= ModelConfig.END_FIRST_STAGE_CALIBRATION)) { adjustment = 1; } else if (ModelConfig.PRICE_UPDATE_BY_MARKET_IMBALANCE) { @@ -117,7 +117,7 @@ public class GlobalPrice implements Serializable { double newPrice = exportPrice * adjustment; double refPrice = ModelConfig.IS_CALIBRATION_RUN ? exportPrice : referencePrice; // during calibration reference price isn't fixed, but it is after that - return new GlobalPrice(timestep, newPrice, updatedStock, newImports, newExportAmountBeforeLoss, newTransportLosses, refPrice); + return new GlobalPrice(thisTimeStep, newPrice, updatedStock, newImports, newExportAmountBeforeLoss, newTransportLosses, refPrice); } else { LogWriter.printlnError(String.format("Price for not updated (still %s), as no imports and no exports for it", exportPrice)); -- GitLab