From df1d41413a3c5eb42d2eef36cd8527e15606dc6b Mon Sep 17 00:00:00 2001
From: Peter Alexander <peter@blackhillock.co.uk>
Date: Fri, 5 Dec 2014 15:32:10 +0000
Subject: [PATCH] no message

---
 GAMS/IntExtOpt.gms                            | 47 ++++++++++---------
 src/ac/ed/lurg/country/CountryAgent.java      | 12 ++---
 .../ed/lurg/country/gams/GamsInputData.java   | 12 ++---
 .../country/gams/GamsLandUseOptimiser.java    | 28 +++++------
 src/ac/ed/lurg/country/gams/GamsTest.java     | 14 +++---
 5 files changed, 58 insertions(+), 55 deletions(-)

diff --git a/GAMS/IntExtOpt.gms b/GAMS/IntExtOpt.gms
index 7b75fba9..587cae08 100644
--- a/GAMS/IntExtOpt.gms
+++ b/GAMS/IntExtOpt.gms
@@ -5,31 +5,29 @@
  SET not_feed_crops(crop)  / fruits, starchyRoots, treenuts, vegetables, pulses, pasture_or_meat /;
  SET location / 1*1 /;    
      
- PARAMETER previous_area(crop, location)       areas for previous timestep in ha;
- PARAMETER yield00(crop, location)             yield in t per ha;
- PARAMETER yield10(crop, location)             yield in t per ha;
- PARAMETER yield01(crop, location)             yield in t per ha;
- PARAMETER yield11(crop, location)             yield in t per ha;
- PARAMETER demand(crop)              in t;
- PARAMETER world_input_energy(crop)  average input energy from world exports used to determine if we should import or export;
- PARAMETER maxNetImport(crop)        maximum net import for each crop based on world market;
- PARAMETER minNetImport(crop)        minimum net import for each crop based on world market;
+ PARAMETER previous_area(crop, location)     areas for previous timestep in ha;
+ PARAMETER yieldNone(crop, location)         yield in t per ha;
+ PARAMETER yieldFertOnly(crop, location)     yield in t per ha;
+ PARAMETER yieldIrrigOnly(crop, location)    yield in t per ha;
+ PARAMETER yieldBoth(crop, location)         yield in t per ha;
+ PARAMETER demand(crop)                      in t;
+ PARAMETER world_input_energy(crop)          average input energy from world exports used to determine if we should import or export;
+ PARAMETER maxNetImport(crop)                maximum net import for each crop based on world market;
+ PARAMETER minNetImport(crop)                minimum net import for each crop based on world market;
  
  SCALAR meatEfficency                efficiency of converting feed and pasture into animal products;
  SCALAR maxLandUseChange             max rate of land use change;
  SCALAR tradeBarrier                 trade barrier which adjust energy cost of imports;
  SCALAR landChangeEnergy             energy required to add ha of agricultural land;
  SCALAR minFeedRate                  minimum rate of feed for producing animal products;
- SCALAR alpha                        yield response to fertilizer parameter;
- SCALAR beta                         yield response to irrigation parameter;
+ SCALAR fertParam                    yield response to fertilizer parameter;
+ SCALAR irrigParam                   yield response to irrigation parameter;
  
 $gdxin %gdxincname%
-$load previous_area, demand, yield00, yield10, yield01, yield11, alpha, beta, world_input_energy, maxNetImport, minNetImport, meatEfficency, maxLandUseChange, tradeBarrier, landChangeEnergy, minFeedRate
+$load previous_area, demand, yieldNone, yieldFertOnly, yieldIrrigOnly, yieldBoth, fertParam, irrigParam, world_input_energy, maxNetImport, minNetImport, meatEfficency, maxLandUseChange, tradeBarrier, landChangeEnergy, minFeedRate
 $gdxin
-
-DISPLAY yield00, yield10, yield01, yield11
   
- SCALAR delta use to smooth power function see 7.5 www.gams.com dd docs solversconopt.pdf / 0.000000001 /  
+ SCALAR delta use to smooth power function see 7.5 www.gams.com dd docs solversconopt.pdf / 0.00000000001 /  
  
  PARAMETER feedEnergy(crop) energy from feed in MJ per t
          /    cereals          13.7
@@ -75,12 +73,19 @@ DISPLAY yield00, yield10, yield01, yield11
             sqr(fertI(crop, location)+irrigI(crop, location)+otherIntensity(crop, location)) / 2;
  
  YIELD_EQ(crop, location) .. yield(crop, location) =E= (
-               yield00(crop, location) + 
-               (yield10(crop, location) - yield00(crop, location)) * ((fertI(crop, location) + delta) ** alpha) +
-               (yield10(crop, location) - yield00(crop, location)) * ((irrigI(crop, location) + delta) ** beta) +
-               (yield11(crop, location) + yield00(crop, location) - yield10(crop, location) - yield01(crop, location)) * ((fertI(crop, location) + delta) ** alpha) * ((irrigI(crop, location) + delta) ** beta)
+               yieldNone(crop, location) + 
+               (yieldFertOnly(crop, location) - yieldNone(crop, location)) * ((fertI(crop, location) + delta) ** fertParam) +
+               (yieldIrrigOnly(crop, location) - yieldNone(crop, location)) * ((irrigI(crop, location) + delta) ** irrigParam) +
+               (yieldBoth(crop, location) + yieldNone(crop, location) - yieldFertOnly(crop, location) - yieldIrrigOnly(crop, location)) * ((fertI(crop, location) + delta) ** fertParam) * ((irrigI(crop, location) + delta) ** irrigParam)
             ) * otherIntensity(crop, location);
  
+*  YIELD_EQ(crop, location) .. yield(crop, location) =E= (
+*               yieldNone(crop, location) + 
+*               (yieldFertOnly(crop, location) - yieldNone(crop, location)) * (1 - exp(-10*fertI(crop, location)) +
+*               (yieldIrrigOnly(crop, location) - yieldNone(crop, location)) * (1 - exp(-5*irrigI(crop, location)) +
+*               (yieldBoth(crop, location) + yieldNone(crop, location) - yieldFertOnly(crop, location) - yieldIrrigOnly(crop, location)) * (1 - exp(-fertParam*fertI(crop, location))) * (1 - exp(-irrigParam*irrigI(crop, location)))
+*            ) * otherIntensity(crop, location);
+ 
  CROP_DEMAND_CONSTRAINT(crop_less_pasture) .. sum(location, area(crop_less_pasture, location) * yield(crop_less_pasture, location)) - feedAmount(crop_less_pasture) =G= 
             demand(crop_less_pasture) - netImportAmount(crop_less_pasture);
  
@@ -113,9 +118,7 @@ DISPLAY yield00, yield10, yield01, yield11
  
  MODEL LAND_USE /ALL/ ;
  SOLVE LAND_USE USING NLP MINIMIZING energy;
- 
- DISPLAY yield00, yield10, yield01, yield11
- 
+  
  Scalar ms 'model status', ss 'solve status'; 
  ms=LAND_USE.modelstat;
  ss=LAND_USE.solvestat;
diff --git a/src/ac/ed/lurg/country/CountryAgent.java b/src/ac/ed/lurg/country/CountryAgent.java
index ebc1d8e8..b86a7590 100644
--- a/src/ac/ed/lurg/country/CountryAgent.java
+++ b/src/ac/ed/lurg/country/CountryAgent.java
@@ -69,32 +69,32 @@ public class CountryAgent implements GamsInputData {
 	}
 
 	@Override
-	public Map<CropType, Double> getYield00() {
+	public Map<CropType, Double> getYieldNone() {
 		return currentRefYield;
 	}
 
 	@Override
-	public Map<CropType, Double> getYield10() {
+	public Map<CropType, Double> getYieldFertOnly() {
 		return currentRefYield;
 	}
 	
 	@Override
-	public Map<CropType, Double> getYield01() {
+	public Map<CropType, Double> getYieldIrrigOnly() {
 		return currentRefYield;
 	}
 	
 	@Override
-	public Map<CropType, Double> getYield11() {
+	public Map<CropType, Double> getYieldBoth() {
 		return currentRefYield;
 	}
 	
 	@Override
-	public double getAlpha() {
+	public double getFertParam() {
 		return 0.4;
 	}
 
 	@Override
-	public double getBeta() {
+	public double getIrrigParam() {
 		return 0.5;
 	}
 
diff --git a/src/ac/ed/lurg/country/gams/GamsInputData.java b/src/ac/ed/lurg/country/gams/GamsInputData.java
index bd87cc7d..80ac380a 100644
--- a/src/ac/ed/lurg/country/gams/GamsInputData.java
+++ b/src/ac/ed/lurg/country/gams/GamsInputData.java
@@ -7,10 +7,10 @@ import ac.ed.lurg.types.CropType;
 public interface GamsInputData {
 
 	Map<CropType, Double> getProjectedDemand();
-	Map<CropType, Double> getYield00();
-	Map<CropType, Double> getYield10();
-	Map<CropType, Double> getYield01();
-	Map<CropType, Double> getYield11();
+	Map<CropType, Double> getYieldNone();
+	Map<CropType, Double> getYieldFertOnly();
+	Map<CropType, Double> getYieldIrrigOnly();
+	Map<CropType, Double> getYieldBoth();
 	Map<CropType, Double> getPreviousCropArea();
 	Map<CropType, Double> getWorldInputEnergy();
 	Map<CropType, Double> getMaxNetImport();
@@ -21,7 +21,7 @@ public interface GamsInputData {
 	double getTradeBarrier();
 	double getLandChangeEnergy();
 	double getMinFeedRate();
-	double getAlpha();
-	double getBeta();
+	double getFertParam();
+	double getIrrigParam();
 
 }
diff --git a/src/ac/ed/lurg/country/gams/GamsLandUseOptimiser.java b/src/ac/ed/lurg/country/gams/GamsLandUseOptimiser.java
index db8587c9..ab4ae9ef 100644
--- a/src/ac/ed/lurg/country/gams/GamsLandUseOptimiser.java
+++ b/src/ac/ed/lurg/country/gams/GamsLandUseOptimiser.java
@@ -50,25 +50,25 @@ public class GamsLandUseOptimiser {
 		parm = db.addParameter("demand", 1, "demand for crop");
 		addItemMapParm(parm, inputData.getProjectedDemand());
 
-		LogWriter.println("\nYield");
-		parm = db.addParameter("yield00", 2, "ref yield t per ha");
+		LogWriter.println("\nYieldNone");
+		parm = db.addParameter("yieldNone", 2, "ref yield t per ha");
 		for (int i= 1; i<=numLocations; i++)
-			addLocationMapParm(parm, inputData.getYield00(), i);
+			addLocationMapParm(parm, inputData.getYieldNone(), i);
 
-		LogWriter.println("\nYield");
-		parm = db.addParameter("yield10", 2, "ref yield t per ha");
+		LogWriter.println("\nYieldFertOnly");
+		parm = db.addParameter("yieldFertOnly", 2, "ref yield t per ha");
 		for (int i= 1; i<=numLocations; i++)
-			addLocationMapParm(parm, inputData.getYield10(), i);
+			addLocationMapParm(parm, inputData.getYieldFertOnly(), i);
 
-		LogWriter.println("\nYield");
-		parm = db.addParameter("yield01", 2, "ref yield t per ha");
+		LogWriter.println("\nYyieldIrrigOnly");
+		parm = db.addParameter("yieldIrrigOnly", 2, "ref yield t per ha");
 		for (int i= 1; i<=numLocations; i++)
-			addLocationMapParm(parm, inputData.getYield01(), i);
+			addLocationMapParm(parm, inputData.getYieldIrrigOnly(), i);
 
-		LogWriter.println("\nYield");
-		parm = db.addParameter("yield11", 2, "ref yield t per ha");
+		LogWriter.println("\nYieldBoth");
+		parm = db.addParameter("yieldBoth", 2, "ref yield t per ha");
 		for (int i= 1; i<=numLocations; i++)
-			addLocationMapParm(parm, inputData.getYield11(), i);
+			addLocationMapParm(parm, inputData.getYieldBoth(), i);
 
 		LogWriter.println("\nWorld input energy");
 		parm = db.addParameter("world_input_energy", 1, "average input energy from world exports used to determine if we should import or export energy per t");
@@ -87,8 +87,8 @@ public class GamsLandUseOptimiser {
 		addScalar(db.addParameter("tradeBarrier", 0, "trade barrier which adjust energy cost of imports"), inputData.getTradeBarrier());
 		addScalar(db.addParameter("landChangeEnergy", 0, "energy required to add ha of agricultural land"), inputData.getLandChangeEnergy());
 		addScalar(db.addParameter("minFeedRate", 0, "minimum rate of feed for producing animal products"), inputData.getMinFeedRate());
-		addScalar(db.addParameter("alpha", 0), inputData.getAlpha());
-		addScalar(db.addParameter("beta", 0), inputData.getBeta());
+		addScalar(db.addParameter("fertParam", 0), inputData.getFertParam());
+		addScalar(db.addParameter("irrigParam", 0), inputData.getIrrigParam());
 
 		GAMSJob gamsJob = ws.addJobFromFile(ModelConfig.GAMS_MODEL);
 		GAMSOptions opt = ws.addOptions();
diff --git a/src/ac/ed/lurg/country/gams/GamsTest.java b/src/ac/ed/lurg/country/gams/GamsTest.java
index 7a2ed062..a28d2411 100644
--- a/src/ac/ed/lurg/country/gams/GamsTest.java
+++ b/src/ac/ed/lurg/country/gams/GamsTest.java
@@ -35,7 +35,7 @@ public class GamsTest implements GamsInputData {
 	}
 
 	@Override
-	public Map<CropType, Double> getYield00() {
+	public Map<CropType, Double> getYieldNone() {
 		Map<CropType, Double> dummyMap = new HashMap<CropType, Double>();
 		dummyMap.put(CropType.CEREALS, 1.0);
 		dummyMap.put(CropType.FRUIT, 1.0);
@@ -48,7 +48,7 @@ public class GamsTest implements GamsInputData {
 		return dummyMap;
 	}
 	
-	public Map<CropType, Double> getYield10() {
+	public Map<CropType, Double> getYieldFertOnly() {
 		Map<CropType, Double> dummyMap = new HashMap<CropType, Double>();
 		dummyMap.put(CropType.CEREALS, 3.0);
 		dummyMap.put(CropType.FRUIT, 3.0);
@@ -61,7 +61,7 @@ public class GamsTest implements GamsInputData {
 		return dummyMap;
 	}
 	
-	public Map<CropType, Double> getYield01() {
+	public Map<CropType, Double> getYieldIrrigOnly() {
 		Map<CropType, Double> dummyMap = new HashMap<CropType, Double>();
 		dummyMap.put(CropType.CEREALS, 2.0);
 		dummyMap.put(CropType.FRUIT, 2.0);
@@ -74,7 +74,7 @@ public class GamsTest implements GamsInputData {
 		return dummyMap;
 	}
 	
-	public Map<CropType, Double> getYield11() {
+	public Map<CropType, Double> getYieldBoth() {
 		Map<CropType, Double> dummyMap = new HashMap<CropType, Double>();
 		dummyMap.put(CropType.CEREALS, 4.0);
 		dummyMap.put(CropType.FRUIT, 4.0);
@@ -174,12 +174,12 @@ public class GamsTest implements GamsInputData {
 	}
 
 	@Override
-	public double getAlpha() {
+	public double getFertParam() {
 		return 0.4;
 	}
 
 	@Override
-	public double getBeta() {
-		return 0.5;
+	public double getIrrigParam() {
+		return 0.3;
 	}
 }
-- 
GitLab