Class ImmutableRiskModel
- All Implemented Interfaces:
RiskModel
,Serializable
RiskModel
.
Use the builder to create immutable instances:
ImmutableRiskModel.builder()
.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from interface io.github.ai4ci.abm.riskmodel.RiskModel
PROB_REPORTING_NEGATIVE_SYMPTOMS, PROB_REPORTING_POSITIVE_SYMPTOMS
-
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutableRiskModel.Builder
builder()
Creates a builder forImmutableRiskModel
.static ImmutableRiskModel
Creates an immutable copy of aRiskModel
value.boolean
This instance is equal to all instances ofImmutableRiskModel
that have equal attribute values.double[]
What is this evidence of this person being infectious 0..N days in the past judged today expressed as a log odds, based on symptoms and test results that are available today.double
What will the evidence be for this person being infectious today as a result of their past contacts.double
What is this individuals odds ratio of infection today compared to the baseline of the populationint
double
What is this individuals risk of infection today based on a prior?int
getTime()
int
hashCode()
Computes a hash code from attributes:entity
,symptomKernel
,testKernel
,contactsKernel
,directLogOdds
,time
,maxLength
,indirectLogOdds
.Creates a builder forImmutableRiskModel
.prefilled with attibute values ofthis
instance to easily create modified copies.toString()
Prints the immutable valueRiskModel
with attribute values.final ImmutableRiskModel
withContactsKernel
(Kernel value) Copy the current immutable object by setting a value for thecontactsKernel
attribute.final ImmutableRiskModel
withDirectLogOdds
(double... elements) Copy the current immutable object with elements that replace the content ofdirectLogOdds
.final ImmutableRiskModel
withEntity
(Person value) Copy the current immutable object by setting a value for theentity
attribute.final ImmutableRiskModel
withSymptomKernel
(Kernel value) Copy the current immutable object by setting a value for thesymptomKernel
attribute.final ImmutableRiskModel
withTestKernel
(Kernel value) Copy the current immutable object by setting a value for thetestKernel
attribute.final ImmutableRiskModel
withTime
(int value) Copy the current immutable object by setting a value for thetime
attribute.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.github.ai4ci.abm.riskmodel.RiskModel
getDirectLogOddsInPast, update
-
Method Details
-
getEntity
-
getSymptomKernel
- Specified by:
getSymptomKernel
in interfaceRiskModel
- Returns:
- The value of the
symptomKernel
attribute
-
getTestKernel
- Specified by:
getTestKernel
in interfaceRiskModel
- Returns:
- The value of the
testKernel
attribute
-
getContactsKernel
- Specified by:
getContactsKernel
in interfaceRiskModel
- Returns:
- The value of the
contactsKernel
attribute
-
getDirectLogOdds
public double[] getDirectLogOdds()What is this evidence of this person being infectious 0..N days in the past judged today expressed as a log odds, based on symptoms and test results that are available today.- Specified by:
getDirectLogOdds
in interfaceRiskModel
-
getTime
public int getTime() -
getMaxLength
public int getMaxLength()- Specified by:
getMaxLength
in interfaceRiskModel
- Returns:
- The computed-at-construction value of the
maxLength
attribute
-
getIndirectLogOdds
public double getIndirectLogOdds()What will the evidence be for this person being infectious today as a result of their past contacts. This value is would change retrospectively if you estimated it again the next day as the contacts test results and symptoms change. However this is only useful information if we are interested in contacts of contacts. We are no so we do the simpler thing which is look at recent contacts and get an estimate for today only.- Specified by:
getIndirectLogOdds
in interfaceRiskModel
-
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
-
withSymptomKernel
Copy the current immutable object by setting a value for thesymptomKernel
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for symptomKernel- Returns:
- A modified copy of the
this
object
-
withTestKernel
Copy the current immutable object by setting a value for thetestKernel
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for testKernel- Returns:
- A modified copy of the
this
object
-
withContactsKernel
Copy the current immutable object by setting a value for thecontactsKernel
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for contactsKernel- Returns:
- A modified copy of the
this
object
-
withDirectLogOdds
Copy the current immutable object with elements that replace the content ofdirectLogOdds
. The array is cloned before being saved as attribute values.- Parameters:
elements
- The non-null elements for directLogOdds- Returns:
- A modified copy of
this
object
-
withTime
Copy the current immutable object by setting a value for thetime
attribute. A value equality check is 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
-
equals
This instance is equal to all instances ofImmutableRiskModel
that have equal attribute values. -
hashCode
public int hashCode()Computes a hash code from attributes:entity
,symptomKernel
,testKernel
,contactsKernel
,directLogOdds
,time
,maxLength
,indirectLogOdds
. -
toString
Prints the immutable valueRiskModel
with attribute values. -
getProbabilityInfectiousToday
public double getProbabilityInfectiousToday()What is this individuals risk of infection today based on a prior?Returns a lazily initialized value of the
probabilityInfectiousToday
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:
getProbabilityInfectiousToday
in interfaceRiskModel
- Returns:
- A lazily initialized value of the
probabilityInfectiousToday
attribute
-
getLogOddsInfectiousToday
public double getLogOddsInfectiousToday()What is this individuals odds ratio of infection today compared to the baseline of the populationReturns a lazily initialized value of the
logOddsInfectiousToday
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:
getLogOddsInfectiousToday
in interfaceRiskModel
- Returns:
- A lazily initialized value of the
logOddsInfectiousToday
attribute
-
copyOf
Creates an immutable copy of aRiskModel
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 RiskModel instance
-
toBuilder
Creates a builder forImmutableRiskModel
.prefilled with attibute values ofthis
instance to easily create modified copies.- Returns:
- A new ImmutableRiskModel builder with attributes of
this
instance
-
builder
Creates a builder forImmutableRiskModel
.ImmutableRiskModel.builder() .setEntity(io.github.ai4ci.abm.Person) // required
entity
.setSymptomKernel(io.github.ai4ci.abm.riskmodel.Kernel) // requiredsymptomKernel
.setTestKernel(io.github.ai4ci.abm.riskmodel.Kernel) // requiredtestKernel
.setContactsKernel(io.github.ai4ci.abm.riskmodel.Kernel) // requiredcontactsKernel
.setDirectLogOdds(double) // optionaldirectLogOdds
.setTime(int) // requiredtime
.build();- Returns:
- A new ImmutableRiskModel builder
-