34 constexpr double epsilon = 1e-6;
35 return std::abs(
tau - other.
tau) < epsilon &&
65 [[nodiscard]] std::string
toString()
const override
67 std::ostringstream result;
68 result <<
"Parameters: ["
69 <<
"Tau: " << std::fixed << std::setprecision(2) <<
tau <<
", "
95 const double width = 0.0,
111 std::string str =
"Bump: [";
112 str +=
"Centroid: " + std::format(
"{:.2f}",
centroid) +
", ";
113 str +=
"Amplitude: " + std::format(
"{:.2f}",
amplitude) +
", ";
114 str +=
"Width: " + std::format(
"{:.2f}",
width) +
", ";
115 str +=
"Start pos.: " + std::format(
"{:.2f}",
startPosition) +
", ";
116 str +=
"End pos.: " + std::format(
"{:.2f}",
endPosition) +
", ";
117 str +=
"Velocity: " + std::format(
"{:.2f}",
velocity) +
", ";
118 str +=
"Acceleration: " + std::format(
"{:.2f}",
acceleration) +
"]";
146 std::string str =
"Neural field state [";
147 str +=
"Stable: " + std::string(
stable ?
"true" :
"false") +
", ";
152 for (
const auto& bump :
bumps)
153 str += bump.toString();
181 double* act_ =
nullptr;
182 double* inp_ =
nullptr;
183 double* rest_ =
nullptr;
185 bool computeStateMetrics_ =
true;
186 std::vector<NeuralFieldBump> prevBumps_;
194 void init()
override;
195 void step(
double t,
double deltaT)
override;
196 std::string
toString()
const override;
197 std::shared_ptr<Element>
clone()
const override;
Abstract base class for all simulation elements.
Definition element.h:28
Continuous attractor neural field — the core DFT building block.
Definition neural_field.h:175
void init() override
Initialize the element (called once before the simulation loop).
Definition neural_field.cpp:30
NeuralFieldState state
Runtime state (bumps, stability, min/max).
Definition neural_field.h:178
void step(double t, double deltaT) override
Advance the element by one time step.
Definition neural_field.cpp:44
std::shared_ptr< Kernel > getSelfExcitationKernel() const
Return the registered self-excitation kernel, if any.
Definition neural_field.cpp:71
NeuralFieldParameters parameters
Dynamics parameters (tau, h, activation function).
Definition neural_field.h:177
double getStabilityThreshold() const
Definition neural_field.h:216
double getHighestActivation() const
Definition neural_field.h:208
void updateState(double deltaT)
Definition neural_field.cpp:117
void setParameters(const NeuralFieldParameters ¶meters)
Definition neural_field.cpp:53
double getLowestActivation() const
Definition neural_field.h:207
std::vector< NeuralFieldBump > getBumps() const
Return all currently detected above-threshold bumps.
Definition neural_field.h:211
void setThresholdForStability(const double threshold)
Set the stability convergence threshold.
Definition neural_field.h:201
bool getComputeStateMetrics() const
Definition neural_field.h:224
std::shared_ptr< Element > clone() const override
Definition neural_field.cpp:98
void updateBumps(double deltaT)
Definition neural_field.cpp:151
std::string toString() const override
Definition neural_field.cpp:89
void setComputeStateMetrics(bool enable)
Enable or disable per-step state-metric computation (stability, bumps, min/max). The default (enabled...
Definition neural_field.h:223
void calculateActivation(double t, double deltaT)
Definition neural_field.cpp:104
void calculateOutput()
Definition neural_field.cpp:112
bool isStable() const
Definition neural_field.cpp:64
NeuralFieldParameters getParameters() const
Definition neural_field.cpp:59
Definition element_parameters.h:10
Abstract base for activation functions applied to a neural field.
Definition activation_function.h:36
Definition element_parameters.h:188
Definition element_parameters.h:206
Describes a single activation bump (peak) in a neural field.
Definition neural_field.h:81
double amplitude
Peak activation value.
Definition neural_field.h:85
double startPosition
Left edge of the above-threshold region.
Definition neural_field.h:83
double endPosition
Right edge of the above-threshold region.
Definition neural_field.h:84
double velocity
Rate of change of the centroid (positions/step).
Definition neural_field.h:88
std::string toString() const
Definition neural_field.h:109
double centroid
Spatial position of the bump's centre of mass.
Definition neural_field.h:82
double width
Width of the above-threshold region.
Definition neural_field.h:86
NeuralFieldBump(const double centroid=0.0, const double startPosition=0.0, const double endPosition=0.0, const double amplitude=0.0, const double width=0.0, const double previousCentroid=0.0, const double velocity=0.0, const double acceleration=0.0)
Definition neural_field.h:91
void print() const
Definition neural_field_parameters.cpp:87
double acceleration
Rate of change of velocity (positions/step²).
Definition neural_field.h:89
double previousCentroid
Centroid at the previous time step.
Definition neural_field.h:87
Parameters that govern a NeuralField's dynamics.
Definition neural_field.h:13
std::unique_ptr< ActivationFunction > activationFunction
Nonlinearity applied to activation to produce output.
Definition neural_field.h:16
NeuralFieldParameters & operator=(const NeuralFieldParameters &other)
Definition neural_field.h:18
NeuralFieldParameters()
Default constructor: tau=25, restingLevel=-5, sigmoid(0, 10).
Definition neural_field.h:41
bool operator==(const NeuralFieldParameters &other) const
Definition neural_field.h:32
NeuralFieldParameters(const NeuralFieldParameters &other)
Definition neural_field.h:55
double tau
Time constant of the field's relaxation dynamics.
Definition neural_field.h:14
double startingRestingLevel
Homogeneous resting level (h); sub-threshold when negative.
Definition neural_field.h:15
std::string toString() const override
Definition neural_field.h:65
NeuralFieldParameters(double tau, double restingLevel, const ActivationFunction &activationFunction)
Construct with explicit tau, resting level, and activation function.
Definition neural_field.h:49
Snapshot of a neural field's observable state.
Definition neural_field.h:129
double highestActivation
Maximum activation across the field.
Definition neural_field.h:133
double previousActivationAvg
Activation average at the previous step — used to detect convergence.
Definition neural_field.h:136
double lowestActivation
Minimum activation across the field.
Definition neural_field.h:132
std::string toString() const
Definition neural_field.h:144
double previousActivationNorm
L2 norm of activation at the previous step — used to detect convergence.
Definition neural_field.h:137
double thresholdForStability
Convergence criterion (default 0.895).
Definition neural_field.h:134
void print() const
Definition neural_field_parameters.cpp:115
std::vector< NeuralFieldBump > bumps
Currently active above-threshold peaks.
Definition neural_field.h:130
bool stable
True when the activation change falls below the stability threshold.
Definition neural_field.h:131
NeuralFieldState()
Definition neural_field.h:139
double previousActivationSum
Activation sum at the previous step — used to detect convergence.
Definition neural_field.h:135