Skip to content
Snippets Groups Projects
Commit daf857ef authored by Peter Alexander's avatar Peter Alexander
Browse files

Silly bug in with changes to timestep in GlobalPrice

parent 9a7eb9dd
No related branches found
No related tags found
No related merge requests found
...@@ -68,16 +68,16 @@ public class GlobalPrice implements Serializable { ...@@ -68,16 +68,16 @@ public class GlobalPrice implements Serializable {
return transportLosses; 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) { 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 oldDiff = timestep.equals(thisTimeStep) ? exportAmountBeforeLoss - transportLosses - importAmount : 0.0; // if recomputing for same year need to back our previous adjustment
double transportLossRate = ModelConfig.updateParameterForShocks(timestep.getYear(), "TRANSPORT_LOSSES"); double transportLossRate = ModelConfig.updateParameterForShocks(thisTimeStep.getYear(), "TRANSPORT_LOSSES");
double newTransportLosses = newExportAmountBeforeLoss * transportLossRate; double newTransportLosses = newExportAmountBeforeLoss * transportLossRate;
double stockChange = newExportAmountBeforeLoss - newTransportLosses - newImports - oldDiff; double stockChange = newExportAmountBeforeLoss - newTransportLosses - newImports - oldDiff;
double updatedStock; 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 updatedStock = stockLevel; // don't update stock in inital stage of calibration
else else
updatedStock = stockLevel + stockChange; updatedStock = stockLevel + stockChange;
...@@ -87,7 +87,7 @@ public class GlobalPrice implements Serializable { ...@@ -87,7 +87,7 @@ public class GlobalPrice implements Serializable {
double adjustment; 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; adjustment = 1;
} }
else if (ModelConfig.PRICE_UPDATE_BY_MARKET_IMBALANCE) { else if (ModelConfig.PRICE_UPDATE_BY_MARKET_IMBALANCE) {
...@@ -117,7 +117,7 @@ public class GlobalPrice implements Serializable { ...@@ -117,7 +117,7 @@ public class GlobalPrice implements Serializable {
double newPrice = exportPrice * adjustment; double newPrice = exportPrice * adjustment;
double refPrice = ModelConfig.IS_CALIBRATION_RUN ? exportPrice : referencePrice; // during calibration reference price isn't fixed, but it is after that 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 { else {
LogWriter.printlnError(String.format("Price for not updated (still %s), as no imports and no exports for it", exportPrice)); LogWriter.printlnError(String.format("Price for not updated (still %s), as no imports and no exports for it", exportPrice));
......
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