Class ImmutableRiskModel

java.lang.Object
io.github.ai4ci.abm.riskmodel.ImmutableRiskModel
All Implemented Interfaces:
RiskModel, Serializable

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

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

See Also:
  • Method Details

    • getEntity

      public Person getEntity()
      Specified by:
      getEntity in interface RiskModel
      Returns:
      The value of the entity attribute
    • getSymptomKernel

      public ImmutableKernel getSymptomKernel()
      Specified by:
      getSymptomKernel in interface RiskModel
      Returns:
      The value of the symptomKernel attribute
    • getTestKernel

      public ImmutableKernel getTestKernel()
      Specified by:
      getTestKernel in interface RiskModel
      Returns:
      The value of the testKernel attribute
    • getContactsKernel

      public ImmutableKernel getContactsKernel()
      Specified by:
      getContactsKernel in interface RiskModel
      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 interface RiskModel
    • getTime

      public int getTime()
      Specified by:
      getTime in interface RiskModel
      Returns:
      The value of the time attribute
    • getMaxLength

      public int getMaxLength()
      Specified by:
      getMaxLength in interface RiskModel
      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 interface RiskModel
    • withEntity

      public final ImmutableRiskModel 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
    • withSymptomKernel

      public final ImmutableRiskModel withSymptomKernel(Kernel value)
      Copy the current immutable object by setting a value for the symptomKernel attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for symptomKernel
      Returns:
      A modified copy of the this object
    • withTestKernel

      public final ImmutableRiskModel withTestKernel(Kernel value)
      Copy the current immutable object by setting a value for the testKernel attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for testKernel
      Returns:
      A modified copy of the this object
    • withContactsKernel

      public final ImmutableRiskModel withContactsKernel(Kernel value)
      Copy the current immutable object by setting a value for the contactsKernel attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for contactsKernel
      Returns:
      A modified copy of the this object
    • withDirectLogOdds

      public final ImmutableRiskModel withDirectLogOdds(double... elements)
      Copy the current immutable object with elements that replace the content of directLogOdds. 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

      public final ImmutableRiskModel withTime(int value)
      Copy the current immutable object by setting a value for the time attribute. A value equality check is 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
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutableRiskModel 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, symptomKernel, testKernel, contactsKernel, directLogOdds, time, maxLength, indirectLogOdds.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value RiskModel with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • 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 interface RiskModel
      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 population

      Returns 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 interface RiskModel
      Returns:
      A lazily initialized value of the logOddsInfectiousToday attribute
    • copyOf

      public static ImmutableRiskModel copyOf(RiskModel instance)
      Creates an immutable copy of a RiskModel 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

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

      public static ImmutableRiskModel.Builder builder()
      Creates a builder for ImmutableRiskModel.
       ImmutableRiskModel.builder()
          .setEntity(io.github.ai4ci.abm.Person) // required entity
          .setSymptomKernel(io.github.ai4ci.abm.riskmodel.Kernel) // required symptomKernel
          .setTestKernel(io.github.ai4ci.abm.riskmodel.Kernel) // required testKernel
          .setContactsKernel(io.github.ai4ci.abm.riskmodel.Kernel) // required contactsKernel
          .setDirectLogOdds(double) // optional directLogOdds
          .setTime(int) // required time
          .build();
       
      Returns:
      A new ImmutableRiskModel builder