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

Forest-fire rule (Drossel & Schwabl, 1992). More...

#include <tpl_ca_stochastic_rules.H>

Public Types

using engine_type = Engine
 Underlying RNG engine type.
 

Public Member Functions

 Forest_Fire_Rule (const double p_growth, const double p_lightning, std::uint64_t master_seed=0)
 Build a forest-fire rule with the given probabilities.
 
double p_growth () const noexcept
 
double p_lightning () const noexcept
 
std::uint64_t master_seed () const noexcept
 
void set_master_seed (std::uint64_t s) noexcept
 Replace the master seed; takes effect on the next step.
 
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 forest-fire state for cell current.
 

Private Attributes

double p_growth_
 
double p_lightning_
 
std::uint64_t master_seed_
 

Detailed Description

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

Forest-fire rule (Drossel & Schwabl, 1992).

Transition (synchronous, neighbourhood-defined by the engine):

  • BURNING → EMPTY.
  • TREE → BURNING if at least one neighbour is BURNING, else BURNING with probability p_lightning, else stays TREE.
  • EMPTY → TREE with probability p_growth, else stays EMPTY.

Probabilities are sampled from a per-cell deterministic engine, so the trajectory only depends on master_seed, the initial frame and the chosen probabilities.

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

Definition at line 114 of file tpl_ca_stochastic_rules.H.

Member Typedef Documentation

◆ engine_type

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

Underlying RNG engine type.

Definition at line 122 of file tpl_ca_stochastic_rules.H.

Constructor & Destructor Documentation

◆ Forest_Fire_Rule()

template<typename Engine = std::mt19937_64>
Aleph::CA::Forest_Fire_Rule< Engine >::Forest_Fire_Rule ( const double  p_growth,
const double  p_lightning,
std::uint64_t  master_seed = 0 
)
inline

Build a forest-fire rule with the given probabilities.

Parameters
[in]p_growthprobability that an EMPTY cell grows a tree.
[in]p_lightningprobability that a TREE ignites spontaneously when no neighbour is burning.
[in]master_seedmaster seed forwarded to cell_seed().
Exceptions
std::domain_errorif p_growth or p_lightning is not in [0, 1].

Definition at line 133 of file tpl_ca_stochastic_rules.H.

References ah_domain_error_if, Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Forest_Fire_Rule< Engine >::p_growth(), and Aleph::CA::Forest_Fire_Rule< Engine >::p_lightning().

Member Function Documentation

◆ master_seed()

template<typename Engine = std::mt19937_64>
std::uint64_t Aleph::CA::Forest_Fire_Rule< Engine >::master_seed ( ) const
inlinenoexcept
Returns
the master seed feeding the per-cell streams.

Definition at line 155 of file tpl_ca_stochastic_rules.H.

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

◆ operator()()

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

Compute the next forest-fire state for cell current.

Template Parameters
Stateintegral or enum-typed cell state convertible to Forest_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 178 of file tpl_ca_stochastic_rules.H.

References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::BURNING, Aleph::CA::EMPTY, Aleph::CA::Forest_Fire_Rule< Engine >::master_seed_, Aleph::CA::Forest_Fire_Rule< Engine >::p_growth_, Aleph::CA::Forest_Fire_Rule< Engine >::p_lightning_, Aleph::CA::TREE, and Aleph::CA::uniform_unit().

◆ p_growth()

template<typename Engine = std::mt19937_64>
double Aleph::CA::Forest_Fire_Rule< Engine >::p_growth ( ) const
inlinenoexcept
Returns
the configured tree-growth probability.

Definition at line 143 of file tpl_ca_stochastic_rules.H.

References Aleph::CA::Forest_Fire_Rule< Engine >::p_growth_.

Referenced by Aleph::CA::Forest_Fire_Rule< Engine >::Forest_Fire_Rule().

◆ p_lightning()

template<typename Engine = std::mt19937_64>
double Aleph::CA::Forest_Fire_Rule< Engine >::p_lightning ( ) const
inlinenoexcept
Returns
the configured lightning probability.

Definition at line 149 of file tpl_ca_stochastic_rules.H.

References Aleph::CA::Forest_Fire_Rule< Engine >::p_lightning_.

Referenced by Aleph::CA::Forest_Fire_Rule< Engine >::Forest_Fire_Rule().

◆ set_master_seed()

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

Replace the master seed; takes effect on the next step.

Definition at line 161 of file tpl_ca_stochastic_rules.H.

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

Member Data Documentation

◆ master_seed_

◆ p_growth_

◆ p_lightning_


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