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
Public Member Functions | Protected Attributes | List of all members
dnf_composer::element::FieldCoupling Class Referencefinal

Full-matrix learned coupling between two neural fields. More...

#include <field_coupling.h>

Inheritance diagram for dnf_composer::element::FieldCoupling:
Collaboration diagram for dnf_composer::element::FieldCoupling:

Public Member Functions

void addInput (const std::shared_ptr< Element > &inputElement, const std::string &inputComponent="output") override
 Register inputElement as an upstream source for this element.
 
void changeDimensions (const ElementDimensions &newDimensions) override
 Resize the output field dimensions and rebuild the weight matrix. Preserves input field dimensions and clears weights. Connections are not removed — call removeInputs()/removeOutputs() first if needed.
 
void changeInputDimensions (const ElementDimensions &newInputDimensions)
 Resize the input field dimensions and rebuild the weight matrix. Preserves output field dimensions and clears weights. Connections are not removed — call removeInputs()/removeOutputs() first if needed.
 
void clearWeights ()
 Reset the weight matrix to all zeros.
 
std::shared_ptr< Elementclone () const override
 
 FieldCoupling (const ElementCommonParameters &elementCommonParameters, const FieldCouplingParameters &fc_parameters)
 Construct a FieldCoupling.
 
FieldCouplingParameters getParameters () const
 
std::string getWeightsDirectory () const
 
void init () override
 Initialize the element (called once before the simulation loop).
 
void readWeights ()
 Load the weight matrix from a binary file in weightsDirectory.
 
void setLearning (bool learning)
 Enable or disable online weight updates.
 
void setLearningRate (double learningRate)
 
void setParameters (const FieldCouplingParameters &fcp)
 
void setWeightsDirectory (const std::string &dir)
 Set the directory used for readWeights() / writeWeights().
 
void step (double t, double deltaT) override
 Advance the element by one time step.
 
std::string toString () const override
 
void tryReadWeights ()
 Load weights if the file exists; log INFO in either case. Unlike readWeights(), this never logs an error — use it when weights may legitimately be absent (e.g. first run of a programmatic simulation).
 
void writeWeights () const
 Save the current weight matrix to a binary file in weightsDirectory.
 
- Public Member Functions inherited from dnf_composer::element::Element
void buildInputCache ()
 Cache raw pointers to input component data. Call after all element init()s complete.
 
void close ()
 
 Element (const ElementCommonParameters &parameters)
 Construct an element with the given common parameters.
 
std::vector< double > getComponent (const std::string &componentName)
 Return a copy of the named component vector.
 
std::vector< std::string > getComponentList () const
 
std::vector< double > * getComponentPtr (const std::string &componentName)
 
const std::unordered_map< std::string, std::vector< double > > * getComponents () const
 Return a read-only pointer to the full components map.
 
ElementCommonParameters getElementCommonParameters () const
 
std::vector< std::shared_ptr< Element > > getInputs ()
 
std::unordered_map< std::shared_ptr< Element >, std::string > getInputsAndComponents ()
 Return all inputs mapped to the component name they expose.
 
ElementLabel getLabel () const
 
int getMaxSpatialDimension () const
 
std::vector< std::shared_ptr< Element > > getOutputs ()
 
int getSize () const
 Return the number of spatial samples (size = round(x_max / d_x)).
 
double getStepSize () const
 Return the spatial resolution (d_x).
 
int getUniqueIdentifier () const
 
std::string getUniqueName () const
 
bool hasInput () const
 
bool hasInput (const std::string &inputElementName, const std::string &inputComponent)
 
bool hasInput (int inputElementId, const std::string &inputComponent)
 
bool hasOutput () const
 
bool hasOutput (const std::string &outputElementName, const std::string &outputComponent)
 
bool hasOutput (int outputElementId, const std::string &outputComponent)
 
void print () const
 
void removeInput (const std::string &inputElementId)
 
void removeInput (int uniqueId)
 
void removeInputs ()
 
void removeOutput (const std::string &outputElementId)
 Deregister this element as an input of outputElementId.
 
void removeOutput (int uniqueId)
 Deregister this element as an input of the element with uniqueId.
 
void removeOutputs ()
 
void setUniqueName (const std::string &name)
 
void updateInput ()
 Pull data from all registered input elements into this element's components.
 
virtual ~Element ()=default
 

Protected Attributes

std::shared_ptr< Elementinput
 
std::shared_ptr< Elementoutput
 
FieldCouplingParameters parameters
 
std::string weightsDirectory
 Directory used for weight serialization.
 
- Protected Attributes inherited from dnf_composer::element::Element
ElementCommonParameters commonParameters
 Name, label, and spatial dimensions.
 
std::unordered_map< std::string, std::vector< double > > components
 Named data arrays (e.g. "output").
 
std::unordered_map< std::shared_ptr< Element >, std::string > inputs
 Upstream elements and the component they expose.
 
std::unordered_map< std::shared_ptr< Element >, std::string > outputs
 Downstream elements that read this element's output.
 

Detailed Description

Full-matrix learned coupling between two neural fields.

FieldCoupling maintains an (output_size × input_size) weight matrix W. On each step() it computes output = W * f(input) (matrix-vector product of the weight matrix with the input field's "output" component).

When learning is active (setLearning(true)), weights are updated according to the selected LearningRule (HEBB, OJA, or DELTA). Weights can be persisted to and loaded from disk via writeWeights() / readWeights().

Constructor & Destructor Documentation

◆ FieldCoupling()

dnf_composer::element::FieldCoupling::FieldCoupling ( const ElementCommonParameters elementCommonParameters,
const FieldCouplingParameters fc_parameters 
)

Construct a FieldCoupling.

Parameters
elementCommonParametersName, label, and dimensions of the output field.
fc_parametersCoupling parameters (input dimensions, learning rule).
Here is the call graph for this function:

Member Function Documentation

◆ addInput()

void dnf_composer::element::FieldCoupling::addInput ( const std::shared_ptr< Element > &  inputElement,
const std::string &  inputComponent = "output" 
)
overridevirtual

Register inputElement as an upstream source for this element.

Parameters
inputElementThe element whose output will be read.
inputComponentWhich component of inputElement to read (default: "output").

Reimplemented from dnf_composer::element::Element.

Here is the call graph for this function:

◆ changeDimensions()

void dnf_composer::element::FieldCoupling::changeDimensions ( const ElementDimensions newDimensions)
overridevirtual

Resize the output field dimensions and rebuild the weight matrix. Preserves input field dimensions and clears weights. Connections are not removed — call removeInputs()/removeOutputs() first if needed.

Reimplemented from dnf_composer::element::Element.

Here is the call graph for this function:

◆ changeInputDimensions()

void dnf_composer::element::FieldCoupling::changeInputDimensions ( const ElementDimensions newInputDimensions)

Resize the input field dimensions and rebuild the weight matrix. Preserves output field dimensions and clears weights. Connections are not removed — call removeInputs()/removeOutputs() first if needed.

Here is the call graph for this function:

◆ clearWeights()

void dnf_composer::element::FieldCoupling::clearWeights ( )

Reset the weight matrix to all zeros.

◆ clone()

std::shared_ptr< Element > dnf_composer::element::FieldCoupling::clone ( ) const
overridevirtual

◆ getParameters()

FieldCouplingParameters dnf_composer::element::FieldCoupling::getParameters ( ) const

◆ getWeightsDirectory()

std::string dnf_composer::element::FieldCoupling::getWeightsDirectory ( ) const

◆ init()

void dnf_composer::element::FieldCoupling::init ( )
overridevirtual

Initialize the element (called once before the simulation loop).

Implements dnf_composer::element::Element.

Here is the caller graph for this function:

◆ readWeights()

void dnf_composer::element::FieldCoupling::readWeights ( )

Load the weight matrix from a binary file in weightsDirectory.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLearning()

void dnf_composer::element::FieldCoupling::setLearning ( bool  learning)

Enable or disable online weight updates.

Parameters
learningTrue to activate learning.

◆ setLearningRate()

void dnf_composer::element::FieldCoupling::setLearningRate ( double  learningRate)

◆ setParameters()

void dnf_composer::element::FieldCoupling::setParameters ( const FieldCouplingParameters fcp)

◆ setWeightsDirectory()

void dnf_composer::element::FieldCoupling::setWeightsDirectory ( const std::string &  dir)

Set the directory used for readWeights() / writeWeights().

◆ step()

void dnf_composer::element::FieldCoupling::step ( double  t,
double  deltaT 
)
overridevirtual

Advance the element by one time step.

Parameters
tCurrent simulation time.
deltaTIntegration step size.

Implements dnf_composer::element::Element.

Here is the call graph for this function:

◆ toString()

std::string dnf_composer::element::FieldCoupling::toString ( ) const
overridevirtual

Implements dnf_composer::element::Element.

Here is the call graph for this function:

◆ tryReadWeights()

void dnf_composer::element::FieldCoupling::tryReadWeights ( )

Load weights if the file exists; log INFO in either case. Unlike readWeights(), this never logs an error — use it when weights may legitimately be absent (e.g. first run of a programmatic simulation).

Here is the call graph for this function:

◆ writeWeights()

void dnf_composer::element::FieldCoupling::writeWeights ( ) const

Save the current weight matrix to a binary file in weightsDirectory.

Here is the call graph for this function:

Member Data Documentation

◆ input

std::shared_ptr<Element> dnf_composer::element::FieldCoupling::input
protected

◆ output

std::shared_ptr<Element> dnf_composer::element::FieldCoupling::output
protected

◆ parameters

FieldCouplingParameters dnf_composer::element::FieldCoupling::parameters
protected

◆ weightsDirectory

std::string dnf_composer::element::FieldCoupling::weightsDirectory
protected

Directory used for weight serialization.


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