76 if (v ==
static_cast<int>(SIR_Cell::S)) ++t.s;
77 else if (v ==
static_cast<int>(SIR_Cell::I)) ++t.i;
87 case SIR_Cell::S:
return '.';
88 case SIR_Cell::I:
return '*';
89 case SIR_Cell::R:
return '#';
100 static_cast<ca_index_t>(j)}));
105std::string
bar(std::size_t v, std::size_t
total, std::size_t width = 40)
107 if (
total == 0)
return std::string(width,
' ');
109 = std::min(width,
static_cast<std::size_t
>(
110 (
static_cast<double>(v) /
static_cast<double>(
total))
111 *
static_cast<double>(width)));
112 return std::string(
k,
'|') + std::string(width -
k,
' ');
116 std::uint64_t master_seed,
124 const double R0 = beta * 8.0 /
gamma;
126 std::cout <<
"\n========================================\n";
127 std::cout <<
" Scenario: " << name <<
"\n";
128 std::cout <<
" size=" <<
rows <<
"x" <<
cols
129 <<
" beta=" << beta <<
" gamma=" <<
gamma
130 <<
" R0~" << std::fixed << std::setprecision(2) <<
R0
132 <<
" seed=0x" << std::hex << master_seed << std::dec <<
'\n';
133 std::cout <<
"========================================\n";
136 lat.set({
rows / 2,
cols / 2},
static_cast<int>(SIR_Cell::I));
145 std::cout <<
"\n--- step 0 (initial) ---\n";
148 std::cout <<
"S=" << t.s <<
" I=" << t.i <<
" R=" << t.r
149 <<
" [" <<
bar(t.i,
total) <<
"]\n";
151 for (std::size_t step = 1; step <=
total_steps; ++step)
158 std::cout <<
"\n--- step " << step <<
" ---\n";
160 std::cout <<
"S=" << t.s <<
" I=" << t.i <<
" R=" << t.r
161 <<
" [" <<
bar(t.i,
total) <<
"]\n";
165 std::cout <<
"\n[epidemic extinct at step " << step <<
"]\n";
170 std::cout <<
"\nSummary: peak prevalence I=" <<
peak_I
172 <<
" (final attack rate R="
173 << std::fixed << std::setprecision(3)
174 << (
static_cast<double>(t.r) /
static_cast<double>(
total))
175 << std::defaultfloat <<
")\n";
182 std::cout <<
"SIR epidemic on a 2-D toroidal lattice (Moore radius 1)\n";
183 std::cout <<
"Glyphs: '.' susceptible '*' infected '#' recovered\n";
188 0x5EEDA1Cull, 120, 30);
193 0x5EEDA1Cull, 40, 8);
195 std::cout <<
"\nNote: master_seed is identical across runs, so the\n"
196 " trace is bit-for-bit reproducible regardless of\n"
197 " the build mode and the number of worker threads.\n";
Reproducible random-number support for stochastic CA rules (Phase 8).
Common typedefs and tag types for the Cellular Automata module.
Lattice that adds boundary-aware access on top of a storage.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
SIR epidemic transition rule.
Synchronous double-buffered engine.
static void bar(int val, int scale=1)
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_gamma_function > > gamma(const __gmp_expr< T, U > &expr)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
SIR_Cell
Discrete states of the SIR automaton.
std::ptrdiff_t ca_index_t
Signed coordinate component used by lattices and neighborhoods.
std::size_t ca_size_t
Unsigned size component used for extents and counts.
Main namespace for Aleph-w library functions.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
The lattice wraps around on every axis.
Synchronous double-buffered engine for cellular automata.
Cellular automata lattice with pluggable boundary policies.
Neighborhoods catalogue for Aleph::CA.
Reproducible stochastic CA rules (Phase 8).
Dense, contiguous storage for cellular automata cells (1D/2D/3D).