diff --git a/GAMS/IntExtOpt.gms b/GAMS/IntExtOpt.gms index 6fa323208f6f10dfe2f96a60399a0cba23bc91d0..2d60e4d3272f60f5edcdcb685077ca364981fadf 100644 --- a/GAMS/IntExtOpt.gms +++ b/GAMS/IntExtOpt.gms @@ -1,9 +1,9 @@ - SET all_types / monogastrics, ruminants, cereals, wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops, pasture, setaside /; + SET all_types / monogastrics, ruminants, cereals, oilcropspulses, wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops, pasture, setaside /; SET crop(all_types) / wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops, pasture, setaside /; SET crop_less_pasture(crop) / wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops, setaside/; SET cereal_crop(crop) / wheat, maize, rice /; - SET non_cereal_crop(crop) / oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops, pasture, setaside /; + SET oilpulse_crop(crop) / oilcrops, pulses /; SET feed_crop(crop) / wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, pasture/; SET feed_crop_less_pasture(feed_crop) / wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg /; SET import_crop(all_types) / monogastrics, ruminants, wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops /; @@ -33,6 +33,7 @@ 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 minDemandPerCereal(cereal_crop) min demand for each cereal crop as factor of all cereals; + PARAMETER minDemandPerOilcrop(oilpulse_crop) min demand for oilcrop pulses as factor of total; PARAMETER seedAndWasteRate(all_types) rate of use for seed and waste combined; PARAMETER subsidyRate(crop) rates of subsidy compared to costs; @@ -58,7 +59,7 @@ $load location, suitableLandArea, demand, agriExpansionCost, cropIncCost, pastur $load previousArea, previousFertIntensity, previousIrrigIntensity, previousOtherIntensity, previousRuminantFeed, previousMonogastricFeed, previousImportAmount, previousExportAmount $load yieldNone, yieldFertOnly, yieldIrrigOnly, yieldBoth $load fertParam, irrigParam, otherIParam, exportPrices, importPrices, maxNetImport, minNetImport, unhandledCropRate, setAsideRate, maxLandExpansionRate, subsidyRate -$load meatEfficency, otherICost, irrigCost, irrigMaxRate, irrigConstraint, fertiliserUnitCost, domesticPriceMarkup, minDemandPerCereal, seedAndWasteRate, animalFeedFromOtherSources +$load meatEfficency, otherICost, irrigCost, irrigMaxRate, irrigConstraint, fertiliserUnitCost, domesticPriceMarkup, minDemandPerCereal, minDemandPerOilcrop, seedAndWasteRate, animalFeedFromOtherSources $gdxin SCALAR delta use to smooth power function see 7.5 www.gams.com dd docs solversconopt.pdf / 0.00000000001 /; @@ -67,6 +68,8 @@ $gdxin SCALAR monogastricOtherFeed; ruminantOtherFeed = animalFeedFromOtherSources * 0.25; monogastricOtherFeed = animalFeedFromOtherSources * 0.75; + demand(cereal_crop) = demand('cereals') * minDemandPerCereal(cereal_crop); + demand(oilpulse_crop) = demand('oilcropspulses') * minDemandPerOilcrop(oilpulse_crop); previousArea(crop_less_pasture, location) = previousArea(crop_less_pasture, location) * (1.0 - unhandledCropRate); @@ -125,9 +128,9 @@ $gdxin EQUATIONS 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 - TOTAL_CEREAL_DEMAND_CONSTRAINT satisfy demand for cereal + CROP_DEMAND_CONSTRAINT(crop) satisfy demand for individual crops + TOTAL_CEREAL_DEMAND_CONSTRAINT satisfy demand for combined cereals + TOTAL_OIL_PULSE_DEMAND_CONSTRAINT satisfy demand for combined oilcrops and pulses RUMINANT_DEMAND_CONSTRAINT satisfy demand for ruminant products MONOGASTRICS_DEMAND_CONSTRAINT satisfy demand for monogastric products TOTAL_NON_PASTURE_FEED_DM_CALC calc total feed dry matter not including pasture @@ -168,12 +171,12 @@ $gdxin NET_SUPPLY_EQ(crop) .. net_supply(crop) =E= sum(location, area(crop, location) * yield(crop, location)) * (1 - seedAndWasteRate(crop)) - ruminantFeed(crop) - monogastricFeed(crop) + importAmount(crop) - exportAmount(crop); - NON_CEREAL_DEMAND_CONSTRAINT(non_cereal_crop) .. net_supply(non_cereal_crop) =G= demand(non_cereal_crop); - - CEREAL_DEMAND_CONSTRAINT(cereal_crop) .. net_supply(cereal_crop) =G= demand('cereals') * minDemandPerCereal(cereal_crop); - + CROP_DEMAND_CONSTRAINT(crop) .. net_supply(crop) =G= demand(crop); + TOTAL_CEREAL_DEMAND_CONSTRAINT .. sum(cereal_crop, net_supply(cereal_crop)) =G= demand('cereals'); + TOTAL_OIL_PULSE_DEMAND_CONSTRAINT .. sum(oilpulse_crop, net_supply(oilpulse_crop)) =G= demand('oilcropspulses'); + RUMINANT_DEMAND_CONSTRAINT .. meatEfficency*(sum(feed_crop, ruminantFeed(feed_crop) * cropDM(feed_crop)) + ruminantOtherFeed) * (1 - seedAndWasteRate('ruminants')) =G= (demand('ruminants') - importAmount('ruminants') + exportAmount('ruminants')); MONOGASTRICS_DEMAND_CONSTRAINT .. meatEfficency*(sum(feed_crop_less_pasture, monogastricFeed(feed_crop_less_pasture) * cropDM(feed_crop_less_pasture)) + monogastricOtherFeed) * (1 - seedAndWasteRate('monogastrics')) =G= (demand('monogastrics') - importAmount('monogastrics') + exportAmount('monogastrics')); diff --git a/GAMS/LUOpt.gms b/GAMS/LUOpt.gms index e3af85e3fefd82e4aa8db4c66dc3311e5442668c..093759502bf4913dbd16ad4e127f6d208a742805 100644 --- a/GAMS/LUOpt.gms +++ b/GAMS/LUOpt.gms @@ -1,16 +1,12 @@ - SET all_types / monogastrics, ruminants, cereals, oilcropspulses, wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops, pasture, setaside /; + SET all_types / monogastrics, ruminants, cereals, oilcropspulses, wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops, pasture, setaside /; + SET crop(all_types) / wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops, pasture, setaside /; + SET crop_less_pasture(crop) / wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops, setaside/; + SET cereal_crop(crop) / wheat, maize, rice /; + SET oilpulse_crop(crop) / oilcrops, pulses /; + SET feed_crop(crop) / wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, pasture/; + SET feed_crop_less_pasture(feed_crop) / wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg /; + SET traded_commodity(all_types) / monogastrics, ruminants, wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops /; - SET crop(all_types) / wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops, pasture, setaside /; - SET crop_less_pasture(crop) / wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops, setaside/; - SET feed_crop(crop) / wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, pasture/; - SET feed_crop_less_pasture(feed_crop) / wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg /; - SET traded_commodity(all_types) / monogastrics, ruminants, wheat, maize, rice, oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops /; - SET non_traded(all_types) / cereals, oilcropspulses, pasture, setaside /; - SET animal_product(all_types) / monogastrics, ruminants /; - - SET cereal_crop(crop) / wheat, maize, rice /; - SET oilcrop_crop(crop) / oilcrops, pulses /; - SET non_cereal_crop(crop) / oilcrops, pulses, starchyRoots, fruitveg, sugar, energycrops, pasture /; SET location; PARAMETER suitableLandArea(location) areas of land in Mha; PARAMETER previousArea(crop, location) areas for previous timestep in Mha; @@ -36,7 +32,7 @@ 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 minDemandPerCereal(cereal_crop) min demand for each cereal crop as factor of all cereals; - PARAMETER minDemandPerOilcrop(oilcrop_crop) min demand for each oilcrop and pulse crop as factor of all oilcrops and pulses; + PARAMETER minDemandPerOilcrop(oilpulse_crop) min demand for each oilcrop and pulse crop as factor of all oilcrops and pulses; PARAMETER seedAndWasteRate(all_types) rate of use for seed and waste combined; PARAMETER subsidyRate(crop) rates of subsidy compared to costs; @@ -73,7 +69,7 @@ $gdxin ruminantOtherFeed = animalFeedFromOtherSources * 0.25; monogastricOtherFeed = animalFeedFromOtherSources * 0.75; demand(cereal_crop) = demand('cereals') * minDemandPerCereal(cereal_crop); - demand(oilcrop_crop) = demand('oilcropspulses') * minDemandPerOilcrop(oilcrop_crop); + demand(oilpulse_crop) = demand('oilcropspulses') * minDemandPerOilcrop(oilpulse_crop); previousArea(crop_less_pasture, location) = previousArea(crop_less_pasture, location) * (1.0 - unhandledCropRate); @@ -111,12 +107,12 @@ $gdxin fertI(crop, location) fertilizer intensity for each crop - factor between 0 and 1 irrigI(crop, location) irrigation intensity for each crop - factor between 0 and 1 otherIntensity(crop, location) - ruminantFeed(all_types) amount of feed for ruminant animals - Mt - monogastricFeed(all_types) amount of feed for monogatric animals - Mt - export(traded_commodity) amount of commodities exported - import(all_types) amount of commodities import - netFoodSupply(all_types) net supply in a country for food - Mt - domesticallyMetDemand(traded_commodity) amount domestically produced and consumed as food - Mt + ruminantFeed(crop) amount of feed for ruminant animals - Mt + monogastricFeed(crop) amount of feed for monogatric animals - Mt + exportAmount(all_types) exports of crops and meat - Mt + importAmount(all_types) imports of crops and meat - Mt + net_supply(all_types) supply after imports exports and feed - Mt + domesticallyMetDemand(traded_commodity) amount domestically produced and consumed as food - 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 @@ -124,25 +120,24 @@ $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, production, - agriLandExpansion, cropIncrease, cropDecrease, pastureDecrease, pastureIncrease, totalFeedDM, - export, import, netFoodSupply, domesticallyMetDemand; + POSITIVE VARIABLE area, fertI, irrigI, otherIntensity, ruminantFeed, monogastricFeed, importAmount, exportAmount, net_supply, + agriLandExpansion, cropIncrease, cropDecrease, pastureDecrease, pastureIncrease, totalFeedDM, domesticallyMetDemand; EQUATIONS UNIT_COST_EQ(crop, location) cost per area YIELD_EQ(crop, location) yield given chosen intensity - DOMESTICALLY_MET_DEMAND_CONSTRAINT1(traded_commodity) constraint on commodity produced and consumed domestically - DOMESTICALLY_MET_DEMAND_CONSTRAINT2(traded_commodity) constraint on commodity produced and consumed domestically - EXPORT_CALC(traded_commodity) calc exports for each traded commodity - IMPORT_CALC(traded_commodity) calc imports for each traded commodity - CROP_PROD_EQ(crop) calc total production for crops - RUMINANT_PROD_EQ production of ruminant - MONOGASTRICS_PROD_EQ production of monogastric - NET_FOOD_SUPPLY_EQ(all_types) calc net production for crops + CROP_NET_SUPPLY_EQ(crop) calc net supply for crops + RUMINANT_NET_SUPPLY calc net supply for ruminant products + MONOGASTRICS_NET_SUPPLY calc net supply for monogastric products + TOTAL_CEREAL_NET_SUPPLY calc net supply for combined cereals + TOTAL_OIL_PULSE_NET_SUPPLY calc net supply for combined oilcrops and pulses + DEMAND_CONSTRAINT(all_types) satisfy demand + PASTURE_IMPORT_CONSTRAINT constraint to not import pasture + DOMESTICALLY_MET_DEMAND_CONSTRAINT1(traded_commodity) constraint to determine commodity produced and consumed domestically + DOMESTICALLY_MET_DEMAND_CONSTRAINT2(traded_commodity) constraint to determine commodity produced and consumed domestically 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 MAX_FERT_INTENSITY_CONSTRAINT(crop, location) constraint on maximum fertilizer intensity @@ -160,7 +155,6 @@ $gdxin PASTURE_DECREASE_CONV_CALC(location) PASTURE_TOTAL_CHANGE_CONSTRAINT(location) LAND_RATE_CHANGE_CONSTRAINT_INCREASE - PASTURE_FEED_CONSTRAINT PROFIT_EQ total profit objective function; UNIT_COST_EQ(crop, location) .. unitCost(crop, location) =E= ( baseCost(crop) + @@ -176,22 +170,32 @@ $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))) ) * (1 - exp(-otherIntensity(crop, location)*otherIParam)); + + CROP_NET_SUPPLY_EQ(crop) .. net_supply(crop) =E= sum(location, area(crop, location) * yield(crop, location)) * (1 - seedAndWasteRate(crop)) - + ruminantFeed(crop) - monogastricFeed(crop) + importAmount(crop) - exportAmount(crop); + + RUMINANT_NET_SUPPLY .. net_supply('ruminants') =E= + meatEfficency*(sum(feed_crop, ruminantFeed(feed_crop) * cropDM(feed_crop)) + ruminantOtherFeed) * (1 - seedAndWasteRate('ruminants')) + + importAmount('ruminants') - exportAmount('ruminants'); + + MONOGASTRICS_NET_SUPPLY .. net_supply('monogastrics') =E= + meatEfficency*(sum(feed_crop_less_pasture, monogastricFeed(feed_crop_less_pasture) * cropDM(feed_crop_less_pasture)) + monogastricOtherFeed) * (1 - seedAndWasteRate('monogastrics')) + + importAmount('monogastrics') - exportAmount('monogastrics'); - CROP_PROD_EQ(crop) .. production(crop) =E= sum(location, area(crop, location) * yield(crop, location)); - RUMINANT_PROD_EQ .. production('ruminants') =L= meatEfficency*(sum(feed_crop, ruminantFeed(feed_crop) * cropDM(feed_crop)) + ruminantOtherFeed); - MONOGASTRICS_PROD_EQ .. production('monogastrics') =L= meatEfficency*(sum(feed_crop_less_pasture, monogastricFeed(feed_crop_less_pasture) * cropDM(feed_crop_less_pasture)) + monogastricOtherFeed); - - NET_FOOD_SUPPLY_EQ(all_types) .. netFoodSupply(all_types) =E= production(all_types) * (1 - seedAndWasteRate(all_types)) - ruminantFeed(all_types) - monogastricFeed(all_types) + import(all_types); + TOTAL_CEREAL_NET_SUPPLY .. net_supply('cereals') =E= sum(cereal_crop, net_supply(cereal_crop)); -* This set of 4 equations used to divide commodities between domestic produced/consumed valued at import prices and those for export valued at export prices - DOMESTICALLY_MET_DEMAND_CONSTRAINT1(traded_commodity) .. domesticallyMetDemand(traded_commodity) =L= netFoodSupply(traded_commodity); - DOMESTICALLY_MET_DEMAND_CONSTRAINT2(traded_commodity) .. domesticallyMetDemand(traded_commodity) =L= demand(traded_commodity); - EXPORT_CALC(traded_commodity) .. export(traded_commodity) =L= netFoodSupply(traded_commodity) - domesticallyMetDemand(traded_commodity); - IMPORT_CALC(traded_commodity) .. netFoodSupply(traded_commodity) =G= demand(traded_commodity); + TOTAL_OIL_PULSE_NET_SUPPLY .. net_supply('oilcropspulses') =E= sum(oilpulse_crop, net_supply(oilpulse_crop)); + + DEMAND_CONSTRAINT(all_types) .. net_supply(all_types) =G= demand(all_types); + + PASTURE_IMPORT_CONSTRAINT .. importAmount('pasture') =E= 0; + DOMESTICALLY_MET_DEMAND_CONSTRAINT1(traded_commodity) .. domesticallyMetDemand(traded_commodity) =L= net_supply(traded_commodity) - importAmount(traded_commodity) + exportAmount(traded_commodity); + DOMESTICALLY_MET_DEMAND_CONSTRAINT2(traded_commodity) .. domesticallyMetDemand(traded_commodity) =L= demand(traded_commodity); + 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.6; - + 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; MAX_OTHER_INTENSITY_CONSTRAINT(crop, location) .. otherIntensity(crop, location) =L= 1; @@ -199,11 +203,9 @@ $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; - PASTURE_FEED_CONSTRAINT .. production('pasture') =G= ruminantFeed('pasture'); + MAX_NET_IMPORT_CONSTRAINT(traded_commodity) .. importAmount(traded_commodity) - exportAmount(traded_commodity) =L= maxNetImport(traded_commodity); + MIN_NET_IMPORT_CONSTRAINT(traded_commodity) .. importAmount(traded_commodity) - exportAmount(traded_commodity) =G= minNetImport(traded_commodity); - MAX_NET_IMPORT_CONSTRAINT(traded_commodity) .. import(traded_commodity) - export(traded_commodity) =L= maxNetImport(traded_commodity); - MIN_NET_IMPORT_CONSTRAINT(traded_commodity) .. import(traded_commodity) - export(traded_commodity) =G= minNetImport(traded_commodity); - 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)); @@ -218,7 +220,7 @@ $gdxin PROFIT_EQ .. totalProfit =E= ( - SUM(traded_commodity, domesticallyMetDemand(traded_commodity) * importPrices(traded_commodity) + export(traded_commodity) * exportPrices(traded_commodity)) - + SUM(traded_commodity, domesticallyMetDemand(traded_commodity) * importPrices(traded_commodity) + exportAmount(traded_commodity) * exportPrices(traded_commodity)) - ( SUM((crop, location), area(crop, location) * unitCost(crop, location) * (1-subsidyRate(crop))) + @@ -231,7 +233,7 @@ $gdxin ) ) - - SUM(traded_commodity, import(traded_commodity) * importPrices(traded_commodity)) + - SUM(traded_commodity, importAmount(traded_commodity) * importPrices(traded_commodity)) ); MODEL LAND_USE /ALL/ ; @@ -241,15 +243,13 @@ $gdxin area.L(crop, location) = previousArea(crop, location); ruminantFeed.L(feed_crop) = previousRuminantFeed(feed_crop); monogastricFeed.L(feed_crop) = previousMonogastricFeed(feed_crop); - import.L(traded_commodity) = previousImportAmount(traded_commodity); - export.L(traded_commodity) = previousExportAmount(traded_commodity); + importAmount.L(all_types) = previousImportAmount(all_types); + exportAmount.L(all_types) = previousExportAmount(all_types); 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, unitCost.l, exportPrices; - display netFoodSupply.l, demand, domesticallyMetDemand.l; - display export.l, import.l, production.l, maxNetImport, minNetImport; + display agriLandExpansion.L, previousArea, irrigMaxRate, otherIntensity.L, fertI.L, irrigI.L, area.L, cropIncrease.L, cropDecrease.L, pastureIncrease.L, pastureDecrease.L; + display domesticallyMetDemand.l, net_supply.l, demand, ruminantFeed.l, monogastricFeed.l, importAmount.l, exportAmount.l; * Calculate summary information used in Java process @@ -259,17 +259,26 @@ $gdxin parameter totalCropland(location); parameter netImportAmount(all_types); parameter netImportCost(all_types); - -* Need to copy to parameter for backward compatibility - totalProd(all_types) = production.l(all_types); + parameter feedCostRate(feed_crop); + +* Production quantities based on smaller area (before unhandledCropArea 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)) + ruminantOtherFeed); + totalProd('monogastrics') = meatEfficency*(sum(feed_crop, monogastricFeed.l(feed_crop) * cropDM(feed_crop)) + monogastricOtherFeed); * Cost based on adjusted area area.l(crop_less_pasture, location) = area.l(crop_less_pasture, location) / (1.0 - unhandledCropRate); totalProdCost(crop) = sum(location, unitCost.l(crop, location) * area.l(crop, location)); totalCropland(location) = sum(crop_less_pasture, area.l(crop_less_pasture, location)); totalArea(crop) = sum(location, area.l(crop, location)); - netImportAmount(traded_commodity) = import.l(traded_commodity) - export.l(traded_commodity); + feedCostRate(feed_crop)$[totalProd(feed_crop) <> 0] = totalProdCost(feed_crop) / totalProd(feed_crop); + totalProdCost('ruminants') = sum(feed_crop, ruminantFeed.l(feed_crop) * feedCostRate(feed_crop)); + totalProdCost('monogastrics') = sum(feed_crop, monogastricFeed.l(feed_crop) * feedCostRate(feed_crop)); + + netImportCost(traded_commodity) = importAmount.l(traded_commodity) * importPrices(traded_commodity) - exportAmount.l(traded_commodity) * exportPrices(traded_commodity); + netImportAmount(traded_commodity) = importAmount.l(traded_commodity) - exportAmount.l(traded_commodity); + Scalar ms 'model status', ss 'solve status'; ms=LAND_USE.modelstat; ss=LAND_USE.solvestat; diff --git a/src/ac/ed/lurg/ModelConfig.java b/src/ac/ed/lurg/ModelConfig.java index a24ef1400cd3df15f7e099180072b7fe1652ed41..203e288d6f089a14ee31dbeba1943c2da6a01fbd 100755 --- a/src/ac/ed/lurg/ModelConfig.java +++ b/src/ac/ed/lurg/ModelConfig.java @@ -144,7 +144,7 @@ public class ModelConfig { public static final boolean CLEANUP_GAMS_DIR = getBooleanProperty("CLEANUP_GAMS_DIR", false); public static final boolean ORIG_LEAST_COST_MIN = getBooleanProperty("ORIG_LEAST_COST_MIN", false); - public static final String GAMS_MODEL_NAME = ORIG_LEAST_COST_MIN==true ? "IntExtOpt.gms" : "LUOpt.gms"; + public static final String GAMS_MODEL_NAME = getProperty("GAMS_MODEL_NAME", ORIG_LEAST_COST_MIN==true ? "IntExtOpt.gms" : "LUOpt.gms"); public static final String GAMS_MODEL = getProperty("GAMS_MODEL", GAMS_DIR + File.separator + GAMS_MODEL_NAME); public static final String DEMAND_GAMS_MODEL = getProperty("DEMAND_GAMS_MODEL", GAMS_DIR + File.separator + "elasticDemand.gms"); public static final String DEMAND_PARAM_FILE = getProperty("DEMAND_PARAM_FILE", DATA_DIR + File.separator + "DemandParamConv.gdx"); diff --git a/src/ac/ed/lurg/country/CountryAgent.java b/src/ac/ed/lurg/country/CountryAgent.java index 0d1294cd92a46e4b053a96095d97ddc2c818f916..1ef4d75d347aedcdaac16bb45c8848a633665c8b 100644 --- a/src/ac/ed/lurg/country/CountryAgent.java +++ b/src/ac/ed/lurg/country/CountryAgent.java @@ -137,10 +137,11 @@ public class CountryAgent extends AbstractCountryAgent { GamsRasterOutput result = opti.run(); - if (!ModelConfig.ORIG_LEAST_COST_MIN) { - GamsCountryInput countryInput = input.getCountryInput(); - updateNetImportsFromProdAndDemand(countryInput.getProjectedDemand(), countryInput.getMinDemandFractions(), result.getCropUsageData()); - } + // No longer need this as even profit max calcs imports in GAMS now + // if (!ModelConfig.ORIG_LEAST_COST_MIN) { + // GamsCountryInput countryInput = input.getCountryInput(); + // updateNetImportsFromProdAndDemand(countryInput.getProjectedDemand(), countryInput.getMinDemandFractions(), result.getCropUsageData()); + // } if (saveGamsGdxFiles) saveGDXFile("landuse"); @@ -198,10 +199,7 @@ public class CountryAgent extends AbstractCountryAgent { baseTrade = 0.0; ecMaxExport = 0.0; } - if (ModelConfig.ORIG_LEAST_COST_MIN) - changeDown = ecMaxExport; - else - changeUp = ecMaxExport; + changeDown = ecMaxExport; if (Double.isNaN(baseTrade)) baseTrade=0; diff --git a/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java b/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java index 51c36dbfd106132cb8bd1dd6a38102940b1fecc8..dfd245c294d12c03654f0105b90532901eb200ac 100644 --- a/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java +++ b/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java @@ -357,12 +357,6 @@ public class GamsLocationOptimiser { GAMSParameter parmCroplandArea = outDB.getParameter("totalCropland"); GAMSParameter parmTotalArea = outDB.getParameter("totalArea"); - if (ModelConfig.ORIG_LEAST_COST_MIN) { - GAMSVariable varTotalCost = outDB.getVariable("total_cost"); - GAMSParameter varTotalCostLessLU = outDB.getParameter("totalCostsLessLU"); - LogWriter.println("total cost " + varTotalCost.getFirstRecord().getLevel() + " total cost less LU " + varTotalCostLessLU.findRecord().getValue()); - } - double totalCropArea = 0; double totalPastureArea = 0; double area, fertIntensity, irrigIntensity, otherIntensity = Double.NaN, ruminantFeed, monogastricFeed, netImport, netImportCost, yield, unitCost, prod, prodCost;