Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ randomSeed: 606 # seed for the first run; incremented automatically if
startYear: 2019 # first year of simulation (must have matching input/donor data)
endYear: 2022 # last year of simulation (inclusive)
popSize: 50000 # simulated population size (larger = more accurate, slower)
# countryString: "United Kingdom" # "United Kingdom" or "Italy" (auto-detected from donor DB if omitted)
# countryString: "United Kingdom" # Auto-detected from donor DB if omitted
# integrationTest: false # true = write output to a fixed folder for comparison in CI tests


Expand Down
7 changes: 3 additions & 4 deletions src/main/java/simpaths/data/ComboBoxCountry.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ public void updateUI() {

// generate combo-box
int numCountries = Country.values().length;
// numCountries = 1; //Overrides the above to only allow selection of Italy
String[] countryNames = new String[numCountries];
for(int i = 0; i < numCountries; i++) {
countryNames[i] = Country.values()[i].getCountryName();
}
JComboBox<String> countryList = new JComboBox<String>(countryNames);
countryList.setSelectedIndex(Country.IT.ordinal());
countryList.setSelectedIndex(Country.UK.ordinal());
countryList.addActionListener(this);

// set-up display for country flag
Expand Down Expand Up @@ -108,7 +107,7 @@ public void actionPerformed(ActionEvent e) {
*
*/
protected void updateLabel(String countryName) {
Country country = Country.IT.getCountryFromNameString(countryName);
Country country = Country.UK.getCountryFromNameString(countryName);
ImageIcon icon = createImageIcon("/images/" + country + ".png");
String text = "You have selected " + countryName;
picture.setText(text);
Expand Down Expand Up @@ -143,5 +142,5 @@ protected static ImageIcon createImageIcon(String path) {
* @return
*
*/
public Country getCountryEnum() { return Country.IT.getCountryFromNameString(this.countryName); }
public Country getCountryEnum() { return Country.UK.getCountryFromNameString(this.countryName); }
}
61 changes: 15 additions & 46 deletions src/main/java/simpaths/data/Parameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,6 @@ else if(numberOfChildren <= 5) {
// private static MultiKeyCoefficientMap coeffCovariancePartnershipU1b; //Probit enter partnership if not in continuous education
private static MultiKeyCoefficientMap coeffCovariancePartnershipU2; //Probit exit partnership (females)

//Partnership for Italy
private static MultiKeyCoefficientMap coeffCovariancePartnershipITU1; //Probit enter partnership for Italy
private static MultiKeyCoefficientMap coeffCovariancePartnershipITU2; //Probit exit partnership for Italy

//Fertility
private static MultiKeyCoefficientMap coeffCovarianceFertilityF1; //Probit fertility if in continuous education
Expand Down Expand Up @@ -794,8 +791,6 @@ else if(numberOfChildren <= 5) {
private static BinomialRegression regPartnershipU1b;
private static BinomialRegression regPartnershipU2;

private static BinomialRegression regPartnershipITU1;
private static BinomialRegression regPartnershipITU2;

//Fertility
private static BinomialRegression regFertilityF1;
Expand Down Expand Up @@ -936,12 +931,7 @@ public static void loadParameters(Country country, int maxAgeModel, boolean enab
loadTimeSeriesFactorMaps(country);
instantiateAlignmentMaps();

// scenario parameters
if (country.equals(Country.IT)) {
SAVINGS_RATE = 0.056;
} else {
SAVINGS_RATE = 0.056;
}
SAVINGS_RATE = 0.056;
saveImperfectTaxDBMatches = taxDBMatches;

flagDefaultToTimeSeriesAverages = defaultToTimeSeriesAverages;
Expand Down Expand Up @@ -1287,8 +1277,6 @@ public static void loadParameters(Country country, int maxAgeModel, boolean enab
{"coeffCovarianceChildcareC1b", coeffCovarianceChildcareC1b},
{"coeffCovariancePartnershipU1", coeffCovariancePartnershipU1},
{"coeffCovariancePartnershipU2", coeffCovariancePartnershipU2},
//{"coeffCovariancePartnershipITU1", coeffCovariancePartnershipITU1},
//{"coeffCovariancePartnershipITU2", coeffCovariancePartnershipITU2},
{"coeffCovarianceFertilityF1", coeffCovarianceFertilityF1},
});
}
Expand Down Expand Up @@ -1408,16 +1396,10 @@ public static void loadParameters(Country country, int maxAgeModel, boolean enab
coeffCovarianceChildcareC1b = bootstrapWithTrace("coeffCovarianceChildcareC1b", coeffCovarianceChildcareC1b);

//Specification of some processes depends on the country:
if (country.equals(Country.UK)) {
coeffCovariancePartnershipU1 = bootstrapWithTrace("coeffCovariancePartnershipU1", coeffCovariancePartnershipU1);
// coeffCovariancePartnershipU1b = RegressionUtils.bootstrap(coeffCovariancePartnershipU1b);
coeffCovariancePartnershipU2 = bootstrapWithTrace("coeffCovariancePartnershipU2", coeffCovariancePartnershipU2);
coeffCovarianceFertilityF1 = bootstrapWithTrace("coeffCovarianceFertilityF1", coeffCovarianceFertilityF1);
} else if (country.equals(Country.IT)) {
coeffCovariancePartnershipITU1 = bootstrapWithTrace("coeffCovariancePartnershipITU1", coeffCovariancePartnershipITU1);
coeffCovariancePartnershipITU2 = bootstrapWithTrace("coeffCovariancePartnershipITU2", coeffCovariancePartnershipITU2);
coeffCovarianceFertilityF1 = bootstrapWithTrace("coeffCovarianceFertilityF1", coeffCovarianceFertilityF1);
}
coeffCovariancePartnershipU1 = bootstrapWithTrace("coeffCovariancePartnershipU1", coeffCovariancePartnershipU1);
// coeffCovariancePartnershipU1b = RegressionUtils.bootstrap(coeffCovariancePartnershipU1b);
coeffCovariancePartnershipU2 = bootstrapWithTrace("coeffCovariancePartnershipU2", coeffCovariancePartnershipU2);
coeffCovarianceFertilityF1 = bootstrapWithTrace("coeffCovarianceFertilityF1", coeffCovarianceFertilityF1);

}

Expand Down Expand Up @@ -1498,25 +1480,16 @@ public static void loadParameters(Country country, int maxAgeModel, boolean enab
regEducationE2 = new GeneralisedOrderedRegression<>(RegressionType.GenOrderedLogit, EducationLevel.class, coeffCovarianceEducationE2);

//Partnership
if (country.equals(Country.UK)) {
MultiKeyCoefficientMap coeffPartnershipU1Appended = appendCoefficientMaps(coeffCovariancePartnershipU1, partnershipTimeAdjustment, "Year");
// MultiKeyCoefficientMap coeffPartnershipU1bAppended = appendCoefficientMaps(coeffCovariancePartnershipU1b, partnershipTimeAdjustment, "Year");
MultiKeyCoefficientMap coeffPartnershipU2Appended = appendCoefficientMaps(coeffCovariancePartnershipU2, partnershipTimeAdjustment, "Year", true);
regPartnershipU1 = new BinomialRegression(RegressionType.Probit, Indicator.class, coeffPartnershipU1Appended);
// regPartnershipU1b = new BinomialRegression(RegressionType.Probit, Indicator.class, coeffPartnershipU1bAppended);
regPartnershipU2 = new BinomialRegression(RegressionType.Probit, ReversedIndicator.class, coeffPartnershipU2Appended);
} else if (country.equals(Country.IT)) {
regPartnershipITU1 = new BinomialRegression(RegressionType.Probit, Indicator.class, coeffCovariancePartnershipITU1);
regPartnershipITU2 = new BinomialRegression(RegressionType.Probit, Indicator.class, coeffCovariancePartnershipITU2);
}
MultiKeyCoefficientMap coeffPartnershipU1Appended = appendCoefficientMaps(coeffCovariancePartnershipU1, partnershipTimeAdjustment, "Year");
// MultiKeyCoefficientMap coeffPartnershipU1bAppended = appendCoefficientMaps(coeffCovariancePartnershipU1b, partnershipTimeAdjustment, "Year");
MultiKeyCoefficientMap coeffPartnershipU2Appended = appendCoefficientMaps(coeffCovariancePartnershipU2, partnershipTimeAdjustment, "Year", true);
regPartnershipU1 = new BinomialRegression(RegressionType.Probit, Indicator.class, coeffPartnershipU1Appended);
// regPartnershipU1b = new BinomialRegression(RegressionType.Probit, Indicator.class, coeffPartnershipU1bAppended);
regPartnershipU2 = new BinomialRegression(RegressionType.Probit, ReversedIndicator.class, coeffPartnershipU2Appended);

//Fertility
if (country.equals(Country.UK)) {
MultiKeyCoefficientMap coeffFertilityF1aAppended = appendCoefficientMaps(coeffCovarianceFertilityF1, fertilityTimeAdjustment, "Year");
regFertilityF1 = new BinomialRegression(RegressionType.Probit, Indicator.class, coeffFertilityF1aAppended);
} else if (country.equals(Country.IT)) {
regFertilityF1 = new BinomialRegression(RegressionType.Probit, Indicator.class, coeffCovarianceFertilityF1);
}
MultiKeyCoefficientMap coeffFertilityF1aAppended = appendCoefficientMaps(coeffCovarianceFertilityF1, fertilityTimeAdjustment, "Year");
regFertilityF1 = new BinomialRegression(RegressionType.Probit, Indicator.class, coeffFertilityF1aAppended);

//Income
regIncomeI1a = new BinomialRegression(RegressionType.Logit, Indicator.class, coeffCovarianceIncomeI1a);
Expand Down Expand Up @@ -1920,10 +1893,8 @@ public static String getEUROMODpolicyForThisYear(int year, Map<Integer, String>

public static void setCountryRegions(Country country) {
countryRegions = new LinkedHashSet<Region>();
for(Region demRgn : Region.values()) { //TODO: restrict this to only regions in the simulated country
if(demRgn.toString().startsWith(country.toString())) { //Only assess the relevant regions for the country
countryRegions.add(demRgn); //Create a set of only relevant regions that we can use below TODO: This should be done in the Parameters class, once and for all!
}
for(Region demRgn : Region.values()) {
countryRegions.add(demRgn);
}
}

Expand Down Expand Up @@ -2038,8 +2009,6 @@ public static void setEmploymentsFurloughedFlex(MultiKeyCoefficientMap employmen
public static BinomialRegression getRegPartnershipU1() {return regPartnershipU1;}
// public static BinomialRegression getRegPartnershipU1b() {return regPartnershipU1b;}
public static BinomialRegression getRegPartnershipU2() {return regPartnershipU2;}
public static BinomialRegression getRegPartnershipITU1() {return regPartnershipITU1;}
public static BinomialRegression getRegPartnershipITU2() {return regPartnershipITU2;}

public static BinomialRegression getRegFertilityF1() {return regFertilityF1;}

Expand Down
9 changes: 2 additions & 7 deletions src/main/java/simpaths/experiment/SimPathsMultiRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,8 @@ public static void main(String[] args) {
// set default values for country and start year
MultiKeyCoefficientMap lastDatabaseCountryAndYear = ExcelAssistant.loadCoefficientMap(Parameters.getInputDirectory() + File.separator + Parameters.DatabaseCountryYearFilename + ".xlsx", "Data", 1);
try {
if (lastDatabaseCountryAndYear.keySet().stream().anyMatch(key -> key.toString().equals("MultiKey[IT]"))) {
countryString = "Italy";
country = Country.IT;
} else {
countryString = "United Kingdom";
country = Country.UK;
}
countryString = "United Kingdom";
country = Country.UK;
String valueYear = lastDatabaseCountryAndYear.getValue(country.toString()).toString();
startYear = Integer.parseInt(valueYear);
} catch (NullPointerException e) {
Expand Down
25 changes: 8 additions & 17 deletions src/main/java/simpaths/experiment/SimPathsStart.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,7 @@ public static void main(String[] args) {

//Adjust the country and year to the value read from Excel, which is updated when the database is rebuilt. Otherwise it will set the country and year to the last one used to build the database
MultiKeyCoefficientMap lastDatabaseCountryAndYear = ExcelAssistant.loadCoefficientMap(Parameters.getInputDirectory() + Parameters.DatabaseCountryYearFilename + ".xlsx", "Data", 1);
if (lastDatabaseCountryAndYear.keySet().stream().anyMatch(key -> key.toString().equals("MultiKey[IT]"))) {
country = Country.IT;
} else {
country = Country.UK;
// country = Country.IT;
}
country = Country.UK;
String valueYear = lastDatabaseCountryAndYear.getValue(country.toString()).toString();
startYear = Integer.parseInt(valueYear);

Expand Down Expand Up @@ -311,7 +306,7 @@ private static void runGUIdialog() {
// initiate radio buttons to define policy environment and input database
count = 0;
Map<String,Integer> startUpOptionsStringsMap = new LinkedHashMap<>();
startUpOptionsStringsMap.put("Change country and/or simulation start year", count++);
startUpOptionsStringsMap.put("Change simulation start year", count++);
startUpOptionsStringsMap.put("Load new input data for starting populations", count++);
startUpOptionsStringsMap.put("Use UKMOD Light to alter description of tax and benefit systems", count++);
startUpOptionsStringsMap.put("Load new input data for tax and benefit systems", count++);
Expand Down Expand Up @@ -447,14 +442,12 @@ private static void runGUIdialog() {

/**
*
* METHOD FOR DISPLAYING GUI FOR SELECTING COUNTRY AND START YEAR OF SIMULATION
* METHOD FOR DISPLAYING GUI FOR SELECTING START YEAR OF SIMULATION
*
*/
private static void chooseCountryAndStartYear() {

// set-up combo-boxes
String textC = null;
ComboBoxCountry cbCountry = new ComboBoxCountry(textC);
String textY = null;
ComboBoxYear cbStartYear = new ComboBoxYear(textY);

Expand All @@ -463,10 +456,8 @@ private static void chooseCountryAndStartYear() {
BasicInternalFrameUI bi = (BasicInternalFrameUI)countryAndYearFrame.getUI();
bi.setNorthPane(null);
countryAndYearFrame.setBorder(null);
cbCountry.setBorder(BorderFactory.createTitledBorder("Country selection drop-down menu"));
cbStartYear.setBorder(BorderFactory.createTitledBorder("Start year selection drop-down menu"));
countryAndYearFrame.setLayout(new BoxLayout(countryAndYearFrame.getContentPane(), BoxLayout.PAGE_AXIS));
countryAndYearFrame.add(cbCountry);
JPanel border = new JPanel();
countryAndYearFrame.add(border);
countryAndYearFrame.add(cbStartYear);
Expand All @@ -475,11 +466,11 @@ private static void chooseCountryAndStartYear() {
countryAndYearFrame.setVisible(true);

// text for GUI
String title = "Country and Start Year";
String text = "<html><h2 style=\"text-align: center; font-size:120%;\">Select simulation country and start year</h2>";
String title = "Start Year";
String text = "<html><h2 style=\"text-align: center; font-size:120%;\">Select simulation start year</h2>";

// sizing for GUI
int height = 350, width = 600;
int height = 280, width = 600;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
if (screenSize.width < 850) {
width = (int) (screenSize.width * 0.95);
Expand All @@ -495,8 +486,8 @@ private static void chooseCountryAndStartYear() {
// Therefore, we should pass some sort of setting to the model blocking the alteration of
// the country if possible. Could this be done by making the setCountry method ineffective
// when the country has been set by the user in the dialog box in the start class?
country = cbCountry.getCountryEnum(); //Temporarily commented out to disallow choice of the country
//country = Country.IT;
//country = cbCountry.getCountryEnum(); //Temporarily commented out to disallow choice of the country
country = Country.UK;
startYear = cbStartYear.getYear();

//Save the last selected country and year to Excel to use in the model if GUI launched straight away
Expand Down
41 changes: 10 additions & 31 deletions src/main/java/simpaths/model/BenefitUnit.java
Original file line number Diff line number Diff line change
Expand Up @@ -2826,29 +2826,21 @@ public double getDoubleValue(Enum<?> variableID) {
} else return 0.;
}
case FixedCostMale_NorthernRegions -> {
if(getMale().getLabourSupplyHoursWeekly() > 0 && (region.equals(Region.ITC) || region.equals(Region.ITH))) {
return 1.;
} else return 0.;
return 0.;
}
case FixedCostMale_SouthernRegions -> {
if(getMale().getLabourSupplyHoursWeekly() > 0 && (region.equals(Region.ITF) || region.equals(Region.ITG))) {
return 1.;
} else return 0.;
return 0.;
}
case FixedCostFemale -> {
if(getFemale().getLabourSupplyHoursWeekly() > 0) {
return 1.;
} else return 0.;
}
case FixedCostFemale_NorthernRegions -> {
if(getFemale().getLabourSupplyHoursWeekly() > 0 && (region.equals(Region.ITC) || region.equals(Region.ITH))) {
return 1.;
} else return 0.;
return 0.;
}
case FixedCostFemale_SouthernRegions -> {
if(getFemale().getLabourSupplyHoursWeekly() > 0 && (region.equals(Region.ITF) || region.equals(Region.ITG))) {
return 1.;
} else return 0.;
return 0.;
}
case FixedCostMale_NChildren017 -> {
if(getMale().getLabourSupplyHoursWeekly() > 0) {
Expand Down Expand Up @@ -3051,16 +3043,9 @@ public double getDoubleValue(Enum<?> variableID) {
return 0.; //Our model doesn't take account of elderly (as people move out of parental home when 18 years old, and we do not provide a mechanism for parents to move back in.
}
case HoursMaleByDregion -> {
if(model.getCountry().equals(Country.IT)) {
if(getRegion().equals(Region.ITF) || getRegion().equals(Region.ITG)) { //For South Italy (Sud) and Islands (Isole)
return getMale().getLabourSupplyHoursWeekly();
} else return 0.;
} else if(model.getCountry().equals(Country.UK)) {
if(getRegion().equals(Region.UKI)) { //For London
return getMale().getLabourSupplyHoursWeekly();
} else return 0.;
} else throw new IllegalArgumentException("Error - household " + this.getId() + " has region " + getRegion() + " which is not yet handled in DonorHousehold.getDoubleValue()!");

if(getRegion().equals(Region.UKI)) { //For London
return getMale().getLabourSupplyHoursWeekly();
} else return 0.;
}
case HoursFemale -> {
return getFemale().getLabourSupplyHoursWeekly();
Expand All @@ -3087,15 +3072,9 @@ public double getDoubleValue(Enum<?> variableID) {
return 0.; //Our model doesn't take account of elderly (as people move out of parental home when 18 years old, and we do not provide a mechanism for parents to move back in.
}
case HoursFemaleByDregion -> { //Value of hours are already taken into account by multiplying regression coefficients in Parameters class
if(model.getCountry().equals(Country.IT)) {
if(getRegion().equals(Region.ITF) || getRegion().equals(Region.ITG)) { //For South Italy (Sud) and Islands (Isole)
return getFemale().getLabourSupplyHoursWeekly();
} else return 0.;
} else if(model.getCountry().equals(Country.UK)) {
if(getRegion().equals(Region.UKI)) { //For London
return getFemale().getLabourSupplyHoursWeekly();
} else return 0.;
} else throw new IllegalArgumentException("Error - household " + this.getKey().getId() + " has region " + getRegion() + " which is not yet handled in DonorHousehold.getDoubleValue()!");
if(getRegion().equals(Region.UKI)) { //For London
return getFemale().getLabourSupplyHoursWeekly();
} else return 0.;

//The following regressors for FixedCosts appear as negative in the Utility regression, and so are multiplied by a factor of -1 below.
//The following regressors only apply when the male hours worked is greater than 0
Expand Down
Loading
Loading