From ce63cc2e81b5c171761a31ba5f0f1959df4cc1bd Mon Sep 17 00:00:00 2001
From: Peter Alexander <p.m.w.alexander@gmail.com>
Date: Wed, 8 Mar 2017 15:28:39 +0000
Subject: [PATCH] Add min natural area

---
 src/ac/ed/lurg/ModelConfig.java         |  1 +
 src/ac/ed/lurg/landuse/LandUseItem.java | 16 +++++++---------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/ac/ed/lurg/ModelConfig.java b/src/ac/ed/lurg/ModelConfig.java
index 20926b6e..9dc548c3 100644
--- a/src/ac/ed/lurg/ModelConfig.java
+++ b/src/ac/ed/lurg/ModelConfig.java
@@ -212,6 +212,7 @@ public class ModelConfig {
 	public static final boolean ACTIVE_TRADE_BARRIERS = getBooleanProperty("ACTIVE_TRADE_BARRIERS", false);  // if set to true read in barrier information from file, otherwise use default as above
 
 	public static final boolean PROTECTED_AREAS_ENABLED = getBooleanProperty("PROTECTED_AREAS_ENABLED", true);
+	public static final double MIN_NATURAL_RATE = getDoubleProperty("MIN_NATURAL_RATE", 0.10);
 
 	public static final int NUM_CEREAL_CATEGORIES = getIntProperty("NUM_CEREAL_CATEGORIES", 15);
 	public static final int NUM_PASTURE_CATEGORIES = getIntProperty("NUM_PASTURE_CATEGORIES", 4);
diff --git a/src/ac/ed/lurg/landuse/LandUseItem.java b/src/ac/ed/lurg/landuse/LandUseItem.java
index f22063e4..29b63019 100644
--- a/src/ac/ed/lurg/landuse/LandUseItem.java
+++ b/src/ac/ed/lurg/landuse/LandUseItem.java
@@ -206,18 +206,16 @@ public class LandUseItem implements InterpolatingRasterItem<LandUseItem>, Serial
 	}
 		
 	public double getSuitableLand() {
-		double d = 0;
-
-		double protectedTotal = ModelConfig.PROTECTED_AREAS_ENABLED ? protectedArea : 0;
 		double totalNatural  = getLandCoverArea(LandCoverType.OTHER_NATURAL) + getLandCoverArea(LandCoverType.FOREST);
-		
-		if (totalNatural >= protectedTotal)
-			d += totalNatural - protectedTotal;
+		double currentAgri = getLandCoverArea(LandCoverType.PASTURE) + getLandCoverArea(LandCoverType.CROPLAND);
 
-			d += getLandCoverArea(LandCoverType.PASTURE);
-			d += getLandCoverArea(LandCoverType.CROPLAND);
+		double protectedA = ModelConfig.PROTECTED_AREAS_ENABLED ? protectedArea : 0;
+		double minNatural = (currentAgri+totalNatural) * ModelConfig.MIN_NATURAL_RATE;
+		double minOrProtectedA = Math.max(protectedA, minNatural);
+		double unprotectedA = Math.max(0, totalNatural - minOrProtectedA);  // if we are already using more than is protected then the unprotectedArea is 0
 
-		return d;
+		double suitable = currentAgri + unprotectedA;
+		return suitable;
 	}
 	
 	public double getForestToNaturalFraction() {
-- 
GitLab