diff --git a/Simulator/Connections/Neuro/ConnStatic.cpp b/Simulator/Connections/Neuro/ConnStatic.cpp index 3f2f712fa..77e41b32d 100644 --- a/Simulator/Connections/Neuro/ConnStatic.cpp +++ b/Simulator/Connections/Neuro/ConnStatic.cpp @@ -93,7 +93,6 @@ void ConnStatic::printParameters() const void ConnStatic::registerHistoryVariables() { // Register the following variables to be recorded - // Note: There may be potential duplicate weight, source, destination vertices Recorder &recorder = Simulator::getInstance().getModel().getRecorder(); recorder.registerVariable("weight", WCurrentEpoch_, Recorder::UpdatedType::DYNAMIC); recorder.registerVariable("sourceVertex", sourceVertexIndexCurrentEpoch_, @@ -101,3 +100,24 @@ void ConnStatic::registerHistoryVariables() recorder.registerVariable("destinationVertex", destVertexIndexCurrentEpoch_, Recorder::UpdatedType::DYNAMIC); } + +bool ConnStatic::updateConnections() +{ + AllEdges &edges = getEdges(); + const vector &inUse = edges.getInUse(); + const vector &weights = edges.getWeights(); + const vector &sourceVertices = edges.getSourceVertexIndices(); + const vector &destVertices = edges.getDestVertexIndices(); + + // Copy one value per active edge into parallel recorder vectors. + // weight/source/destination entries at the same index describe the same edge. + for (BGSIZE iEdg = 0; iEdg < inUse.size(); iEdg++) { + if (inUse[iEdg]) { + WCurrentEpoch_.push_back(weights[iEdg]); + sourceVertexIndexCurrentEpoch_.push_back(sourceVertices[iEdg]); + destVertexIndexCurrentEpoch_.push_back(destVertices[iEdg]); + } + } + + return false; +} diff --git a/Simulator/Connections/Neuro/ConnStatic.h b/Simulator/Connections/Neuro/ConnStatic.h index 67d0a8fb6..fbb7bbc44 100644 --- a/Simulator/Connections/Neuro/ConnStatic.h +++ b/Simulator/Connections/Neuro/ConnStatic.h @@ -64,6 +64,9 @@ class ConnStatic : public Connections { /// Registers history variables for recording during simulation virtual void registerHistoryVariables() override; + /// Populates edge history variables for recording during the current epoch. + virtual bool updateConnections() override; + /// Get array of vertex weights const vector &getWCurrentEpoch() const { diff --git a/Simulator/Edges/AllEdges.h b/Simulator/Edges/AllEdges.h index ccc49308a..b726cdfec 100644 --- a/Simulator/Edges/AllEdges.h +++ b/Simulator/Edges/AllEdges.h @@ -59,6 +59,30 @@ class AllEdges { /// Populate a edge index map. virtual void createEdgeIndexMap(EdgeIndexMap &edgeIndexMap); + /// Get array of source vertex indices. + const vector &getSourceVertexIndices() const + { + return sourceVertexIndex_; + } + + /// Get array of destination vertex indices. + const vector &getDestVertexIndices() const + { + return destVertexIndex_; + } + + /// Get array of edge weights. + const vector &getWeights() const + { + return W_; + } + + /// Get array of active edge flags. + const vector &getInUse() const + { + return inUse_; + } + /// Cereal serialization method template void serialize(Archive &archive); @@ -253,4 +277,4 @@ template void AllEdges::serialize(Archive &archive) cereal::make_nvp("totalEdgeCount", totalEdgeCount_), cereal::make_nvp("maxEdgesPerVertex", maxEdgesPerVertex_), cereal::make_nvp("countVertices", countVertices_)); -} \ No newline at end of file +}