|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Reproducible stochastic rule wrapper (Phase 8). More...
#include <tpl_ca_rule.H>
Public Types | |
| using | engine_type = Engine |
Underlying engine type used when the wrapped functor accepts an Engine& reference. | |
Public Member Functions | |
| constexpr | Probabilistic_Rule (F func) |
| Construct a stochastic wrapper from a functor. | |
| constexpr | Probabilistic_Rule (F func, std::uint64_t master_seed) |
| Construct a stochastic wrapper with an explicit master seed. | |
| constexpr std::uint64_t | master_seed () const noexcept |
| void | set_master_seed (std::uint64_t s) noexcept |
| Replace the master seed without rebuilding the rule. | |
| template<typename State > requires std::invocable<F &, const State &, Neighbor_View<State>> | |
| State | operator() (const State ¤t, Neighbor_View< State > neighbours) const |
Legacy invocation: forward (state, neighbours) to F. | |
| template<typename State , std::size_t Rank> | |
| State | operator() (const State ¤t, Neighbor_View< State > neighbours, const Cell_Context< Rank > &ctx) const |
| Reproducible invocation with engine context. | |
Private Attributes | |
| F | f_ |
| std::uint64_t | master_seed_ = 0 |
Reproducible stochastic rule wrapper (Phase 8).
Probabilistic_Rule<F, Engine> accepts two functor flavours:
F(State, Neighbor_View<State>) -> State. Random sources are managed by the functor; the rule simply forwards the call. This is the Phase 0–7 behaviour.F(State, Neighbor_View<State>, Engine&) -> State. The rule receives a Cell_Context<Rank> from the engine, derives a per-cell seed via cell_seed(master_seed, ctx), builds a fresh Engine and hands it by reference to F. Two runs with the same (master_seed, initial frame) are bit-for-bit identical regardless of the number of worker threads.Both invocation modes coexist on the same class, so a rule that was already a Probabilistic_Rule<F> keeps compiling without changes.
| F | functor type accepting one of the two signatures above. |
| Engine | RNG engine handed to reproducible functors. Defaults to std::mt19937_64. |
Definition at line 348 of file tpl_ca_rule.H.
| using Aleph::CA::Probabilistic_Rule< F, Engine >::engine_type = Engine |
Underlying engine type used when the wrapped functor accepts an Engine& reference.
Definition at line 356 of file tpl_ca_rule.H.
|
inlineexplicitconstexpr |
Construct a stochastic wrapper from a functor.
Backwards-compatible 1-argument form: the master seed defaults to 0 and is only consulted when the functor opts in to the reproducible signature.
| [in] | func | callable object satisfying one of the two signatures described above. |
| Any | exception thrown while moving/copying func. |
Definition at line 368 of file tpl_ca_rule.H.
|
inlineconstexpr |
Construct a stochastic wrapper with an explicit master seed.
| [in] | func | callable object accepting (State, Neighbor_View<State>, Engine&). |
| [in] | master_seed | root seed forwarded to cell_seed(master_seed, ctx) for every cell. |
| Any | exception thrown while moving/copying func. |
Definition at line 378 of file tpl_ca_rule.H.
|
inlineconstexprnoexcept |
Definition at line 383 of file tpl_ca_rule.H.
References Aleph::CA::Probabilistic_Rule< F, Engine >::master_seed_.
|
inline |
Legacy invocation: forward (state, neighbours) to F.
| State | cell state type. |
| [in] | current | current centre-cell state. |
| [in] | neighbours | read-only neighbour values. |
| Any | exception thrown by the wrapped functor. |
Definition at line 400 of file tpl_ca_rule.H.
References Aleph::CA::Probabilistic_Rule< F, Engine >::f_.
|
inline |
Reproducible invocation with engine context.
When F accepts an Engine&, the rule constructs an engine seeded with cell_seed(master_seed_, ctx) and forwards it. When F only accepts the legacy 2-argument signature, the call is forwarded as-is and ctx is ignored.
| State | cell state type. |
| Rank | lattice rank carried by ctx. |
| [in] | current | current centre-cell state. |
| [in] | neighbours | read-only neighbour values. |
| [in] | ctx | per-cell context provided by the engine. |
| Any | exception thrown by the wrapped functor. |
Definition at line 423 of file tpl_ca_rule.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Probabilistic_Rule< F, Engine >::f_, and Aleph::CA::Probabilistic_Rule< F, Engine >::master_seed_.
|
inlinenoexcept |
Replace the master seed without rebuilding the rule.
Definition at line 389 of file tpl_ca_rule.H.
References Aleph::CA::Probabilistic_Rule< F, Engine >::master_seed_.
|
mutableprivate |
Definition at line 350 of file tpl_ca_rule.H.
Referenced by Aleph::CA::Probabilistic_Rule< F, Engine >::operator()(), and Aleph::CA::Probabilistic_Rule< F, Engine >::operator()().
|
private |
Definition at line 351 of file tpl_ca_rule.H.
Referenced by Aleph::CA::Probabilistic_Rule< F, Engine >::master_seed(), Aleph::CA::Probabilistic_Rule< F, Engine >::operator()(), and Aleph::CA::Probabilistic_Rule< F, Engine >::set_master_seed().