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

Fix to problem getting values for crop not produced

parent 6895337e
No related branches found
No related tags found
No related merge requests found
......@@ -54,8 +54,8 @@ $gdxin
* pasture yield is done in DM terms
PARAMETER baseCost(crop) cost per ha before intensity values just made up at the moment
/ wheat 0.5
maize 0.5
/ wheat 0.8
maize 1.0
rice 1.0
tropicalCereals 0.5
oilcrops 0.5
......
......@@ -106,7 +106,7 @@ public class ModelConfig {
public static final int START_TIMESTEP = getIntProperty("START_TIMESTEP", 0);
public static final int END_TIMESTEP = getIntProperty("END_TIMESTEP", 0);
public static final int END_TIMESTEP = getIntProperty("END_TIMESTEP", 1);
public static final int BASE_YEAR = getIntProperty("BASE_YEAR", 2010);
public static final double MAX_IMPORT_CHANGE = getDoubleProperty("MAX_IMPORT_CHANGE", 0.2);
......
......@@ -18,6 +18,7 @@ import ac.ed.lurg.utils.LogWriter;
import ac.ed.lurg.yield.YieldResponsesItem;
import com.gams.api.GAMSDatabase;
import com.gams.api.GAMSException;
import com.gams.api.GAMSGlobals;
import com.gams.api.GAMSJob;
import com.gams.api.GAMSOptions;
......@@ -224,9 +225,9 @@ public class GamsLocationOptimiser {
if (!cropType.equals(prevCropType)) {
feedAmount = varFeedAmount.findRecord(itemName).getLevel();
netImport = cropType.isImportedCrop() ? varNetImports.findRecord(itemName).getLevel() : 0;
cropAdj = parmCropAdj.findRecord(itemName).getValue();
prod = parmProd.findRecord(itemName).getValue();
prodCost = parmProdCost.findRecord(itemName).getValue();
cropAdj = getParmValue(parmCropAdj, itemName);
prod = getParmValue(parmProd, itemName);
prodCost = getParmValue(parmProdCost, itemName);
cropUsageData.put(cropType, new CropUsageData(feedAmount, netImport, prod, prodCost));
cropAdjs.put(cropType, cropAdj);
......@@ -267,6 +268,17 @@ public class GamsLocationOptimiser {
GamsLocationOutput results = new GamsLocationOutput(modelStatus, intensities, cropAreas, cropUsageData, cropAdjs);
return results;
}
private double getParmValue(GAMSParameter aParm, String itemName) {
try {
double d = aParm.findRecord(itemName).getValue();
return d;
}
catch (GAMSException gamsEx) {
//LogWriter.println("GAMSException thrown for " + itemName);
return 0;
}
}
private void addScalar(GAMSParameter param, double val) {
param.addRecord().setValue(val);
......
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