Class ImmutablePersonState
- All Implemented Interfaces:
Abstraction.TemporalState<Person>
,PersonState
,PersonTemporalState
,Serializable
PersonState
.
Use the builder to create immutable instances:
ImmutablePersonState.builder()
.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Builds instances of typeImmutablePersonState
. -
Field Summary
Fields inherited from interface io.github.ai4ci.abm.PersonState
MAX_EXPOSURE
-
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutablePersonState.Builder
builder()
Creates a builder forImmutablePersonState
.static ImmutablePersonState
copyOf
(PersonState instance) Creates an immutable copy of aPersonState
value.boolean
This instance is equal to all instances ofImmutablePersonState
that have equal attribute values.double
An odds ratio that modifies the baseline probability that the person is using a smart agent to record data, and get personalised guidancedouble
An odds ratio of compliance that modifies the baseline compliance probability that the person is going to follow guidance.double
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.double
An immunisation dose is a fraction of dormant immune cells that are activated by any immunising exposure in the previous day.double
A viral exposure as a result of importation this may be the result of a time varying function representing external drivers.Most recent test with a result, so excluding pending results.Most recent (relevant) test whether or not there is a result.double
An odds ratio of mobility that modifies the baseline contact probabilitydouble
Estimate the local prevalence for an individual.double
An odds ratio of that modifies the baseline probability of transmission from another person to this onegetTime()
double
An odds ratio of transmission that modifies the baseline probability of transmission to another persondouble
How many people in this persons recent contacts are infectious regardless of whether on not the contact is detected.getUrn()
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
.boolean
boolean
isDead()
The person is deadboolean
Is the persons internal viral load above the threshold for potential infectivity.boolean
The user has reported symptoms via the app.boolean
Is the persons in-host state above the threshold for requiring hospitalisation on this day.boolean
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.boolean
Creates a builder forImmutablePersonState
.prefilled with attibute values ofthis
instance to easily create modified copies.toString()
Prints the immutable valuePersonState
with attribute values.final ImmutablePersonState
withAppUseModifier
(double value) Copy the current immutable object by setting a value for theappUseModifier
attribute.final ImmutablePersonState
withComplianceModifier
(double value) Copy the current immutable object by setting a value for thecomplianceModifier
attribute.final ImmutablePersonState
withEntity
(Person value) Copy the current immutable object by setting a value for theentity
attribute.final ImmutablePersonState
withImmunisationDose
(double value) Copy the current immutable object by setting a value for theimmunisationDose
attribute.final ImmutablePersonState
withImportationExposure
(double value) Copy the current immutable object by setting a value for theimportationExposure
attribute.final ImmutablePersonState
withInHostModel
(InHostModelState<?> value) Copy the current immutable object by setting a value for theinHostModel
attribute.final ImmutablePersonState
withMobilityModifier
(double value) Copy the current immutable object by setting a value for themobilityModifier
attribute.final ImmutablePersonState
withRiskModel
(RiskModel value) Copy the current immutable object by setting a value for theriskModel
attribute.final ImmutablePersonState
withSusceptibilityModifier
(double value) Copy the current immutable object by setting a value for thesusceptibilityModifier
attribute.final ImmutablePersonState
Copy the current immutable object by setting a value for thetime
attribute.final ImmutablePersonState
withTransmissibilityModifier
(double value) Copy the current immutable object by setting a value for thetransmissibilityModifier
attribute.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.github.ai4ci.abm.mechanics.Abstraction.TemporalState
getExperimentName, getExperimentReplica, getModelName, getModelReplica
Methods inherited from interface io.github.ai4ci.abm.PersonState
getAbsoluteComplianceDecrease, getAbsoluteMobilityDecrease, getAdjustedAppUseProbability, getAdjustedCompliance, getAdjustedMobility, getAdjustedTransmissibility, getContactCount, getContactHistory, getExposureCount, getExposureHistory, getNormalisedSeverity, getNormalisedViralLoad, getProbabilityInfectiousToday, getRecentRuleOutTests, getStillRelevantTests, getTotalExposure, getYesterday, isCompliant, isLastTestExactly, isRecentlyTested, isRecentlyTested, isSymptomaticConsecutively, isUsingAppToday
Methods inherited from interface io.github.ai4ci.abm.PersonTemporalState
incubPeriod, infPeriod
-
Method Details
-
getEntity
- Specified by:
getEntity
in interfaceAbstraction.TemporalState<Person>
- Returns:
- The value of the
entity
attribute
-
getTime
- Specified by:
getTime
in interfaceAbstraction.TemporalState<Person>
- Returns:
- The value of the
time
attribute
-
getUrn
- Specified by:
getUrn
in interfaceAbstraction.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 interfacePersonState
-
getMobilityModifier
public double getMobilityModifier()An odds ratio of mobility that modifies the baseline contact probability- Specified by:
getMobilityModifier
in interfacePersonState
-
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 interfacePersonState
-
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 interfacePersonState
-
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 interfacePersonState
-
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 interfacePersonState
-
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 interfacePersonState
-
getInHostModel
- Specified by:
getInHostModel
in interfacePersonState
- Returns:
- The value of the
inHostModel
attribute
-
getRiskModel
- Specified by:
getRiskModel
in interfacePersonState
- 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 interfacePersonState
- Specified by:
isInfectious
in interfacePersonTemporalState
-
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 interfacePersonState
- Specified by:
isSymptomatic
in interfacePersonTemporalState
-
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 interfacePersonState
- Specified by:
isRequiringHospitalisation
in interfacePersonTemporalState
-
isDead
public boolean isDead()The person is dead- Specified by:
isDead
in interfacePersonState
- Specified by:
isDead
in interfacePersonTemporalState
-
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 interfacePersonState
- Specified by:
isReportedSymptomatic
in interfacePersonTemporalState
-
isCompliant
public boolean isCompliant()- Specified by:
isCompliant
in interfacePersonState
- Returns:
- The computed-at-construction value of the
compliant
attribute
-
isUsingAppToday
public boolean isUsingAppToday()- Specified by:
isUsingAppToday
in interfacePersonState
- Returns:
- The computed-at-construction value of the
usingAppToday
attribute
-
withEntity
Copy the current immutable object by setting a value for theentity
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for entity- Returns:
- A modified copy of the
this
object
-
withTime
Copy the current immutable object by setting a value for thetime
attribute. An equals check used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for time- Returns:
- A modified copy of the
this
object
-
withTransmissibilityModifier
Copy the current immutable object by setting a value for thetransmissibilityModifier
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for transmissibilityModifier- Returns:
- A modified copy of the
this
object
-
withMobilityModifier
Copy the current immutable object by setting a value for themobilityModifier
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for mobilityModifier- Returns:
- A modified copy of the
this
object
-
withComplianceModifier
Copy the current immutable object by setting a value for thecomplianceModifier
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for complianceModifier- Returns:
- A modified copy of the
this
object
-
withSusceptibilityModifier
Copy the current immutable object by setting a value for thesusceptibilityModifier
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for susceptibilityModifier- Returns:
- A modified copy of the
this
object
-
withAppUseModifier
Copy the current immutable object by setting a value for theappUseModifier
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for appUseModifier- Returns:
- A modified copy of the
this
object
-
withImportationExposure
Copy the current immutable object by setting a value for theimportationExposure
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for importationExposure- Returns:
- A modified copy of the
this
object
-
withImmunisationDose
Copy the current immutable object by setting a value for theimmunisationDose
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for immunisationDose- Returns:
- A modified copy of the
this
object
-
withInHostModel
Copy the current immutable object by setting a value for theinHostModel
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for inHostModel- Returns:
- A modified copy of the
this
object
-
withRiskModel
Copy the current immutable object by setting a value for theriskModel
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for riskModel- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofImmutablePersonState
that have equal attribute values. -
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
. -
toString
Prints the immutable valuePersonState
with attribute values. -
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 interfacePersonState
- 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 interfacePersonState
- Specified by:
getContactExposure
in interfacePersonTemporalState
- 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 interfacePersonState
- Specified by:
getPresumedLocalPrevalence
in interfacePersonTemporalState
- 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 interfacePersonState
- Returns:
- A lazily initialized value of the
trueLocalPrevalence
attribute
-
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 interfacePersonState
- Returns:
- A lazily initialized value of the
lastTest
attribute
-
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 interfacePersonState
- Returns:
- A lazily initialized value of the
lastResult
attribute
-
copyOf
Creates an immutable copy of aPersonState
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
Creates a builder forImmutablePersonState
.prefilled with attibute values ofthis
instance to easily create modified copies.- Returns:
- A new ImmutablePersonState builder with attributes of
this
instance
-
builder
Creates a builder forImmutablePersonState
.ImmutablePersonState.builder() .setEntity(io.github.ai4ci.abm.Person) // required
entity
.setTime(Integer) // requiredtime
.setTransmissibilityModifier(double) // optionaltransmissibilityModifier
.setMobilityModifier(double) // optionalmobilityModifier
.setComplianceModifier(double) // optionalcomplianceModifier
.setSusceptibilityModifier(double) // optionalsusceptibilityModifier
.setAppUseModifier(double) // optionalappUseModifier
.setImportationExposure(double) // optionalimportationExposure
.setImmunisationDose(double) // optionalimmunisationDose
.setInHostModel(io.github.ai4ci.abm.inhost.InHostModelState<?>) // requiredinHostModel
.setRiskModel(io.github.ai4ci.abm.riskmodel.RiskModel) // optionalriskModel
.build();- Returns:
- A new ImmutablePersonState builder
-