API reference

Basic schema

Functions to create basic Markov individual-based models (IBM).

Individual.SchemaBase.npeopleFunction
npeople(model::AbstractIBM, states)

Return the number of people in some set of states (an element of the State Ob). If called without the argument states, simply return the total population size.

source
Individual.SchemaBase.get_index_stateFunction
get_index_state(model::AbstractIBM, states)

Return an integer vector giving the persons who are in the states specified in states. If called without the argument states, simply return everyone's index.

source
Individual.SchemaBase.render_statesFunction
render_states(model::AbstractIBM, steps::Integer)

Return a tuple whose first element is a matrix containing counts of states (columns) by time step (rows), and whose second element is a process function which can be used in the simulation loop.

source
Individual.SchemaBase.initialize_statesFunction
initialize_states(model::AbstractIBM, initial_states, state_labels::Vector{String})

Initialize the categorical states of a model. The argument initial_states can either be provided as a vector of integers, corresponding to the internal storage of the ACSet, or as a vector of strings. It should be equal in length to the population which is to be simulated.

source
Individual.SchemaBase.create_state_updateFunction
create_state_update(model::AbstractIBM)

Return a function that is called with no arguments that updates any Ob that has an accompanying update Ob. For example, if you provide both risk and risk_update, then risk_update will be used to update risk and then cleared.

source
Individual.SchemaBase.create_attr_updateFunction

createattrupdate(model::AbstractIBM)

Return a function that is called with no arguments that updates any Attr that has an accompanying update Attr. For example, if you provide both antibody and antibody_titre as Attr objects from Person to the apropriate AttrType, this function will update antibody to the values in antibody_titre on each time step. This requires that when the model is initialized, each attribute and its update have approximately the same starting values.

source
Individual.SchemaBase.simulation_loopFunction
simulation_loop(model::AbstractIBM, processes::Union{Function, AbstractVector{Function}}, steps::Integer)

A simple predefined simulation loop for basic (no events) individual based models. Processes are called first, followed by state updates.

source
simulation_loop(model::AbstractIBM, processes::Union{Function, AbstractVector{Function}}, steps::Integer)

A method for simulation models with event scheduling.

source

Event scheduling schema

Create IBMs with event scheduling capabilities.

Individual.SchemaEvents.schedule_eventFunction
schedule_event(model::AbstractSchedulingIBM, target, delay, event)

Schedule a set of persons in target for the event after some delay. Note that event should correspond to an element in the set EventLabel in your model.

source
Individual.SchemaEvents.get_scheduledFunction
get_scheduled(model::AbstractSchedulingIBM, event)

Get the set of persons scheduled for event. Note that event should correspond to an element in the set EventLabel in your model.

source
Individual.SchemaEvents.clear_scheduleFunction
clear_schedule(model::AbstractSchedulingIBM, target)

Clear the persons in target from any events they are scheduled for. If 'target' is not specified, clear all scheduled events.

source

Sampling

Methods for Sampling random variates commonly used in IBMs.

Individual.Sampling.delay_geom_sampleFunction
delay_geom_sample(n::Integer, rate::AbstractFloat, dt::AbstractFloat)

Sample time steps until an event fires given a rate and dt where the waiting time follows a Geometric distribution. The minimum delay is 1, otherwise there could be "instantaneous" events, which are better (more efficiently) simulated as processes.

source
Individual.Sampling.bernoulli_sampleFunction
bernoulli_sample(target::AbstractVector, prob::AbstractFloat)

Sample without replacement from target with success probability prob.

source
bernoulli_sample(target::AbstractVector, rate::AbstractFloat, dt::AbstractFloat)

Sample without replacement from target with success probability calculated from $1 - e^{-\mathrm{rate} * \mathrm{dt}}$

source
bernoulli_sample(target::AbstractVector{T}, prob::Vector{R})

Sample without replacement from target where each element has a unique success probability given in the vector prob.

source
bernoulli_sample(target::AbstractVector{T}, rate::Vector{R}, dt::AbstractFloat)

Sample without replacement from target where each element's success probability is calculated from $1 - e^{-\mathrm{rate} * \mathrm{dt}}$.

source
Individual.Sampling.chooseFunction
choose(target::T, K::Integer) where {T <: Integer}
choose(target::AbstractVector{T}, K::Integer) where {T <: Integer}

Return a vector of size K with that number of random elements selected without replacement from target.

source