Skip to content
Snippets Groups Projects
Commit e5a166a7 authored by Bart Arendarczyk's avatar Bart Arendarczyk
Browse files

Added option to exclude countries.

parent 83f95d88
No related branches found
No related tags found
No related merge requests found
Country
United Kingdom
......@@ -372,6 +372,9 @@ public class ModelConfig {
public static final boolean DEBUG_LIMIT_COUNTRIES = getBooleanProperty("DEBUG_LIMIT_COUNTRIES", false);
public static final String DEBUG_COUNTRY_NAME = getProperty("DEBUG_COUNTRY_NAME", "United States of America");
public static final String GAMS_COUNTRY_TO_SAVE = getProperty("GAMS_COUNTRY_TO_SAVE", "China");;
public static final boolean EXCLUDE_COUNTRIES_IN_LIST = getBooleanProperty("EXCLUDE_COUNTRIES_IN_LIST", false);
public static final String EXCLUDED_COUNTRIES_FILE = DATA_DIR + File.separator + "countries_excluded.csv";
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 = getIntProperty("LPJG_TIMESTEP_SIZE", 5);
......
......@@ -5,6 +5,8 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import ac.ed.lurg.ModelConfig;
import ac.ed.lurg.demand.BaseConsumpManager;
......@@ -17,6 +19,7 @@ public class CompositeCountryManager {
private Map<SingleCountry, CompositeCountry> mapFromSingleCountry;
private Map<CompositeCountry, List<SingleCountry>> mapFromCompositeCountry;
private StringTabularReader countryGroups;
private Set<String> countryExclusionList = new HashSet<String>();
public CompositeCountryManager(BaseConsumpManager baseConsumpManager) {
super();
......@@ -24,6 +27,10 @@ public class CompositeCountryManager {
countryGroups = new StringTabularReader(",", new String[]{"Country", "PlumGroup"});
countryGroups.read(ModelConfig.COUNTRY_GROUPING_FILE);
}
if (ModelConfig.EXCLUDE_COUNTRIES_IN_LIST) {
countryExclusionList = new StringTabularReader(",", new String[] {"Country"}).read(ModelConfig.EXCLUDED_COUNTRIES_FILE)
.stream().map(m -> m.get("Country")).collect(Collectors.toSet());
}
populate(baseConsumpManager);
}
......@@ -38,14 +45,14 @@ public class CompositeCountryManager {
private void populate(BaseConsumpManager baseConsumpManager) {
mapFromSingleCountry = new HashMap<SingleCountry, CompositeCountry>();
HashSet<String> countryExclusionList = new HashSet<String>();
for (SingleCountry c : baseConsumpManager.getAllCountries()) {
CompositeCountry cc;
if (ModelConfig.PREDEFINED_COUNTRY_GROUPING)
if (countryExclusionList.contains(c.getCountryName()))
continue;
else if (ModelConfig.PREDEFINED_COUNTRY_GROUPING)
cc = getForName(getCountryGroup(c),c.getRegion());
else if (baseConsumpManager.getPopForGrouping(c) < ModelConfig.POPULATION_AGGREG_LIMIT || countryExclusionList.contains(c.getCountryName()))
else if (baseConsumpManager.getPopForGrouping(c) < ModelConfig.POPULATION_AGGREG_LIMIT)
cc = getForName(c.getRegion() + "_other", c.getRegion());
else
cc = getForName(c.getCountryName(),c.getRegion());
......
......@@ -73,7 +73,7 @@ public class TradeManager {
CompositeCountry cc = compositeCountryManager.getForSingleCountry(country);
if (cc == null) {
LogWriter.printlnError("CompositeCountryManager: Can find country for " + country);
continue;
}
else {
CropToDoubleMap countryData = tradeMap.get(cc);
......
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