Class StateUtils

java.lang.Object
io.github.ai4ci.abm.mechanics.StateUtils

public class StateUtils extends Object
  • Constructor Details

    • StateUtils

      public StateUtils()
  • Method Details

    • decayTo

      protected static double decayTo(double p, double target, double rate)
    • decreaseSociabilityIfSymptomatic

      public static void decreaseSociabilityIfSymptomatic(ImmutablePersonState.Builder builder, PersonState person)
      Self isolate in response to symptoms but only if person is compliant.
    • decreaseSociabilityIfCompliant

      public static void decreaseSociabilityIfCompliant(ImmutablePersonState.Builder builder, PersonState person)
      Self isolate but only if compliant. More for an advisory or self imposed reduction in response to symptoms. lockdown.
    • decreaseSociabilityStrictly

      public static void decreaseSociabilityStrictly(ImmutablePersonState.Builder builder, PersonState person)
      Self isolate. If not compliant this will still have an effect. This is the option in enforced lock-down type scenarios.
    • decreaseSociabilitySlowlyIfSymptomatic

      public static void decreaseSociabilitySlowlyIfSymptomatic(ImmutablePersonState.Builder builder, PersonState person)
      Decrease mobility by a set proportion for every day that the person is symptomatic, towards the minimum value of their self isolation
    • restoreSociabilitySlowlyIfAsymptomatic

      public static void restoreSociabilitySlowlyIfAsymptomatic(ImmutablePersonState.Builder builder, PersonState person)
      Restore mobility and transmissibility by a set proportion to their default levels while a patient remains asymptomatic
    • restoreSociabilitySlowly

      public static void restoreSociabilitySlowly(ImmutablePersonState.Builder builder, PersonState person)
      Restore mobility and transmissibility by a set proportion to their default levels.
    • resetBehaviour

      public static void resetBehaviour(ImmutablePersonState.Builder builder, PersonState current)
      Restore mobility and transmissibility to baseline.
    • seekPcrIfSymptomatic

      public static void seekPcrIfSymptomatic(ImmutablePersonHistory.Builder builder, PersonState person)
      Seek a test if any symptoms (and compliant, and not recently tested)
    • doPCR

      public static TestResult doPCR(ImmutablePersonHistory.Builder builder, PersonState person)
      do a PCR test.
    • doLFT

      public static TestResult doLFT(ImmutablePersonHistory.Builder builder, PersonState person)
      do a LFT test.
    • seekPcrIfSymptomatic

      public static void seekPcrIfSymptomatic(ImmutablePersonHistory.Builder builder, PersonState person, int days)
      The person will test themselves using PCR (immediately) if they are symptomatic consecutively for a number of days, compliant and they have not recently been tested. Recent here is defined as they have had a PCR test within the last presumed incubation period of the disease
    • isSymptomaticAndCompliant

      public static boolean isSymptomaticAndCompliant(PersonState person, int days)
    • isHighRiskOfInfectionAndCompliant

      public static boolean isHighRiskOfInfectionAndCompliant(PersonState person, double cutoff)
    • isPCRTestingAllowed

      public static boolean isPCRTestingAllowed(PersonState person)
      The person is compliant and they have not had a recent test (within the presumed incubation period of disease). If there is some question as to whether they need a test and they have recently has one this will stop them having another one.
    • isLFTTestingAllowed

      public static boolean isLFTTestingAllowed(PersonState person)
      The person is compliant and they have not had a recent LFT test (within the last 2 days. If there is some question as to whether they need a test and they have recently has one this will stop them having another one.
    • isTestedToday

      public static boolean isTestedToday(PersonState person)
      Only for use in nextState behaviour methods. Looks to see if a test was conducted on this day.
    • isPositiveTestToday

      public static boolean isPositiveTestToday(PersonState person)
      Only for use in nextState behaviour methods. Looks to see if a test was conducted on this day and the result is positive. This will generally only be the case for LFTs
    • complianceFatigue

      public static void complianceFatigue(ImmutablePersonState.Builder builder, PersonState person)
      Linear step reduction in compliance until reaches zero. The amount is configured in the ExecutionConfiguration.
    • complianceRestoreSlowly

      public static void complianceRestoreSlowly(ImmutablePersonState.Builder builder, PersonState person)
      Linear step improvement in compliance until reaches 1. The amount is configured in the ExecutionConfiguration.
    • countdown

      public static StateMachine.BehaviourState countdown(int i, StateMachine.BehaviourState state)
      places machine into given behaviour for up to i iterations, then reverts to the last pushed behaviour. If the behaviour changes before the countdown is up then the machine will proceed with new behaviour.
      Parameters:
      i - the number of iterations
      state - the state to temporarily enter
    • graduallyRestoreBehaviour

      public static StateMachine.BehaviourState graduallyRestoreBehaviour(int i, StateMachine.BehaviourState state)
      A state that reverts mobility and transmissibility to baseline while the machine continues in normal operation, over a set time period.
      Parameters:
      i - time over which to restore behaviour
      state - next state to enter into immediately.
    • branchPeopleTo

      public static void branchPeopleTo(OutbreakState current, StateMachine.BehaviourState behaviour)
    • branchPeopleTo

      public static void branchPeopleTo(OutbreakState current, StateMachine.BehaviourState behaviour, Predicate<Person> filter)
      Force all people in a model to branch to a specified behaviour, the current state is pushed to allow people to return to the current behaviour (using a returnFromBranch call).
      Parameters:
      current - the current model state.
      behaviour - the target behaviour.
      filter - ally update only to certain people (e.g. by age for changing behaviour)
    • returnPeopleFromBranch

      public static void returnPeopleFromBranch(OutbreakState current)
      Force all people in a model to branch to a set behaviour, the current state is pushed to allow people to return to the current behaviour (using a returnFromBranch call).
    • branchTo

      public static StateMachine.BehaviourState branchTo(PersonState current, StateMachine.BehaviourState behaviour)
      Force one person to branch to a set behaviour, the current state is pushed to allow them to return to the current behaviour (using a returnFromBranch call).
    • toLastBranchPoint

      public static StateMachine.BehaviourState toLastBranchPoint(StateMachineContext context)
      return from a branched behaviour model.