diff --git a/GAMS/IntExtOpt.gms b/GAMS/IntExtOpt.gms index c0eaaf02b9488a2988dfc4113ff42e0db4579abf..fb1501fb5a3f0da158bd249747870d018e073d37 100644 --- a/GAMS/IntExtOpt.gms +++ b/GAMS/IntExtOpt.gms @@ -23,12 +23,12 @@ PARAMETER worldImportPrices(import_crop) prices for imports; PARAMETER maxNetImport(import_crop) maximum net import for each crop based on world market; PARAMETER minNetImport(import_crop) minimum net import for each crop based on world market; - PARAMETER irrigCost(location) irrigation cost in energy per 1000 Mlitre or Mha for each litre per m2; + PARAMETER irrigCost(location) irrigation cost in cost 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; SCALAR meatEfficency efficiency of converting feed and pasture into animal products; - SCALAR landChangeEnergy energy required to add ha of agricultural land; + SCALAR landChangeCost cost required to add ha of agricultural land; SCALAR minFeedRate minimum rate of feed for producing animal products (why is this needed?); SCALAR fertiliserUnitCost fert cost at max fert rate; SCALAR otherIParam yield response to other intensity; @@ -38,7 +38,7 @@ *$gdxin "/Users/peteralexander/Documents/R_Workspace/temp/GamsTest/_gams_java_1091455539.gdx" $gdxin %gdxincname% -$load location, suitableLandArea, previousArea, demand, landChangeEnergy +$load location, suitableLandArea, previousArea, demand, landChangeCost $load yieldNone, yieldFertOnly, yieldIrrigOnly, yieldBoth $load fertParam, irrigParam, otherIParam, worldExportPrices, worldImportPrices, maxNetImport, minNetImport, unhandledCropArea $load meatEfficency, minFeedRate, otherICost, irrigCost, irrigMaxRate, irrigConstraint, fertiliserUnitCost, domesticPriceMarkup @@ -77,20 +77,20 @@ $gdxin importAmount(all_types) imports of crops and meat - Mt exportAmount(all_types) exports of crops and meat - Mt yield(crop, location) yield per area for each crop - t per ha - unitEnergy(crop, location) energy per area for each crop - energy + unitCost(crop, location) cost per area for each crop - cost net_supply(crop) supply after exports and feed agriLandExpansion(location) addition agricultural land needed as it must be positive it deliberately does not account for abandonment cropIncrease(location) cropDecrease(location) pastureIncrease(location) pastureDecrease(location) - energy total input energy - energy; + total_cost total cost of domestic supply including net imports; POSITIVE VARIABLE area, fertI, irrigI, otherIntensity, feedAmount, importAmount, exportAmount, agriLandExpansion, cropIncrease, cropDecrease, pastureDecrease, pastureIncrease; EQUATIONS - UNIT_ENERGY_EQ(crop, location) energy per area + UNIT_COST_EQ(crop, location) cost per area YIELD_EQ(crop, location) yield given chosen intensity NON_CEREAL_DEMAND_CONSTRAINT(non_cereal_crop) satisfy demand for non-cereal crop CEREAL_DEMAND_CONSTRAINT(cereal_crop) satisfy demand for cereal so that exports can at least be met. Could also allow min. proporation of cereal consumption of each type @@ -113,9 +113,9 @@ $gdxin CROP_DECREASE_CALC(location) PASTURE_INCREASE_CONV_CALC(location) PASTURE_DECREASE_CONV_CALC(location) - ENERGY_EQ total energy objective function; + COST_EQ total cost objective function; - UNIT_ENERGY_EQ(crop, location) .. unitEnergy(crop, location) =E= ( baseCost(crop) + + UNIT_COST_EQ(crop, location) .. unitCost(crop, location) =E= ( baseCost(crop) + fertiliserUnitCost * fertI(crop, location) + irrigCost(location) * irrigMaxRate(crop, location) * irrigI(crop, location) + otherICost * otherIntensity(crop, location) @@ -169,19 +169,19 @@ $gdxin PASTURE_INCREASE_CONV_CALC(location) .. pastureIncrease(location) =G= area('pasture', location) - previousArea('pasture', location); PASTURE_DECREASE_CONV_CALC(location) .. pastureDecrease(location) =G= -(area('pasture', location) - previousArea('pasture', location)); - ENERGY_EQ .. energy =E= + COST_EQ .. total_cost =E= ( - ( SUM((crop, location), area(crop, location) * unitEnergy(crop, location)) + + ( SUM((crop, location), area(crop, location) * unitCost(crop, location)) + sum(location, agriLandExpansion(location) + 0.5 * cropIncrease(location) + 0.5 * cropDecrease(location) + 0.5 * pastureIncrease(location) + 0.5 * pastureDecrease(location) - ) * landChangeEnergy + ) * landChangeCost ) * domesticPriceMarkup + sum(import_crop, importAmount(import_crop) * worldImportPrices(import_crop) - exportAmount(import_crop) * worldExportPrices(import_crop)) - ) / 1000000; + ) / 1000000; MODEL LAND_USE /ALL/ ; @@ -194,7 +194,7 @@ $gdxin exportAmount.L(import_crop)$((maxNetImport(import_crop) + minNetImport(import_crop)) lt 0) = -(maxNetImport(import_crop) + minNetImport(import_crop)) / 2; area.L(crop, location) = previousArea(crop, location) - SOLVE LAND_USE USING NLP MINIMIZING energy; + SOLVE LAND_USE USING NLP MINIMIZING total_cost; * display agriLandExpansion.l, previousArea, area.l, net_supply.l, demand, feedAmount.l, yield.l, importAmount.l, exportAmount.l; @@ -204,8 +204,8 @@ $gdxin parameter totalProdCost(all_types); parameter totalCropland(location); parameter netImportAmount(all_types); - parameter netImportEnergy(all_types); - parameter feedEnergy(all_types); + parameter netImportCost(all_types); + parameter feedCost(all_types); * Production quantities based on smaller area (before unhandledCropArea adjustment applied) totalProd(crop) = sum(location, area.l(crop, location) * yield.l(crop, location)); @@ -213,17 +213,17 @@ $gdxin * Cost based on adjusted area area.l(crop_less_pasture, location) = area.l(crop_less_pasture, location) / (1.0 - unhandledCropArea); - totalProdCost(crop) = sum(location, unitEnergy.l(crop, location) * area.l(crop, location)); + totalProdCost(crop) = sum(location, unitCost.l(crop, location) * area.l(crop, location)); totalCropland(location) = sum(crop_less_pasture, area.l(crop_less_pasture, location)); - netImportEnergy(import_crop) = importAmount.l(import_crop) * worldImportPrices(import_crop) - exportAmount.l(import_crop) * worldExportPrices(import_crop); + netImportCost(import_crop) = importAmount.l(import_crop) * worldImportPrices(import_crop) - exportAmount.l(import_crop) * worldExportPrices(import_crop); netImportAmount(import_crop) = importAmount.l(import_crop) - exportAmount.l(import_crop); - feedEnergy(feed_crop)$(netImportAmount(feed_crop) gt 0) = (totalProdCost(feed_crop) + netImportEnergy(feed_crop)) * feedAmount.l(feed_crop) / (totalProd(feed_crop) + netImportAmount(feed_crop)); - feedEnergy(feed_crop)$(netImportAmount(feed_crop) le 0 and totalProd(feed_crop) gt 0) = totalProdCost(feed_crop) * feedAmount.l(feed_crop) / totalProd(feed_crop); - totalProdCost('meat') = sum(feed_crop, feedEnergy(feed_crop)); + feedCost(feed_crop)$(netImportAmount(feed_crop) gt 0) = (totalProdCost(feed_crop) + netImportCost(feed_crop)) * feedAmount.l(feed_crop) / (totalProd(feed_crop) + netImportAmount(feed_crop)); + feedCost(feed_crop)$(netImportAmount(feed_crop) le 0 and totalProd(feed_crop) gt 0) = totalProdCost(feed_crop) * feedAmount.l(feed_crop) / totalProd(feed_crop); + totalProdCost('meat') = sum(feed_crop, feedCost(feed_crop)); -* display totalProdCost, totalProd, totalImportEnergy, feedEnergy, totalProdCost +* display totalProdCost, totalProd, totalImportCost, feedCost, totalProdCost Scalar ms 'model status', ss 'solve status'; ms=LAND_USE.modelstat; diff --git a/src/ac/ed/lurg/ModelConfig.java b/src/ac/ed/lurg/ModelConfig.java index fe305c6a4d560676811fa95c1498d8b1530256ee..4e901c47512a8fb94177c8c30348444a7b266e0d 100644 --- a/src/ac/ed/lurg/ModelConfig.java +++ b/src/ac/ed/lurg/ModelConfig.java @@ -141,7 +141,7 @@ public class ModelConfig { public static final double PASTURE_HARVEST_FRACTION = getDoubleProperty("PASTURE_HARVEST_FRACTION", 0.25); public static final double MEAT_EFFICIENCY = getDoubleProperty("MEAT_EFFICIENCY", 1.0); // 'meat' is includes feed conversion ratio already, this is tech. change or similar public static final double IRRIGIATION_EFFICIENCY = getDoubleProperty("IRRIGIATION_EFFICIENCY", 0.5); - public static final double LAND_CHANGE_COST = getDoubleProperty("LAND_CHANGE_COST", 1.0); + public static final double LAND_CHANGE_ENERGY = getDoubleProperty("LAND_CHANGE_COST", 1.0); public static final double MIN_FEED_RATE = getDoubleProperty("MIN_FEED_RATE", 0.15); public static final double SEED_AND_WASTE_FRACTION = getDoubleProperty("SEED_AND_WASTE_FRACTION", 0.15); diff --git a/src/ac/ed/lurg/country/gams/GamsCountryInput.java b/src/ac/ed/lurg/country/gams/GamsCountryInput.java index 431a39920a715d1696a216237cafd9b2b0d11433..a45ff0485779c46705cc1ddaab9161688e54f021 100644 --- a/src/ac/ed/lurg/country/gams/GamsCountryInput.java +++ b/src/ac/ed/lurg/country/gams/GamsCountryInput.java @@ -81,8 +81,8 @@ public class GamsCountryInput { return ModelConfig.MEAT_EFFICIENCY; // this is already handled by the feed conversion efficiency for each animal product } - public double getLandChangeEnergy() { - return ModelConfig.LAND_CHANGE_COST; + public double getLandChangeCost() { + return ModelConfig.LAND_CHANGE_ENERGY; } public double getMinFeedRate() { diff --git a/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java b/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java index a9e106a4af753c4a8257e51bd39a73f014c179f5..a6236cfa21be0698f7336349a272fe5498957857 100644 --- a/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java +++ b/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java @@ -192,7 +192,7 @@ public class GamsLocationOptimiser { addScalar(inDB, "fertiliserUnitCost", ModelConfig.FERTILISER_MAX_COST); addScalar(inDB, "otherICost",ModelConfig.OTHER_INTENSITY_COST); addScalar(inDB, "otherIParam", ModelConfig.OTHER_INTENSITY_PARAM); - addScalar(inDB, "landChangeEnergy", countryInput.getLandChangeEnergy()); + addScalar(inDB, "landChangeCost", countryInput.getLandChangeCost()); addScalar(inDB, "minFeedRate", countryInput.getMinFeedRate()); addScalar(inDB, "unhandledCropArea", ModelConfig.UNHANDLED_CROP_AREA); addScalar(inDB, "domesticPriceMarkup", ModelConfig.DOMESTIC_PRICE_MARKUP); @@ -227,7 +227,7 @@ public class GamsLocationOptimiser { GAMSVariable varFeedAmount = outDB.getVariable("feedAmount"); GAMSParameter parmNetImports = outDB.getParameter("netImportAmount"); GAMSVariable varYields = outDB.getVariable("yield"); - GAMSVariable varUnitEnergies = outDB.getVariable("unitEnergy"); + GAMSVariable varUnitEnergies = outDB.getVariable("unitCost"); // GAMSParameter parmCropAdj = outDB.getParameter("cropAdj"); GAMSParameter parmProd = outDB.getParameter("totalProd"); GAMSParameter parmProdCost = outDB.getParameter("totalProdCost"); @@ -235,7 +235,7 @@ public class GamsLocationOptimiser { double totalCropArea = 0; double totalPastureArea = 0; - double area, fertIntensity, irrigIntensity, otherIntensity = Double.NaN, feedAmount, netImport, yield, unitEnergy, cropAdj, prod, prodCost; + double area, fertIntensity, irrigIntensity, otherIntensity = Double.NaN, feedAmount, netImport, yield, unitCost, cropAdj, prod, prodCost; final LazyHashMap<Integer, LandUseItem> landUses = new LazyHashMap<Integer, LandUseItem>() { protected LandUseItem createValue() { return new LandUseItem(); } @@ -254,7 +254,7 @@ public class GamsLocationOptimiser { irrigIntensity = varIrrigIntensities.findRecord(itemName, locationName).getLevel(); otherIntensity = varOtherIntensities.findRecord(itemName, locationName).getLevel(); yield = varYields.findRecord(itemName, locationName).getLevel(); - unitEnergy = varUnitEnergies.findRecord(itemName, locationName).getLevel(); + unitCost = varUnitEnergies.findRecord(itemName, locationName).getLevel(); int locId = Integer.parseInt(locationName); CropType cropType = CropType.getForGamsName(itemName); @@ -276,7 +276,7 @@ public class GamsLocationOptimiser { if (area > 0) { if (DEBUG) LogWriter.println(String.format("\t location %s, %s:\tarea= %.1f,\tfert= %.3f,\tirrg= %.3f,\tintensity= %.3f", locationName, itemName, area, fertIntensity, irrigIntensity, otherIntensity)); IrrigationItem irrigRefData = allIrrigationRefData.get(locId); - landUseItem.setIntensity(cropType, new Intensity(fertIntensity, irrigIntensity, otherIntensity, yield, unitEnergy, irrigRefData.getMaxIrrigAmount(cropType))); + landUseItem.setIntensity(cropType, new Intensity(fertIntensity, irrigIntensity, otherIntensity, yield, unitCost, irrigRefData.getMaxIrrigAmount(cropType))); } double croplandArea = getParmValue(parmCroplandArea, locationName);