From c8ac4ebf63ac7af7e83c08e3cd8ddfcbefe03f66 Mon Sep 17 00:00:00 2001
From: Peter Alexander <peter@blackhillock.co.uk>
Date: Mon, 5 Aug 2019 08:35:55 +0100
Subject: [PATCH] Remove land rate change constraint

---
 GAMS/IntExtOpt.gms                                |  4 ++--
 src/ac/ed/lurg/country/CountryAgent.java          | 14 +++++---------
 src/ac/ed/lurg/utils/cluster/YieldClusterSet.java | 10 ----------
 3 files changed, 7 insertions(+), 21 deletions(-)
 delete mode 100644 src/ac/ed/lurg/utils/cluster/YieldClusterSet.java

diff --git a/GAMS/IntExtOpt.gms b/GAMS/IntExtOpt.gms
index 23de5350..4e157e7f 100644
--- a/GAMS/IntExtOpt.gms
+++ b/GAMS/IntExtOpt.gms
@@ -153,7 +153,6 @@ $gdxin
        PASTURE_INCREASE_CONV_CALC(location)             
        PASTURE_DECREASE_CONV_CALC(location)          
        PASTURE_TOTAL_CHANGE_CONSTRAINT(location)   
-       LAND_RATE_CHANGE_CONSTRAINT_INCREASE
        COST_EQ                                        total cost objective function;
  
  UNIT_COST_EQ(crop, location) .. unitCost(crop, location) =E=  (     baseCost(crop) +           
@@ -208,7 +207,8 @@ $gdxin
  PASTURE_DECREASE_CONV_CALC(location) .. pastureDecrease(location) =G= -(area('pasture', location) - previousArea('pasture', location));
  PASTURE_TOTAL_CHANGE_CONSTRAINT(location) .. pastureIncrease(location) -pastureDecrease(location) =G= area('pasture', location) - previousArea('pasture', location);
   
- LAND_RATE_CHANGE_CONSTRAINT_INCREASE .. sum(location, cropIncrease(location)) / sum(location, (suitableLandArea(location)*(1.0 - unhandledCropRate))-sum(crop, previousArea(crop, location))) =L= maxLandExpansionRate;
+* CROPLAND_INCREASE_CONSTRAINT(location) .. cropIncrease(location)/(1.0 - unhandledCropRate) =L=  maxLandChangeRate * ( suitableLandArea(location) -sum(crop_less_pasture, previousArea(crop_less_pasture, location))/*(1.0 - unhandledCropRate) - previousArea('pasture', location) );
+* PASTURE_DECREASE_CONSTRAINT(location) .. pastureDecrease(location) =L=  maxLandChangeRate * previousArea('pasture', location);
 
  COST_EQ .. total_cost =E= 
          ( 
diff --git a/src/ac/ed/lurg/country/CountryAgent.java b/src/ac/ed/lurg/country/CountryAgent.java
index bd48a282..e32842fa 100644
--- a/src/ac/ed/lurg/country/CountryAgent.java
+++ b/src/ac/ed/lurg/country/CountryAgent.java
@@ -27,7 +27,6 @@ import ac.ed.lurg.types.LandCoverType;
 import ac.ed.lurg.utils.LogWriter;
 import ac.ed.lurg.utils.cluster.Cluster;
 import ac.ed.lurg.utils.cluster.KMeans;
-import ac.ed.lurg.utils.cluster.YieldClusterSet;
 import ac.ed.lurg.yield.YieldClusterPoint;
 import ac.ed.lurg.yield.YieldRaster;
 import ac.ed.lurg.yield.YieldResponsesItem;
@@ -67,8 +66,8 @@ public class CountryAgent extends AbstractCountryAgent {
 		
 		// create collection of ClusteringPoints from countryYieldSurfaces, these have the RasterKey and data for yield (or access to them)
 		
-		YieldClusterSet clusteringPoints = new YieldClusterSet();
-		YieldClusterSet clusteringPointsProtected = new YieldClusterSet();
+		HashSet<YieldClusterPoint> clusteringPoints = new HashSet<YieldClusterPoint>();
+		HashSet<YieldClusterPoint> clusteringPointsProtected = new HashSet<YieldClusterPoint>();
 		
 		for (Entry<RasterKey, YieldResponsesItem> entry : countryYieldSurfaces.entrySet()) {
 			YieldResponsesItem yieldresp = entry.getValue();
@@ -85,17 +84,14 @@ public class CountryAgent extends AbstractCountryAgent {
 				}
 				else 
 					clusteringPoints.add(new YieldClusterPoint(key, yieldresp, irrigItem, protectedAreaFrac));
-				
-					
 			}
 		}
 		
-		Collection<YieldClusterSet> clusterGroups = new HashSet<YieldClusterSet>();
+		Collection<HashSet<YieldClusterPoint>> clusterGroups = new HashSet<HashSet<YieldClusterPoint>>();
 		clusterGroups.add(clusteringPoints);
 
-		if(ModelConfig.HALFEARTH) {
-		clusterGroups.add(clusteringPointsProtected);
-		}
+		if(clusteringPointsProtected.size() > 0)
+			clusterGroups.add(clusteringPointsProtected);
 		
 		RasterSet<IntegerRasterItem> mapping = new RasterSet<IntegerRasterItem>(countryYieldSurfaces.getHeaderDetails());
 		int id = 1;
diff --git a/src/ac/ed/lurg/utils/cluster/YieldClusterSet.java b/src/ac/ed/lurg/utils/cluster/YieldClusterSet.java
deleted file mode 100644
index e9f8339f..00000000
--- a/src/ac/ed/lurg/utils/cluster/YieldClusterSet.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package ac.ed.lurg.utils.cluster;
-
-import java.util.HashSet;
-import ac.ed.lurg.yield.YieldClusterPoint;
-
-public class YieldClusterSet extends HashSet<YieldClusterPoint> {
-
-	private static final long serialVersionUID = -9207189503886440121L;
-	
-}
-- 
GitLab