Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ca-observer.H File Reference

Phase-7 observability layer for cellular automata engines. More...

#include <concepts>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <optional>
#include <tuple>
#include <utility>
#include <ah-errors.H>
#include <tpl_array.H>
#include <ca-metrics.H>
#include <ca-traits.H>
#include <tpl_ca_concepts.H>
Include dependency graph for ca-observer.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Aleph::CA::Composite_Observer< Observers >
 Variadic adaptor that fan-outs notifications to many observers. More...
 
class  Aleph::CA::Density_Observer< State >
 Records the count of cells in tracked_state per step. More...
 
class  Aleph::CA::Activity_Observer< Lattice >
 Records the number of cells that changed across each step. More...
 
class  Aleph::CA::Entropy_Observer< MaxState >
 Records the Shannon entropy of the state distribution. More...
 
class  Aleph::CA::Stationary_Detector
 Detects fixed points and short cycles via frame hashing. More...
 
class  Aleph::CA::Sampling_Observer< Lattice >
 Snapshots the lattice every period steps. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::CA
 

Concepts

concept  Aleph::CA::ObserverLike
 Concept satisfied by any cellular-automaton observer.
 

Functions

template<typename... Observers>
auto Aleph::CA::make_composite_observer (Observers &&...observers)
 Build a Composite_Observer with deduced ownership semantics.
 
template<typename Engine , typename Observer >
void Aleph::CA::attach_observer (Engine &engine, Observer &observer)
 Plug an observer into an engine's pre/post-step hooks.
 
template<typename Engine , typename Observer >
void Aleph::CA::attach_observer_graph (Engine &engine, Observer &observer)
 Attach an observer to engines without a lattice_type alias.
 

Detailed Description

Phase-7 observability layer for cellular automata engines.

Observers are passive listeners that receive a (step, frame) notification before and after every step, without modifying the rule, the lattice or the engine. They are the primary way to collect time series, compute metrics, snapshot frames or detect cycles without poking at the simulation.

Catalogue:

  • ObserverLike<O, Lattice> — concept that any observer must satisfy: on_step_begin(step, frame) and on_step_end(step, frame).
  • Composite_Observer<...> — variadic adaptor that delegates both callbacks to a tuple of observers.
  • Density_Observer<State> — records the count of cells in a chosen state per step.
  • Activity_Observer — records the number of cells that changed value across each step (delta with the previous frame).
  • Entropy_Observer<MaxState> — Shannon entropy of the integer state distribution per step.
  • Stationary_Detector — keeps a sliding window of the last K frame hashes and reports the cycle length the moment a new frame hashes equal to one already seen.
  • Sampling_Observer<Lattice> — copies the current frame every period steps into an in-memory snapshot array.

Wiring helpers:

  • attach_observer(engine, observer) plugs an observer into the pre/post-step hooks of any engine that exposes on_pre_step / on_post_step (Synchronous_Engine, Parallel_Synchronous_Engine, Graph_Synchronous_Engine).

All observers are header-only and stateful by design (they own their own time series). They do not allocate inside their callbacks except where the spec requires it (e.g. Sampling_Observer clones the frame).

Author
Leandro Rabindranath Leon

Definition in file ca-observer.H.