Skip to content

Commit e7a4ef6

Browse files
authored
Merge branch 'development' into issue-516-rename-summationMap
2 parents e4a9ce2 + 86361b1 commit e7a4ef6

File tree

17 files changed

+56
-208
lines changed

17 files changed

+56
-208
lines changed

Simulator/Connections/NG911/Connections911.cpp

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

38-
BGSIZE iEdg;
39-
edges_->addEdge(iEdg, type, srcV, destV, Simulator::getInstance().getDeltaT());
38+
BGSIZE iEdg = edges_->addEdge(type, srcV, destV, Simulator::getInstance().getDeltaT());
4039
added++;
4140
}
4241

@@ -190,8 +189,8 @@ bool Connections911::erasePSAP(AllVertices &vertices, Layout &layout)
190189
}
191190

192191
// Insert Caller to PSAP edge
193-
BGSIZE iEdg;
194-
edges_->addEdge(iEdg, CP, srcVertex, closestPSAP, Simulator::getInstance().getDeltaT());
192+
BGSIZE iEdg
193+
= edges_->addEdge(CP, srcVertex, closestPSAP, Simulator::getInstance().getDeltaT());
195194

196195
// Record added edge
197196
ChangedEdge addedEdge;
@@ -218,8 +217,8 @@ bool Connections911::erasePSAP(AllVertices &vertices, Layout &layout)
218217
}
219218

220219
// Insert PSAP to Responder edge
221-
BGSIZE iEdg;
222-
edges_->addEdge(iEdg, PR, closestPSAP, destVertex, Simulator::getInstance().getDeltaT());
220+
BGSIZE iEdg
221+
= edges_->addEdge(PR, closestPSAP, destVertex, Simulator::getInstance().getDeltaT());
223222

224223
// Record added edge
225224
ChangedEdge addedEdge;

Simulator/Connections/Neuro/ConnGrowth.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ void ConnGrowth::updateSynapsesWeights()
240240
for (int srcVertex = 0; srcVertex < numVertices; srcVertex++) {
241241
// and each destination neuron 'b'
242242
for (int destVertex = 0; destVertex < numVertices; destVertex++) {
243+
if (destVertex == srcVertex) {
244+
// we don't create a synapse between the same neuron
245+
continue;
246+
}
247+
243248
// visit each synapse at (xa,ya)
244249
bool connected = false;
245250
edgeType type = layout.edgType(srcVertex, destVertex);
@@ -278,9 +283,8 @@ void ConnGrowth::updateSynapsesWeights()
278283
// if not connected and weight(a,b) > 0, add a new synapse from a to b
279284
if (!connected && (W_(srcVertex, destVertex) > 0)) {
280285
added++;
281-
BGSIZE iEdg;
282-
synapses.addEdge(iEdg, type, srcVertex, destVertex,
283-
Simulator::getInstance().getDeltaT());
286+
BGSIZE iEdg = synapses.addEdge(type, srcVertex, destVertex,
287+
Simulator::getInstance().getDeltaT());
284288
synapses.W_[iEdg] = W_(srcVertex, destVertex) * synapses.edgSign(type)
285289
* AllNeuroEdges::SYNAPSE_STRENGTH_ADJUSTMENT;
286290
}

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/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/Edges/NG911/All911Edges.cpp

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,20 @@ All911Edges::All911Edges(const int numVertices, const int maxEdges)
1414

1515
void All911Edges::setupEdges()
1616
{
17-
int numVertices = Simulator::getInstance().getTotalVertices();
18-
int maxEdges = Simulator::getInstance().getMaxEdgesPerVertex();
19-
BGSIZE maxTotalEdges = maxEdges * numVertices;
20-
21-
isAvailable_ = make_unique<bool[]>(maxTotalEdges);
22-
fill_n(isAvailable_.get(), maxTotalEdges, true);
23-
24-
isRedial_ = make_unique<bool[]>(maxTotalEdges);
25-
fill_n(isRedial_.get(), maxTotalEdges, false);
26-
27-
call_.resize(maxTotalEdges);
28-
29-
maxEdgesPerVertex_ = maxEdges;
30-
totalEdgeCount_ = 0;
31-
countVertices_ = numVertices;
32-
33-
// To do: Figure out whether we need all of these
34-
// Jardi: Removing this seems to break the creating of the EdgeIndexMap
35-
if (maxTotalEdges != 0) {
36-
// psr_.assign(maxTotalEdges, 0.0);
37-
W_.assign(maxTotalEdges, 0);
38-
type_.assign(maxTotalEdges, ETYPE_UNDEF);
39-
edgeCounts_.assign(numVertices, 0);
40-
destVertexIndex_.assign(maxTotalEdges, 0);
41-
sourceVertexIndex_.assign(maxTotalEdges, 0);
42-
inUse_ = make_unique<bool[]>(maxTotalEdges);
43-
fill_n(inUse_.get(), maxTotalEdges, false);
17+
// Setup the variables in the Super Class
18+
AllEdges::setupEdges();
19+
20+
// Setup the variables in the sub Class
21+
BGSIZE maxTotalEdges = maxEdgesPerVertex_ * countVertices_;
22+
23+
if (maxTotalEdges > 0) {
24+
isAvailable_ = make_unique<bool[]>(maxTotalEdges);
25+
fill_n(isAvailable_.get(), maxTotalEdges, true);
26+
27+
isRedial_ = make_unique<bool[]>(maxTotalEdges);
28+
fill_n(isRedial_.get(), maxTotalEdges, false);
29+
30+
call_.resize(maxTotalEdges);
4431
}
4532
}
4633

@@ -108,15 +95,6 @@ void All911Edges::advanceEdges(AllVertices &vertices, EdgeIndexMap &edgeIndexMap
10895
}
10996
}
11097
}
111-
// All911Vertices *allVertices = dynamic_cast<All911Vertices *>(vertices);
112-
// for (BGSIZE i = 0; i < totalEdgeCount_; i++) {
113-
// if (!inUse_[i]) {
114-
// continue;
115-
// }
116-
// // if the edge is in use...
117-
// BGSIZE iEdg = edgeIndexMap->incomingEdgeIndexMap_[i];
118-
// advance911Edge(iEdg, allVertices);
119-
// }
12098
}
12199

122100
/// Advance one specific edge.

Simulator/Edges/Neuro/AllSynapsesDeviceFuncs_d.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,11 @@ __global__ void updateSynapsesWeightsDevice(int numVertices, BGFLOAT deltaT, BGF
552552

553553
// and each destination neuron 'b'
554554
for (int srcVertex = 0; srcVertex < numVertices; srcVertex++) {
555+
if (destVertex == srcVertex) {
556+
// we don't create a synapse between the same neuron
557+
continue;
558+
}
559+
555560
// visit each synapse at (xa,ya)
556561
bool connected = false;
557562
edgeType type = edgType(neuronTypeMap_d, srcVertex, destVertex);

Simulator/Layouts/NG911/Layout911.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,6 @@ void Layout911::generateVertexTypeMap(int numVertices)
110110
LOG4CPLUS_INFO(fileLogger_, "Finished initializing vertex type map");
111111
}
112112

113-
void Layout911::initStarterMap(const int numVertices)
114-
{
115-
Layout::initStarterMap(numVertices);
116-
}
117-
118-
// Get the zone of the vertex
119-
// Only built for 10x10 grid
120-
// See: https://docs.google.com/spreadsheets/d/1DqP8sjkfJ_pkxtETzuEdoVZbWOGu633EMQAeShe5k68/edit?usp=sharing
121-
int Layout911::zone(int index)
122-
{
123-
return (index % 10 >= 5) + 2 * (index < 50);
124-
}
125-
126113
/// Returns the type of synapse at the given coordinates
127114
///
128115
/// @param srcVertex integer that points to a Neuron in the type map as a source.

Simulator/Layouts/NG911/Layout911.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,6 @@ class Layout911 : public Layout {
5151
/// @param numVertices number of the vertices to have in the type map.
5252
virtual void generateVertexTypeMap(int numVertices) override;
5353

54-
/// Populates the starter map.
55-
///
56-
/// @param numVertices number of vertices to have in the map.
57-
virtual void initStarterMap(const int numVertices) override;
58-
59-
/// Get the zone of the vertex
60-
/// Only built for 10x10 grid
61-
/// See: https://docs.google.com/spreadsheets/d/1DqP8sjkfJ_pkxtETzuEdoVZbWOGu633EMQAeShe5k68/edit?usp=sharing
62-
/// @param index the index of the vertex
63-
int zone(int index);
64-
6554
/// Returns the type of synapse at the given coordinates
6655
/// @param srcVertex integer that points to a Neuron in the type map as a source.
6756
/// @param destVertex integer that points to a Neuron in the type map as a destination.

Simulator/Vertices/NG911/All911Vertices.cpp

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ void All911Vertices::setupVertices()
1717
{
1818
AllVertices::setupVertices();
1919

20-
callNum_.resize(size_);
21-
dispNum_.resize(size_);
22-
respNum_.resize(size_);
23-
24-
// Populate arrays with 0
25-
callNum_.assign(size_, 0);
26-
dispNum_.assign(size_, 0);
27-
respNum_.assign(size_, 0);
28-
2920
// Resize and fill vectors with 0
3021
numAgents_.assign(size_, 0);
3122
numTrunks_.assign(size_, 0);
@@ -83,69 +74,10 @@ void All911Vertices::createAllVertices(Layout &layout)
8374

8475
// Read Input Events using the InputManager
8576
inputManager_.readInputs();
86-
87-
88-
// TODO: The code below is from previous version. I am keeping because
89-
// it is usefull for testing the output against the previous version.
90-
vector<int> psapList;
91-
vector<int> respList;
92-
psapList.clear();
93-
respList.clear();
94-
95-
int callersPerZone[] = {0, 0, 0, 0};
96-
int respPerZone[] = {0, 0, 0, 0};
97-
98-
Layout911 &layout911 = dynamic_cast<Layout911 &>(layout);
99-
100-
for (int i = 0; i < Simulator::getInstance().getTotalVertices(); i++) {
101-
// Create all callers
102-
if (layout.vertexTypeMap_[i] == CALR) {
103-
callNum_[i] = initRNG.inRange(callNumRange_[0], callNumRange_[1]);
104-
callersPerZone[layout911.zone(i)] += callNum_[i];
105-
}
106-
107-
// Find all PSAPs
108-
if (layout.vertexTypeMap_[i] == PSAP) {
109-
psapList.push_back(i);
110-
}
111-
112-
// Find all resps
113-
if (layout.vertexTypeMap_[i] == RESP) {
114-
respList.push_back(i);
115-
respPerZone[layout911.zone(i)] += 1;
116-
}
117-
}
118-
119-
// Create all psaps
120-
// Dispatchers in a psap = [callers in the zone * k] + some randomness
121-
for (int i = 0; i < psapList.size(); i++) {
122-
int psapQ = layout911.zone(i);
123-
int dispCount = (callersPerZone[psapQ] * dispNumScale_) + initRNG.inRange(-5, 5);
124-
if (dispCount < 1) {
125-
dispCount = 1;
126-
}
127-
dispNum_[psapList[i]] = dispCount;
128-
}
129-
130-
// Create all responders
131-
// Responders in a node = [callers in the zone * k]/[number of responder nodes] + some randomness
132-
for (int i = 0; i < respList.size(); i++) {
133-
int respQ = layout911.zone(respList[i]);
134-
int respCount
135-
= (callersPerZone[respQ] * respNumScale_) / respPerZone[respQ] + initRNG.inRange(-5, 5);
136-
if (respCount < 1) {
137-
respCount = 1;
138-
}
139-
respNum_[respList[i]] = respCount;
140-
}
14177
}
14278

14379
void All911Vertices::loadParameters()
14480
{
145-
ParameterManager::getInstance().getIntByXpath("//CallNum/min/text()", callNumRange_[0]);
146-
ParameterManager::getInstance().getIntByXpath("//CallNum/max/text()", callNumRange_[1]);
147-
ParameterManager::getInstance().getBGFloatByXpath("//DispNumScale/text()", dispNumScale_);
148-
ParameterManager::getInstance().getBGFloatByXpath("//RespNumScale/text()", respNumScale_);
14981
ParameterManager::getInstance().getBGFloatByXpath("//RedialP/text()", redialP_);
15082
}
15183

@@ -297,37 +229,4 @@ void All911Vertices::advanceVertices(AllEdges &edges, const EdgeIndexMap &edgeIn
297229
}
298230
}
299231
}
300-
301-
/// Update internal state of the indexed Neuron (called by every simulation step).
302-
///
303-
/// @param index Index of the Neuron to update.
304-
void All911Vertices::advanceVertex(const int index)
305-
{
306-
// BGFLOAT &Vm = this->Vm_[index];
307-
// BGFLOAT &Vthresh = this->Vthresh_[index];
308-
// BGFLOAT &summationPoint = this->summationPoints_[index];
309-
// BGFLOAT &I0 = this->I0_[index];
310-
// BGFLOAT &Inoise = this->Inoise_[index];
311-
// BGFLOAT &C1 = this->C1_[index];
312-
// BGFLOAT &C2 = this->C2_[index];
313-
// int &nStepsInRefr = this->numStepsInRefractoryPeriod_[index];
314-
315-
// if (nStepsInRefr > 0) {
316-
// // is neuron refractory?
317-
// --nStepsInRefr;
318-
// } else if (Vm >= Vthresh) {
319-
// // should it fire?
320-
// fire(index);
321-
// } else {
322-
// summationPoint += I0; // add IO
323-
// // add noise
324-
// BGFLOAT noise = (*rgNormrnd)();
325-
// //LOG4CPLUS_DEBUG(vertexLogger_, "ADVANCE NEURON[" << index << "] :: Noise = " << noise);
326-
// summationPoint += noise * Inoise; // add noise
327-
// Vm = C1 * Vm + C2 * summationPoint; // decay Vm and add inputs
328-
// }
329-
// // clear synaptic input for next time step
330-
// summationPoint = 0;
331-
}
332-
333232
#endif

0 commit comments

Comments
 (0)