Class ImmutablePersonHistory

java.lang.Object
io.github.ai4ci.abm.ImmutablePersonHistory
All Implemented Interfaces:
Abstraction.TemporalState<Person>, PersonHistory, PersonTemporalState, Serializable

@ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutablePersonHistory extends Object implements PersonHistory
Immutable implementation of PersonHistory.

Use the builder to create immutable instances: ImmutablePersonHistory.builder().

See Also:
  • Method Details

    • getEntity

      public Person getEntity()
      Specified by:
      getEntity in interface Abstraction.TemporalState<Person>
      Returns:
      The value of the entity attribute
    • getTime

      public Integer getTime()
      Specified by:
      getTime in interface Abstraction.TemporalState<Person>
      Returns:
      The value of the time attribute
    • getUrn

      public String getUrn()
      Specified by:
      getUrn in interface Abstraction.TemporalState<Person>
      Returns:
      The computed-at-construction value of the urn attribute
    • isInfectious

      public boolean isInfectious()
      Is the persons internal viral load above the threshold for potential infectivity.
      Specified by:
      isInfectious in interface PersonTemporalState
    • isSymptomatic

      public boolean isSymptomatic()
      Is the persons internal infected targets above the threshold for exhibiting symptoms.
      Specified by:
      isSymptomatic in interface PersonTemporalState
    • isReportedSymptomatic

      public boolean isReportedSymptomatic()
      Is the persons internal infected targets above the threshold for exhibiting symptoms and they have reported it on a smart agent.
      Specified by:
      isReportedSymptomatic in interface PersonTemporalState
    • isRequiringHospitalisation

      public boolean isRequiringHospitalisation()
      Is the persons disease severe enough to require hospitalisation
      Specified by:
      isRequiringHospitalisation in interface PersonTemporalState
    • isDead

      public boolean isDead()
      Specified by:
      isDead in interface PersonTemporalState
      Returns:
      The value of the dead attribute
    • getNormalisedSeverity

      public double getNormalisedSeverity()
      A continuous value for the severity of disease, as determined by the in host model. This is interpreted relative to disease cutoffs, which are calibrated, so its not really normalised at all and this may change.
      Specified by:
      getNormalisedSeverity in interface PersonTemporalState
    • getNormalisedViralLoad

      public double getNormalisedViralLoad()
      A continuous value for the viral load of disease, as determined by the in host model. This is scaled to be 0 if uninfected and 1 if minimally infectious. Values smaller than 1 imply viral load may be detectible by tests but not infectious. This may need to be revisited with a view to more formally relating viral load with infectivity.
      Specified by:
      getNormalisedViralLoad in interface PersonTemporalState
    • getContactExposure

      public double getContactExposure()
      The viral exposure an individual experienced in a day as a result of all contacts in the model (there is also a random chance of exposure due to importation). This should be on the same scale as the viral load.
      Specified by:
      getContactExposure in interface PersonTemporalState
    • getPresumedLocalPrevalence

      public double getPresumedLocalPrevalence()
      An estimate of the local prevalence as estimated by the probability of infection in todays contacts, as might be calculated by a smart agent.
      Specified by:
      getPresumedLocalPrevalence in interface PersonTemporalState
    • getTodaysTests

      public com.google.common.collect.ImmutableList<TestResult> getTodaysTests()
      The list of tests taken on this day. Initially the result will be marked as PENDING until the test is processed. (the true result is available internally to the model immediately, but not necessarily observed).
      Specified by:
      getTodaysTests in interface PersonHistory
    • getTodaysContacts

      public Contact[] getTodaysContacts()
      A list of contacts made in this time period and their weight from the perspective of transmission (i.e. context). Weights might be less if for example the participants are wearing masks. In the future we might build contact venue into this context.
      Specified by:
      getTodaysContacts in interface PersonHistory
      Returns:
    • getTodaysExposures

      public Exposure[] getTodaysExposures()
      A list of exposures made in this time period. These are contacts who are infectious.
      Specified by:
      getTodaysExposures in interface PersonHistory
    • getMaxDelay

      public int getMaxDelay()
      The maximum delay for test results for this individual is used when we assemble the forward looking list of test results on a per day basis. i.e. the list of results organised by sample date as they would appear on the release date, including delay distribution.
      Specified by:
      getMaxDelay in interface PersonHistory
    • withEntity

      public final ImmutablePersonHistory withEntity(Person value)
      Copy the current immutable object by setting a value for the entity attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for entity
      Returns:
      A modified copy of the this object
    • withTime

      public final ImmutablePersonHistory withTime(Integer value)
      Copy the current immutable object by setting a value for the time attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for time
      Returns:
      A modified copy of the this object
    • withInfectious

      public final ImmutablePersonHistory withInfectious(boolean value)
      Copy the current immutable object by setting a value for the infectious attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for infectious
      Returns:
      A modified copy of the this object
    • withSymptomatic

      public final ImmutablePersonHistory withSymptomatic(boolean value)
      Copy the current immutable object by setting a value for the symptomatic attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for symptomatic
      Returns:
      A modified copy of the this object
    • withReportedSymptomatic

      public final ImmutablePersonHistory withReportedSymptomatic(boolean value)
      Copy the current immutable object by setting a value for the reportedSymptomatic attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for reportedSymptomatic
      Returns:
      A modified copy of the this object
    • withRequiringHospitalisation

      public final ImmutablePersonHistory withRequiringHospitalisation(boolean value)
      Copy the current immutable object by setting a value for the requiringHospitalisation attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for requiringHospitalisation
      Returns:
      A modified copy of the this object
    • withDead

      public final ImmutablePersonHistory withDead(boolean value)
      Copy the current immutable object by setting a value for the dead attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for dead
      Returns:
      A modified copy of the this object
    • withNormalisedSeverity

      public final ImmutablePersonHistory withNormalisedSeverity(double value)
      Copy the current immutable object by setting a value for the normalisedSeverity attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for normalisedSeverity
      Returns:
      A modified copy of the this object
    • withNormalisedViralLoad

      public final ImmutablePersonHistory withNormalisedViralLoad(double value)
      Copy the current immutable object by setting a value for the normalisedViralLoad attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for normalisedViralLoad
      Returns:
      A modified copy of the this object
    • withContactExposure

      public final ImmutablePersonHistory withContactExposure(double value)
      Copy the current immutable object by setting a value for the contactExposure attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for contactExposure
      Returns:
      A modified copy of the this object
    • withPresumedLocalPrevalence

      public final ImmutablePersonHistory withPresumedLocalPrevalence(double value)
      Copy the current immutable object by setting a value for the presumedLocalPrevalence attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for presumedLocalPrevalence
      Returns:
      A modified copy of the this object
    • withTodaysTests

      public final ImmutablePersonHistory withTodaysTests(TestResult... elements)
      Copy the current immutable object with elements that replace the content of todaysTests.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withTodaysTests

      public final ImmutablePersonHistory withTodaysTests(Iterable<? extends TestResult> elements)
      Copy the current immutable object with elements that replace the content of todaysTests. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of todaysTests elements to set
      Returns:
      A modified copy of this object
    • withTodaysContacts

      public final ImmutablePersonHistory withTodaysContacts(Contact... elements)
      Copy the current immutable object with elements that replace the content of todaysContacts. The array is cloned before being saved as attribute values.
      Parameters:
      elements - The non-null elements for todaysContacts
      Returns:
      A modified copy of this object
    • withTodaysExposures

      public final ImmutablePersonHistory withTodaysExposures(Exposure... elements)
      Copy the current immutable object with elements that replace the content of todaysExposures. The array is cloned before being saved as attribute values.
      Parameters:
      elements - The non-null elements for todaysExposures
      Returns:
      A modified copy of this object
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutablePersonHistory that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: entity, time, urn, infectious, symptomatic, reportedSymptomatic, requiringHospitalisation, dead, normalisedSeverity, normalisedViralLoad, contactExposure, presumedLocalPrevalence, todaysTests, todaysContacts, todaysExposures, maxDelay.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value PersonHistory with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • getInfector

      public Optional<PersonHistory> getInfector()
      For a new infection this finds the contact with maximal viral exposure on the first day before the subject is infectious when the subject was exposed by an "infector". From this "infector" the time of their infection is identified so that all the infections from one infector should map back to the same instant in time for that infector.

      Returns a lazily initialized value of the infector attribute. Initialized once and only once and stored for subsequent access with proper synchronization. In case of any exception or error thrown by the lazy value initializer, the result will not be memoised (i.e. remembered) and on next call computation will be attempted again.

      Specified by:
      getInfector in interface PersonHistory
      Returns:
      A lazily initialized value of the infector attribute
    • getInfectiousContact

      public Optional<Exposure> getInfectiousContact()
      For a new infection this finds the contact with maximal viral exposure on the first day before the subject is infectious when the subject was exposed by an "infector". From this "infector" the time of their infection is identified so that all the infections from one infector should map back to the same instant in time for that infector.

      Returns a lazily initialized value of the infectiousContact attribute. Initialized once and only once and stored for subsequent access with proper synchronization. In case of any exception or error thrown by the lazy value initializer, the result will not be memoised (i.e. remembered) and on next call computation will be attempted again.

      Specified by:
      getInfectiousContact in interface PersonHistory
      Returns:
      A lazily initialized value of the infectiousContact attribute
    • getInfectionStart

      public Optional<PersonHistory> getInfectionStart()
      If person is infected here find the infectee state at the point in time they became infectious.

      Returns a lazily initialized value of the infectionStart attribute. Initialized once and only once and stored for subsequent access with proper synchronization. In case of any exception or error thrown by the lazy value initializer, the result will not be memoised (i.e. remembered) and on next call computation will be attempted again.

      Specified by:
      getInfectionStart in interface PersonHistory
      Returns:
      A lazily initialized value of the infectionStart attribute
    • getNewInfection

      public Optional<PersonHistory> getNewInfection()
      Find if a person is newly infectious on this day. This is not the same as being newly exposed.

      Returns a lazily initialized value of the newInfection attribute. Initialized once and only once and stored for subsequent access with proper synchronization. In case of any exception or error thrown by the lazy value initializer, the result will not be memoised (i.e. remembered) and on next call computation will be attempted again.

      Specified by:
      getNewInfection in interface PersonHistory
      Returns:
      A lazily initialized value of the newInfection attribute
    • isIncidentExposure

      public boolean isIncidentExposure()
      Is this person newly exposed on this day? defined as the first time a non zero exposure is recorded within one infectious period.

      Returns a lazily initialized value of the incidentExposure attribute. Initialized once and only once and stored for subsequent access with proper synchronization. In case of any exception or error thrown by the lazy value initializer, the result will not be memoised (i.e. remembered) and on next call computation will be attempted again.

      Specified by:
      isIncidentExposure in interface PersonHistory
      Returns:
      A lazily initialized value of the incidentExposure attribute
    • isIncidentInfection

      public boolean isIncidentInfection()
      Is this person newly infectious on this day.

      Returns a lazily initialized value of the incidentInfection attribute. Initialized once and only once and stored for subsequent access with proper synchronization. In case of any exception or error thrown by the lazy value initializer, the result will not be memoised (i.e. remembered) and on next call computation will be attempted again.

      Specified by:
      isIncidentInfection in interface PersonHistory
      Returns:
      A lazily initialized value of the incidentInfection attribute
    • isIncidentHospitalisation

      public boolean isIncidentHospitalisation()
      Is this person newly needing hospitalisation on this day, or is this part of the same infection episode (as defined by the average duration of symptoms.

      Returns a lazily initialized value of the incidentHospitalisation attribute. Initialized once and only once and stored for subsequent access with proper synchronization. In case of any exception or error thrown by the lazy value initializer, the result will not be memoised (i.e. remembered) and on next call computation will be attempted again.

      Specified by:
      isIncidentHospitalisation in interface PersonHistory
      Returns:
      A lazily initialized value of the incidentHospitalisation attribute
    • getResults

      public List<TestResult> getResults()
      The collection of possibly still relevant test results for an individual that generate a result on this day, regardless of when they were taken. This does look backwards over all possibly relevant tests, there is possibility that some tests that take a very long time to process compared to the infectious period will not get picked up by this logic and we may have to revisit

      Returns a lazily initialized value of the results attribute. Initialized once and only once and stored for subsequent access with proper synchronization. In case of any exception or error thrown by the lazy value initializer, the result will not be memoised (i.e. remembered) and on next call computation will be attempted again.

      Specified by:
      getResults in interface PersonHistory
      Returns:
      A lazily initialized value of the results attribute
    • getResultsBySampleDate

      public List<List<TestResult>> getResultsBySampleDate()
      The list of tests taken on this day, indexed by the delay until the results are available.

      Returns a lazily initialized value of the resultsBySampleDate attribute. Initialized once and only once and stored for subsequent access with proper synchronization. In case of any exception or error thrown by the lazy value initializer, the result will not be memoised (i.e. remembered) and on next call computation will be attempted again.

      Specified by:
      getResultsBySampleDate in interface PersonHistory
      Returns:
      A lazily initialized value of the resultsBySampleDate attribute
    • copyOf

      public static ImmutablePersonHistory copyOf(PersonHistory instance)
      Creates an immutable copy of a PersonHistory value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable PersonHistory instance
    • toBuilder

      public ImmutablePersonHistory.Builder toBuilder()
      Creates a builder for ImmutablePersonHistory.prefilled with attibute values of this instance to easily create modified copies.
      Returns:
      A new ImmutablePersonHistory builder with attributes of this instance
    • builder

      public static ImmutablePersonHistory.Builder builder()
      Creates a builder for ImmutablePersonHistory.
       ImmutablePersonHistory.builder()
          .setEntity(io.github.ai4ci.abm.Person) // required entity
          .setTime(Integer) // required time
          .setInfectious(boolean) // required infectious
          .setSymptomatic(boolean) // required symptomatic
          .setReportedSymptomatic(boolean) // required reportedSymptomatic
          .setRequiringHospitalisation(boolean) // required requiringHospitalisation
          .setDead(boolean) // required dead
          .setNormalisedSeverity(double) // required normalisedSeverity
          .setNormalisedViralLoad(double) // required normalisedViralLoad
          .setContactExposure(double) // required contactExposure
          .setPresumedLocalPrevalence(double) // required presumedLocalPrevalence
          .addTodaysTest|addAllTodaysTests(io.github.ai4ci.abm.TestResult) // todaysTests elements
          .setTodaysContacts(io.github.ai4ci.abm.Contact) // required todaysContacts
          .setTodaysExposures(io.github.ai4ci.abm.Exposure) // required todaysExposures
          .build();
       
      Returns:
      A new ImmutablePersonHistory builder