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

Records the number of cells that changed across each step. More...

#include <ca-observer.H>

Collaboration diagram for Aleph::CA::Activity_Observer< Lattice >:
[legend]

Public Member Functions

 Activity_Observer ()=default
 Construct an empty activity observer.
 
const Array< ca_size_t > & activity () const noexcept
 Return the activity time series.
 
std::size_t size () const noexcept
 Return the number of recorded steps.
 
void reset () noexcept
 Clear the previous frame and activity samples.
 
void on_step_begin (std::size_t step, const Lattice &frame)
 Capture the frame before a step.
 
void on_step_end (const std::size_t step, const Lattice &frame)
 Record changed cells after a step.
 

Private Attributes

std::optional< Lattice > prev_
 
Array< ca_size_t > activity_
 

Detailed Description

template<typename Lattice>
class Aleph::CA::Activity_Observer< Lattice >

Records the number of cells that changed across each step.

Implementation note: the observer maintains a copy of the previous frame between on_step_begin and on_step_end. This costs O(N) memory but avoids depending on the engine to expose the previous frame, and keeps the observer self-contained.

Template Parameters
Latticelattice type the observer is wired to. Stored as a member so the previous frame can be retained.
Complexity
on_step_begin copies one frame in O(N); on_step_end compares frames in O(N).
Thread-safety
Thread-safe for concurrent readers after simulation stops; not thread-safe for concurrent callbacks.
Exception-safety
Strong guarantee unless copying the frame or appending the sample throws.

Definition at line 458 of file ca-observer.H.

Constructor & Destructor Documentation

◆ Activity_Observer()

template<typename Lattice >
Aleph::CA::Activity_Observer< Lattice >::Activity_Observer ( )
default

Construct an empty activity observer.

Exceptions
Thisfunction does not throw.

Member Function Documentation

◆ activity()

template<typename Lattice >
const Array< ca_size_t > & Aleph::CA::Activity_Observer< Lattice >::activity ( ) const
inlinenoexcept

Return the activity time series.

Returns
changed-cell counts, one per completed step.
Exceptions
Thisfunction does not throw.

Definition at line 473 of file ca-observer.H.

References Aleph::CA::Activity_Observer< Lattice >::activity_.

◆ on_step_begin()

template<typename Lattice >
void Aleph::CA::Activity_Observer< Lattice >::on_step_begin ( std::size_t  step,
const Lattice &  frame 
)
inline

Capture the frame before a step.

Parameters
[in]stepstep index about to run, ignored.
[in]frameframe before the step.
Exceptions
Anyexception thrown while copying frame.

Definition at line 504 of file ca-observer.H.

References Aleph::blossom_maximum_cardinality_matching(), and Aleph::CA::Activity_Observer< Lattice >::prev_.

◆ on_step_end()

template<typename Lattice >
void Aleph::CA::Activity_Observer< Lattice >::on_step_end ( const std::size_t  step,
const Lattice &  frame 
)
inline

Record changed cells after a step.

Parameters
[in]stepcompleted step index, ignored.
[in]frameframe after the step.
Exceptions
std::bad_allocif appending the sample allocates.

Definition at line 515 of file ca-observer.H.

References Aleph::CA::Activity_Observer< Lattice >::activity_, Aleph::Array< T >::append(), Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::cell_diff_count(), and Aleph::CA::Activity_Observer< Lattice >::prev_.

◆ reset()

template<typename Lattice >
void Aleph::CA::Activity_Observer< Lattice >::reset ( )
inlinenoexcept

Clear the previous frame and activity samples.

Exceptions
Thisfunction does not throw.
Complexity
O(size()) plus destruction cost of the stored frame.

Definition at line 493 of file ca-observer.H.

References Aleph::CA::Activity_Observer< Lattice >::activity_, Aleph::Array< T >::clear(), and Aleph::CA::Activity_Observer< Lattice >::prev_.

◆ size()

template<typename Lattice >
std::size_t Aleph::CA::Activity_Observer< Lattice >::size ( ) const
inlinenoexcept

Return the number of recorded steps.

Returns
sample count.
Exceptions
Thisfunction does not throw.

Definition at line 482 of file ca-observer.H.

References Aleph::CA::Activity_Observer< Lattice >::activity_, and Aleph::Array< T >::size().

Member Data Documentation

◆ activity_

◆ prev_


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