|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
SIR epidemic transition rule. More...
#include <tpl_ca_stochastic_rules.H>
Public Types | |
| using | engine_type = Engine |
Public Member Functions | |
| SIR_Rule (double beta, double gamma, std::uint64_t master_seed=0) | |
Build an SIR rule with infection rate beta and recovery rate gamma. | |
| double | beta () const noexcept |
| double | gamma () const noexcept |
| std::uint64_t | master_seed () const noexcept |
| void | set_master_seed (std::uint64_t s) noexcept |
| Replace the master seed. | |
| template<typename State , std::size_t Rank> | |
| State | operator() (const State ¤t, Neighbor_View< State > neighbours, const Cell_Context< Rank > &ctx) const |
Compute the next SIR state for cell current. | |
Private Attributes | |
| double | beta_ |
| double | gamma_ |
| std::uint64_t | master_seed_ |
SIR epidemic transition rule.
Synchronous discrete-time SIR on the cellular automaton:
R stays R.I recovers to R with probability gamma, else stays I.S becomes I with probability 1 - (1 - beta)^k where k is the number of infected neighbours; else stays S.When R0 = beta * <degree> / gamma < 1, the epidemic asymptotically goes extinct on the lattice for any finite seed of infections; the unit tests cover this regime explicitly.
| Engine | RNG engine; defaults to std::mt19937_64. |
Definition at line 241 of file tpl_ca_stochastic_rules.H.
| using Aleph::CA::SIR_Rule< Engine >::engine_type = Engine |
Definition at line 248 of file tpl_ca_stochastic_rules.H.
|
inline |
Build an SIR rule with infection rate beta and recovery rate gamma.
| [in] | beta | per-contact infection probability. |
| [in] | gamma | per-step recovery probability. |
| [in] | master_seed | master seed forwarded to cell_seed(). |
| std::domain_error | if either probability is outside [0, 1]. |
Definition at line 259 of file tpl_ca_stochastic_rules.H.
References ah_domain_error_if, Aleph::CA::SIR_Rule< Engine >::beta(), Aleph::blossom_maximum_cardinality_matching(), and Aleph::CA::SIR_Rule< Engine >::gamma().
|
inlinenoexcept |
Definition at line 268 of file tpl_ca_stochastic_rules.H.
References Aleph::CA::SIR_Rule< Engine >::beta_.
Referenced by Aleph::CA::SIR_Rule< Engine >::SIR_Rule().
|
inlinenoexcept |
Definition at line 274 of file tpl_ca_stochastic_rules.H.
References Aleph::CA::SIR_Rule< Engine >::gamma_.
Referenced by Aleph::CA::SIR_Rule< Engine >::SIR_Rule().
|
inlinenoexcept |
Definition at line 280 of file tpl_ca_stochastic_rules.H.
References Aleph::CA::SIR_Rule< Engine >::master_seed_.
|
inline |
Compute the next SIR state for cell current.
| State | integral or enum-typed cell state convertible to SIR_Cell. |
| Rank | lattice rank carried by ctx. |
| [in] | current | current centre-cell state. |
| [in] | neighbours | read-only neighbour values. |
| [in] | ctx | per-cell context with step and coord. |
| Any | exception thrown by the RNG constructor. |
Definition at line 303 of file tpl_ca_stochastic_rules.H.
References Aleph::CA::SIR_Rule< Engine >::beta_, Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::SIR_Rule< Engine >::gamma_, Aleph::CA::I, Aleph::CA::SIR_Rule< Engine >::master_seed_, Aleph::CA::R, and Aleph::CA::uniform_unit().
|
inlinenoexcept |
Replace the master seed.
Definition at line 286 of file tpl_ca_stochastic_rules.H.
References Aleph::CA::SIR_Rule< Engine >::master_seed_.
|
private |
Definition at line 243 of file tpl_ca_stochastic_rules.H.
Referenced by Aleph::CA::SIR_Rule< Engine >::beta(), and Aleph::CA::SIR_Rule< Engine >::operator()().
|
private |
Definition at line 244 of file tpl_ca_stochastic_rules.H.
Referenced by Aleph::CA::SIR_Rule< Engine >::gamma(), and Aleph::CA::SIR_Rule< Engine >::operator()().
|
private |
Definition at line 245 of file tpl_ca_stochastic_rules.H.
Referenced by Aleph::CA::SIR_Rule< Engine >::master_seed(), Aleph::CA::SIR_Rule< Engine >::operator()(), and Aleph::CA::SIR_Rule< Engine >::set_master_seed().