From 6b6de6ad52c057c5193e888198c85cfb4e3a8984 Mon Sep 17 00:00:00 2001 From: Peter Alexander <peter@blackhillock.co.uk> Date: Sat, 28 Jul 2018 18:47:56 +0100 Subject: [PATCH] More config changes arising from feed and waste changes --- GAMS/IntExtOpt.gms | 2 +- GAMS/LUOpt.gms | 62 ++++++++++++++++++--------------- debug_config.properties | 2 +- scripts/createScenarios.sh | 1 - src/ac/ed/lurg/ModelConfig.java | 6 ++-- 5 files changed, 39 insertions(+), 34 deletions(-) diff --git a/GAMS/IntExtOpt.gms b/GAMS/IntExtOpt.gms index efd52056..125271f9 100644 --- a/GAMS/IntExtOpt.gms +++ b/GAMS/IntExtOpt.gms @@ -91,7 +91,7 @@ $gdxin PARAMETER otherIntCost(crop); baseCost(crop) = prodCost(crop)*0.3; otherIntCost(crop) = baseCost(crop)*0.7 + otherICost; - baseCost('pasture') = 0.03; + baseCost('pasture') = 0.04; otherIntCost('pasture') = 0.8 + otherICost; VARIABLES diff --git a/GAMS/LUOpt.gms b/GAMS/LUOpt.gms index 958fba8d..817f03b8 100644 --- a/GAMS/LUOpt.gms +++ b/GAMS/LUOpt.gms @@ -6,6 +6,7 @@ SET feed_crop_less_pasture(feed_crop) / wheat, maize, rice, oilcrops, pulses, starchyRoots /; SET traded_commodity(all_types) / monogastrics, ruminants, wheat, maize, rice, oilcrops, pulses, starchyRoots, energycrops /; SET non_traded(all_types) / cereals, pasture, setaside /; + SET animal_product(all_types) / monogastrics, ruminants /; SET cereal_crop(crop) / wheat, maize, rice /; SET non_cereal_crop(crop) / oilcrops, pulses, starchyRoots, energycrops, pasture /; @@ -27,8 +28,8 @@ PARAMETER demand(all_types) in t; PARAMETER exportPrices(traded_commodity) prices for exports and domestic farmgate price; PARAMETER importPrices(traded_commodity) prices for imports; - PARAMETER maxProduction(traded_commodity) maximum Production crop based domestic demand and net imports; - PARAMETER minProduction(traded_commodity) minimum Production crop based domestic demand and net imports; + PARAMETER maxProduction(all_types) maximum Production crop based domestic demand and net imports; + PARAMETER minProduction(all_types) minimum Production crop based domestic demand and net imports; 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; @@ -81,7 +82,7 @@ $gdxin PARAMETER prodCost(crop) cost per ha before intensity values not including fertiliser or irrigation i.e. seed spray and other. In 1000 $ per ha / wheat 0.32 - maize 0.31 + maize 0.28 rice 0.36 oilcrops 0.2 pulses 0.31 @@ -92,7 +93,7 @@ $gdxin PARAMETER otherIntCost(crop); baseCost(crop) = prodCost(crop)*0.35; otherIntCost(crop) = baseCost(crop)*0.65 + otherICost; - baseCost('pasture') = 0.03; + baseCost('pasture') = 0.04; otherIntCost('pasture') = 0.8 + otherICost; VARIABLES @@ -103,7 +104,7 @@ $gdxin ruminantFeed(crop) amount of feed for ruminant animals - Mt monogastricFeed(crop) amount of feed for monogatric animals - Mt importAmount(all_types) imports of crops and meat - Mt - netProduction(all_types) net domestic production of crops and meat after feed use - Mt + domesticallyProducedFoodSupply(all_types) net domestically produced food after feed use - Mt yield(crop, location) yield per area for each crop - t per ha unitCost(crop, location) cost per area for each crop - cost agriLandExpansion(location) addition agricultural land needed as it must be positive it deliberately does not account for abandonment @@ -111,29 +112,34 @@ $gdxin cropDecrease(location) pastureIncrease(location) pastureDecrease(location) + production(all_types) totalFeedDM totalProfit total profit from domestic production; - POSITIVE VARIABLE area, fertI, irrigI, otherIntensity, ruminantFeed, monogastricFeed, importAmount, + POSITIVE VARIABLE area, fertI, irrigI, otherIntensity, ruminantFeed, monogastricFeed, importAmount, production, agriLandExpansion, cropIncrease, cropDecrease, pastureDecrease, pastureIncrease, totalFeedDM; EQUATIONS UNIT_COST_EQ(crop, location) cost per area YIELD_EQ(crop, location) yield given chosen intensity + CROP_PROD_EQ(crop) calc total production for crops RUMINANT_PROD_EQ production of ruminant MONOGASTRICS_PROD_EQ production of monogastric + CROP_NET_PROD_EQ(crop) calc net production for crops + ANIMAL_NET_PROD_EQ(animal_product) calc net production for animal products NON_TRADED_CONSTRAINT(non_traded) stop not traded stuff like pasture being imported TOTAL_NON_PASTURE_FEED_DM_CALC calc total feed dry matter not including pasture - FEED_MIX_CONSTRAINT(feed_crop_less_pasture) limit amount of feed for each feed crop +* FEED_MIX_CONSTRAINT(feed_crop_less_pasture) limit amount of feed for each feed crop MAX_FERT_INTENSITY_CONSTRAINT(crop, location) constraint on maximum fertilizer intensity MAX_IRRIG_INTENSITY_CONSTRAINT(crop, location) constraint on maximum irrigation intensity MAX_OTHER_INTENSITY_CONSTRAINT(crop, location) SETASIDE_AREA_CALC(location) TOTAL_LAND_CHANGE_CONSTRAINT(location) constraint on suitable land use - MAX_PRODUCTION_CONSTRAINT(traded_commodity) constraint on max production - MIN_PRODUCTION_CONSTRAINT(traded_commodity) constraint on min production + CROP_MAX_PROD_CONSTRAINT(crop) constraint on max production for crops + CROP_MIN_PROD_CONSTRAINT(crop) constraint on min production for crops + ANIMAL_MAX_PROD_CONSTRAINT(animal_product) constraint on max production for animal product + ANIMAL_MIN_PROD_CONSTRAINT(animal_product) constraint on min production for animal products IRRIGATION_CONSTRAINT(location) constraint no water usage - NET_PRODUCTION_EQ(crop) calc net production for crops POSITIVE_SUPPLY_CONSTRAINT(crop) AGRI_LAND_EXPANSION_CALC(location) calc agriLandExpansion CROP_INCREASE_CALC(location) @@ -158,18 +164,18 @@ $gdxin (1 - exp(-fertParam(crop, location)*fertI(crop, location))) * (1 - exp(-irrigParam(crop, location)*irrigI(crop, location))) ) * (1 - exp(-otherIntensity(crop, location)*otherIParam)); - NET_PRODUCTION_EQ(crop) .. netProduction(crop) =E= sum(location, area(crop, location) * yield(crop, location)) * (1 - seedAndWasteRate(crop)) - ruminantFeed(crop) - monogastricFeed(crop); - - POSITIVE_SUPPLY_CONSTRAINT(crop) .. importAmount(crop) + netProduction(crop) =G= 0; + CROP_PROD_EQ(crop) .. production(crop) =E= sum(location, area(crop, location) * yield(crop, location)); + RUMINANT_PROD_EQ .. production('ruminants') =E= meatEfficency*(sum(feed_crop, ruminantFeed(feed_crop) * cropDM(feed_crop)) + ruminantOtherFeed); + MONOGASTRICS_PROD_EQ .. production('monogastrics') =E= meatEfficency*(sum(feed_crop_less_pasture, monogastricFeed(feed_crop_less_pasture) * cropDM(feed_crop_less_pasture)) + monogastricOtherFeed); + + CROP_NET_PROD_EQ(crop) .. domesticallyProducedFoodSupply(crop) =E= production(crop) * (1 - seedAndWasteRate(crop)) - ruminantFeed(crop) - monogastricFeed(crop); + ANIMAL_NET_PROD_EQ(animal_product) .. domesticallyProducedFoodSupply(animal_product) =E= production(animal_product) * (1 - seedAndWasteRate(animal_product)); + POSITIVE_SUPPLY_CONSTRAINT(crop) .. importAmount(crop) + domesticallyProducedFoodSupply(crop) =G= 0; NON_TRADED_CONSTRAINT(non_traded) .. importAmount(non_traded) =E= 0; - RUMINANT_PROD_EQ .. netProduction('ruminants') =E= meatEfficency*(sum(feed_crop, ruminantFeed(feed_crop) * cropDM(feed_crop)) + ruminantOtherFeed) * (1 - seedAndWasteRate('ruminants')); - - MONOGASTRICS_PROD_EQ .. netProduction('monogastrics') =E= meatEfficency*(sum(feed_crop_less_pasture, monogastricFeed(feed_crop_less_pasture) * cropDM(feed_crop_less_pasture)) + monogastricOtherFeed) * (1 - seedAndWasteRate('monogastrics')); - TOTAL_NON_PASTURE_FEED_DM_CALC .. totalFeedDM =E= sum(feed_crop_less_pasture, (ruminantFeed(feed_crop_less_pasture) + monogastricFeed(feed_crop_less_pasture)) * cropDM(feed_crop_less_pasture)); - FEED_MIX_CONSTRAINT(feed_crop_less_pasture) .. (ruminantFeed(feed_crop_less_pasture) + monogastricFeed(feed_crop_less_pasture)) * cropDM(feed_crop_less_pasture) =L= totalFeedDM * 0.7; +* FEED_MIX_CONSTRAINT(feed_crop_less_pasture) .. (ruminantFeed(feed_crop_less_pasture) + monogastricFeed(feed_crop_less_pasture)) * cropDM(feed_crop_less_pasture) =L= totalFeedDM * 0.7; MAX_FERT_INTENSITY_CONSTRAINT(crop, location) .. fertI(crop, location) =L= 1; MAX_IRRIG_INTENSITY_CONSTRAINT(crop, location) .. irrigI(crop, location) =L= 1; @@ -178,9 +184,11 @@ $gdxin TOTAL_LAND_CHANGE_CONSTRAINT(location) .. suitableLandArea(location) =G= sum(crop_less_pasture, area(crop_less_pasture, location)) / (1.0 - unhandledCropRate) + area('pasture', location); SETASIDE_AREA_CALC(location) .. area('setaside', location) =E= sum(crop_less_pasture, area(crop_less_pasture, location)) * setAsideRate; - MAX_PRODUCTION_CONSTRAINT(traded_commodity) .. netProduction(traded_commodity) =L= maxProduction(traded_commodity); - MIN_PRODUCTION_CONSTRAINT(traded_commodity) .. netProduction(traded_commodity) =G= minProduction(traded_commodity); - + CROP_MAX_PROD_CONSTRAINT(crop) .. production(crop) - ruminantFeed(crop) - monogastricFeed(crop) =L= maxProduction(crop); + CROP_MIN_PROD_CONSTRAINT(crop) .. production(crop) - ruminantFeed(crop) - monogastricFeed(crop) =G= minProduction(crop); + ANIMAL_MAX_PROD_CONSTRAINT(animal_product) .. production(animal_product) =L= maxProduction(animal_product); + ANIMAL_MIN_PROD_CONSTRAINT(animal_product) .. production(animal_product) =G= minProduction(animal_product); + IRRIGATION_CONSTRAINT(location) .. irrigConstraint(location) * suitableLandArea(location) * (1.0 - unhandledCropRate) =G= sum(crop, irrigMaxRate(crop, location) * irrigI(crop, location) * area(crop, location)); AGRI_LAND_EXPANSION_CALC(location) .. agriLandExpansion(location) =G= sum(crop, area(crop, location) - previousArea(crop, location)); @@ -195,7 +203,7 @@ $gdxin PROFIT_EQ .. totalProfit =E= ( - SUM(traded_commodity, netProduction(traded_commodity) * exportPrices(traded_commodity)) - + SUM(traded_commodity, domesticallyProducedFoodSupply(traded_commodity) * exportPrices(traded_commodity)) - ( SUM((crop, location), area(crop, location) * unitCost(crop, location)) + @@ -223,7 +231,7 @@ $gdxin SOLVE LAND_USE USING NLP MAXIMIZING totalProfit; display agriLandExpansion.L, previousArea, irrigMaxRate, otherIntensity.L, fertI.L, irrigI.L, area.L, cropIncrease.L, cropDecrease.L, pastureIncrease.L, pastureDecrease.L; -* display suitableLandArea, area.l, yield.l, netProduction.l, unitCost.l, exportPrices, maxProduction, minProduction; +* display suitableLandArea, area.l, yield.l, domesticallyProducedFoodSupply.l, unitCost.l, exportPrices, maxProduction, minProduction; * Calculate summary information used in Java process parameter totalProd(all_types); @@ -232,11 +240,9 @@ $gdxin parameter totalCropland(location); parameter netImportAmount(all_types); parameter netImportCost(all_types); - -* Production quantities based on smaller area (before unhandledCropRate adjustment applied) - totalProd(crop) = sum(location, area.l(crop, location) * yield.l(crop, location)); - totalProd('ruminants') = meatEfficency*sum(feed_crop, ruminantFeed.l(feed_crop) * cropDM(feed_crop)); - totalProd('monogastrics') = meatEfficency*sum(feed_crop, monogastricFeed.l(feed_crop) * cropDM(feed_crop)); + +* Need to copy to parameter for backward compatibility + totalProd(all_types) = production.l(all_types); * Cost based on adjusted area area.l(crop_less_pasture, location) = area.l(crop_less_pasture, location) / (1.0 - unhandledCropRate); diff --git a/debug_config.properties b/debug_config.properties index cc32a5f3..ae20c5aa 100644 --- a/debug_config.properties +++ b/debug_config.properties @@ -16,4 +16,4 @@ INTERPOLATE_OUTPUT_YEARS = false CHANGE_YIELD_DATA_YEAR=false -ORIG_LEAST_COST_MIN=true \ No newline at end of file +ORIG_LEAST_COST_MIN=false \ No newline at end of file diff --git a/scripts/createScenarios.sh b/scripts/createScenarios.sh index 310d2b2d..a3dbec07 100755 --- a/scripts/createScenarios.sh +++ b/scripts/createScenarios.sh @@ -40,7 +40,6 @@ do config_file=$scenario_dir/config.properties cp $common_prop_file $config_file - echo "OUTPUT_DIR=$scenario_dir" >> $config_file for index in "${!array[@]}" do diff --git a/src/ac/ed/lurg/ModelConfig.java b/src/ac/ed/lurg/ModelConfig.java index dbe6a6ff..74b0be9d 100644 --- a/src/ac/ed/lurg/ModelConfig.java +++ b/src/ac/ed/lurg/ModelConfig.java @@ -99,7 +99,7 @@ public class ModelConfig { // Directory information public static final String BASE_DIR = getProperty("BASE_DIR"); // this must to be set in config file - public static final String OUTPUT_DIR = getProperty("OUTPUT_DIR", System.getProperty("user.dir")); + public static final String OUTPUT_DIR = getProperty("OUTPUT_DIR", "."); public static final String TEMP_DIR = getProperty("TEMP_DIR", OUTPUT_DIR + File.separator + "GamsTmp"); public static final String DATA_DIR = getProperty("DATA_DIR", BASE_DIR + File.separator + "data"); public static final String GAMS_DIR = getProperty("GAMS_DIR", BASE_DIR + File.separator + "GAMS"); @@ -228,11 +228,11 @@ public class ModelConfig { public static final double CROP_TO_PASTURE_COST_FACTOR = getDoubleProperty("CROP_TO_PASTURE_COST_FACTOR", 1.0); public static final double AGRI_LAND_EXPANSION_COST_FACTOR = getDoubleProperty("AGRI_LAND_EXPANSION_COST_FACTOR", 1.0); - public static final double CROP_INCREASE_COST = getDoubleProperty("CROP_INCREASE_COST", 0.09 * LAND_CHANGE_COST * AGRI_LAND_EXPANSION_COST_FACTOR); + public static final double CROP_INCREASE_COST = getDoubleProperty("CROP_INCREASE_COST", 0.05 * LAND_CHANGE_COST * AGRI_LAND_EXPANSION_COST_FACTOR); public static final double PASTURE_DECREASE_COST = getDoubleProperty("PASTURE_DECREASE_COST", LAND_CHANGE_COST); public static final double CROP_DECREASE_COST = getDoubleProperty("CROP_DECREASE_COST", 1.65 * LAND_CHANGE_COST); public static final double PASTURE_INCREASE_COST = getDoubleProperty("PASTURE_INCREASE_COST", 0.4 * LAND_CHANGE_COST * CROP_TO_PASTURE_COST_FACTOR * AGRI_LAND_EXPANSION_COST_FACTOR); - public static final double AGRI_EXPANSION_COST_BASE = getDoubleProperty("AGRI_EXPANSION_COST_BASE", 0.04 * LAND_CHANGE_COST * AGRI_LAND_EXPANSION_COST_FACTOR); + public static final double AGRI_EXPANSION_COST_BASE = getDoubleProperty("AGRI_EXPANSION_COST_BASE", 0.03 * LAND_CHANGE_COST * AGRI_LAND_EXPANSION_COST_FACTOR); public static final double AGRI_EXPANSION_COST_BASE_MANAGED_FOREST = getDoubleProperty("AGRI_EXPANSION_COST_BASE_MANAGED_FOREST", 0.5 * LAND_CHANGE_COST * AGRI_LAND_EXPANSION_COST_FACTOR); public static final double TECHNOLOGY_CHANGE_ANNUAL_RATE = getDoubleProperty("TECHNOLOGY_CHANGE_ANNUAL_RATE", 0.002); -- GitLab