From b61438740aa46975fe9f1dfb22da6feaa0161e23 Mon Sep 17 00:00:00 2001 From: Peter Alexander <peter@blackhillock.co.uk> Date: Tue, 5 Jul 2016 09:51:01 +0100 Subject: [PATCH] Remove cropAdj --- GAMS/IntExtOpt.gms | 13 +++++++------ src/ac/ed/lurg/ModelConfig.java | 6 +++--- src/ac/ed/lurg/country/GlobalPrice.java | 2 +- .../ed/lurg/country/gams/GamsLocationOptimiser.java | 12 +++++------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/GAMS/IntExtOpt.gms b/GAMS/IntExtOpt.gms index 9ba87c32..c0eaaf02 100644 --- a/GAMS/IntExtOpt.gms +++ b/GAMS/IntExtOpt.gms @@ -26,7 +26,6 @@ PARAMETER irrigCost(location) irrigation cost in energy per 1000 Mlitre or Mha for each litre per m2; PARAMETER irrigMaxRate(crop, location) max water application rate irrigation in litre per m2; PARAMETER irrigConstraint(location) max water available for irrigation in litre per m2; - PARAMETER cropAdj(crop) this is the fudge factor that allows the model to fit the observed data SCALAR meatEfficency efficiency of converting feed and pasture into animal products; SCALAR landChangeEnergy energy required to add ha of agricultural land; @@ -35,13 +34,14 @@ SCALAR otherIParam yield response to other intensity; SCALAR otherICost cost of other intensity; SCALAR unhandledCropArea includes fruit veg forage crops set aside and failed crop; + SCALAR domesticPriceMarkup factor price increased from cost of production; *$gdxin "/Users/peteralexander/Documents/R_Workspace/temp/GamsTest/_gams_java_1091455539.gdx" $gdxin %gdxincname% $load location, suitableLandArea, previousArea, demand, landChangeEnergy $load yieldNone, yieldFertOnly, yieldIrrigOnly, yieldBoth $load fertParam, irrigParam, otherIParam, worldExportPrices, worldImportPrices, maxNetImport, minNetImport, unhandledCropArea -$load meatEfficency, minFeedRate, otherICost, irrigCost, irrigMaxRate, irrigConstraint, cropAdj, fertiliserUnitCost +$load meatEfficency, minFeedRate, otherICost, irrigCost, irrigMaxRate, irrigConstraint, fertiliserUnitCost, domesticPriceMarkup $gdxin SCALAR delta use to smooth power function see 7.5 www.gams.com dd docs solversconopt.pdf / 0.00000000001 / @@ -133,7 +133,7 @@ $gdxin (yieldBoth(crop, location) + yieldNone(crop, location) - yieldFertOnly(crop, location) - yieldIrrigOnly(crop, location)) * (1 - exp(-fertParam(crop, location)*fertI(crop, location))) * (1 - exp(-irrigParam(crop, location)*irrigI(crop, location))) - ) * cropAdj(crop) * (1 - exp(-otherIntensity(crop, location)*otherIParam)); + ) * (1 - exp(-otherIntensity(crop, location)*otherIParam)); NET_SUPPLY_EQ(crop) .. net_supply(crop) =E= (sum(location, area(crop, location) * yield(crop, location)) - feedAmount(crop)) / cropDM(crop) + importAmount(crop) - exportAmount(crop); @@ -171,14 +171,15 @@ $gdxin ENERGY_EQ .. energy =E= ( - SUM((crop, location), area(crop, location) * unitEnergy(crop, location)) + - sum(location, + ( SUM((crop, location), area(crop, location) * unitEnergy(crop, location)) + + sum(location, agriLandExpansion(location) + 0.5 * cropIncrease(location) + 0.5 * cropDecrease(location) + 0.5 * pastureIncrease(location) + 0.5 * pastureDecrease(location) - ) * landChangeEnergy + + ) * landChangeEnergy + ) * domesticPriceMarkup + sum(import_crop, importAmount(import_crop) * worldImportPrices(import_crop) - exportAmount(import_crop) * worldExportPrices(import_crop)) ) / 1000000; diff --git a/src/ac/ed/lurg/ModelConfig.java b/src/ac/ed/lurg/ModelConfig.java index 12d53d9e..fe305c6a 100644 --- a/src/ac/ed/lurg/ModelConfig.java +++ b/src/ac/ed/lurg/ModelConfig.java @@ -157,9 +157,9 @@ public class ModelConfig { public static final double FERTILISER_COST_PER_T = getDoubleProperty("FERTILISER_COST_PER_T", 0.87 * 1.4 * 2); // £900/t N * 1.4$/£ * 2NPK/N public static final double FERTILISER_MAX_COST = FERTILISER_COST_PER_T * MAX_FERT_AMOUNT/1000; - public static final double DOMESTIC_LOSSES = getDoubleProperty("DOMESTIC_LOSSES", 0.1); // in international trade - public static final double TRANSPORT_LOSSES = getDoubleProperty("TRANSPORT_LOSSES", 0.15); // in international trade - public static final double TRADE_BARRIER_FACTOR = getDoubleProperty("TRADE_BARRIER_FACTOR", 1.5); // price factor in international trade, transport cost and real trade barriers + public static final double DOMESTIC_PRICE_MARKUP = getDoubleProperty("DOMESTIC_PRICE_MARKUP", 1.4); + public static final double TRANSPORT_LOSSES = getDoubleProperty("TRANSPORT_LOSSES", 0.1); // in international trade + public static final double TRADE_BARRIER_FACTOR = getDoubleProperty("TRADE_BARRIER_FACTOR", 1.4); // price factor in international trade, transport cost and real trade barriers public static final int NUM_CEREAL_CATEGORIES = getIntProperty("NUM_CEREAL_CATEGORIES", 5); public static final int NUM_PASTURE_CATEGORIES = getIntProperty("NUM_PASTURE_CATEGORIES", 1); diff --git a/src/ac/ed/lurg/country/GlobalPrice.java b/src/ac/ed/lurg/country/GlobalPrice.java index 61758314..3d5dd5e6 100644 --- a/src/ac/ed/lurg/country/GlobalPrice.java +++ b/src/ac/ed/lurg/country/GlobalPrice.java @@ -16,7 +16,7 @@ public class GlobalPrice { } public static GlobalPrice createInitial(double exportPrice) { - return new GlobalPrice(exportPrice * ModelConfig.TRADE_BARRIER_FACTOR / (1-ModelConfig.TRANSPORT_LOSSES), exportPrice, Double.NaN, Double.NaN); + return new GlobalPrice(exportPrice, exportPrice * (1-ModelConfig.TRANSPORT_LOSSES) / ModelConfig.TRADE_BARRIER_FACTOR, Double.NaN, Double.NaN); } public double getImportPrice() { diff --git a/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java b/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java index 85f26bb3..a9e106a4 100644 --- a/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java +++ b/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java @@ -195,9 +195,7 @@ public class GamsLocationOptimiser { addScalar(inDB, "landChangeEnergy", countryInput.getLandChangeEnergy()); addScalar(inDB, "minFeedRate", countryInput.getMinFeedRate()); addScalar(inDB, "unhandledCropArea", ModelConfig.UNHANDLED_CROP_AREA); - - if (DEBUG) LogWriter.println("\ncropAdj"); - addItemMapParm(inDB.addParameter("cropAdj", 1), countryInput.getCropAdjustments(), DEBUG); + addScalar(inDB, "domesticPriceMarkup", ModelConfig.DOMESTIC_PRICE_MARKUP); } private void addScalar(GAMSDatabase gamsDb, String recordName, double val) { @@ -230,7 +228,7 @@ public class GamsLocationOptimiser { GAMSParameter parmNetImports = outDB.getParameter("netImportAmount"); GAMSVariable varYields = outDB.getVariable("yield"); GAMSVariable varUnitEnergies = outDB.getVariable("unitEnergy"); - GAMSParameter parmCropAdj = outDB.getParameter("cropAdj"); +// GAMSParameter parmCropAdj = outDB.getParameter("cropAdj"); GAMSParameter parmProd = outDB.getParameter("totalProd"); GAMSParameter parmProdCost = outDB.getParameter("totalProdCost"); GAMSParameter parmCroplandArea = outDB.getParameter("totalCropland"); @@ -264,13 +262,13 @@ public class GamsLocationOptimiser { if (!cropUsageData.containsKey(cropType)) { // then we must not have seen this crop type before, so need to do all non location specific stuff feedAmount = varFeedAmount.findRecord(itemName).getLevel(); netImport = cropType.isImportedCrop() ? getParmValue(parmNetImports, itemName) : 0; - cropAdj = getParmValue(parmCropAdj, itemName); +// 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); - if (DEBUG) LogWriter.println(String.format("\n%s:\tfeedAmount= %.1f,\tnetImports= %.3f,\tprod= %.3f,\tprodCost= %.3f,\tcropAdj= %.3f", itemName, feedAmount, netImport, prod, prodCost, cropAdj)); +// cropAdjs.put(cropType, cropAdj); + if (DEBUG) LogWriter.println(String.format("\n%s:\tfeedAmount= %.1f,\tnetImports= %.3f,\tprod= %.3f,\tprodCost= %.3f,\tcropAdj= %.3f", itemName, feedAmount, netImport, prod, prodCost, Double.NaN)); } LandUseItem landUseItem = landUses.lazyGet(locId); -- GitLab