Class Generator

java.lang.Object
org.mitre.synthea.engine.Generator

public class Generator extends Object
Generator creates a population by running the generic modules each timestep per Person.
  • Field Details

    • id

      public final UUID id
      Unique ID for this instance of the Generator. Even if the same settings are used multiple times, this ID should be unique.
    • options

      Options for configuring the generator.
    • timestep

      public long timestep
      The amount of time per timestep, in milliseconds.
    • stop

      public long stop
      The time at which the simulation stops, in milliseconds since epoch.
    • referenceTime

      public long referenceTime
      The reference time for the simulation, in milliseconds since epoch.
    • stats

      public Map<String,AtomicInteger> stats
      Statistics about the generated population, such as counts of alive and dead individuals.
    • location

      public Location location
      The location where the population is generated.
    • totalGeneratedPopulation

      public AtomicInteger totalGeneratedPopulation
      The total number of individuals generated in the population.
    • DEFAULT_STATE

      public static String DEFAULT_STATE
      The state to default to
    • entityManager

      public static EntityManager entityManager
      EntityManager is used to manage fixed patient demographics records.
    • threadPoolSize

      public final int threadPoolSize
      The size of the thread pool used for generating patients.
  • Constructor Details

    • Generator

      public Generator()
      Create a Generator, using all default settings.
    • Generator

      public Generator(int population)
      Create a Generator, with the given population size and seed. All other settings are left as defaults.
      Parameters:
      population - Target population size
    • Generator

      public Generator(int population, long seed, long clinicianSeed)
      Create a Generator, with the given population size and seed. All other settings are left as defaults.
      Parameters:
      population - Target population size
      seed - Seed used for randomness
      clinicianSeed - Seed used for clinician randomness
    • Generator

      public Generator(Generator.GeneratorOptions o)
      Create a Generator, with the given options.
      Parameters:
      o - Desired configuration options
    • Generator

      public Generator(Generator.GeneratorOptions o, org.mitre.synthea.export.Exporter.ExporterRuntimeOptions ero)
      Create a Generator, with the given options.
      Parameters:
      o - Desired configuration options
      ero - Desired exporter options
  • Method Details

    • run

      public void run()
      Generate the population, using the currently set configuration settings.
    • generatePerson

      @Deprecated public Person generatePerson(int index)
      Deprecated.
      Generate a completely random Person. The returned person will be alive at the end of the simulation. This means that if in the course of the simulation the person dies, a new person will be started to replace them. The seed used to generate the person is randomized as well. Note that this method is only used by unit tests.
      Parameters:
      index - Target index in the whole set of people to generate
      Returns:
      generated Person
    • generatePerson

      public Person generatePerson(int index, long personSeed)
      Generate a random Person, from the given seed. The returned person will be alive at the end of the simulation. This means that if in the course of the simulation the person dies, a new person will be started to replace them. Note also that if the person dies, the seed to produce them can't be re-used (otherwise the new person would die as well) so a new seed is picked, based on the given seed.
      Parameters:
      index - Target index in the whole set of people to generate
      personSeed - Seed for the random person
      Returns:
      generated Person
    • checkCriteria

      public org.mitre.synthea.engine.Generator.CriteriaCheck checkCriteria(Person person, long finishTime, int index, boolean isAlive)
      Determines if a patient meets the requested criteria. If a patient does not meet the criteria the process will be repeated so a new one is generated.
      Parameters:
      person - the patient to check if we want to export them
      finishTime - the time simulation finished
      index - Target index in the whole set of people to generate
      isAlive - Whether the patient is alive at end of simulation.
      Returns:
      CriteriaCheck to determine if the patient should be exported/re-simulated
    • updateRecordExportPerson

      public Person updateRecordExportPerson(Person person, int index)
      Update person record to stop time, record the entry and export record.
      Parameters:
      person - the person to update and export
      index - the index of the person being updated
      Returns:
      the updated person
    • createPerson

      public Person createPerson(long personSeed, Map<String,Object> demoAttributes)
      Create a new person and update them until Generator.stop or they die, whichever comes sooner.
      Parameters:
      personSeed - Seed for the random person
      demoAttributes - Demographic attributes for the new person, randomDemographics(org.mitre.synthea.helpers.RandomNumberGenerator)
      Returns:
      the new person
    • updatePerson

      public void updatePerson(Person person)
      Update a previously created person from the time they were last updated until Generator.stop or they die, whichever comes sooner.
      Parameters:
      person - the previously created person to update
    • randomDemographics

      public Map<String,Object> randomDemographics(RandomNumberGenerator random)
      Create a set of random demographics.
      Parameters:
      random - The random number generator to use.
      Returns:
      a map of random demographics
    • pickFixedDemographics

      public Map<String,Object> pickFixedDemographics(Entity entity, RandomNumberGenerator random)
      Pick a person's demographics based on their seed fixed record.
      Parameters:
      entity - The record group to pull demographics from.
      random - Random object.
      Returns:
      a map of fixed demographics
    • recordPerson

      public void recordPerson(Person person, int index)
      Record the person using whatever tracking mechanisms are currently configured.
      Parameters:
      person - the person to record
      index - the index of the person being recorded, e.g. if generating 100 people, the index would identify which of those 100 is being recorded.
    • getRandomizer

      public RandomNumberGenerator getRandomizer()
      Get the seeded random number generator used by this Generator.
      Returns:
      the random number generator.