32#ifndef ALEPH_REPRODUCTIONS_SOURCE_DIR
33# define ALEPH_REPRODUCTIONS_SOURCE_DIR "reproductions"
48 std::discrete_distribution<int> pick({0.10, 0.45, 0.45});
51 grid.set({static_cast<ca_index_t>(r), static_cast<ca_index_t>(c)}, pick(
rng));
59 constexpr std::size_t
steps = 200;
60 constexpr double threshold = 0.5;
61 constexpr std::uint64_t master_seed = 0x5C4E111971ull;
67 static_cast<int>(Schelling_Cell::EMPTY),
68 static_cast<int>(Schelling_Cell::TYPE_A),
69 static_cast<int>(Schelling_Cell::TYPE_B));
77 static_cast<int>(Schelling_Cell::EMPTY),
78 static_cast<int>(Schelling_Cell::TYPE_A),
79 static_cast<int>(Schelling_Cell::TYPE_B));
81 std::filesystem::create_directories(
root /
"results");
82 std::ofstream
summary(
root /
"results" /
"schelling_summary.csv");
85 std::cerr <<
"Cannot write Schelling summary\n";
88 summary <<
"side,steps,threshold,initial_morans_i,final_morans_i\n"
89 <<
side <<
',' <<
steps <<
',' << threshold <<
','
90 << std::setprecision(12) <<
initial <<
',' <<
final <<
'\n';
92 std::cout <<
"Schelling segregation: initial Moran's I=" << std::fixed
93 << std::setprecision(4) <<
initial <<
" final=" <<
final <<
'\n';
96 std::cerr <<
"Schelling final Moran's I must be greater than 0.7\n";
Internal helpers shared by the cellular-automata reproductions.
Lattice that adds boundary-aware access on top of a storage.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
Local approximation of the Schelling segregation model.
Synchronous double-buffered engine.
__gmp_expr< T, __gmp_binary_expr< __gmp_expr< T, U >, unsigned long int, __gmp_root_function > > root(const __gmp_expr< T, U > &expr, unsigned long int l)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
double morans_i_binary(const Lattice &frame, const typename Lattice::state_type empty_state, const typename Lattice::state_type type_a, const typename Lattice::state_type type_b)
Compute Moran's I for two occupied Schelling cell types.
std::size_t ca_size_t
Unsigned size component used for extents and counts.
#define ALEPH_REPRODUCTIONS_SOURCE_DIR
The lattice wraps around on every axis.
Reproducible stochastic CA rules (Phase 8).