Dynamic Neural Field Composer 0.0.0
A C++20 library and interactive application for building and simulating Dynamic Neural Field (DNF) architectures.
Loading...
Searching...
No Matches
memory_trace_2d.h
Go to the documentation of this file.
1#pragma once
2
3#include <cmath>
4#include <sstream>
5#include <iomanip>
6
7#include "element.h"
8
10{
19 {
20 double tauBuild;
21 double tauDecay;
22 double threshold;
23
24 explicit MemoryTrace2DParameters(double tauBuild = 100.0,
25 double tauDecay = 1000.0,
26 double threshold = 0.5)
28 {}
29
30 bool operator==(const MemoryTrace2DParameters& other) const
31 {
32 constexpr double epsilon = 1e-6;
33 return std::abs(tauBuild - other.tauBuild) < epsilon &&
34 std::abs(tauDecay - other.tauDecay) < epsilon &&
35 std::abs(threshold - other.threshold) < epsilon;
36 }
37
38 [[nodiscard]] std::string toString() const override
39 {
40 std::ostringstream result;
41 result << std::fixed << std::setprecision(2);
42 result << "Parameters: ["
43 << "TauBuild: " << tauBuild << ", "
44 << "TauDecay: " << tauDecay << ", "
45 << "Threshold: " << threshold << "]";
46 return result.str();
47 }
48 };
49
62 class MemoryTrace2D final : public Element
63 {
64 private:
65 MemoryTrace2DParameters parameters;
66 public:
67 MemoryTrace2D(const ElementCommonParameters& elementCommonParameters,
68 const MemoryTrace2DParameters& parameters);
69
70 void init() override;
71 void step(double t, double deltaT) override;
72 [[nodiscard]] std::string toString() const override;
73 [[nodiscard]] std::shared_ptr<Element> clone() const override;
74
75 void setParameters(const MemoryTrace2DParameters& parameters);
76 [[nodiscard]] MemoryTrace2DParameters getParameters() const;
77 };
78}
Abstract base class for all simulation elements.
Definition element.h:28
Persistent 2D spatial memory that accumulates and decays field activity.
Definition memory_trace_2d.h:63
void init() override
Initialize the element (called once before the simulation loop).
Definition memory_trace_2d.cpp:16
std::shared_ptr< Element > clone() const override
Definition memory_trace_2d.cpp:45
MemoryTrace2DParameters getParameters() const
Definition memory_trace_2d.cpp:56
void setParameters(const MemoryTrace2DParameters &parameters)
Definition memory_trace_2d.cpp:50
std::string toString() const override
Definition memory_trace_2d.cpp:37
void step(double t, double deltaT) override
Advance the element by one time step.
Definition memory_trace_2d.cpp:22
Definition element_parameters.h:10
Definition element_parameters.h:188
Definition element_parameters.h:206
Parameters governing MemoryTrace2D build-up and decay dynamics.
Definition memory_trace_2d.h:19
double tauDecay
Time constant for trace decay (ms).
Definition memory_trace_2d.h:21
std::string toString() const override
Definition memory_trace_2d.h:38
bool operator==(const MemoryTrace2DParameters &other) const
Definition memory_trace_2d.h:30
double tauBuild
Time constant for trace accumulation (ms).
Definition memory_trace_2d.h:20
MemoryTrace2DParameters(double tauBuild=100.0, double tauDecay=1000.0, double threshold=0.5)
Definition memory_trace_2d.h:24
double threshold
Minimum input value above which the trace accumulates.
Definition memory_trace_2d.h:22