From 4106415af1fa5a089c6c84de96b8a72f289d7ac7 Mon Sep 17 00:00:00 2001
From: Peter Alexander <peter@blackhillock.co.uk>
Date: Tue, 14 Jul 2015 19:36:51 +0100
Subject: [PATCH] no message

---
 GAMS/IntExtOpt.gms                            | 21 +++++++++++++++----
 .../lurg/country/gams/GamsCountryInput.java   |  4 ++--
 .../country/gams/GamsLocationOptimiser.java   |  6 +++---
 .../country/gams/GamsRasterOptimiser.java     |  4 ++--
 4 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/GAMS/IntExtOpt.gms b/GAMS/IntExtOpt.gms
index f73e4f79..248f5745 100644
--- a/GAMS/IntExtOpt.gms
+++ b/GAMS/IntExtOpt.gms
@@ -48,9 +48,21 @@ $gdxin
               pasture   1    / ; 
 * pasture yield is done in DM terms
  
+ PARAMETER baseCost(crop)  cost per ha before intensity values just made up at the moment
+          /   wheat             0.5   
+              maize             0.5 
+              rice              1.0 
+              tropicalCereals   0.5
+              oilcrops          0.5 
+              soybean           0.5
+              pulses            0.4
+              starchyRoots      1.0
+              pasture           0  / ; 
+              
+  SCALAR fertiliserUnitCost / 0.4 /
  
   PARAMETER zeroIntensityYieldFrac(crop)  fraction of no fertiliser and irrigiation yield with zero intensity. Most or all arable crops this is 0 but not for pasture 
-          /   pasture   0.6    / ; 
+          /   pasture   0.3    / ; 
  
  VARIABLES
        area(crop, location)               total area for each crop - Mha
@@ -93,9 +105,10 @@ $gdxin
        NET_SUPPLY_EQ(crop_less_pasture)                 calc net supply for crops
        ENERGY_EQ                                        total energy objective function;
  
- UNIT_ENERGY_EQ(crop, location) .. unitEnergy(crop, location) =E= fertI(crop, location) + 
-                                                                     ((1+irrigI(crop, location) ** 2) * irrigCost(location)) -1 +
-                                                                     (1+otherIntensity(crop, location) ** 2) - 1;
+ UNIT_ENERGY_EQ(crop, location) .. unitEnergy(crop, location) =E=  baseCost(crop) + 
+                                                                     fertiliserUnitCost* fertI(crop, location) + 
+                                                                     (exp(irrigI(crop, location)*2) - 1) * irrigCost(location) +
+                                                                     exp(otherIntensity(crop, location)*2) - 1;
  
  YIELD_EQ(crop, location) .. yield(crop, location) =E= (
                yieldNone(crop, location) + 
diff --git a/src/ac/ed/lurg/country/gams/GamsCountryInput.java b/src/ac/ed/lurg/country/gams/GamsCountryInput.java
index abe96dd4..0529ba9f 100644
--- a/src/ac/ed/lurg/country/gams/GamsCountryInput.java
+++ b/src/ac/ed/lurg/country/gams/GamsCountryInput.java
@@ -62,11 +62,11 @@ public class GamsCountryInput {
 	}
 
 	public double getMaxLandUseChange() {
-		return 0.95;
+		return 0;
 	}
 
 	public double getLandChangeEnergy() {
-		return 0.001;
+		return 0.0;
 	}
 
 	public double getMinFeedRate() {
diff --git a/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java b/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java
index 1daa46b6..f42f6cc8 100644
--- a/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java
+++ b/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java
@@ -183,14 +183,14 @@ public class GamsLocationOptimiser {
 		GAMSVariable varAreas = outDB.getVariable("area");
 		GAMSVariable varFertIntensities = outDB.getVariable("fertI");
 		GAMSVariable varIrrigIntensities = outDB.getVariable("irrigI");
-		GAMSVariable varOtherIntensities = outDB.getVariable("otherIntensity");
+//		GAMSVariable varOtherIntensities = outDB.getVariable("otherIntensity");
 		GAMSVariable varFeedAmount = outDB.getVariable("feedAmount");
 		GAMSVariable varNetImports = outDB.getVariable("netImportAmount");
 		GAMSVariable varYields = outDB.getVariable("yield");
 		GAMSVariable varUnitEnergies = outDB.getVariable("unitEnergy");
 
 		double totalArea = 0;
-		double area, fertIntensity, irrigIntensity, otherIntensity, feedAmount, netImport, yield, unitEnergy;
+		double area, fertIntensity, irrigIntensity, otherIntensity = Double.NaN, feedAmount, netImport, yield, unitEnergy;
 
 		Map<Integer, IntensitiesItem> intensities = new HashMap<Integer, IntensitiesItem>();
 		Map<Integer, AreasItem> cropAreas = new HashMap<Integer, AreasItem>();
@@ -203,7 +203,7 @@ public class GamsLocationOptimiser {
 			area = rec.getLevel();
 			fertIntensity = varFertIntensities.findRecord(itemName, locationName).getLevel();
 			irrigIntensity = varIrrigIntensities.findRecord(itemName, locationName).getLevel();
-			otherIntensity = varOtherIntensities.findRecord(itemName, locationName).getLevel();
+//			otherIntensity = varOtherIntensities.findRecord(itemName, locationName).getLevel();
 			yield = varYields.findRecord(itemName, locationName).getLevel();
 			unitEnergy = varUnitEnergies.findRecord(itemName, locationName).getLevel();
 
diff --git a/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java b/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java
index 31096c52..be7e66bc 100644
--- a/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java
+++ b/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java
@@ -191,8 +191,8 @@ public class GamsRasterOptimiser {
 
 		}
 
-		int numCerealCats = 2;
-		int numPastureCats = 2;
+		int numCerealCats = 1;
+		int numPastureCats = 1;
 
 		int thisShouldLookAtCropsOtherThanJustWheat; // need to consider other crops, and perhaps other yieldTypes as well
 		List<Double> wheatlDivisions = getDivisions(yieldRaster, CropType.WHEAT, numCerealCats); 
-- 
GitLab