Class ImmutablePersonHistory
- All Implemented Interfaces:
Abstraction.TemporalState<Person>
,PersonHistory
,PersonTemporalState
,Serializable
PersonHistory
.
Use the builder to create immutable instances:
ImmutablePersonHistory.builder()
.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Builds instances of typeImmutablePersonHistory
. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Creates a builder forImmutablePersonHistory
.static ImmutablePersonHistory
copyOf
(PersonHistory instance) Creates an immutable copy of aPersonHistory
value.boolean
This instance is equal to all instances ofImmutablePersonHistory
that have equal attribute values.double
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).If person is infected here find the infectee state at the point in time they became infectious.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".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".int
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.Find if a person is newly infectious on this day.double
A continuous value for the severity of disease, as determined by the in host model.double
A continuous value for the viral load of disease, as determined by the in host model.double
An estimate of the local prevalence as estimated by the probability of infection in todays contacts, as might be calculated by a smart agent.The collection of possibly still relevant test results for an individual that generate a result on this day, regardless of when they were taken.The list of tests taken on this day, indexed by the delay until the results are available.getTime()
Contact[]
A list of contacts made in this time period and their weight from the perspective of transmission (i.e. context).Exposure[]
A list of exposures made in this time period.com.google.common.collect.ImmutableList<TestResult>
The list of tests taken on this day.getUrn()
int
hashCode()
Computes a hash code from attributes:entity
,time
,urn
,infectious
,symptomatic
,reportedSymptomatic
,requiringHospitalisation
,dead
,normalisedSeverity
,normalisedViralLoad
,contactExposure
,presumedLocalPrevalence
,todaysTests
,todaysContacts
,todaysExposures
,maxDelay
.boolean
isDead()
boolean
Is this person newly exposed on this day?boolean
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.boolean
Is this person newly infectious on this day.boolean
Is the persons internal viral load above the threshold for potential infectivity.boolean
Is the persons internal infected targets above the threshold for exhibiting symptoms and they have reported it on a smart agent.boolean
Is the persons disease severe enough to require hospitalisationboolean
Is the persons internal infected targets above the threshold for exhibiting symptoms.Creates a builder forImmutablePersonHistory
.prefilled with attibute values ofthis
instance to easily create modified copies.toString()
Prints the immutable valuePersonHistory
with attribute values.final ImmutablePersonHistory
withContactExposure
(double value) Copy the current immutable object by setting a value for thecontactExposure
attribute.final ImmutablePersonHistory
withDead
(boolean value) Copy the current immutable object by setting a value for thedead
attribute.final ImmutablePersonHistory
withEntity
(Person value) Copy the current immutable object by setting a value for theentity
attribute.final ImmutablePersonHistory
withInfectious
(boolean value) Copy the current immutable object by setting a value for theinfectious
attribute.final ImmutablePersonHistory
withNormalisedSeverity
(double value) Copy the current immutable object by setting a value for thenormalisedSeverity
attribute.final ImmutablePersonHistory
withNormalisedViralLoad
(double value) Copy the current immutable object by setting a value for thenormalisedViralLoad
attribute.final ImmutablePersonHistory
withPresumedLocalPrevalence
(double value) Copy the current immutable object by setting a value for thepresumedLocalPrevalence
attribute.final ImmutablePersonHistory
withReportedSymptomatic
(boolean value) Copy the current immutable object by setting a value for thereportedSymptomatic
attribute.final ImmutablePersonHistory
withRequiringHospitalisation
(boolean value) Copy the current immutable object by setting a value for therequiringHospitalisation
attribute.final ImmutablePersonHistory
withSymptomatic
(boolean value) Copy the current immutable object by setting a value for thesymptomatic
attribute.final ImmutablePersonHistory
Copy the current immutable object by setting a value for thetime
attribute.final ImmutablePersonHistory
withTodaysContacts
(Contact... elements) Copy the current immutable object with elements that replace the content oftodaysContacts
.final ImmutablePersonHistory
withTodaysExposures
(Exposure... elements) Copy the current immutable object with elements that replace the content oftodaysExposures
.final ImmutablePersonHistory
withTodaysTests
(TestResult... elements) Copy the current immutable object with elements that replace the content oftodaysTests
.final ImmutablePersonHistory
withTodaysTests
(Iterable<? extends TestResult> elements) Copy the current immutable object with elements that replace the content oftodaysTests
.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.PersonHistory
getHistoricalContacts, getHistoricalTests, getLastExposure, getNext, getPrevious, getPrevious, getResultsBySampleDate, getStillRelevantContacts, getStillRelevantTests
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
-
isInfectious
public boolean isInfectious()Is the persons internal viral load above the threshold for potential infectivity.- Specified by:
isInfectious
in interfacePersonTemporalState
-
isSymptomatic
public boolean isSymptomatic()Is the persons internal infected targets above the threshold for exhibiting symptoms.- Specified by:
isSymptomatic
in interfacePersonTemporalState
-
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 interfacePersonTemporalState
-
isRequiringHospitalisation
public boolean isRequiringHospitalisation()Is the persons disease severe enough to require hospitalisation- Specified by:
isRequiringHospitalisation
in interfacePersonTemporalState
-
isDead
public boolean isDead()- Specified by:
isDead
in interfacePersonTemporalState
- 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 interfacePersonTemporalState
-
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 interfacePersonTemporalState
-
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 interfacePersonTemporalState
-
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 interfacePersonTemporalState
-
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 interfacePersonHistory
-
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 interfacePersonHistory
- Returns:
-
getTodaysExposures
A list of exposures made in this time period. These are contacts who are infectious.- Specified by:
getTodaysExposures
in interfacePersonHistory
-
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 interfacePersonHistory
-
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
-
withInfectious
Copy the current immutable object by setting a value for theinfectious
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for infectious- Returns:
- A modified copy of the
this
object
-
withSymptomatic
Copy the current immutable object by setting a value for thesymptomatic
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for symptomatic- Returns:
- A modified copy of the
this
object
-
withReportedSymptomatic
Copy the current immutable object by setting a value for thereportedSymptomatic
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for reportedSymptomatic- Returns:
- A modified copy of the
this
object
-
withRequiringHospitalisation
Copy the current immutable object by setting a value for therequiringHospitalisation
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for requiringHospitalisation- Returns:
- A modified copy of the
this
object
-
withDead
Copy the current immutable object by setting a value for thedead
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for dead- Returns:
- A modified copy of the
this
object
-
withNormalisedSeverity
Copy the current immutable object by setting a value for thenormalisedSeverity
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for normalisedSeverity- Returns:
- A modified copy of the
this
object
-
withNormalisedViralLoad
Copy the current immutable object by setting a value for thenormalisedViralLoad
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for normalisedViralLoad- Returns:
- A modified copy of the
this
object
-
withContactExposure
Copy the current immutable object by setting a value for thecontactExposure
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for contactExposure- Returns:
- A modified copy of the
this
object
-
withPresumedLocalPrevalence
Copy the current immutable object by setting a value for thepresumedLocalPrevalence
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for presumedLocalPrevalence- Returns:
- A modified copy of the
this
object
-
withTodaysTests
Copy the current immutable object with elements that replace the content oftodaysTests
.- Parameters:
elements
- The elements to set- Returns:
- A modified copy of
this
object
-
withTodaysTests
Copy the current immutable object with elements that replace the content oftodaysTests
. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
elements
- An iterable of todaysTests elements to set- Returns:
- A modified copy of
this
object
-
withTodaysContacts
Copy the current immutable object with elements that replace the content oftodaysContacts
. 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
Copy the current immutable object with elements that replace the content oftodaysExposures
. 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
This instance is equal to all instances ofImmutablePersonHistory
that have equal attribute values. -
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
. -
toString
Prints the immutable valuePersonHistory
with attribute values. -
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 interfacePersonHistory
- Returns:
- A lazily initialized value of the
infector
attribute
-
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 interfacePersonHistory
- Returns:
- A lazily initialized value of the
infectiousContact
attribute
-
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 interfacePersonHistory
- Returns:
- A lazily initialized value of the
infectionStart
attribute
-
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 interfacePersonHistory
- 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 interfacePersonHistory
- 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 interfacePersonHistory
- 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 interfacePersonHistory
- Returns:
- A lazily initialized value of the
incidentHospitalisation
attribute
-
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 revisitReturns 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 interfacePersonHistory
- Returns:
- A lazily initialized value of the
results
attribute
-
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 interfacePersonHistory
- Returns:
- A lazily initialized value of the
resultsBySampleDate
attribute
-
copyOf
Creates an immutable copy of aPersonHistory
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
Creates a builder forImmutablePersonHistory
.prefilled with attibute values ofthis
instance to easily create modified copies.- Returns:
- A new ImmutablePersonHistory builder with attributes of
this
instance
-
builder
Creates a builder forImmutablePersonHistory
.ImmutablePersonHistory.builder() .setEntity(io.github.ai4ci.abm.Person) // required
entity
.setTime(Integer) // requiredtime
.setInfectious(boolean) // requiredinfectious
.setSymptomatic(boolean) // requiredsymptomatic
.setReportedSymptomatic(boolean) // requiredreportedSymptomatic
.setRequiringHospitalisation(boolean) // requiredrequiringHospitalisation
.setDead(boolean) // requireddead
.setNormalisedSeverity(double) // requirednormalisedSeverity
.setNormalisedViralLoad(double) // requirednormalisedViralLoad
.setContactExposure(double) // requiredcontactExposure
.setPresumedLocalPrevalence(double) // requiredpresumedLocalPrevalence
.addTodaysTest|addAllTodaysTests(io.github.ai4ci.abm.TestResult) //todaysTests
elements .setTodaysContacts(io.github.ai4ci.abm.Contact) // requiredtodaysContacts
.setTodaysExposures(io.github.ai4ci.abm.Exposure) // requiredtodaysExposures
.build();- Returns:
- A new ImmutablePersonHistory builder
-