diff --git a/src/ac/ed/lurg/country/CountryAgent.java b/src/ac/ed/lurg/country/CountryAgent.java index 3e80087c56fe62c17375b79c75cd0abec2e283e1..f7f5e4e553e334014369bcf6097a5cd01a49cce4 100644 --- a/src/ac/ed/lurg/country/CountryAgent.java +++ b/src/ac/ed/lurg/country/CountryAgent.java @@ -75,7 +75,10 @@ public class CountryAgent { if (yieldresp != null) { RasterKey key = entry.getKey(); IrrigationItem irrigItem = irrigData.get(key); - clusteringPoints.add(new YieldClusterPoint(key, yieldresp, irrigItem)); + + LandUseItem luItem = previousGamsRasterOutput.getLandUses().get(key); + double protectedArea = luItem.getProtectedArea(); + clusteringPoints.add(new YieldClusterPoint(key, yieldresp, irrigItem, protectedArea)); } } diff --git a/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java b/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java index 69a1f581726c0bf0da068a38ed30c15e3a5633ed..2fe9081d37ef1b2b9c0e5f8327291a9ac0705cd8 100644 --- a/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java +++ b/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java @@ -76,18 +76,18 @@ public class GamsRasterOptimiser { LogWriter.printlnError("Total Area " + comment + ": " + l.getName() + ": " + total); } - double protectedAreaIncMinNatural=0, suitableArea=0, protectedArea=0, unprotectedArea=0; + double unprotectedNatural=0, suitableArea=0, protectedArea=0, unprotectedArea=0; for (LandUseItem a : areaRaster.values()) { if (a != null) { protectedArea += a.getProtectedArea(); unprotectedArea += a.getUnprotectedArea(); - protectedAreaIncMinNatural += a.getProtectedAreaIncMinNatural(); + unprotectedNatural += a.getUnprotectedNatural(); suitableArea += a.getSuitableLand(); } } LogWriter.println("Total protectedArea " + comment + ": " + protectedArea); LogWriter.println("Total unprotectedArea " + comment + ": " + unprotectedArea); - LogWriter.println("Total protectedAreaIncMinNatural " + comment + ": " + protectedAreaIncMinNatural); + LogWriter.println("Total unprotectedNatural " + comment + ": " + unprotectedNatural); LogWriter.println("Total suitableArea " + comment + ": " + suitableArea); } diff --git a/src/ac/ed/lurg/landuse/LandUseItem.java b/src/ac/ed/lurg/landuse/LandUseItem.java index 819a4d5d9e30579bfb3956fdc2cfd4e373d33403..09e13438efa9ccc7a553f10424695841e155fc7e 100644 --- a/src/ac/ed/lurg/landuse/LandUseItem.java +++ b/src/ac/ed/lurg/landuse/LandUseItem.java @@ -54,15 +54,6 @@ public class LandUseItem implements InterpolatingRasterItem<LandUseItem>, Serial return getTotalLandCoverArea()-getProtectedArea(); } - public double getProtectedAreaIncMinNatural() { - double protectedLand = getProtectedArea(); - double unprotectedLand = getUnprotectedArea(); - double unsuitableLand = Math.max(unprotectedLand * ModelConfig.MIN_NATURAL_RATE, unprotectedLand*unavailableFract); - - double minOrProtectedA = protectedLand + unsuitableLand; - return minOrProtectedA; - } - public Intensity getIntensity(CropType crop) { return intensityMap.get(crop); } @@ -273,9 +264,13 @@ public class LandUseItem implements InterpolatingRasterItem<LandUseItem>, Serial } public double getUnprotectedNatural() { + double totalLand = getTotalLandCoverArea(); double totalNatural = getLandCoverArea(LandCoverType.OTHER_NATURAL) + getLandCoverArea(LandCoverType.MANAGED_FOREST) + getLandCoverArea(LandCoverType.UNMANAGED_FOREST); - double minOrProtectedA = getProtectedAreaIncMinNatural(); - double unprotectedNat = Math.max(0, totalNatural - minOrProtectedA); // if we are already using more than is protected then the unprotectedArea is 0 + + double protectedFract = getProtectedArea() / totalLand; + double minAndProtectedA = totalLand * (1 - (1-protectedFract) * (1-unavailableFract) * (1-ModelConfig.MIN_NATURAL_RATE)); + + double unprotectedNat = Math.max(0, totalNatural - minAndProtectedA); // if we are already using more than is protected then the unprotectedArea is 0 return unprotectedNat; } diff --git a/src/ac/ed/lurg/output/LandUseOutputer.java b/src/ac/ed/lurg/output/LandUseOutputer.java index 680de4d5229a460dcb6e18e02348623e21203689..7b194644ad2585995cb1887eefa1a58560a94d57 100644 --- a/src/ac/ed/lurg/output/LandUseOutputer.java +++ b/src/ac/ed/lurg/output/LandUseOutputer.java @@ -29,7 +29,7 @@ public class LandUseOutputer extends AbstractLandUseOutputer { String landCoverFileName = outputDir.getPath() + File.separator + "LandUse.txt"; fertWriter = new BufferedWriter(new FileWriter(landCoverFileName, false)); - StringBuffer sbHeader = new StringBuffer("Lon Lat area protected"); + StringBuffer sbHeader = new StringBuffer("Lon Lat area suitable"); for (LandCoverType cover : LandCoverType.values()) { sbHeader.append(" " + cover.getName()); @@ -57,7 +57,7 @@ public class LandUseOutputer extends AbstractLandUseOutputer { StringBuffer sbData = new StringBuffer(String.format("%.2f %.2f", lat, lon)); sbData.append(String.format(" %.8f", item.getTotalLandCoverArea())); - sbData.append(String.format(" %.8f", item.getProtectedAreaIncMinNatural())); + sbData.append(String.format(" %.8f", item.getSuitableLand())); for (LandCoverType cover : LandCoverType.values()) { sbData.append(String.format(" %.8f", item.getLandCoverArea(cover))); diff --git a/src/ac/ed/lurg/yield/YieldClusterPoint.java b/src/ac/ed/lurg/yield/YieldClusterPoint.java index c04a91717a7f02953f93348861d1f7f082388694..f8f5cfc3f07cfa0a30945401b82c0a2b3545362d 100644 --- a/src/ac/ed/lurg/yield/YieldClusterPoint.java +++ b/src/ac/ed/lurg/yield/YieldClusterPoint.java @@ -17,8 +17,8 @@ public class YieldClusterPoint implements ClusteringPoint<String> { private final static String RICE_MAX = "riceMin"; private final static String MAIZE_MIN = "maizeMin"; private final static String MAIZE_MAX = "maizeMax"; - private final static String ROOTS_MIN = "rootsMin"; private final static String IRRIG_WATER_AVAL = "irrigWaterAval"; + private final static String PROTECTED_AREA = "protectedArea"; private RasterKey rasterKey; private double wheatMin; @@ -26,22 +26,22 @@ public class YieldClusterPoint implements ClusteringPoint<String> { private double riceMax; private double maizeMin; private double maizeMax; - private double rootsMin; private double pasture; private double irrigWaterAval; + private double protectedArea; - public YieldClusterPoint(RasterKey rasterKey, YieldResponsesItem yields, IrrigationItem irrigItem) { + public YieldClusterPoint(RasterKey rasterKey, YieldResponsesItem yields, IrrigationItem irrigItem, double protectedArea) { this.rasterKey = rasterKey; // not sure if we be better to get a reference to the YieldResponsesItem, rather than caching these values? this.wheatMin = yields.getYieldNone(CropType.WHEAT); this.riceMax = yields.getYieldMax(CropType.RICE); this.maizeMin = yields.getYieldNone(CropType.MAIZE); - this.rootsMin = yields.getYieldNone(CropType.STARCHY_ROOTS); this.pasture = yields.getYieldNone(CropType.PASTURE); this.wheatMax = yields.getYieldMax(CropType.WHEAT); this.maizeMax = yields.getYieldMax(CropType.MAIZE); this.irrigWaterAval = irrigItem.getIrrigConstraint(); + this.protectedArea = protectedArea; } public RasterKey getRasterKey() { @@ -58,8 +58,8 @@ public class YieldClusterPoint implements ClusteringPoint<String> { case RICE_MAX: return riceMax; case MAIZE_MIN: return maizeMin; case MAIZE_MAX: return maizeMax; - case ROOTS_MIN: return rootsMin; case IRRIG_WATER_AVAL: return irrigWaterAval; + case PROTECTED_AREA: return protectedArea; } LogWriter.printlnError("YieldClusterPoint.getClusteringValue: got unknown value " + key); return Double.NaN; @@ -67,7 +67,7 @@ public class YieldClusterPoint implements ClusteringPoint<String> { @Override public Collection<String> getAllClusteringKeys() { - return Arrays.asList(PASTURE, WHEAT_MIN, WHEAT_MAX, MAIZE_MIN, MAIZE_MAX, RICE_MAX, IRRIG_WATER_AVAL); + return Arrays.asList(PASTURE, WHEAT_MIN, WHEAT_MAX, MAIZE_MIN, MAIZE_MAX, IRRIG_WATER_AVAL, PROTECTED_AREA); } public String toString() {