Skip to content

Commit

Permalink
Merge pull request #931 from synthetichealth/c19-updates
Browse files Browse the repository at this point in the history
COVID-19 Related Updates
  • Loading branch information
jawalonoski authored Sep 16, 2021
2 parents 440c0a4 + 86de12d commit a3482c8
Show file tree
Hide file tree
Showing 18 changed files with 2,156 additions and 69 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/mitre/synthea/engine/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.mitre.synthea.modules.LifecycleModule;
import org.mitre.synthea.modules.QualityOfLifeModule;
import org.mitre.synthea.modules.WeightLossModule;
import org.mitre.synthea.modules.covid.C19ImmunizationModule;
import org.mitre.synthea.world.agents.Person;

/**
Expand Down Expand Up @@ -72,6 +73,7 @@ private static Map<String, ModuleSupplier> loadModules() {
retVal.put("Cardiovascular Disease", new ModuleSupplier(new CardiovascularDiseaseModule()));
retVal.put("Quality Of Life", new ModuleSupplier(new QualityOfLifeModule()));
retVal.put("Weight Loss", new ModuleSupplier(new WeightLossModule()));
retVal.put("COVID-19 Immunization Module", new ModuleSupplier(new C19ImmunizationModule()));

Properties moduleOverrides = getModuleOverrides();

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/mitre/synthea/helpers/Attributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.mitre.synthea.modules.Immunizations;
import org.mitre.synthea.modules.LifecycleModule;
import org.mitre.synthea.modules.QualityOfLifeModule;
import org.mitre.synthea.modules.covid.C19ImmunizationModule;
import org.mitre.synthea.world.agents.Person;

/**
Expand Down Expand Up @@ -149,6 +150,7 @@ public static Map<String,Inventory> getAttributeInventory() throws Exception {
Immunizations.inventoryAttributes(attributes);
LifecycleModule.inventoryAttributes(attributes);
QualityOfLifeModule.inventoryAttributes(attributes);
C19ImmunizationModule.inventoryAttributes(attributes);

return attributes;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.mitre.synthea.helpers;

import java.util.List;

import org.apache.commons.math3.distribution.EnumeratedDistribution;
import org.apache.commons.math3.exception.MathArithmeticException;
import org.apache.commons.math3.exception.NotANumberException;
import org.apache.commons.math3.exception.NotFiniteNumberException;
import org.apache.commons.math3.exception.NotPositiveException;
import org.apache.commons.math3.util.Pair;
import org.mitre.synthea.world.agents.Person;

/**
* Class that wraps EnumeratedDistribution for thread safe use in Synthea. In several places in
* Synthea, EnumeratedDistributions are used following a
* <a href="https://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a>. One distribution
* is used in a particular aspect of simulation. To support reproducibility of simulations, its
* source of randomness is reseeded for each individual. Since multiple threads may be accessing
* the distribution at the same time, it would be possible to reseed the distribution in one thread
* but sample on that seed in another thread. This class offers a synchronized method to prevent
* that with the handy side benefit that it takes the well-known and loved Synthea Person as a
* source of randomness.
* @param <T> The type to be returned when sampling from the distribiution.
*/
public class SyncedEnumeratedDistro<T> extends EnumeratedDistribution {
/**
* Just calls super. Look at the docs for EnumeratedDistributed for more details.
* @param pmf List of pairs of values and their weight in the distribution.
*/
public SyncedEnumeratedDistro(List<Pair<T, Double>> pmf) throws NotPositiveException,
MathArithmeticException, NotFiniteNumberException, NotANumberException {
super(pmf);
}

/**
* Sample from the distribution after it has been reseeded using the Person provided as a source
* of randomness.
* @param person Where the randomness comes from
* @return a value from the distribution based on a weighted, random selection
*/
public synchronized T syncedReseededSample(Person person) {
reseedRandomGenerator(person.randLong());
return (T) sample();
}
}
Loading

0 comments on commit a3482c8

Please sign in to comment.