Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tpl_ca_stochastic_rules.H File Reference

Reproducible stochastic CA rules (Phase 8). More...

#include <cmath>
#include <cstddef>
#include <cstdint>
#include <random>
#include <type_traits>
#include <ah-errors.H>
#include <ca-rng.H>
#include <ca-traits.H>
Include dependency graph for tpl_ca_stochastic_rules.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Aleph::CA::Forest_Fire_Rule< Engine >
 Forest-fire rule (Drossel & Schwabl, 1992). More...
 
class  Aleph::CA::SIR_Rule< Engine >
 SIR epidemic transition rule. More...
 
class  Aleph::CA::Ising_Glauber_Rule< Engine >
 Ising rule with Glauber single-spin-flip dynamics. More...
 
class  Aleph::CA::Ising_Metropolis_Rule< Engine >
 Ising rule with Metropolis–Hastings single-spin-flip dynamics. More...
 
class  Aleph::CA::Schelling_Rule< Engine >
 Local approximation of the Schelling segregation model. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::CA
 
namespace  Aleph::CA::ca_ising_detail
 

Enumerations

enum class  Aleph::CA::Forest_Cell : std::uint8_t { Aleph::CA::EMPTY = 0 , Aleph::CA::TREE = 1 , Aleph::CA::BURNING = 2 }
 Discrete states of the forest-fire automaton. More...
 
enum class  Aleph::CA::SIR_Cell : std::uint8_t { Aleph::CA::S = 0 , Aleph::CA::I = 1 , Aleph::CA::R = 2 }
 Discrete states of the SIR automaton. More...
 
enum class  Aleph::CA::Schelling_Cell : std::uint8_t { Aleph::CA::EMPTY = 0 , Aleph::CA::TYPE_A = 1 , Aleph::CA::TYPE_B = 2 }
 Discrete states of the Schelling automaton. More...
 

Functions

template<typename State >
int Aleph::CA::ca_ising_detail::state_to_spin (const State &v) noexcept
 Map any integral state to a spin in {-1, +1}.
 
template<typename State >
State Aleph::CA::ca_ising_detail::spin_to_state (int spin) noexcept
 Inverse of state_to_spin.
 
template<typename State >
double Aleph::CA::ca_ising_detail::delta_energy (const State &current, Neighbor_View< State > neighbours, double J, double H)
 Compute the local energy delta for flipping the centre spin.
 

Detailed Description

Reproducible stochastic CA rules (Phase 8).

Implements four canonical stochastic transition rules on top of the Phase 8 RNG framework (ca-rng.H):

  • Forest_Fire_Rule(p_growth, p_lightning) Drossel–Schwabl forest fire automaton.
  • SIR_Rule(beta, gamma) Discrete-time SIR epidemic on a lattice.
  • Ising_Glauber_Rule(temperature, J, H) / Ising_Metropolis_Rule(temperature, J, H) Single-spin-flip dynamics with two flip-acceptance strategies.
  • Schelling_Rule(threshold, p_move, p_fill) Local approximation of Schelling segregation.

Every rule satisfies ContextualRuleLike<R, L> and therefore plugs directly into Synchronous_Engine, Parallel_Synchronous_Engine and Graph_Synchronous_Engine via apply_rule().

Determinism contract: for any rule listed above, given the same initial frame, the same master_seed, the same configuration and the same number of steps, the resulting frame is bit-for-bit identical regardless of the number of worker threads or the partitioning strategy used by the engine. This is achieved by seeding a fresh Engine per (master_seed, step, coord) triple via cell_seed().

Author
Leandro Rabindranath Leon

Definition in file tpl_ca_stochastic_rules.H.