Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::CA::SIR_Rule< Engine > Class Template Reference

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 &current, 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_
 

Detailed Description

template<typename Engine = std::mt19937_64>
class Aleph::CA::SIR_Rule< Engine >

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.

Template Parameters
EngineRNG engine; defaults to std::mt19937_64.

Definition at line 241 of file tpl_ca_stochastic_rules.H.

Member Typedef Documentation

◆ engine_type

template<typename Engine = std::mt19937_64>
using Aleph::CA::SIR_Rule< Engine >::engine_type = Engine

Definition at line 248 of file tpl_ca_stochastic_rules.H.

Constructor & Destructor Documentation

◆ SIR_Rule()

template<typename Engine = std::mt19937_64>
Aleph::CA::SIR_Rule< Engine >::SIR_Rule ( double  beta,
double  gamma,
std::uint64_t  master_seed = 0 
)
inline

Build an SIR rule with infection rate beta and recovery rate gamma.

Parameters
[in]betaper-contact infection probability.
[in]gammaper-step recovery probability.
[in]master_seedmaster seed forwarded to cell_seed().
Exceptions
std::domain_errorif 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().

Member Function Documentation

◆ beta()

template<typename Engine = std::mt19937_64>
double Aleph::CA::SIR_Rule< Engine >::beta ( ) const
inlinenoexcept
Returns
the configured infection probability.

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().

◆ gamma()

template<typename Engine = std::mt19937_64>
double Aleph::CA::SIR_Rule< Engine >::gamma ( ) const
inlinenoexcept
Returns
the configured recovery probability.

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().

◆ master_seed()

template<typename Engine = std::mt19937_64>
std::uint64_t Aleph::CA::SIR_Rule< Engine >::master_seed ( ) const
inlinenoexcept
Returns
the master seed.

Definition at line 280 of file tpl_ca_stochastic_rules.H.

References Aleph::CA::SIR_Rule< Engine >::master_seed_.

◆ operator()()

template<typename Engine = std::mt19937_64>
template<typename State , std::size_t Rank>
State Aleph::CA::SIR_Rule< Engine >::operator() ( const State &  current,
Neighbor_View< State >  neighbours,
const Cell_Context< Rank > &  ctx 
) const
inline

Compute the next SIR state for cell current.

Template Parameters
Stateintegral or enum-typed cell state convertible to SIR_Cell.
Ranklattice rank carried by ctx.
Parameters
[in]currentcurrent centre-cell state.
[in]neighboursread-only neighbour values.
[in]ctxper-cell context with step and coord.
Returns
next state produced by the rule.
Exceptions
Anyexception 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().

◆ set_master_seed()

template<typename Engine = std::mt19937_64>
void Aleph::CA::SIR_Rule< Engine >::set_master_seed ( std::uint64_t  s)
inlinenoexcept

Replace the master seed.

Definition at line 286 of file tpl_ca_stochastic_rules.H.

References Aleph::CA::SIR_Rule< Engine >::master_seed_.

Member Data Documentation

◆ beta_

template<typename Engine = std::mt19937_64>
double Aleph::CA::SIR_Rule< Engine >::beta_
private

◆ gamma_

template<typename Engine = std::mt19937_64>
double Aleph::CA::SIR_Rule< Engine >::gamma_
private

◆ master_seed_


The documentation for this class was generated from the following file: