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
8 changes: 4 additions & 4 deletions .github/workflows/SimPathsBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ jobs:
name: simpaths_jars
path: .
- name: Setup run
run: java -jar singlerun.jar -c UK -s 2017 -Setup -g false --rewrite-policy-schedule
run: java -jar multirun.jar -DBSetup -config test_create_database.yml
- name: Check input db exists
id: check_file
uses: thebinaryfelix/check-file-existence-action@1.0.0
with:
files: 'input/input.mv.db, input/EUROMODpolicySchedule.xlsx, input/DatabaseCountryYear.xlsx'
- name: Do two runs with persistence to root database
run: java -jar multirun.jar -p 20000 -s 2019 -e 2022 -r 100 -n 2 -g false --persist=root
run: java -jar multirun.jar -config test_run.yml --persist=root

run-simpaths-no-persist:
needs: build
Expand All @@ -82,11 +82,11 @@ jobs:
name: simpaths_jars
path: .
- name: Setup run
run: java -jar singlerun.jar -c UK -s 2017 -Setup -g false --rewrite-policy-schedule
run: java -jar multirun.jar -DBSetup -config test_create_database.yml
- name: Check input db exists
id: check_file
uses: thebinaryfelix/check-file-existence-action@1.0.0
with:
files: 'input/input.mv.db, input/EUROMODpolicySchedule.xlsx, input/DatabaseCountryYear.xlsx'
- name: Do two runs with no persistence
run: java -jar multirun.jar -p 20000 -s 2019 -e 2022 -r 100 -n 2 -g false --persist=none
run: java -jar multirun.jar -config test_run.yml --persist=none
10 changes: 10 additions & 0 deletions config/test_create_database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# FOR TESTING
# CONFIG FILE TO CREATE NEW DATABASE OBJECTS

# Arguments of the SimPathsMultiRun object overridden by the command-line
countryString: "United Kingdom"
executeWithGui: false
randomSeed: 606
startYear: 2019
endYear: 2030
popSize: 40000
17 changes: 17 additions & 0 deletions config/test_run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file can be used to override defaults for multirun arguments.
# Arguments of the SimPathsMultiRun object overridden by the command-line

maxNumberOfRuns: 2
executeWithGui: false
randomSeed: 100
startYear: 2019
endYear: 2022
popSize: 20000

collector_args:
persistStatistics: true
persistStatistics2: true
persistStatistics3: true
persistPersons: false
persistBenefitUnits: false
persistHouseholds: false
20 changes: 19 additions & 1 deletion src/main/java/simpaths/data/Parameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.*;

// import plug-in packages
import org.apache.commons.io.FileUtils;
import simpaths.data.startingpop.DataParser;
import simpaths.model.AnnuityRates;
import simpaths.model.enums.*;
Expand Down Expand Up @@ -1907,7 +1908,19 @@ private static void calculatePopulationGrowthRatiosFromProjections() {

public static TreeMap<Integer, String> calculateEUROMODpolicySchedule(Country country) {
//Load current values for policy description and initiation year
MultiKeyCoefficientMap currentEUROMODpolicySchedule = ExcelAssistant.loadCoefficientMap("input" + File.separator + EUROMODpolicyScheduleFilename + ".xlsx", country.toString(), 1, 3);
MultiKeyCoefficientMap currentEUROMODpolicySchedule;

if (trainingFlag) {
File trainingSchedule = new File("input" + File.separator + "EUROMODoutput" + File.separator + "training" + File.separator + EUROMODpolicyScheduleFilename + ".xlsx");
File runSchedule = new File("input" + File.separator + EUROMODpolicyScheduleFilename + ".xlsx");
try {
FileUtils.copyFile(trainingSchedule, runSchedule);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed that this will always copy the policy schedule if training flag is true. So this scenario is possible:

  • User runs GUI with only training data
  • User modifies policy schedule in GUI to change years
  • User runs model
  • Model then loads calculateEUROMODpolicySchedule, tests whether training flag is true, and if so overwrites user's policy file

Ideally, the training policy schedule file should always be loaded automatically at the very start if only training data is available, and this step should only occur before the user specifies the file.

Or, this file never gets used and if the policy schedule file doesn't match it checks and errors out?

} catch (IOException e) {
System.err.println("Could not replace EUROMODoutput.xlsx from training data");
}
}

currentEUROMODpolicySchedule = ExcelAssistant.loadCoefficientMap("input" + File.separator + EUROMODpolicyScheduleFilename + ".xlsx", country.toString(), 1, 3);
TreeMap<Integer, String> newEUROMODpolicySchedule = new TreeMap<>();

for(Object o: currentEUROMODpolicySchedule.keySet()) {
Expand Down Expand Up @@ -3318,6 +3331,11 @@ public static void databaseSetup(Country country, boolean executeWithGui, int st
String filePath = "./input" + File.separator + "input.mv.db";
safeDelete(filePath);

// Detect if data available; set to testing data if not
Collection<File> testList = FileUtils.listFiles(new File(Parameters.getInputDirectoryInitialPopulations()), new String[]{"csv"}, false);
if (testList.size()==0)
Parameters.setTrainingFlag(true);

// populate new database for starting data
DataParser.databaseFromCSV(country, executeWithGui); // Initial database tables

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ public class RunSimPathsIntegrationTest {
@Order(1)
void testRunSetup() {
runCommand(
"java", "-jar", "singlerun.jar",
"-c", "UK",
"-s", "2017",
"-Setup",
"-g", "false",
"--rewrite-policy-schedule"
"java", "-jar", "multirun.jar", "-DBSetup", "-config", "test_create_database.yml"
);
}

Expand All @@ -48,13 +43,7 @@ void testVerifySetupOutput() {
@Order(3)
void testRunSimulation() {
runCommand(
"java", "-jar", "multirun.jar",
"-p", "20000",
"-s", "2019",
"-e", "2022",
"-r", "100",
"-n", "2",
"-g", "false"
"java", "-jar", "multirun.jar", "-config", "test_run.yml", "-P", "root"
);
}

Expand Down