use of org.mitre.synthea.helpers.DefaultRandomNumberGenerator in project synthea by synthetichealth.
the class GeneratorTest method testUpdateAfterCreation.
@Test
public void testUpdateAfterCreation() throws Exception {
// Get 100 people
Generator.GeneratorOptions opts = new Generator.GeneratorOptions();
opts.population = 1;
opts.minAge = 50;
opts.maxAge = 100;
Generator generator = new Generator(opts);
final int NUM_RECS = 10;
Person[] people = new Person[NUM_RECS];
for (int i = 0; i < NUM_RECS; i++) {
long personSeed = UUID.randomUUID().getMostSignificantBits() & Long.MAX_VALUE;
RandomNumberGenerator random = new DefaultRandomNumberGenerator(personSeed);
Map<String, Object> demoAttributes = generator.randomDemographics(random);
people[i] = generator.createPerson(personSeed, demoAttributes);
generator.recordPerson(people[i], i);
}
// Update them for 10 years in the future
generator.stop = generator.stop + Utilities.convertTime("years", 10);
for (Person p : people) {
generator.updatePerson(p);
}
}
use of org.mitre.synthea.helpers.DefaultRandomNumberGenerator in project synthea by synthetichealth.
the class Generator method init.
private void init() {
if (options.state == null) {
options.state = DEFAULT_STATE;
}
int stateIndex = Location.getIndex(options.state);
if (Config.getAsBoolean("exporter.cdw.export")) {
CDWExporter.getInstance().setKeyStart((stateIndex * 1_000_000) + 1);
}
this.populationRandom = new DefaultRandomNumberGenerator(options.seed);
this.clinicianRandom = new DefaultRandomNumberGenerator(options.clinicianSeed);
this.timestep = Long.parseLong(Config.get("generate.timestep"));
this.stop = options.endTime;
this.referenceTime = options.referenceTime;
this.location = new Location(options.state, options.city);
this.logLevel = Config.get("generate.log_patients.detail", "simple");
this.onlyDeadPatients = Config.getAsBoolean("generate.only_dead_patients");
this.onlyAlivePatients = Config.getAsBoolean("generate.only_alive_patients");
// If both values are set to true, then they are both set back to the default
if (this.onlyDeadPatients && this.onlyAlivePatients) {
Config.set("generate.only_dead_patients", "false");
Config.set("generate.only_alive_patients", "false");
this.onlyDeadPatients = false;
this.onlyAlivePatients = false;
}
try {
this.maxAttemptsToKeepPatient = Long.parseLong(Config.get("generate.max_attempts_to_keep_patient", "1000"));
if (this.maxAttemptsToKeepPatient == 0) {
// set it to null to make the check more clear
this.maxAttemptsToKeepPatient = null;
}
} catch (Exception e) {
this.maxAttemptsToKeepPatient = null;
}
this.onlyVeterans = Config.getAsBoolean("generate.veteran_population_override");
this.totalGeneratedPopulation = new AtomicInteger(0);
this.stats = Collections.synchronizedMap(new HashMap<String, AtomicInteger>());
this.modulePredicate = getModulePredicate();
stats.put("alive", new AtomicInteger(0));
stats.put("dead", new AtomicInteger(0));
if (Config.getAsBoolean("generate.track_detailed_transition_metrics", false)) {
this.metrics = new TransitionMetrics();
}
// initialize hospitals
Provider.loadProviders(location, this.clinicianRandom);
// Initialize Payers
Payer.loadPayers(location);
// ensure modules load early
if (options.localModuleDir != null) {
Module.addModules(options.localModuleDir);
}
List<String> coreModuleNames = getModuleNames(Module.getModules(path -> false));
List<String> moduleNames = getModuleNames(Module.getModules(modulePredicate));
if (options.keepPatientsModulePath != null) {
try {
Path path = options.keepPatientsModulePath.toPath().toAbsolutePath();
this.keepPatientsModule = Module.loadFile(path, false, null, true);
} catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
}
// ensure cost data loads early
Costs.loadCostData();
String locationName;
if (options.city == null) {
locationName = options.state;
} else {
locationName = options.city + ", " + options.state;
}
System.out.println("Running with options:");
System.out.println(String.format("Population: %d\nSeed: %d\nProvider Seed:%d\nReference Time: %d\nLocation: %s", options.population, options.seed, options.clinicianSeed, options.referenceTime, locationName));
System.out.println(String.format("Min Age: %d\nMax Age: %d", options.minAge, options.maxAge));
if (options.gender != null) {
System.out.println(String.format("Gender: %s", options.gender));
}
if (options.enabledModules != null) {
moduleNames.removeAll(coreModuleNames);
moduleNames.sort(String::compareToIgnoreCase);
System.out.println("Modules: " + String.join("\n & ", moduleNames));
System.out.println(String.format(" > [%d loaded]", moduleNames.size()));
}
if (Config.getAsBoolean("growtherrors", false)) {
HealthRecordEditors hrm = HealthRecordEditors.getInstance();
hrm.registerEditor(new GrowthDataErrorsEditor());
}
}
Aggregations