Skip to content

Commit 962f275

Browse files
authored
Merge pull request #607 from UWB-Biocomputing/release-0.9.2
Release 0.9.2
2 parents 7cd7de6 + 5b0d8de commit 962f275

File tree

159 files changed

+87426
-209469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+87426
-209469
lines changed

.github/workflows/tests.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
run: cmake ..
2626
- id: build
2727
name: build
28-
run: make
28+
run: make -j
2929
- name: run unit tests
3030
run: ./tests
3131

@@ -70,6 +70,14 @@ jobs:
7070
if: always() && steps.tscl.conclusion == 'success'
7171
run: diff ../Testing/RegressionTesting/TestOutput/test-small-connected-long-out.xml ../Testing/RegressionTesting/GoodOutput/test-small-connected-long-out.xml
7272

73+
- id: ts911
74+
name: run test-small-911
75+
if: always() && steps.build.conclusion == 'success'
76+
run: ./cgraphitti -c ../Testing/RegressionTesting/configfiles/test-small-911.xml
77+
- name: verify test-small-911
78+
if: always() && steps.tt.conclusion == 'success'
79+
run: diff ../Testing/RegressionTesting/TestOutput/test-small-911-out.xml ../Testing/RegressionTesting/GoodOutput/test-small-911-out.xml
80+
7381
- id: tm
7482
name: run test-medium
7583
if: always() && steps.build.conclusion == 'success'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
*.lib
2828

2929
# Generated Files
30+
__pycache__/
3031
build/.cmake
3132
build/bin
3233
build/Simulator
@@ -88,3 +89,5 @@ build/Output/Results/*.xml
8889
build/Output/Results/*.h5
8990
Testing/RegressionTesting/TestOutput/*.xml
9091
Testing/RegressionTesting/TestOutput/*.h5
92+
Testing/UnitTesting/TestOutput/*.xml
93+
Testing/UnitTesting/TestOutput/*.h5

CMakeLists.txt

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -343,20 +343,22 @@ endif()
343343
# included in the executable.
344344
add_executable(tests
345345
Testing/RunTests.cpp
346-
Testing/Core/OperationManagerTests.cpp
347-
Testing/Core/EdgeIndexMapTests.cpp
348-
Testing/Core/FunctionNodeTests.cpp
349-
Testing/Core/SimulatorTests.cpp
350-
Testing/Core/OperationManagerTestingClass.h
351-
Testing/Core/VerticesFactoryTests.cpp
352-
Testing/Core/ConnectionsFactoryTests.cpp
353-
Testing/Core/EdgesFactoryTests.cpp
354-
Testing/Core/LayoutFactoryTests.cpp
355-
Testing/Core/RecorderFactoryTests.cpp
356-
Testing/Core/InputManagerTests.cpp
357-
Testing/Core/RNGFactoryTests.cpp
346+
Testing/UnitTesting/OperationManagerTests.cpp
347+
Testing/UnitTesting/EdgeIndexMapTests.cpp
348+
Testing/UnitTesting/FunctionNodeTests.cpp
349+
Testing/UnitTesting/SimulatorTests.cpp
350+
Testing/UnitTesting/OperationManagerTestingClass.h
351+
Testing/UnitTesting/VerticesFactoryTests.cpp
352+
Testing/UnitTesting/ConnectionsFactoryTests.cpp
353+
Testing/UnitTesting/EdgesFactoryTests.cpp
354+
Testing/UnitTesting/LayoutFactoryTests.cpp
355+
Testing/UnitTesting/RecorderFactoryTests.cpp
356+
Testing/UnitTesting/InputManagerTests.cpp
357+
Testing/UnitTesting/RNGFactoryTests.cpp
358358
Testing/Utils/ParameterManagerTests.cpp
359-
Testing/Utils/CircularBufferTests.cpp)
359+
Testing/Utils/CircularBufferTests.cpp
360+
# Testing/UnitTesting/XmlRecorderTests.cpp)
361+
)
360362

361363
# Links the Googletest framework with the testing executable
362364
target_link_libraries(tests gtest gtest_main)
@@ -366,7 +368,7 @@ target_link_libraries(tests combinedLib)
366368

367369
add_executable(serialTest
368370
Testing/RunTests.cpp
369-
Testing/Core/SerializationTests.cpp)
371+
Testing/UnitTesting/SerializationTests.cpp)
370372

371373
# Links the Googletest framework with the serialTest executable
372374
target_link_libraries(serialTest gtest gtest_main)
@@ -376,14 +378,24 @@ target_link_libraries(serialTest combinedLib)
376378

377379
add_executable(deserialTest
378380
Testing/RunTests.cpp
379-
Testing/Core/DeserializationTests.cpp)
381+
Testing/UnitTesting/DeserializationTests.cpp)
380382

381383
# Links the Googletest framework with the deserialTest executable
382384
target_link_libraries(deserialTest gtest gtest_main)
383385

384386
# Link the combined library into the 'deserialTest' executable.
385387
target_link_libraries(deserialTest combinedLib)
386388

389+
add_executable(serialFileAccessTest
390+
Testing/RunTests.cpp
391+
Testing/UnitTesting/SerializationFileAccessTest.cpp)
392+
393+
# Links the Googletest framework with the serialFileAccessTest executable
394+
target_link_libraries(serialFileAccessTest gtest gtest_main)
395+
396+
# Link the combined library into the 'serialFileAccessTest' executable.
397+
target_link_libraries(serialFileAccessTest combinedLib)
398+
387399
# Clear ENABLE_CUDA, PERFORMANCE_METRICS and GPROF from the cache so it's reset for subsequent builds
388400
unset(ENABLE_CUDA CACHE)
389401
unset(PERFORMANCE_METRICS CACHE)

Simulator/Connections/Connections.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ bool Connections::updateConnections(AllVertices &vertices)
8989
}
9090

9191
#if defined(USE_GPU)
92-
void Connections::updateSynapsesWeights(const int numVertices, AllVertices &vertices,
93-
AllEdges &synapses,
92+
void Connections::updateSynapsesWeights(int numVertices, AllVertices &vertices, AllEdges &synapses,
9493
AllSpikingNeuronsDeviceProperties *allVerticesDevice,
9594
AllSpikingSynapsesDeviceProperties *allEdgesDevice,
9695
Layout &layout)
@@ -121,13 +120,12 @@ void Connections::createSynapsesFromWeights()
121120
// if the synapse weight is not zero (which means there is a connection), create the synapse
122121
if (edges_->W_[iEdg] != 0.0) {
123122
BGFLOAT theW = edges_->W_[iEdg];
124-
BGFLOAT *sumPoint = &(vertices.summationMap_[i]);
125123
int srcVertex = edges_->sourceVertexIndex_[iEdg];
126124
int destVertex = edges_->destVertexIndex_[iEdg];
127125
edgeType type = layout.edgType(srcVertex, destVertex);
128126
edges_->edgeCounts_[i]++;
129-
edges_->createEdge(iEdg, srcVertex, destVertex, sumPoint,
130-
Simulator::getInstance().getDeltaT(), type);
127+
edges_->createEdge(iEdg, srcVertex, destVertex, Simulator::getInstance().getDeltaT(),
128+
type);
131129
edges_->W_[iEdg] = theW;
132130
}
133131
}

Simulator/Connections/Connections.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ class Connections {
8585
/// @param allVerticesDevice GPU address of the allVertices struct on device memory.
8686
/// @param allEdgesDevice GPU address of the allEdges struct on device memory.
8787
/// @param layout Layout information of the neural network.
88-
virtual void updateSynapsesWeights(const int numVertices, AllVertices &vertices,
89-
AllEdges &synapses,
88+
virtual void updateSynapsesWeights(int numVertices, AllVertices &vertices, AllEdges &synapses,
9089
AllSpikingNeuronsDeviceProperties *allVerticesDevice,
9190
AllSpikingSynapsesDeviceProperties *allEdgesDevice,
9291
Layout &layout);

Simulator/Connections/NG911/Connections911.cpp

Lines changed: 71 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
*
44
* @ingroup Simulator/Connections/NG911
55
*
6-
* @brief The model of the static network
7-
*
6+
* @brief This class manages the Connections of the NG911 network
87
*/
98

109
#include "Connections911.h"
11-
#include "All911Vertices.h"
10+
#include "All911Edges.h"
1211
#include "GraphManager.h"
1312
#include "Layout911.h"
1413
#include "ParameterManager.h"
@@ -31,13 +30,11 @@ void Connections911::setup()
3130
size_t srcV = gm.source(*it);
3231
size_t destV = gm.target(*it);
3332
edgeType type = layout.edgType(srcV, destV);
34-
BGFLOAT *sumPoint = &vertices.summationMap_[destV];
3533

3634
BGFLOAT dist = layout.dist_(srcV, destV);
3735
LOG4CPLUS_DEBUG(edgeLogger_, "Source: " << srcV << " Dest: " << destV << " Dist: " << dist);
3836

39-
BGSIZE iEdg;
40-
edges_->addEdge(iEdg, type, srcV, destV, sumPoint, Simulator::getInstance().getDeltaT());
37+
BGSIZE iEdg = edges_->addEdge(type, srcV, destV, Simulator::getInstance().getDeltaT());
4138
added++;
4239
}
4340

@@ -46,7 +43,6 @@ void Connections911::setup()
4643

4744
void Connections911::loadParameters()
4845
{
49-
ParameterManager::getInstance().getIntByXpath("//connsPerVertex/text()", connsPerVertex_);
5046
ParameterManager::getInstance().getIntByXpath("//psapsToErase/text()", psapsToErase_);
5147
ParameterManager::getInstance().getIntByXpath("//respsToErase/text()", respsToErase_);
5248
}
@@ -55,20 +51,18 @@ void Connections911::loadParameters()
5551
/// Registered to OperationManager as Operation::printParameters
5652
void Connections911::printParameters() const
5753
{
58-
LOG4CPLUS_DEBUG(fileLogger_, "CONNECTIONS PARAMETERS"
59-
<< endl
60-
<< "\tConnections Type: Connections911" << endl
61-
<< "\tConnections per vertex: " << connsPerVertex_ << endl
62-
<< "\tPSAPs to erase: " << psapsToErase_ << endl
63-
<< "\tRESPs to erase: " << respsToErase_ << endl
64-
<< endl);
54+
LOG4CPLUS_DEBUG(fileLogger_,
55+
"CONNECTIONS PARAMETERS"
56+
<< endl
57+
<< "\tConnections Type: Connections911" << endl
58+
<< "\tMaximum Connections per vertex: " << edges_->maxEdgesPerVertex_ << endl
59+
<< "\tPSAPs to erase: " << psapsToErase_ << endl
60+
<< "\tRESPs to erase: " << respsToErase_ << endl
61+
<< endl);
6562
}
6663

6764
#if !defined(USE_GPU)
6865
/// Update the connections status in every epoch.
69-
///
70-
/// @param vertices The Vertex list to search from.
71-
/// @return true if successful, false otherwise.
7266
bool Connections911::updateConnections(AllVertices &vertices)
7367
{
7468
// Only run on the first epoch
@@ -94,11 +88,54 @@ bool Connections911::updateConnections(AllVertices &vertices)
9488
return true;
9589
}
9690

91+
92+
/// Finds the outgoing edge from the given vertex to the Responder closest to
93+
/// the emergency call location
94+
BGSIZE Connections911::getEdgeToClosestResponder(const Call &call, BGSIZE vertexIdx)
95+
{
96+
All911Edges &edges911 = dynamic_cast<All911Edges &>(*edges_);
97+
98+
vertexType requiredType;
99+
if (call.type == "Law")
100+
requiredType = LAW;
101+
else if (call.type == "EMS")
102+
requiredType = EMS;
103+
else if (call.type == "Fire")
104+
requiredType = FIRE;
105+
106+
// loop over the outgoing edges looking for the responder with the shortest
107+
// Euclidean distance to the call's location.
108+
BGSIZE startOutEdg = synapseIndexMap_->outgoingEdgeBegin_[vertexIdx];
109+
BGSIZE outEdgCount = synapseIndexMap_->outgoingEdgeCount_[vertexIdx];
110+
Layout911 &layout911
111+
= dynamic_cast<Layout911 &>(Simulator::getInstance().getModel().getLayout());
112+
113+
BGSIZE resp, respEdge;
114+
double minDistance = numeric_limits<double>::max();
115+
for (BGSIZE eIdxMap = startOutEdg; eIdxMap < startOutEdg + outEdgCount; ++eIdxMap) {
116+
BGSIZE outEdg = synapseIndexMap_->outgoingEdgeIndexMap_[eIdxMap];
117+
assert(edges911.inUse_[outEdg]); // Edge must be in use
118+
119+
BGSIZE dstVertex = edges911.destVertexIndex_[outEdg];
120+
if (layout911.vertexTypeMap_[dstVertex] == requiredType) {
121+
double distance = layout911.getDistance(dstVertex, call.x, call.y);
122+
123+
if (distance < minDistance) {
124+
minDistance = distance;
125+
resp = dstVertex;
126+
respEdge = outEdg;
127+
}
128+
}
129+
}
130+
131+
// We must have found the closest responder of the right type
132+
assert(minDistance < numeric_limits<double>::max());
133+
assert(layout911.vertexTypeMap_[resp] == requiredType);
134+
return respEdge;
135+
}
136+
137+
97138
/// Randomly delete 1 PSAP and rewire all the edges around it.
98-
///
99-
/// @param vertices The Vertex list to search from.
100-
/// @param layout Layout information of the vertex network.
101-
/// @return true if successful, false otherwise.
102139
bool Connections911::erasePSAP(AllVertices &vertices, Layout &layout)
103140
{
104141
int numVertices = Simulator::getInstance().getTotalVertices();
@@ -157,7 +194,8 @@ bool Connections911::erasePSAP(AllVertices &vertices, Layout &layout)
157194
}
158195

159196
// Identify all psap-less responders
160-
if (layout.vertexTypeMap_[destVertex] == RESP) {
197+
if (layout.vertexTypeMap_[destVertex] == LAW || layout.vertexTypeMap_[destVertex] == FIRE
198+
|| layout.vertexTypeMap_[destVertex] == EMS) {
161199
respsToReroute.push_back(destVertex);
162200
}
163201
}
@@ -191,10 +229,8 @@ bool Connections911::erasePSAP(AllVertices &vertices, Layout &layout)
191229
}
192230

193231
// Insert Caller to PSAP edge
194-
BGFLOAT *sumPoint = &vertices.summationMap_[closestPSAP];
195-
BGSIZE iEdg;
196-
edges_->addEdge(iEdg, CP, srcVertex, closestPSAP, sumPoint,
197-
Simulator::getInstance().getDeltaT());
232+
BGSIZE iEdg
233+
= edges_->addEdge(CP, srcVertex, closestPSAP, Simulator::getInstance().getDeltaT());
198234

199235
// Record added edge
200236
ChangedEdge addedEdge;
@@ -221,10 +257,8 @@ bool Connections911::erasePSAP(AllVertices &vertices, Layout &layout)
221257
}
222258

223259
// Insert PSAP to Responder edge
224-
BGFLOAT *sumPoint = &vertices.summationMap_[destVertex];
225-
BGSIZE iEdg;
226-
edges_->addEdge(iEdg, PR, closestPSAP, destVertex, sumPoint,
227-
Simulator::getInstance().getDeltaT());
260+
BGSIZE iEdg
261+
= edges_->addEdge(PR, closestPSAP, destVertex, Simulator::getInstance().getDeltaT());
228262

229263
// Record added edge
230264
ChangedEdge addedEdge;
@@ -238,10 +272,6 @@ bool Connections911::erasePSAP(AllVertices &vertices, Layout &layout)
238272
}
239273

240274
/// Randomly delete 1 RESP.
241-
///
242-
/// @param vertices The Vertex list to search from.
243-
/// @param layout Layout information of the vertex network.
244-
/// @return true if successful, false otherwise.
245275
bool Connections911::eraseRESP(AllVertices &vertices, Layout &layout)
246276
{
247277
int numVertices = Simulator::getInstance().getTotalVertices();
@@ -251,7 +281,8 @@ bool Connections911::eraseRESP(AllVertices &vertices, Layout &layout)
251281

252282
// Find all resps
253283
for (int i = 0; i < numVertices; i++) {
254-
if (layout.vertexTypeMap_[i] == RESP) {
284+
if (layout.vertexTypeMap_[i] == LAW || layout.vertexTypeMap_[i] == FIRE
285+
|| layout.vertexTypeMap_[i] == EMS) {
255286
resps.push_back(i);
256287
}
257288
}
@@ -300,7 +331,8 @@ bool Connections911::eraseRESP(AllVertices &vertices, Layout &layout)
300331
return changesMade;
301332
}
302333

303-
/// @return xml representation of a single edge
334+
335+
/// Returns an xml representation of a single edge
304336
string Connections911::ChangedEdge::toString()
305337
{
306338
stringstream os;
@@ -322,6 +354,9 @@ string Connections911::ChangedEdge::toString()
322354
case RP:
323355
type_s = "RP";
324356
break;
357+
case RC:
358+
type_s = "RC";
359+
break;
325360
default:
326361
type_s = "ETYPE_UNDEF";
327362
}
@@ -334,8 +369,6 @@ string Connections911::ChangedEdge::toString()
334369
}
335370

336371
/// Returns the complete list of all deleted or added edges as a string.
337-
/// @param added true returns the list of added edges, false = erased
338-
/// @return xml representation of all deleted or added edges
339372
string Connections911::changedEdgesToXML(bool added)
340373
{
341374
stringstream os;
@@ -360,7 +393,6 @@ string Connections911::changedEdgesToXML(bool added)
360393
}
361394

362395
/// Returns the complete list of deleted vertices as a string.
363-
/// @return xml representation of all deleted vertices
364396
string Connections911::erasedVerticesToXML()
365397
{
366398
stringstream os;

0 commit comments

Comments
 (0)