AnimatLab
2
Test
|
Neural module. More...
#include <NeuralModule.h>
Public Member Functions | |
NeuralModule () | |
Default constructor. More... | |
virtual | ~NeuralModule () |
Destructor. More... | |
virtual void | AddExternalSynapse (AnimatSim::Link *lpSynapse) |
virtual void | AddExternalSynapse (std::string strXml, bool bDoNotInit) |
Adds a synapse using an xml packet. More... | |
virtual void | AttachSourceAdapter (Adapter *lpAdapter) |
Attaches a source adapter. More... | |
virtual void | AttachTargetAdapter (Adapter *lpAdapter) |
Attaches a target adapter. More... | |
virtual IStdClassFactory * | ClassFactory () |
Gets the class factory. More... | |
virtual void | ClassFactory (IStdClassFactory *lpFactory) |
virtual int | FindExternalSynapseListPos (std::string strID, bool bThrowError=true) |
Searches for a synapse with the specified ID and returns its position in the list. More... | |
virtual float * | GetDataPointer (const std::string &strDataType) |
Returns a float pointer to a data item of interest in this object. More... | |
Organism * | GetOrganism () |
Gets the organism. More... | |
Simulator * | GetSimulator () |
Gets the simulator. More... | |
virtual void | Initialize () |
Initializes this object. More... | |
virtual std::string | ModuleName ()=0 |
Gets the module name. More... | |
virtual bool | NeedToStep (bool bIncrement) |
Tells whether this NeuralModule needs to call StepSimulation. More... | |
virtual void | RemoveExternalSynapse (std::string strID, bool bThrowError=true) |
Removes the synapse by the GUID ID. More... | |
virtual void | RemoveSourceAdapter (Adapter *lpAdapter) |
Removes a source adapter. More... | |
virtual void | RemoveTargetAdapter (Adapter *lpAdapter) |
Removes a target adapter. More... | |
virtual void | ResetSimulation () |
Resets the simulation back to time 0. More... | |
virtual void | ResetStepCounter () |
virtual void | SetSystemPointers (Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify) |
Sets the system pointers. More... | |
virtual void | StepAdapters () |
Step adapters. More... | |
virtual void | StepSimulation () |
Step the simulation for this object. More... | |
virtual float | TimeStep () |
Gets the time step for this moudle in time units. More... | |
virtual void | TimeStep (float fltVal) |
Sets the Time step for this moudle in time units. More... | |
virtual short | TimeStepInterval () |
Gets the time step interval. More... | |
virtual void | TimeStepInterval (short iVal) |
Sets ime step interval. More... | |
virtual void | VerifySystemPointers () |
Verify that system pointers have been set correctly. More... | |
Public Member Functions inherited from AnimatSim::AnimatBase | |
AnimatBase () | |
Constructs an AnimatBase object. More... | |
virtual | ~AnimatBase () |
Destroys the AnimatBase object.. More... | |
virtual bool | AddItem (const std::string &strItemType, const std::string &strXml, bool bThrowError=true, bool bDoNotInit=false) |
Adds a new object to this parent. More... | |
virtual void | AfterResetSimulation () |
Called after a simulation reset for some objects. More... | |
virtual long | CalculateSnapshotByteSize () |
Calculates the snapshot byte size. More... | |
virtual void | Copy (CStdSerialize *lpSource) |
virtual void | Enabled (bool bVal) |
Tells whether this item is enabled or not. This is not actually used for all objects, only specific ones. I am putting it in the base class though to prevent numerous duplications. More... | |
virtual bool | Enabled () |
Tells whether this item is enabled or not. This is not actually used for all objects, only specific ones. I am putting it in the base class though to prevent numerous duplications. More... | |
virtual NeuralModule * | GetNeuralModule () |
Gets the neural module. More... | |
virtual Node * | GetNode () |
Gets the node. More... | |
virtual Structure * | GetStructure () |
Gets the structure for this node. More... | |
virtual bool | HasProperty (const std::string &strName) |
Queries this object if it has a property with the given name. More... | |
virtual std::string | ID () |
Gets the unique GUID ID of this object. More... | |
virtual void | ID (std::string strValue) |
Sets the unique GUID ID of the object. More... | |
virtual void | Kill (bool bState=true) |
Kills. More... | |
virtual void | Load (StdUtils::CStdXml &oXml) |
Loads the item using an XML data packet. More... | |
virtual void | LoadKeyFrameSnapshot (byte *aryBytes, long &lIndex) |
Loads a key frame snapshot. More... | |
virtual std::string | Name () |
Gets the name of this object. More... | |
virtual void | Name (std::string strValue) |
Sets the name of the object. Blank is acceptable. More... | |
virtual AnimatPropertyType | PropertyType (const std::string &strName) |
virtual void | QueryProperties (CStdPtrArray< TypeProperty > &aryProperties) |
Queries this object for a list of properties that can be changed using SetData. More... | |
virtual void | ReInitialize () |
Re-initialize this object. More... | |
virtual bool | RemoveItem (const std::string &strItemType, const std::string &strID, bool bThrowError=true) |
Removes a child item from this parent. More... | |
virtual void | Reset () |
Resets this object. More... | |
virtual void | RigidBodyAdded (std::string strID) |
virtual void | RigidBodyRemoved (std::string strID) |
virtual void | SaveKeyFrameSnapshot (byte *aryBytes, long &lIndex) |
Saves a key frame snapshot. More... | |
virtual bool | Selected () |
Tells if this items is selected or not. More... | |
virtual void | Selected (bool bValue, bool bSelectMultiple) |
Selects this object. More... | |
virtual bool | SetData (const std::string &strDataType, const std::string &strValue, bool bThrowError=true) |
Set a variable based on a string data type name. More... | |
virtual bool | SetData (const std::string &strDataType, const float fltValue, bool bThrowError=true) |
Set a variable based on a string data type name. More... | |
virtual bool | SetData (const std::string &strDataType, const long lValue, bool bThrowError=true) |
Set a variable based on a string data type name. More... | |
virtual void | SetSystemPointers (Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify) |
Sets the system pointers. More... | |
virtual void | SimPausing () |
Called just before the simulation pauses. More... | |
virtual void | SimStarting () |
Called just before the simulation starts. More... | |
virtual void | SimStopping () |
Called just before the simulation stops. More... | |
virtual void | TimeStepModified () |
Notification method that the time step modified has been modified. Objects should recalculate any slice times as needed. More... | |
virtual std::string | Type () |
returns the string type name of this object. More... | |
virtual void | Type (std::string strValue) |
Sets the class type for this object. More... | |
virtual void | VisualSelectionModeChanged (int iNewMode) |
Visual selection mode changed. More... | |
Static Public Member Functions | |
static NeuralModule * | CastToDerived (AnimatBase *lpBase) |
Protected Member Functions | |
virtual int | FindAdapterListIndex (CStdArray< Adapter * > aryAdapters, std::string strID, bool bThrowError=true) |
virtual AnimatSim::Link * | LoadExternalSynapse (CStdXml &oXml) |
Loads an external synapse. More... | |
virtual void | LoadExternalSynapses (CStdXml &oXml) |
Loads external synapses. More... | |
Protected Attributes | |
CStdPtrArray< AnimatSim::Link > | m_aryExternalSynapses |
An array of external synapses connected to nodes within this module. | |
CStdArray< Adapter * > | m_arySourceAdapters |
An array of source adapters for this module. | |
CStdArray< Adapter * > | m_aryTargetAdapters |
An array of target adapters for this module. | |
float | m_fltTimeStep |
The DT time step for this neural module in seconds. | |
short | m_iTargetAdapterCount |
Number of target adapters. | |
short | m_iTimeStepCount |
Count variable that keeps track of how many slices have occured since the last StepSimulation. | |
short | m_iTimeStepInterval |
IStdClassFactory * | m_lpClassFactory |
The pointer to the class factory for this module. | |
Organism * | m_lpOrganism |
The pointer to the organism. | |
std::string | m_strNeuralNetworkFile |
The string neural network file name. | |
std::string | m_strProjectPath |
Full pathname of the string project file for this module. | |
Protected Attributes inherited from AnimatSim::AnimatBase | |
bool | m_bEnabled |
Tells if this item is enabled or not. If it is not enabled then it is not run. | |
bool | m_bSelected |
Tells whether the object is selected or not. | |
AnimatSim::Behavior::NeuralModule * | m_lpModule |
The pointer to this items parentNeuralModule. If this is not relevant for this object then this is NULL. | |
Node * | m_lpNode |
The pointer to this items parent Node. If this is not relevant for this object then this is NULL. | |
Simulator * | m_lpSim |
The pointer to a Simulation. | |
AnimatSim::Environment::Structure * | m_lpStructure |
The pointer to this items parent Structure. If this is not relevant for this object then this is NULL. | |
std::string | m_strID |
The unique Id for this object. | |
std::string | m_strName |
The name for this object. | |
std::string | m_strType |
The type for this object. Examples are Box, Plane, Neuron, etc.. | |
Neural module.
An organism is a structure with a nervous system (NervousSystem). The nervous system contains one or more neural modules. A neural module performs the processing for a given neural model library (firing rate, integrate and fire, etc.). Each neural module can operate with an independent time step. Elements in one module can interact with elements in an another by using adapters to connect them. The module has a list of target adapters. At each time step of the module it calls StepSimulation to add an external value to the target node in another module.
Definition at line 29 of file NeuralModule.h.
AnimatSim::Behavior::NeuralModule::NeuralModule | ( | ) |
Default constructor.
Definition at line 64 of file NeuralModule.cpp.
References m_fltTimeStep, m_iTargetAdapterCount, m_iTimeStepCount, m_iTimeStepInterval, m_lpClassFactory, m_lpOrganism, and AnimatSim::AnimatBase::m_lpSim.
|
virtual |
Destructor.
This deletes the class factory when destroyed.
Definition at line 85 of file NeuralModule.cpp.
References m_arySourceAdapters, m_aryTargetAdapters, m_lpClassFactory, and StdUtils::Std_TraceMsg().
|
virtual |
Adds a synapse using an xml packet.
strXml | The xml of the synapse to add. |
Definition at line 326 of file NeuralModule.cpp.
References StdUtils::CStdXml::Deserialize(), StdUtils::CStdXml::FindChildElement(), StdUtils::CStdXml::FindElement(), AnimatSim::AnimatBase::Initialize(), and LoadExternalSynapse().
|
virtual |
Attaches a source adapter.
This adds the specified adapter to this module. It can then process the adapters during a step of the simulation.
[in,out] | lpAdapter | Pointer to an adapter. |
|
virtual |
Attaches a target adapter.
This adds the specified adapter to this module. It can then process the adapters during a step of the simulation.
[in,out] | lpAdapter | Pointer to an adapter. |
|
virtual |
Gets the class factory.
Definition at line 110 of file NeuralModule.cpp.
References m_lpClassFactory.
|
virtual |
Searches for a synapse with the specified ID and returns its position in the list.
strID | GUID ID of the synapse to find. |
bThrowError | true to throw error if no synapse is found. |
Definition at line 364 of file NeuralModule.cpp.
References AnimatSim::AnimatBase::ID(), m_aryExternalSynapses, StdUtils::Std_ToUpper(), and StdUtils::Std_Trim().
Referenced by RemoveExternalSynapse().
|
virtual |
Returns a float pointer to a data item of interest in this object.
This is a generic method used to get a pointer to data variable of interest. It is used by a variety of systems in the simulation. The most prominent are the data charting and stimulus classes. Within this method we associate a variable with a string name. By passing in the name of the data type we are interested in we can recieve back a float pointer to that data type. We can use that to read or set the data item in other classes. For example, the data charting system gets the pointer and then each time it needs to log a data point it reads the value into an array.
strDataType | name of the data item for which we are looking. |
If | DataType is not found. |
Reimplemented from AnimatSim::AnimatBase.
Reimplemented in AnimatSim::Behavior::ThreadedModule.
Definition at line 476 of file NeuralModule.cpp.
References AnimatSim::AnimatBase::GetDataPointer(), m_fltTimeStep, and StdUtils::Std_CheckString().
Referenced by AnimatSim::Behavior::ThreadedModule::GetDataPointer().
Organism * AnimatSim::Behavior::NeuralModule::GetOrganism | ( | ) |
Gets the organism.
Definition at line 144 of file NeuralModule.cpp.
References m_lpOrganism.
|
virtual |
Gets the simulator.
Reimplemented from AnimatSim::AnimatBase.
Definition at line 132 of file NeuralModule.cpp.
References AnimatSim::AnimatBase::m_lpSim.
Referenced by IntegrateFireSim::IntegrateFireNeuralModule::LoadInternal(), and IntegrateFireSim::IntegrateFireNeuralModule::RemoveSynapseType().
|
virtual |
Initializes this object.
After an object is loaded in it must be initialized before it can be used. This allows the object to retrieve any pointers or setup memory that it will need during execution. Each object is responsible for initializing any of its child objects, so you simply need to call this method on the containing class to init all child objects. It also calls VerifySystemPointers to make sure that the system pointers have been setup correctly.
Reimplemented from AnimatSim::AnimatBase.
Reimplemented in IntegrateFireSim::IntegrateFireNeuralModule, AnimatCarlSim::CsNeuralModule, FiringRateSim::FiringRateModule, and AnimatSim::Behavior::PhysicsNeuralModule.
Definition at line 226 of file NeuralModule.cpp.
References m_aryExternalSynapses, m_fltTimeStep, and TimeStep().
Referenced by AnimatSim::Behavior::NervousSystem::AddNeuralModule(), AnimatSim::Behavior::PhysicsNeuralModule::Initialize(), and AnimatSim::Behavior::NervousSystem::Initialize().
|
protectedvirtual |
Loads an external synapse.
[in,out] | oXml | The xml to load. |
Definition at line 419 of file NeuralModule.cpp.
References AnimatSim::Simulator::CreateObject(), StdUtils::CStdXml::GetChildString(), StdUtils::CStdXml::IntoElem(), AnimatSim::AnimatBase::Load(), AnimatSim::AnimatBase::m_lpSim, AnimatSim::AnimatBase::m_lpStructure, StdUtils::CStdXml::OutOfElem(), and AnimatSim::Link::SetSystemPointers().
Referenced by AddExternalSynapse(), and LoadExternalSynapses().
|
protectedvirtual |
Loads external synapses.
[in,out] | oXml | The xml to load. |
Definition at line 389 of file NeuralModule.cpp.
References StdUtils::CStdXml::FindChildByIndex(), StdUtils::CStdXml::FindChildElement(), StdUtils::CStdXml::IntoChildElement(), LoadExternalSynapse(), StdUtils::CStdXml::NumberOfChildren(), and StdUtils::CStdXml::OutOfElem().
Referenced by FiringRateSim::FiringRateModule::LoadNetworkXml().
|
pure virtual |
Gets the module name.
Implemented in IntegrateFireSim::IntegrateFireNeuralModule, AnimatCarlSim::CsNeuralModule, FiringRateSim::FiringRateModule, and AnimatSim::Behavior::PhysicsNeuralModule.
Referenced by AnimatSim::Behavior::NervousSystem::AddNeuralModule().
|
virtual |
Tells whether this NeuralModule needs to call StepSimulation.
This is determined by the m_iTimeStepInterval. We only step on some whole number interval of the physics time step.
Definition at line 250 of file NeuralModule.cpp.
References m_iTimeStepCount, and m_iTimeStepInterval.
|
virtual |
Removes the synapse by the GUID ID.
strID | GUID ID for the synapse to remove. |
bThrowError | true to throw error if synaspe not found. |
Definition at line 347 of file NeuralModule.cpp.
References FindExternalSynapseListPos(), and m_aryExternalSynapses.
Referenced by IntegrateFireSim::IntegrateFireNeuralModule::RemoveItem().
|
virtual |
Removes a source adapter.
This removes the specified adapter from this module.
[in,out] | lpAdapter | Pointer to an adapter. |
|
virtual |
Removes a target adapter.
This removes the specified adapter from this module.
[in,out] | lpAdapter | Pointer to an adapter. |
|
virtual |
Resets the simulation back to time 0.
This method calls the ResetSimulation method on all subitems in order to reset the simulation back to the beginning.
Reimplemented from AnimatSim::AnimatBase.
Reimplemented in IntegrateFireSim::IntegrateFireNeuralModule, AnimatCarlSim::CsNeuralModule, FiringRateSim::FiringRateModule, and AnimatSim::Behavior::PhysicsNeuralModule.
Definition at line 486 of file NeuralModule.cpp.
References m_aryExternalSynapses.
Referenced by AnimatSim::Behavior::NervousSystem::ResetSimulation().
|
virtual |
Sets the system pointers.
There are a number of system pointers that are needed for use in the objects. The primariy one being a pointer to the simulation object itself so that you can get global parameters like the scale units and so on. However, each object may need other types of pointers as well, for example neurons need to have a pointer to their parent structure/organism, and to the NeuralModule they reside within. So different types of objects will need different sets of system pointers. We call this method to set the pointers just after creation and before Load is called. We then call VerifySystemPointers here, during Load and during Initialize in order to ensure that the correct pointers have been set for each type of objects. These pointers can then be safely used throughout the rest of the system.
[in,out] | lpSim | The pointer to a simulation. |
[in,out] | lpStructure | The pointer to the parent structure. |
[in,out] | lpModule | The pointer to the parent module module. |
[in,out] | lpNode | The pointer to the parent node. |
bVerify | true to call VerifySystemPointers. |
Referenced by AnimatSim::Behavior::NervousSystem::LoadNeuralModule().
|
virtual |
Step adapters.
Definition at line 500 of file NeuralModule.cpp.
References AnimatSim::AnimatBase::Enabled(), m_aryTargetAdapters, and m_iTargetAdapterCount.
|
virtual |
Step the simulation for this object.
This is called on an object each time it is stepped in the simulation. this is where its simulation code is processed. However, StepSimulation is not necessarily called every single time that the simulation as a whole is stepped. A good example of this is that neural modules can have different integration time steps. So a firing rate module may have a DT of 0.5 ms, while an integrate and fire model may have one of 0.1 ms. So the firing rate module would only get its StepSimulation method called every 5th time that the other module was called. This is all handed in the StepSimulation method of the Simulator and NervousSystem.
Reimplemented from AnimatSim::AnimatBase.
Reimplemented in IntegrateFireSim::IntegrateFireNeuralModule, AnimatCarlSim::CsNeuralModule, and FiringRateSim::FiringRateModule.
Definition at line 493 of file NeuralModule.cpp.
References m_aryExternalSynapses.
|
virtual |
Gets the time step for this moudle in time units.
Reimplemented in IntegrateFireSim::IntegrateFireNeuralModule, and AnimatSim::Behavior::PhysicsNeuralModule.
Definition at line 190 of file NeuralModule.cpp.
References m_fltTimeStep.
Referenced by FiringRateSim::Neurons::Neuron::AccommodationTimeConstant(), FiringRateSim::Neurons::PacemakerNeuron::CalculateIntrinsicCurrent(), FiringRateSim::Neurons::RandomNeuron::CalculateIntrinsicCurrent(), IntegrateFireSim::Synapses::SpikingChemicalSynapse::FacilitationDecay(), Initialize(), FiringRateSim::Neurons::Neuron::Initialize(), FiringRateSim::Neurons::Neuron::RelativeAccommodation(), FiringRateSim::FiringRateModule::SetData(), AnimatCarlSim::CsNeuralModule::SetData(), FiringRateSim::Synapses::Synapse::SetDelayBufferSize(), FiringRateSim::Neurons::Neuron::StepSimulation(), AnimatSim::Adapters::Adapter::SynchUpdateInterval(), AnimatSim::Adapters::Adapter::SynchUpdateStartInterval(), AnimatSim::Behavior::PhysicsNeuralModule::TimeStep(), FiringRateSim::Neurons::Neuron::TimeStepModified(), and FiringRateSim::Neurons::Neuron::UseAccom().
|
virtual |
Sets the Time step for this moudle in time units.
This method calculates the required m_iTimeStepInterval.
fltVal | The flt value. |
Reimplemented in IntegrateFireSim::IntegrateFireNeuralModule, and AnimatSim::Behavior::PhysicsNeuralModule.
Definition at line 203 of file NeuralModule.cpp.
References m_fltTimeStep, m_iTimeStepInterval, AnimatSim::AnimatBase::m_lpSim, StdUtils::Std_IsAboveMin(), AnimatSim::Simulator::TimeStep(), and TimeStepInterval().
|
virtual |
Gets the time step interval.
The m_iTimeStepInterval is the number of time slices between that this module must wait before stepping again.
Definition at line 159 of file NeuralModule.cpp.
References m_iTimeStepInterval.
Referenced by TimeStep().
|
virtual |
Sets ime step interval.
iVal | New time step interval. |
new | value must be greater than zero. |
Definition at line 174 of file NeuralModule.cpp.
References m_iTimeStepInterval, and StdUtils::Std_IsAboveMin().
|
virtual |
Verify that system pointers have been set correctly.
The system pointers should be set just after an object is created. However, if for some reason it was not then this could cause read/write memory access errors later on because we would be using NULL pointers. This method is called during SetSystemPointers, Load, and Initialize to verify that the pointers for that type of object have been set correctly. We are calling three different places to ensure that it is checked before use. For example, if you are doing a Load call then you want to check it before attempting the load, but there may be an object that does not Load, but only does Initialize. So we need to check it there as well.
Reimplemented from AnimatSim::AnimatBase.
Definition at line 464 of file NeuralModule.cpp.
References m_lpOrganism, AnimatSim::AnimatBase::m_lpStructure, AnimatSim::AnimatBase::m_strName, and AnimatSim::AnimatBase::VerifySystemPointers().
Referenced by IntegrateFireSim::IntegrateFireNeuralModule::LoadInternal().
|
protected |
Zero-based integer index of the time step interval. This is the number of time slices between that this module must wait before stepping again.
Definition at line 37 of file NeuralModule.h.
Referenced by NeedToStep(), NeuralModule(), TimeStep(), and TimeStepInterval().