Skip to content

Commit a55c465

Browse files
committed
Merge branch 'development' into issue-490-responder-dispatch
2 parents db3db87 + 54fff38 commit a55c465

File tree

18 files changed

+112
-111
lines changed

18 files changed

+112
-111
lines changed

Simulator/Connections/NG911/Connections911.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ void Connections911::setup()
3333
BGFLOAT dist = layout.dist_(srcV, destV);
3434
LOG4CPLUS_DEBUG(edgeLogger_, "Source: " << srcV << " Dest: " << destV << " Dist: " << dist);
3535

36-
BGSIZE iEdg;
37-
edges_->addEdge(iEdg, type, srcV, destV, Simulator::getInstance().getDeltaT());
36+
BGSIZE iEdg = edges_->addEdge(type, srcV, destV, Simulator::getInstance().getDeltaT());
3837
added++;
3938
}
4039

@@ -230,8 +229,8 @@ bool Connections911::erasePSAP(AllVertices &vertices, Layout &layout)
230229
}
231230

232231
// Insert Caller to PSAP edge
233-
BGSIZE iEdg;
234-
edges_->addEdge(iEdg, CP, srcVertex, closestPSAP, Simulator::getInstance().getDeltaT());
232+
BGSIZE iEdg
233+
= edges_->addEdge(CP, srcVertex, closestPSAP, Simulator::getInstance().getDeltaT());
235234

236235
// Record added edge
237236
ChangedEdge addedEdge;
@@ -258,8 +257,8 @@ bool Connections911::erasePSAP(AllVertices &vertices, Layout &layout)
258257
}
259258

260259
// Insert PSAP to Responder edge
261-
BGSIZE iEdg;
262-
edges_->addEdge(iEdg, PR, closestPSAP, destVertex, Simulator::getInstance().getDeltaT());
260+
BGSIZE iEdg
261+
= edges_->addEdge(PR, closestPSAP, destVertex, Simulator::getInstance().getDeltaT());
263262

264263
// Record added edge
265264
ChangedEdge addedEdge;

Simulator/Connections/Neuro/ConnGrowth.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,8 @@ void ConnGrowth::updateSynapsesWeights()
283283
// if not connected and weight(a,b) > 0, add a new synapse from a to b
284284
if (!connected && (W_(srcVertex, destVertex) > 0)) {
285285
added++;
286-
BGSIZE iEdg;
287-
synapses.addEdge(iEdg, type, srcVertex, destVertex,
288-
Simulator::getInstance().getDeltaT());
286+
BGSIZE iEdg = synapses.addEdge(type, srcVertex, destVertex,
287+
Simulator::getInstance().getDeltaT());
289288
synapses.W_[iEdg] = W_(srcVertex, destVertex) * synapses.edgSign(type)
290289
* AllNeuroEdges::SYNAPSE_STRENGTH_ADJUSTMENT;
291290
}

Simulator/Connections/Neuro/ConnStatic.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,9 @@ void ConnStatic::setup()
7979
"Source: " << srcVertex << " Dest: " << destVertex
8080
<< " Dist: " << distDestVertices[srcVertex][i].dist);
8181

82-
BGSIZE iEdg;
83-
edges_->addEdge(iEdg, type, srcVertex, destVertex, simulator.getDeltaT());
82+
BGSIZE iEdg = edges_->addEdge(type, srcVertex, destVertex, simulator.getDeltaT());
8483
added++;
8584

86-
8785
// set edge weight
8886
// TODO: we need another synaptic weight distibution mode (normal distribution)
8987
if (neuroEdges.edgSign(type) > 0) {

Simulator/Core/Model.cpp

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515

1616
#include "Model.h"
17-
#include "ConnGrowth.h"
1817
#include "Connections.h"
1918
#include "Factory.h"
2019
#include "ParameterManager.h"
@@ -106,55 +105,17 @@ void Model::setupSim()
106105
connections_->createEdgeIndexMap();
107106
}
108107

108+
// Note: This method was previously used for debugging, but it is now dead code left behind.
109109
/// Log this simulation step.
110-
void Model::logSimStep() const
111-
{
112-
ConnGrowth *pConnGrowth = dynamic_cast<ConnGrowth *>(connections_.get());
113-
if (pConnGrowth == nullptr)
114-
return;
115-
116-
cout << "format:\ntype,radius,firing rate" << endl;
117-
118-
for (int y = 0; y < Simulator::getInstance().getHeight(); y++) {
119-
stringstream ss;
120-
ss << fixed;
121-
ss.precision(1);
122-
123-
for (int x = 0; x < Simulator::getInstance().getWidth(); x++) {
124-
switch (layout_->vertexTypeMap_[x + y * Simulator::getInstance().getWidth()]) {
125-
case EXC:
126-
if (layout_->starterMap_[x + y * Simulator::getInstance().getWidth()])
127-
ss << "s";
128-
else
129-
ss << "e";
130-
break;
131-
case INH:
132-
ss << "i";
133-
break;
134-
case VTYPE_UNDEF:
135-
assert(false);
136-
break;
137-
}
138-
139-
ss << " " << pConnGrowth->radii_[x + y * Simulator::getInstance().getWidth()];
140-
141-
if (x + 1 < Simulator::getInstance().getWidth()) {
142-
ss.width(2);
143-
ss << "|";
144-
ss.width(2);
145-
}
146-
}
147-
148-
ss << endl;
149-
150-
for (int i = ss.str().length() - 1; i >= 0; i--) {
151-
ss << "_";
152-
}
153-
154-
ss << endl;
155-
cout << ss.str();
156-
}
157-
}
110+
// void Model::logSimStep() const
111+
// {
112+
// FixedLayout *fixedLayout = dynamic_cast<FixedLayout *>(layout_.get());
113+
// if (fixedLayout == nullptr) {
114+
// return;
115+
// }
116+
117+
// fixedLayout->printLayout();
118+
// }
158119

159120
/// Update the simulation history of every epoch.
160121
void Model::updateHistory()

Simulator/Core/Model.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ class Model {
8080
virtual void updateConnections() = 0;
8181

8282
protected:
83+
// Note: This method was previously used for debugging, but it is now dead code left behind.
8384
/// Prints debug information about the current state of the network.
84-
void logSimStep() const;
85+
// void logSimStep() const;
8586

8687
/// Copy GPU Edge data to CPU.
8788
virtual void copyGPUtoCPU() = 0;

Simulator/Core/Simulator.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ void Simulator::finish()
7676
/// Load member variables from configuration file
7777
void Simulator::loadParameters()
7878
{
79-
ParameterManager::getInstance().getIntByXpath("//PoolSize/x/text()", width_);
80-
ParameterManager::getInstance().getIntByXpath("//PoolSize/y/text()", height_);
81-
// numVertices_ = width_ * height_;
82-
8379
ParameterManager::getInstance().getBGFloatByXpath("//SimParams/epochDuration/text()",
8480
epochDuration_);
8581
ParameterManager::getInstance().getIntByXpath("//SimParams/numEpochs/text()", numEpochs_);
@@ -110,7 +106,6 @@ void Simulator::printParameters() const
110106
LOG4CPLUS_DEBUG(fileLogger_,
111107
"\nSIMULATION PARAMETERS"
112108
<< endl
113-
<< "\tpool size x:" << width_ << " y:" << height_ << endl
114109
<< "\tTime between growth updates (in seconds): " << epochDuration_ << endl
115110
<< "\tNumber of epochs to run: " << numEpochs_ << endl
116111
<< "\tMax firing rate: " << maxFiringRate_ << endl
@@ -284,16 +279,6 @@ void Simulator::setStimulusFileName(const string &fileName)
284279
* Accessors
285280
***********************************************/
286281
///@{
287-
int Simulator::getWidth() const
288-
{
289-
return width_;
290-
}
291-
292-
int Simulator::getHeight() const
293-
{
294-
return height_;
295-
}
296-
297282
int Simulator::getTotalVertices() const
298283
{
299284
return model_->getLayout().getNumVertices();

Simulator/Core/Simulator.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ class Simulator {
6161
* Accessors
6262
***********************************************/
6363
///@{
64-
int getWidth() const; /// Width of neuron map (assumes square)
65-
66-
int getHeight() const; /// Height of neuron map
67-
6864
int getTotalVertices() const; /// Count of neurons in the simulation
6965

7066
int getCurrentStep() const; /// Current simulation step
@@ -130,10 +126,6 @@ class Simulator {
130126
Simulator(); /// Constructor is private to keep a singleton instance of this
131127
/// class.
132128

133-
int width_; /// Width of neuron map (assumes square)
134-
135-
int height_; /// Height of neuron map
136-
137129
int totalNeurons_; /// Count of neurons in the simulation
138130

139131
int currentEpoch_; /// Current epoch step

Simulator/Edges/AllEdges.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,15 @@ void AllEdges::eraseEdge(const int iVert, const BGSIZE iEdg)
250250

251251
/// Adds an edge to the model, connecting two Vertices.
252252
///
253-
/// @param iEdg Index of the edge to be added.
254253
/// @param type The type of the edge to add.
255254
/// @param srcVertex The Vertex that sends to this edge.
256255
/// @param destVertex The Vertex that receives from the edge.
257256
/// @param deltaT Inner simulation step duration
258-
void AllEdges::addEdge(BGSIZE &iEdg, edgeType type, const int srcVertex, const int destVertex,
259-
const BGFLOAT deltaT)
257+
/// @return iEdg Index of the edge to be added.
258+
BGSIZE AllEdges::addEdge(edgeType type, const int srcVertex, const int destVertex,
259+
const BGFLOAT deltaT)
260260
{
261+
BGSIZE iEdg;
261262
if (edgeCounts_[destVertex] >= maxEdgesPerVertex_) {
262263
LOG4CPLUS_FATAL(edgeLogger_, "Vertex : " << destVertex << " ran out of space for new edges.");
263264
throw runtime_error("Vertex " + to_string(destVertex)
@@ -278,4 +279,5 @@ void AllEdges::addEdge(BGSIZE &iEdg, edgeType type, const int srcVertex, const i
278279

279280
// create an edge
280281
createEdge(iEdg, srcVertex, destVertex, deltaT, type);
282+
return iEdg;
281283
}

Simulator/Edges/AllEdges.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ class AllEdges {
3636

3737
/// Adds a Edge to the model, connecting two Vertices.
3838
///
39-
/// @param iEdg Index of the edge to be added.
4039
/// @param type The type of the Edge to add.
4140
/// @param srcVertex The Vertex that sends to this Edge.
4241
/// @param destVertex The Vertex that receives from the Edge.
4342
/// @param deltaT Inner simulation step duration
44-
virtual void addEdge(BGSIZE &iEdg, edgeType type, const int srcVertex, const int destVertex,
45-
const BGFLOAT deltaT);
43+
/// @return iEdg Index of the edge to be added.
44+
virtual BGSIZE addEdge(edgeType type, const int srcVertex, const int destVertex,
45+
const BGFLOAT deltaT);
4646

4747
/// Create a Edge and connect it to the model.
4848
///

Simulator/Layouts/Neuro/FixedLayout.cpp

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#include "FixedLayout.h"
10+
#include "ConnGrowth.h"
1011
#include "ParameterManager.h"
1112
#include "ParseParamError.h"
1213
#include "Util.h"
@@ -129,11 +130,10 @@ void FixedLayout::loadParameters()
129130
+ inhibitoryNListFilePath);
130131
}
131132

132-
// Get the total number of vertices
133-
int width, height;
134-
ParameterManager::getInstance().getIntByXpath("//PoolSize/x/text()", width);
135-
ParameterManager::getInstance().getIntByXpath("//PoolSize/y/text()", height);
136-
numVertices_ = width * height;
133+
// Get width, height and total number of vertices
134+
ParameterManager::getInstance().getIntByXpath("//PoolSize/x/text()", width_);
135+
ParameterManager::getInstance().getIntByXpath("//PoolSize/y/text()", height_);
136+
numVertices_ = width_ * height_;
137137
}
138138

139139
/// Returns the type of synapse at the given coordinates
@@ -164,14 +164,64 @@ void FixedLayout::initVerticesLocs()
164164
if (gridLayout_) {
165165
// grid layout
166166
for (int i = 0; i < numVertices; i++) {
167-
xloc_[i] = i % Simulator::getInstance().getHeight();
168-
yloc_[i] = i / Simulator::getInstance().getHeight();
167+
xloc_[i] = i % height_;
168+
yloc_[i] = i / height_;
169169
}
170170
} else {
171171
// random layout
172172
for (int i = 0; i < numVertices; i++) {
173-
xloc_[i] = initRNG.inRange(0, Simulator::getInstance().getWidth());
174-
yloc_[i] = initRNG.inRange(0, Simulator::getInstance().getHeight());
173+
xloc_[i] = initRNG.inRange(0, width_);
174+
yloc_[i] = initRNG.inRange(0, height_);
175175
}
176176
}
177177
}
178+
179+
// Note: This code was previously used for debugging, but it is now dead code left behind
180+
// and it is never executed.
181+
void FixedLayout::printLayout()
182+
{
183+
ConnGrowth &pConnGrowth
184+
= dynamic_cast<ConnGrowth &>(Simulator::getInstance().getModel().getConnections());
185+
186+
cout << "format:\ntype,radius,firing rate" << endl;
187+
188+
for (int y = 0; y < height_; y++) {
189+
stringstream ss;
190+
ss << fixed;
191+
ss.precision(1);
192+
193+
for (int x = 0; x < width_; x++) {
194+
switch (vertexTypeMap_[x + y * width_]) {
195+
case EXC:
196+
if (starterMap_[x + y * width_])
197+
ss << "s";
198+
else
199+
ss << "e";
200+
break;
201+
case INH:
202+
ss << "i";
203+
break;
204+
case VTYPE_UNDEF:
205+
assert(false);
206+
break;
207+
}
208+
209+
ss << " " << pConnGrowth.radii_[x + y * width_];
210+
211+
if (x + 1 < width_) {
212+
ss.width(2);
213+
ss << "|";
214+
ss.width(2);
215+
}
216+
}
217+
218+
ss << endl;
219+
220+
for (int i = ss.str().length() - 1; i >= 0; i--) {
221+
ss << "_";
222+
}
223+
224+
ss << endl;
225+
cout << ss.str();
226+
}
227+
}

0 commit comments

Comments
 (0)