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

Local approximation of the Schelling segregation model. More...

#include <tpl_ca_stochastic_rules.H>

Public Types

using engine_type = Engine
 

Public Member Functions

 Schelling_Rule (const double threshold, const double p_move=1.0, const double p_fill=1.0, const std::uint64_t master_seed=0)
 Build a Schelling rule.
 
double threshold () const noexcept
 
double p_move () const noexcept
 
double p_fill () const noexcept
 
std::uint64_t master_seed () const noexcept
 
void set_master_seed (std::uint64_t s) noexcept
 
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 Schelling state for cell current.
 

Private Attributes

double threshold_
 
double p_move_
 
double p_fill_
 
std::uint64_t master_seed_
 

Detailed Description

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

Local approximation of the Schelling segregation model.

The classical Schelling model is non-local: unhappy agents move to a vacant cell anywhere on the lattice. The CA-friendly local approximation implemented here updates each cell synchronously:

  • For an occupied cell, count same-type and other-type occupied neighbours. The cell is unhappy when the fraction same / (same + other) is strictly below threshold. An unhappy cell vacates with probability p_move (becomes EMPTY); otherwise it stays put.
  • For an empty cell, look at its occupied neighbours: if one type strictly dominates, the cell is filled with that type with probability p_fill. With equal counts (or no occupied neighbours), the cell stays EMPTY.

This is not the canonical Schelling dynamics — it is the standard local CA approximation used in pedagogical settings (Vinkovic & Kirman, 2006, similar). It preserves the qualitative segregation behaviour while remaining fully synchronous and local.

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

Definition at line 603 of file tpl_ca_stochastic_rules.H.

Member Typedef Documentation

◆ engine_type

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

Definition at line 611 of file tpl_ca_stochastic_rules.H.

Constructor & Destructor Documentation

◆ Schelling_Rule()

template<typename Engine = std::mt19937_64>
Aleph::CA::Schelling_Rule< Engine >::Schelling_Rule ( const double  threshold,
const double  p_move = 1.0,
const double  p_fill = 1.0,
const std::uint64_t  master_seed = 0 
)
inline

Build a Schelling rule.

Parameters
[in]thresholdminimum same-type fraction below which an agent becomes unhappy. Must be in [0, 1].
[in]p_moveprobability that an unhappy agent vacates the cell (default 1.0). Must be in [0, 1].
[in]p_fillprobability that an empty cell with a strict majority of one neighbour type is filled (default 1.0). Must be in [0, 1].
[in]master_seedmaster seed forwarded to cell_seed().
Exceptions
std::domain_errorif any probability is outside [0, 1].

Definition at line 625 of file tpl_ca_stochastic_rules.H.

References ah_domain_error_if, Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Schelling_Rule< Engine >::p_fill(), Aleph::CA::Schelling_Rule< Engine >::p_move(), and Aleph::CA::Schelling_Rule< Engine >::threshold().

Member Function Documentation

◆ master_seed()

template<typename Engine = std::mt19937_64>
std::uint64_t Aleph::CA::Schelling_Rule< Engine >::master_seed ( ) const
inlinenoexcept

◆ operator()()

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

◆ p_fill()

template<typename Engine = std::mt19937_64>
double Aleph::CA::Schelling_Rule< Engine >::p_fill ( ) const
inlinenoexcept

◆ p_move()

template<typename Engine = std::mt19937_64>
double Aleph::CA::Schelling_Rule< Engine >::p_move ( ) const
inlinenoexcept

◆ set_master_seed()

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

◆ threshold()

template<typename Engine = std::mt19937_64>
double Aleph::CA::Schelling_Rule< Engine >::threshold ( ) const
inlinenoexcept

Member Data Documentation

◆ master_seed_

◆ p_fill_

◆ p_move_

◆ threshold_


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