Class ImmutablePersonState

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

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

Use the builder to create immutable instances: ImmutablePersonState.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
    • getTransmissibilityModifier

      public double getTransmissibilityModifier()
      An odds ratio of transmission that modifies the baseline probability of transmission to another person
      Specified by:
      getTransmissibilityModifier in interface PersonState
    • getMobilityModifier

      public double getMobilityModifier()
      An odds ratio of mobility that modifies the baseline contact probability
      Specified by:
      getMobilityModifier in interface PersonState
    • getComplianceModifier

      public double getComplianceModifier()
      An odds ratio of compliance that modifies the baseline compliance probability that the person is going to follow guidance.
      Specified by:
      getComplianceModifier in interface PersonState
    • getSusceptibilityModifier

      public double getSusceptibilityModifier()
      An odds ratio of that modifies the baseline probability of transmission from another person to this one
      Specified by:
      getSusceptibilityModifier in interface PersonState
    • getAppUseModifier

      public double getAppUseModifier()
      An odds ratio that modifies the baseline probability that the person is using a smart agent to record data, and get personalised guidance
      Specified by:
      getAppUseModifier in interface PersonState
    • getImportationExposure

      public double getImportationExposure()
      A viral exposure as a result of importation this may be the result of a time varying function representing external drivers.
      Specified by:
      getImportationExposure in interface PersonState
    • getImmunisationDose

      public double getImmunisationDose()
      An immunisation dose is a fraction of dormant immune cells that are activated by any immunising exposure in the previous day. Setting this to something non zero implies that the person was immunised at this time point. It is cleared after every timestep by the Updater.
      Specified by:
      getImmunisationDose in interface PersonState
    • getInHostModel

      public InHostModelState<?> getInHostModel()
      Specified by:
      getInHostModel in interface PersonState
      Returns:
      The value of the inHostModel attribute
    • getRiskModel

      public ImmutableRiskModel getRiskModel()
      Specified by:
      getRiskModel in interface PersonState
      Returns:
      The value of the riskModel attribute
    • isInfectious

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

      public boolean isSymptomatic()
      Is the persons in-host state above the calibrated threshold for exhibiting symptoms on this day and symptom sensitivity and specificity are taken into account. This will be non deterministic
      Specified by:
      isSymptomatic in interface PersonState
      Specified by:
      isSymptomatic in interface PersonTemporalState
    • isRequiringHospitalisation

      public boolean isRequiringHospitalisation()
      Is the persons in-host state above the threshold for requiring hospitalisation on this day. This is deterministic on the result of the in-host model at the moment.
      Specified by:
      isRequiringHospitalisation in interface PersonState
      Specified by:
      isRequiringHospitalisation in interface PersonTemporalState
    • isDead

      public boolean isDead()
      The person is dead
      Specified by:
      isDead in interface PersonState
      Specified by:
      isDead in interface PersonTemporalState
    • isReportedSymptomatic

      public boolean isReportedSymptomatic()
      The user has reported symptoms via the app. This means their symptom state can inform local estimates of prevalence.
      Specified by:
      isReportedSymptomatic in interface PersonState
      Specified by:
      isReportedSymptomatic in interface PersonTemporalState
    • isCompliant

      public boolean isCompliant()
      Specified by:
      isCompliant in interface PersonState
      Returns:
      The computed-at-construction value of the compliant attribute
    • isUsingAppToday

      public boolean isUsingAppToday()
      Specified by:
      isUsingAppToday in interface PersonState
      Returns:
      The computed-at-construction value of the usingAppToday attribute
    • withEntity

      public final ImmutablePersonState 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 ImmutablePersonState 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
    • withTransmissibilityModifier

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

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

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

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

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

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

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

      public final ImmutablePersonState withInHostModel(InHostModelState<?> value)
      Copy the current immutable object by setting a value for the inHostModel attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for inHostModel
      Returns:
      A modified copy of the this object
    • withRiskModel

      public final ImmutablePersonState withRiskModel(RiskModel value)
      Copy the current immutable object by setting a value for the riskModel attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for riskModel
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutablePersonState 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, transmissibilityModifier, mobilityModifier, complianceModifier, susceptibilityModifier, appUseModifier, importationExposure, immunisationDose, inHostModel, riskModel, infectious, symptomatic, requiringHospitalisation, dead, reportedSymptomatic, compliant, usingAppToday.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

      public String getBehaviour()

      Returns a lazily initialized value of the behaviour 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:
      getBehaviour in interface PersonState
      Returns:
      A lazily initialized value of the behaviour attribute
    • getContactExposure

      public double getContactExposure()
      A normalised viral load dose, this is converted into virion numbers later and it is the sum of all the exposures over the course of a day. This is always going to work one day behind as the viral load model can only pick up the change for the next day. This is derived form the contact network when that is initialised. N.B. the dose maxes out at 20 times the infectious viral load. This prevents ridiculously large initial viral doses when uncontrolled exponential growth. I could have done this in the getEposure() method of contact to control the maximum amount one individual can expose another by.

      Returns a lazily initialized value of the contactExposure 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:
      getContactExposure in interface PersonState
      Specified by:
      getContactExposure in interface PersonTemporalState
      Returns:
      A lazily initialized value of the contactExposure attribute
    • getPresumedLocalPrevalence

      public double getPresumedLocalPrevalence()
      Estimate the local prevalence for an individual. This is average of all this person's contacts presumed probability of being infectious. I.e. if a contact has a positive test result their risk will be higher, and this will .

      Returns a lazily initialized value of the presumedLocalPrevalence 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:
      getPresumedLocalPrevalence in interface PersonState
      Specified by:
      getPresumedLocalPrevalence in interface PersonTemporalState
      Returns:
      A lazily initialized value of the presumedLocalPrevalence attribute
    • getTrueLocalPrevalence

      public double getTrueLocalPrevalence()
      How many people in this persons recent contacts are infectious regardless of whether on not the contact is detected. This integrates over approx one infectious period (0.95 quantile) so will be lagged.

      Returns a lazily initialized value of the trueLocalPrevalence 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:
      getTrueLocalPrevalence in interface PersonState
      Returns:
      A lazily initialized value of the trueLocalPrevalence attribute
    • getLastTest

      public Optional<TestResult> getLastTest()
      Most recent (relevant) test whether or not there is a result. This is not particularly deterministic and weakly assumes there is only one test per day.

      Returns a lazily initialized value of the lastTest 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:
      getLastTest in interface PersonState
      Returns:
      A lazily initialized value of the lastTest attribute
    • getLastResult

      public Optional<TestResult> getLastResult()
      Most recent test with a result, so excluding pending results.

      Returns a lazily initialized value of the lastResult 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:
      getLastResult in interface PersonState
      Returns:
      A lazily initialized value of the lastResult attribute
    • copyOf

      public static ImmutablePersonState copyOf(PersonState instance)
      Creates an immutable copy of a PersonState 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 PersonState instance
    • toBuilder

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

      public static ImmutablePersonState.Builder builder()
      Creates a builder for ImmutablePersonState.
       ImmutablePersonState.builder()
          .setEntity(io.github.ai4ci.abm.Person) // required entity
          .setTime(Integer) // required time
          .setTransmissibilityModifier(double) // optional transmissibilityModifier
          .setMobilityModifier(double) // optional mobilityModifier
          .setComplianceModifier(double) // optional complianceModifier
          .setSusceptibilityModifier(double) // optional susceptibilityModifier
          .setAppUseModifier(double) // optional appUseModifier
          .setImportationExposure(double) // optional importationExposure
          .setImmunisationDose(double) // optional immunisationDose
          .setInHostModel(io.github.ai4ci.abm.inhost.InHostModelState&lt;?&gt;) // required inHostModel
          .setRiskModel(io.github.ai4ci.abm.riskmodel.RiskModel) // optional riskModel
          .build();
       
      Returns:
      A new ImmutablePersonState builder