From 3a933125faf71f4137c129c9e850e13cc92ff667 Mon Sep 17 00:00:00 2001
From: Peter Alexander <peter@blackhillock.co.uk>
Date: Fri, 27 Feb 2015 13:24:49 +0000
Subject: [PATCH] Seems to be working a bit better...

---
 GAMS/IntExtOpt.gms                       | 6 +++---
 src/ac/ed/lurg/demand/DemandManager.java | 2 +-
 src/ac/ed/lurg/landuse/AreasItem.java    | 7 ++++---
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/GAMS/IntExtOpt.gms b/GAMS/IntExtOpt.gms
index b67923ac..42988c1a 100644
--- a/GAMS/IntExtOpt.gms
+++ b/GAMS/IntExtOpt.gms
@@ -60,7 +60,7 @@ $gdxin
  
  fertI.L(crop, location) = 0.5;
  irrigI.L(crop, location) = 0.5;
- otherIntensity.L(crop, location) = 0.5;
+ otherIntensity.L(crop, location) = 1.0;
  area.L(crop, location) = previousArea(crop, location)
  
  EQUATIONS
@@ -82,8 +82,8 @@ $gdxin
        ENERGY_EQ                                        total energy objective function;
  
  UNIT_ENERGY_EQ(crop, location) .. unitEnergy(crop, location) =E= fertI(crop, location) + 
-                                                                       irrigI(crop, location)*irrigCost(location) +
-                                                                       power((1+otherIntensity(crop, location)), 2);
+                                                                       (1+irrigI(crop, location)*irrigCost(location) ** 1.3) +
+                                                                       (1+otherIntensity(crop, location) ** 2);
  
  YIELD_EQ(crop, location) .. yield(crop, location) =E= (
                yieldNone(crop, location) + 
diff --git a/src/ac/ed/lurg/demand/DemandManager.java b/src/ac/ed/lurg/demand/DemandManager.java
index d35d2dbf..f18afe46 100644
--- a/src/ac/ed/lurg/demand/DemandManager.java
+++ b/src/ac/ed/lurg/demand/DemandManager.java
@@ -45,7 +45,7 @@ public class DemandManager {
 			
 			double thisFudgeFactorShouldBeSomewhereElse;
 			if (dc.getCropType().equals(CropType.MEAT_OR_PASTURE))
-				d *= 0.1;
+				d *= 0.9;
 			
 			demandMap.put(dc.getCropType(), d);
 		}
diff --git a/src/ac/ed/lurg/landuse/AreasItem.java b/src/ac/ed/lurg/landuse/AreasItem.java
index a9b818ec..b2a084ec 100644
--- a/src/ac/ed/lurg/landuse/AreasItem.java
+++ b/src/ac/ed/lurg/landuse/AreasItem.java
@@ -51,9 +51,10 @@ public class AreasItem implements RasterItem {
 	public CropToDouble getCropChanges(AreasItem prevAreaAggItem) {
 		CropToDouble changes = new CropToDouble();
 		
-		for (Entry<CropType, Double> entry : cropAreas.entrySet()) {
-			double change = entry.getValue() - prevAreaAggItem.getCropArea(entry.getKey());
-			changes.put(entry.getKey(), change);
+		for (Entry<CropType, Double> entry : prevAreaAggItem.cropAreas.entrySet()) {
+			CropType crop = entry.getKey();
+			double change = getCropArea(crop) - entry.getValue();
+			changes.put(crop, change);
 		}
 		
 		return changes;
-- 
GitLab