Package io.github.ai4ci.abm.mechanics
Class StateUtils
java.lang.Object
io.github.ai4ci.abm.mechanics.StateUtils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Flags a behaviour model for not needing any testing or history updates.static interface
Flags a behaviour model as seeking (and performing) a PCR test if the person has been symptomatic for 2 days in a row and is compliant and has not had a test in a set number of days (regardless of test outcome). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
branchPeopleTo
(OutbreakState current, StateMachine.BehaviourState behaviour) 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).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).static void
complianceFatigue
(ImmutablePersonState.Builder builder, PersonState person) Linear step reduction in compliance until reaches zero.static void
complianceRestoreSlowly
(ImmutablePersonState.Builder builder, PersonState person) Linear step improvement in compliance until reaches 1.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.protected static double
decayTo
(double p, double target, double rate) static void
decreaseSociabilityIfCompliant
(ImmutablePersonState.Builder builder, PersonState person) Self isolate but only if compliant.static void
decreaseSociabilityIfSymptomatic
(ImmutablePersonState.Builder builder, PersonState person) Self isolate in response to symptoms but only if person is compliant.static void
Decrease mobility by a set proportion for every day that the person is symptomatic, towards the minimum value of their self isolationstatic void
decreaseSociabilityStrictly
(ImmutablePersonState.Builder builder, PersonState person) Self isolate.static TestResult
doLFT
(ImmutablePersonHistory.Builder builder, PersonState person) do a LFT test.static TestResult
doPCR
(ImmutablePersonHistory.Builder builder, PersonState person) do a PCR test.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.static boolean
isHighRiskOfInfectionAndCompliant
(PersonState person, double cutoff) static boolean
isLFTTestingAllowed
(PersonState person) The person is compliant and they have not had a recent LFT test (within the last 2 days.static boolean
isPCRTestingAllowed
(PersonState person) The person is compliant and they have not had a recent test (within the presumed incubation period of disease).static boolean
isPositiveTestToday
(PersonState person) Only for use in nextState behaviour methods.static boolean
isSymptomaticAndCompliant
(PersonState person, int days) static boolean
isTestedToday
(PersonState person) Only for use in nextState behaviour methods.static void
resetBehaviour
(ImmutablePersonState.Builder builder, PersonState current) Restore mobility and transmissibility to baseline.static void
restoreSociabilitySlowly
(ImmutablePersonState.Builder builder, PersonState person) Restore mobility and transmissibility by a set proportion to their default levels.static void
Restore mobility and transmissibility by a set proportion to their default levels while a patient remains asymptomaticstatic 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).static void
seekPcrIfSymptomatic
(ImmutablePersonHistory.Builder builder, PersonState person) Seek a test if any symptoms (and compliant, and not recently tested)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.static StateMachine.BehaviourState
toLastBranchPoint
(StateMachineContext context) return from a branched behaviour model.
-
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
Restore mobility and transmissibility to baseline. -
seekPcrIfSymptomatic
Seek a test if any symptoms (and compliant, and not recently tested) -
doPCR
do a PCR test. -
doLFT
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
-
isHighRiskOfInfectionAndCompliant
-
isPCRTestingAllowed
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
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
Only for use in nextState behaviour methods. Looks to see if a test was conducted on this day. -
isPositiveTestToday
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
Linear step reduction in compliance until reaches zero. The amount is configured in theExecutionConfiguration
. -
complianceRestoreSlowly
public static void complianceRestoreSlowly(ImmutablePersonState.Builder builder, PersonState person) Linear step improvement in compliance until reaches 1. The amount is configured in theExecutionConfiguration
. -
countdown
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 iterationsstate
- 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 behaviourstate
- next state to enter into immediately.
-
branchPeopleTo
-
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
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
return from a branched behaviour model.
-