AnimatLab  2
Test
CsConnectionGenerator.cpp
1 
7 #include "StdAfx.h"
8 
9 #include "CsSynapseGroup.h"
10 #include "CsNeuronGroup.h"
11 #include "CsNeuralModule.h"
12 #include "CsConnectionGenerator.h"
13 
14 namespace AnimatCarlSim
15 {
16 
24 {
25  m_lpCsModule = NULL;
26  m_iFromGroupID = -1;
27  m_iToGroupID = -1;
28 }
29 
36 CsConnectionGenerator::CsConnectionGenerator(int iFromGroupID, int iToGroupID, bool bPlastic, Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule)
37 {
38  m_iFromGroupID = iFromGroupID;
39  m_iToGroupID = iToGroupID;
40  m_bPlastic = bPlastic;
41 
42  SetSystemPointers(lpSim, lpStructure, lpModule, NULL, true);
43 }
44 
52 {
53 
54 try
55 {
56  //m_arySynapseMap.clear();
57 }
58 catch(...)
59 {Std_TraceMsg(0, "Caught Error in desctructor of CsConnectionGenerator\r\n", "", -1, false, true);}
60 }
61 
62 void CsConnectionGenerator::FromGroupID(int iVal) {m_iFromGroupID = iVal;}
63 
64 int CsConnectionGenerator::FromGroupID() {return m_iFromGroupID;}
65 
66 void CsConnectionGenerator::ToGroupID(int iVal) {m_iToGroupID = iVal;}
67 
68 int CsConnectionGenerator::ToGroupID() {return m_iToGroupID;}
69 
70 void CsConnectionGenerator::Plastic(bool bVal) {m_bPlastic = bVal;}
71 
72 bool CsConnectionGenerator::Plastic() {return m_bPlastic;}
73 
74 void CsConnectionGenerator::SetSystemPointers(Simulator *m_lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
75 {
76  AnimatBase::SetSystemPointers(m_lpSim, lpStructure, lpModule, lpNode, false);
77 
78  m_lpCsModule = dynamic_cast<CsNeuralModule *>(lpModule);
79 
80  if(bVerify) VerifySystemPointers();
81 }
82 
84 {
85  AnimatBase::VerifySystemPointers();
86 
87  if(!m_lpCsModule)
88  THROW_PARAM_ERROR(Al_Err_lUnableToCastNeuralModuleToDesiredType, Al_Err_strUnableToCastNeuralModuleToDesiredType, "ID: ", m_lpCsModule->ID());
89 
90  if(!m_lpStructure)
91  THROW_PARAM_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType, "Structure: ", m_strID);
92 }
93 
94 void CsConnectionGenerator::SetCARLSimulation()
95 {
96  if(m_lpCsModule && m_lpCsModule->SNN() && m_iFromGroupID >= 0 && m_iToGroupID >= 0)
98 }
99 
100 void CsConnectionGenerator::connect(CpuSNN* s, int srcGrpId, int i, int destGrpId, int j, float& weight, float& maxWt, float& delay, bool& connected)
101 {
102  std::pair<int, int> vKey(i, j);
103 
104  //If we find it then go through the list and create the connection.
105  if(m_arySynapseMap.count(vKey) > 0)
106  {
107  //Get a list of items with this key
108  std::pair<std::multimap<std::pair<int, int>, CsSynapseIndividual *>::iterator, std::multimap<std::pair<int, int>, CsSynapseIndividual *>::iterator> itRange = m_arySynapseMap.equal_range(vKey);
109 
110  //Then iterate through them
111  for (std::multimap<std::pair<int, int>, CsSynapseIndividual *>::iterator it2 = itRange.first; it2 != itRange.second; ++it2)
112  {
113  CsSynapseIndividual *lpSynapse = (CsSynapseIndividual *)((*it2).second);
114 
115  if(lpSynapse->SetCARLSimulation(i, j, weight, maxWt, delay, connected))
116  return;
117  }
118  }
119  else
120  connected = false;
121 }
122 
123 
124 } //AnimatCarlSim
125 
126 
127 
128 
129 
130 
Contains the classes for a firing rate neural model.
Definition: CsAdapter.cpp:14
virtual void connect(CpuSNN *s, int srcGrpId, int i, int destGrpId, int j, float &weight, float &maxWt, float &delay, bool &connected)
specifies which synaptic connections (per group, per neuron, per synapse) should be made ...
int connect(int gIDpre, int gIDpost, const string &_type, float initWt, float maxWt, float _C, uint8_t minDelay, uint8_t maxDelay, bool synWtType=SYN_FIXED, const string &wtType=" ")
make from each neuron in grpId1 to 'numPostSynapses' neurons in grpId2
Definition: snn_cpu.cpp:1600
int m_iFromGroupID
The ID of the pre-synaptic neuron population.
Declares the CsNeuronGroup class.
CsNeuralModule * m_lpCsModule
Pointer to parent CsNeuralModule.
virtual std::string ID()
Gets the unique GUID ID of this object.
Definition: AnimatBase.cpp:167
AnimatSim::Environment::Structure * m_lpStructure
The pointer to this items parent Structure. If this is not relevant for this object then this is NULL...
Definition: AnimatBase.h:46
std::string m_strID
The unique Id for this object.
Definition: AnimatBase.h:55
Firing rate neural module.
std::multimap< std::pair< int, int >, CsSynapseIndividual * > m_arySynapseMap
A map relating the pre/post synaptic index to a given synapse.
Declares the synapse class.
int m_iToGroupID
The ID of the post-synaptic neuron population.
virtual void VerifySystemPointers()
Verify that system pointers have been set correctly.
Firing rate synapse model.
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.
Contains all of CARLsim's core functionality.
Definition: snn.h:619
bool m_bPlastic
Tells whether the connections generated by this class are plastic or fixed.