Skip to content
Snippets Groups Projects
Commit ff1b7c3e authored by Peter Alexander's avatar Peter Alexander
Browse files

Cluster include water avaliablitity

parent de73f2fd
No related branches found
No related tags found
No related merge requests found
...@@ -250,6 +250,6 @@ public class ModelConfig { ...@@ -250,6 +250,6 @@ public class ModelConfig {
public static final double PASTURE_MAX_IRRIGATION_RATE = getDoubleProperty("DEFAULT_MAX_IRRIGATION_RATE", 50.0); // shouldn't need this but some areas crops don't have a value, but was causing them to be selected public static final double PASTURE_MAX_IRRIGATION_RATE = getDoubleProperty("DEFAULT_MAX_IRRIGATION_RATE", 50.0); // shouldn't need this but some areas crops don't have a value, but was causing them to be selected
public static final int LPJG_TIMESTEP_SIZE = 5; public static final int LPJG_TIMESTEP_SIZE = 5;
public static final int NUM_YIELD_CLUSTERS = getIntProperty("NUM_YIELD_CLUSTERS", 500); public static final int NUM_YIELD_CLUSTERS = getIntProperty("NUM_YIELD_CLUSTERS", 5000);
public static final long RANDOM_SEED = getIntProperty("RANDOM_SEED", 1974329); // any number will do public static final long RANDOM_SEED = getIntProperty("RANDOM_SEED", 1974329); // any number will do
} }
...@@ -62,7 +62,7 @@ public class CountryAgent { ...@@ -62,7 +62,7 @@ public class CountryAgent {
return yieldClusters; return yieldClusters;
} }
private RasterSet<IntegerRasterItem> calcYieldClusters(YieldRaster countryYieldSurfaces) { private RasterSet<IntegerRasterItem> calcYieldClusters(RasterSet<IrrigationItem> irrigData, YieldRaster countryYieldSurfaces) {
LogWriter.println("calcYieldClusters: for " + ModelConfig.NUM_YIELD_CLUSTERS + " clusters"); LogWriter.println("calcYieldClusters: for " + ModelConfig.NUM_YIELD_CLUSTERS + " clusters");
...@@ -70,8 +70,11 @@ public class CountryAgent { ...@@ -70,8 +70,11 @@ public class CountryAgent {
Collection<YieldClusterPoint> clusteringPoints = new HashSet<YieldClusterPoint>(); Collection<YieldClusterPoint> clusteringPoints = new HashSet<YieldClusterPoint>();
for (Entry<RasterKey, YieldResponsesItem> entry : countryYieldSurfaces.entrySet()) { for (Entry<RasterKey, YieldResponsesItem> entry : countryYieldSurfaces.entrySet()) {
YieldResponsesItem yieldresp = entry.getValue(); YieldResponsesItem yieldresp = entry.getValue();
if (yieldresp != null) if (yieldresp != null) {
clusteringPoints.add(new YieldClusterPoint(entry.getKey(), yieldresp)); RasterKey key = entry.getKey();
IrrigationItem irrigItem = irrigData.get(key);
clusteringPoints.add(new YieldClusterPoint(key, yieldresp, irrigItem));
}
} }
// do the clustering // do the clustering
...@@ -114,7 +117,7 @@ public class CountryAgent { ...@@ -114,7 +117,7 @@ public class CountryAgent {
} }
else { else {
if (yieldClusters==null) if (yieldClusters==null)
yieldClusters = calcYieldClusters(countryYieldSurfaces); // this should only be on the first timestep yieldClusters = calcYieldClusters(irrigData, countryYieldSurfaces); // this should only be on the first timestep
// optimize areas and intensity // optimize areas and intensity
GamsRasterInput input = getGamsRasterInput(irrigData, countryYieldSurfaces, globalGen2EcIncrease); GamsRasterInput input = getGamsRasterInput(irrigData, countryYieldSurfaces, globalGen2EcIncrease);
......
...@@ -3,6 +3,7 @@ package ac.ed.lurg.yield; ...@@ -3,6 +3,7 @@ package ac.ed.lurg.yield;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import ac.ed.lurg.landuse.IrrigationItem;
import ac.ed.lurg.types.CropType; import ac.ed.lurg.types.CropType;
import ac.ed.lurg.utils.LogWriter; import ac.ed.lurg.utils.LogWriter;
import ac.ed.lurg.utils.cluster.ClusteringPoint; import ac.ed.lurg.utils.cluster.ClusteringPoint;
...@@ -13,31 +14,34 @@ public class YieldClusterPoint implements ClusteringPoint<String> { ...@@ -13,31 +14,34 @@ public class YieldClusterPoint implements ClusteringPoint<String> {
private final static String PASTURE = "pas"; private final static String PASTURE = "pas";
private final static String WHEAT_MIN = "wheatMin"; private final static String WHEAT_MIN = "wheatMin";
private final static String WHEAT_MAX = "wheatMax"; private final static String WHEAT_MAX = "wheatMax";
private final static String RICE_MIN = "riceMin"; private final static String RICE_MAX = "riceMin";
private final static String MAIZE_MIN = "maizeMin"; private final static String MAIZE_MIN = "maizeMin";
private final static String MAIZE_MAX = "maizeMax"; private final static String MAIZE_MAX = "maizeMax";
private final static String ROOTS_MIN = "rootsMin"; private final static String ROOTS_MIN = "rootsMin";
private final static String IRRIG_WATER_AVAL = "irrigWaterAval";
private RasterKey rasterKey; private RasterKey rasterKey;
private double wheatMin; private double wheatMin;
private double wheatMax; private double wheatMax;
private double riceMin; private double riceMax;
private double maizeMin; private double maizeMin;
private double maizeMax; private double maizeMax;
private double rootsMin; private double rootsMin;
private double pasture; private double pasture;
private double irrigWaterAval;
public YieldClusterPoint(RasterKey rasterKey, YieldResponsesItem yields) { public YieldClusterPoint(RasterKey rasterKey, YieldResponsesItem yields, IrrigationItem irrigItem) {
this.rasterKey = rasterKey; this.rasterKey = rasterKey;
// not sure if we be better to get a reference to the YieldResponsesItem, rather than caching these values? // 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.wheatMin = yields.getYieldNone(CropType.WHEAT);
this.riceMin = yields.getYieldNone(CropType.RICE); this.riceMax = yields.getYieldMax(CropType.RICE);
this.maizeMin = yields.getYieldNone(CropType.MAIZE); this.maizeMin = yields.getYieldNone(CropType.MAIZE);
this.rootsMin = yields.getYieldNone(CropType.STARCHY_ROOTS); this.rootsMin = yields.getYieldNone(CropType.STARCHY_ROOTS);
this.pasture = yields.getYieldNone(CropType.PASTURE); this.pasture = yields.getYieldNone(CropType.PASTURE);
this.wheatMax = yields.getYieldMax(CropType.WHEAT); this.wheatMax = yields.getYieldMax(CropType.WHEAT);
this.maizeMax = yields.getYieldMax(CropType.MAIZE); this.maizeMax = yields.getYieldMax(CropType.MAIZE);
this.irrigWaterAval = irrigItem.getIrrigConstraint();
} }
public RasterKey getRasterKey() { public RasterKey getRasterKey() {
...@@ -51,10 +55,11 @@ public class YieldClusterPoint implements ClusteringPoint<String> { ...@@ -51,10 +55,11 @@ public class YieldClusterPoint implements ClusteringPoint<String> {
case PASTURE: return pasture; case PASTURE: return pasture;
case WHEAT_MIN: return wheatMin; case WHEAT_MIN: return wheatMin;
case WHEAT_MAX: return wheatMax; case WHEAT_MAX: return wheatMax;
case RICE_MIN: return riceMin; case RICE_MAX: return riceMax;
case MAIZE_MIN: return maizeMin; case MAIZE_MIN: return maizeMin;
case MAIZE_MAX: return maizeMax; case MAIZE_MAX: return maizeMax;
case ROOTS_MIN: return rootsMin; case ROOTS_MIN: return rootsMin;
case IRRIG_WATER_AVAL: return irrigWaterAval;
} }
LogWriter.printlnError("YieldClusterPoint.getClusteringValue: got unknown value " + key); LogWriter.printlnError("YieldClusterPoint.getClusteringValue: got unknown value " + key);
return Double.NaN; return Double.NaN;
...@@ -62,7 +67,7 @@ public class YieldClusterPoint implements ClusteringPoint<String> { ...@@ -62,7 +67,7 @@ public class YieldClusterPoint implements ClusteringPoint<String> {
@Override @Override
public Collection<String> getAllClusteringKeys() { public Collection<String> getAllClusteringKeys() {
return Arrays.asList(PASTURE, WHEAT_MIN, WHEAT_MAX, RICE_MIN, MAIZE_MIN, MAIZE_MAX, ROOTS_MIN); return Arrays.asList(PASTURE, WHEAT_MIN, WHEAT_MAX, MAIZE_MIN, MAIZE_MAX, RICE_MAX, IRRIG_WATER_AVAL);
} }
public String toString() { public String toString() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment