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

Stop stocks changes in first phase of calibration

parent 3d6c42b3
No related branches found
No related tags found
No related merge requests found
......@@ -155,7 +155,7 @@ public class ModelConfig {
public static final boolean DONT_REBASE_DEMAND = getBooleanProperty("DONT_REBASE_DEMAND", false);;
public static final String DEMAND_CURVES_FILE = getProperty("DEMAND_CURVES_FILE", DATA_DIR + File.separator + "com_curves.csv"); // either DEMAND_CURVES_FILE or DEMAND_CONSUMPTION_FILE is used, but not both
public static final String DEMAND_CONSUMPTION_FILE = getProperty("DEMAND_CONSUMPTION_FILE", DATA_DIR + File.separator + "hist_comsump.csv");
public static final boolean DEMAND_PRICE_IMPORT_AND_PROD_COST = getBooleanProperty("DEMAND_PRICE_IMPORT_AND_PROD_COST", true);
public static final boolean DEMAND_PRICE_IMPORT_AND_PROD_COST = getBooleanProperty("DEMAND_PRICE_IMPORT_AND_PROD_COST", false);
public static final String SSP_FILE = DATA_DIR + File.separator + "ssp.csv";
public static final String BASELINE_CONSUMP_FILE = DATA_DIR + File.separator + "base_consump.csv";
public static final String CALORIE_PER_T_FILE = DATA_DIR + File.separator + "calories_per_t.csv";
......
......@@ -73,7 +73,12 @@ public class GlobalPrice implements Serializable {
double transportLossRate = (!ModelConfig.SHOCKS_POSSIBLE) ? ModelConfig.TRANSPORT_LOSSES : ModelConfig.getParameter(Parameter.TRANSPORT_LOSSES, timestep.getYear());
double newTransportLosses = newExportAmountBeforeLoss * transportLossRate;
double stockChange = newExportAmountBeforeLoss - newTransportLosses - newImports - oldDiff;
double updatedStock = stockLevel + stockChange;
double updatedStock;
if (ModelConfig.IS_CALIBRATION_RUN && timestep.getTimestep() <= ModelConfig.END_FIRST_STAGE_CALIBRATION)
updatedStock = stockLevel; // don't update stock in inital stage of calibration
else
updatedStock = stockLevel + stockChange;
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));
......
......@@ -61,10 +61,9 @@ public class YieldResponse {
double yMinNoI = getYield(YieldType.NO_FERT_NO_IRRIG);
double yMidNoI = getYield(YieldType.FERT_MID_NO_IRRIG);
double yMaxNoI = getYield(YieldType.FERT_MAX_NO_IRRIG);
double fMid = (ModelConfig.MID_FERT_AMOUNT-ModelConfig.MIN_FERT_AMOUNT)/(ModelConfig.MAX_FERT_AMOUNT-ModelConfig.MIN_FERT_AMOUNT);
if (ModelConfig.EXTRAPOLATE_YIELD_FERT_RESPONSE && !(yMidNoI <= yMinNoI || yMaxNoI <= yMidNoI)) {
if (ModelConfig.EXTRAPOLATE_YIELD_FERT_RESPONSE) {
double yMinI = getYield(YieldType.NO_FERT_IRRIG_MAX);
double yMidI = getYield(YieldType.FERT_MID_IRRIG_MAX);
double yMaxI = getYield(YieldType.FERT_MAX_IRRIG_MAX);
......@@ -76,6 +75,8 @@ public class YieldResponse {
if (Double.isNaN(asymptoteYieldIncI) || Double.isNaN(fertParm)) {
LogWriter.println("Not finding a suitable extrapolating solution. Defaulting to old style");
fertParm = calcParam(yMinNoI, yMidNoI, yMaxNoI, fMid);
yieldsExtrapolated = yields;
}
else {
yieldsExtrapolated = new HashMap<YieldType, Double>();
......@@ -85,10 +86,8 @@ public class YieldResponse {
yieldsExtrapolated.put(YieldType.FERT_MAX_IRRIG_MAX, asymptoteYieldIncI+yMinI);
}
}
if (yieldsExtrapolated == null) { // Default behaviour if EXTRAPOLATE_YIELD_FERT_RESPONSE is false or a problem with the other approach
else {
fertParm = calcParam(yMinNoI, yMidNoI, yMaxNoI, fMid);
yieldsExtrapolated = yields;
}
return fertParm;
......@@ -128,8 +127,8 @@ public class YieldResponse {
double b = yH * 20;
double epsilon = 0.0001;
if (fM * yH > yM) {
LogWriter.printlnError(String.format("yieldAsymptoteSolve: not diminishing yield increases to N: yM=%.3f, yH=%.3f, fM=%.3f", yM, yH, fM));
if (yM < 0 || yH < 0 || fM * yH > yM) {
LogWriter.printlnError(String.format("yieldAsymptoteSolve: less than zero yield or not diminishing yield increases to N: yM=%.3f, yH=%.3f, fM=%.3f", yM, yH, fM));
return Double.NaN;
}
......
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