CARLsim  4.1.0
CARLsim: a GPU-accelerated SNN simulator
connection_monitor_core.cpp
Go to the documentation of this file.
1 /* * Copyright (c) 2016 Regents of the University of California. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions
5 * are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * 3. The names of its contributors may not be used to endorse or promote
15 * products derived from this software without specific prior written
16 * permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * *********************************************************************************************** *
31 * CARLsim
32 * created by: (MDR) Micah Richert, (JN) Jayram M. Nageswaran
33 * maintained by:
34 * (MA) Mike Avery <averym@uci.edu>
35 * (MB) Michael Beyeler <mbeyeler@uci.edu>,
36 * (KDC) Kristofor Carlson <kdcarlso@uci.edu>
37 * (TSC) Ting-Shuo Chou <tingshuc@uci.edu>
38 * (HK) Hirak J Kashyap <kashyaph@uci.edu>
39 *
40 * CARLsim v1.0: JM, MDR
41 * CARLsim v2.0/v2.1/v2.2: JM, MDR, MA, MB, KDC
42 * CARLsim3: MB, KDC, TSC
43 * CARLsim4: TSC, HK
44 *
45 * CARLsim available from http://socsci.uci.edu/~jkrichma/CARLsim/
46 * Ver 12/31/2016
47 */
49 
50 #include <snn.h> // CARLsim private implementation
51 #include <snn_definitions.h> // KERNEL_ERROR, KERNEL_INFO, ...
52 
53 #include <sstream> // std::stringstream
54 #include <algorithm> // std::sort
55 #include <iomanip> // std::setfill, std::setw
56 #include <float.h> // FLT_EPSILON
57 
58 
59 
60 // we aren't using namespace std so pay attention!
61 ConnectionMonitorCore::ConnectionMonitorCore(SNN* snn,int monitorId,short int connId,int grpIdPre,int grpIdPost) {
62  snn_ = snn;
63  connId_= connId;
64  grpIdPre_ = grpIdPre;
65  grpIdPost_ = grpIdPost;
66  monitorId_ = monitorId;
67 
68  wtTime_ = -1;
69  wtTimeLast_ = -1;
70  wtTimeWrite_ = -1;
71 
72  connFileId_ = NULL;
73  needToWriteFileHeader_ = true;
74  needToInit_ = true;
75  connFileSignature_ = 202029319;
76  connFileVersion_ = 0.3f;
77 
78  minWt_ = -1.0f;
79  maxWt_ = -1.0f;
80 
81  connFileTimeIntervalSec_ = 1;
82 }
83 
85  if (!needToInit_)
86  return;
87 
88  nNeurPre_ = snn_->getGroupNumNeurons(grpIdPre_);
89  nNeurPost_ = snn_->getGroupNumNeurons(grpIdPost_);
90  isPlastic_ = snn_->isConnectionPlastic(connId_);
91  nSynapses_ = snn_->getNumSynapticConnections(connId_);
92 
93  ConnectConfig connInfo = snn_->getConnectConfig(connId_);
94  minWt_ = 0.0f; // for now, no non-zero min weights allowed
95  maxWt_ = fabs(connInfo.maxWt);
96 
97  assert(nNeurPre_>0);
98  assert(nNeurPost_>0);
99 
100  // use KERNEL_{ERROR|WARNING|etc} typesetting (const FILE*)
101  fpInf_ = snn_->getLogFpInf();
102  fpErr_ = snn_->getLogFpErr();
103  fpDeb_ = snn_->getLogFpDeb();
104  fpLog_ = snn_->getLogFpLog();
105 
106  // init weight matrix with right dimensions
107  for (int i = 0; i < nNeurPre_; i++) {
108  std::vector<float> wt;
109  for (int j = 0; j < nNeurPost_; j++) {
110  wt.push_back(NAN);
111  }
112  wtMat_.push_back(wt);
113  wtMatLast_.push_back(wt);
114  }
115 
116  // then load current weigths from SNN into weight matrix
117  updateStoredWeights();
118 }
119 
121  if (connFileId_!=NULL) {
122  // flush: store last snapshot to file if update interval set
123  if (connFileTimeIntervalSec_ > 0) {
124  // make sure SNN is not already deallocated!
125  assert(snn_!=NULL);
126  writeConnectFileSnapshot(snn_->getSimTime(), snn_->getWeightMatrix2D(connId_));
127  }
128 
129  // then close file and clean up
130  fclose(connFileId_);
131  connFileId_ = NULL;
132  needToInit_ = true;
133  needToWriteFileHeader_ = true;
134  }
135 }
136 
137 // +++++ PUBLIC METHODS: +++++++++++++++++++++++++++++++++++++++++++++++//
138 
139 // calculate weight changes since last update (element-wise )
140 std::vector< std::vector<float> > ConnectionMonitorCore::calcWeightChanges() {
141  updateStoredWeights();
142  std::vector< std::vector<float> > wtChange(nNeurPre_, std::vector<float>(nNeurPost_));
143 
144  // take the naive approach for now
145  for (int i=0; i<nNeurPre_; i++) {
146  for (int j=0; j<nNeurPost_; j++) {
147  wtChange[i][j] = wtMat_[i][j] - wtMatLast_[i][j];
148  }
149  }
150 
151  return wtChange;
152 }
153 
154 
155 // reset weight matrix
157  for (int i=0; i<nNeurPre_; i++) {
158  for (int j=0; j<nNeurPost_; j++) {
159  wtMat_[i][j] = NAN;
160  wtMatLast_[i][j] = NAN;
161  }
162  }
163 }
164 
165 // find number of incoming synapses for a specific post neuron
166 int ConnectionMonitorCore::getFanIn(int neurPostId) {
167  assert(neurPostId<nNeurPost_);
168  int nSyn = 0;
169  for (int i=0; i<nNeurPre_; i++) {
170  if (!isnan(wtMat_[i][neurPostId])) {
171  nSyn++;
172  }
173  }
174  return nSyn;
175 }
176 
177 // find number of outgoing synapses of a specific pre neuron
179  assert(neurPreId<nNeurPre_);
180  int nSyn = 0;
181  for (int j=0; j<nNeurPost_; j++) {
182  if (!isnan(wtMat_[neurPreId][j])) {
183  nSyn++;
184  }
185  }
186  return nSyn;
187 }
188 
189 float ConnectionMonitorCore::getMaxWeight(bool getCurrent) {
190  float maxVal = minWt_;
191  if (getCurrent) {
192  updateStoredWeights();
193 
194  // find currently largest weight value
195  for (int i=0; i<nNeurPre_; i++) {
196  for (int j=0; j<nNeurPost_; j++) {
197  // skip entries in matrix where no synapse exists
198  if (isnan(wtMat_[i][j]))
199  continue;
200 
201  if (wtMat_[i][j] > maxVal) {
202  maxVal = wtMat_[i][j];
203  }
204  }
205  }
206  } else {
207  // return RangeWeight.max
208  maxVal = maxWt_;
209  }
210 
211  return maxVal;
212 }
213 
214 float ConnectionMonitorCore::getMinWeight(bool getCurrent) {
215  float minVal = maxWt_;
216  if (getCurrent) {
217  updateStoredWeights();
218 
219  // find currently largest weight value
220  for (int i=0; i<nNeurPre_; i++) {
221  for (int j=0; j<nNeurPost_; j++) {
222  // skip entries in matrix where no synapse exists
223  if (isnan(wtMat_[i][j]))
224  continue;
225 
226  if (wtMat_[i][j] < minVal) {
227  minVal = wtMat_[i][j];
228  }
229  }
230  }
231  } else {
232  // return RangeWeight.min
233  minVal = minWt_;
234  }
235 
236  return minVal;
237 }
238 
239 // find number of synapses whose weights changed
241  assert(minAbsChange>=0.0);
242  std::vector< std::vector<float> > wtChange = calcWeightChanges();
243 
244  int nChanged = 0;
245  for (int i=0; i<nNeurPre_; i++) {
246  for (int j=0; j<nNeurPost_; j++) {
247  // skip entries in matrix where no synapse exists
248  if (isnan(wtMat_[i][j]))
249  continue;
250 
251  if (fabs(wtChange[i][j]) >= minAbsChange) {
252  nChanged++;
253  }
254  }
255  }
256  return nChanged;
257 }
258 
259 // finds the number of weights with values in some range
260 int ConnectionMonitorCore::getNumWeightsInRange(double minVal, double maxVal) {
261  assert(maxVal>=minVal);
262 
263  updateStoredWeights();
264 
265  // make sure values are inside a reasonable range
266  if (minVal<=getMinWeight(false) && minVal>=getMaxWeight(false)) {
267  return getNumSynapses();
268  }
269 
270  int cnt = 0;
271  for (int i=0; i<nNeurPre_; i++) {
272  for (int j=0; j<nNeurPost_; j++) {
273  // skip entries in matrix where no synapse exists
274  if (isnan(wtMat_[i][j]))
275  continue;
276 
277  if (wtMat_[i][j]>=minVal && wtMat_[i][j]<=maxVal) {
278  cnt++;
279  }
280  }
281  }
282 
283  return cnt;
284 }
285 
286 // finds the number of weights with some exact weight value
288  // make sure value is inside a reasonable range
289  if (value<getMinWeight(false) || value>getMaxWeight(false)) {
290  return 0;
291  }
292 
293  return getNumWeightsInRange(value-FLT_EPSILON, value+FLT_EPSILON);
294 }
295 
296 // calculate total absolute amount of weight change
298  std::vector< std::vector<float> > wtChange = calcWeightChanges();
299  double wtTotalChange = 0.0;
300  for (int i=0; i<nNeurPre_; i++) {
301  for (int j=0; j<nNeurPost_; j++) {
302  // skip entries in matrix where no synapse exists
303  if (isnan(wtMat_[i][j]))
304  continue;
305  wtTotalChange += fabs(wtChange[i][j]);
306  }
307  }
308  return wtTotalChange;
309 }
310 
312  updateStoredWeights();
313 
314  KERNEL_INFO("(t=%.3fs) ConnectionMonitor ID=%d: %d(%s) => %d(%s)",
315  (getTimeMsCurrentSnapshot()/1000.0f), connId_,
316  grpIdPre_, snn_->getGroupName(grpIdPre_).c_str(),
317  grpIdPost_, snn_->getGroupName(grpIdPost_).c_str());
318 
319  // generate header
320  std::stringstream header, header2;
321  header << " pre\\post |";
322  header2 << "----------|";
323  for (int j=0; j<nNeurPost_; j++) {
324  header << std::setw(9) << std::setfill(' ') << j << " |";
325  header2 << "-----------";
326  }
327  KERNEL_INFO("%s",header.str().c_str());
328  KERNEL_INFO("%s",header2.str().c_str());
329 
330  for (int i=0; i<nNeurPre_; i++) {
331  std::stringstream line;
332  line << std::setw(9) << std::setfill(' ') << i << " |";
333  for (int j=0; j<nNeurPost_; j++) {
334  line << std::fixed << std::setprecision(4) << (isnan(wtMat_[i][j])?" ":(wtMat_[i][j]>=0?" ":" "))
335  << wtMat_[i][j] << " ";
336  }
337  KERNEL_INFO("%s",line.str().c_str());
338  }
339 }
340 
341 void ConnectionMonitorCore::printSparse(int neurPostId, int maxConn, int connPerLine, bool storeNewSnapshot) {
342  assert(neurPostId<nNeurPost_);
343  assert(maxConn>0);
344  assert(connPerLine>0);
345 
346  // give the option of not storing the new snapshot
347  std::vector< std::vector<float> > wtNew, wtOld;
348  long int timeNew, timeOld;
349  if (!storeNewSnapshot) {
350  // make a copy of current snapshots so that we can restore them later
351  wtNew = wtMat_;
352  wtOld = wtMatLast_;
353  timeNew = wtTime_;
354  timeOld = wtTimeLast_;
355  }
356 
357  updateStoredWeights();
358  KERNEL_INFO("(t=%.3fs) ConnectionMonitor ID=%d %d(%s) => %d(%s): [preId,postId] wt (+/-wtChange in %ldms) "
359  "show first %d", getTimeMsCurrentSnapshot()/1000.0f, connId_,
360  grpIdPre_, snn_->getGroupName(grpIdPre_).c_str(), grpIdPost_, snn_->getGroupName(grpIdPost_).c_str(),
361  getTimeMsSinceLastSnapshot(), maxConn);
362 
363  int postA, postZ;
364  if (neurPostId==ALL) {
365  postA = 0;
366  postZ = nNeurPost_ - 1;
367  } else {
368  postA = neurPostId;
369  postZ = neurPostId;
370  }
371 
372  std::vector< std::vector<float> > wtChange;
373  if (isPlastic_) {
374  wtChange = calcWeightChanges();
375  }
376 
377  std::stringstream line;
378  int nConn = 0;
379  int maxIntDigits = ceil(log10((double)std::max(nNeurPre_,nNeurPost_)));
380  for (int i=0; i<nNeurPre_; i++) {
381  for (int j = postA; j <= postZ; j++) {
382  // display only so many connections
383  if (nConn>=maxConn)
384  break;
385 
386  if (!isnan(wtMat_[i][j])) {
387  line << "[" << std::setw(maxIntDigits) << i << "," << std::setw(maxIntDigits) << j << "] "
388  << std::fixed << std::setprecision(4) << wtMat_[i][j];
389  if (isPlastic_) {
390  line << " (" << ((wtChange[i][j]<0)?"":"+");
391  line << std::setprecision(4) << wtChange[i][j] << ")";
392  }
393  line << " ";
394  if (!(++nConn % connPerLine)) {
395  KERNEL_INFO("%s",line.str().c_str());
396  line.str(std::string());
397  }
398  }
399  }
400  }
401  // flush
402  if (nConn % connPerLine)
403  KERNEL_INFO("%s",line.str().c_str());
404 
405  if (!storeNewSnapshot) {
406  wtMat_ = wtNew;
407  wtMatLast_ = wtOld;
408  wtTime_ = timeNew;
409  wtTimeLast_ = timeOld;
410  }
411 
412 }
413 
415  // \TODO consider the case where this function is called more than once
416  if (connFileId_!=NULL)
417  KERNEL_ERROR("ConnectionMonitorCore: setConnectFileId has already been called.");
418 
419  connFileId_=connFileId;
420 
421  if (connFileId_==NULL) {
422  needToWriteFileHeader_ = false;
423  }
424  else {
425  // for now: file pointer has changed, so we need to write header (again)
426  needToWriteFileHeader_ = true;
427  writeConnectFileHeader();
428  }
429 }
430 
432  assert(intervalSec==-1 || intervalSec>=1);
433  connFileTimeIntervalSec_ = intervalSec;
434 }
435 
436 // updates the internally stored last two snapshots (current one and last one)
437 void ConnectionMonitorCore::updateStoredWeights() {
438  if (snn_->getSimTime() > wtTime_) {
439  // time has advanced: get new weights
440  wtMatLast_ = wtMat_;
441  wtTimeLast_ = wtTime_;
442 
443  wtMat_ = snn_->getWeightMatrix2D(connId_);
444  wtTime_ = snn_->getSimTime();
445  }
446 }
447 
448 // returns a current snapshot
449 std::vector< std::vector<float> > ConnectionMonitorCore::takeSnapshot() {
450  updateStoredWeights();
451  writeConnectFileSnapshot(wtTime_, wtMat_);
452  return wtMat_;
453 }
454 
455 // write the header section of the spike file
456 // this should be done once per file, and should be the very first entries in the file
457 void ConnectionMonitorCore::writeConnectFileHeader() {
458  init();
459 
460  if (!needToWriteFileHeader_)
461  return;
462 
463  // write file signature
464  if (!fwrite(&connFileSignature_,sizeof(int),1,connFileId_))
465  KERNEL_ERROR("ConnectionMonitorCore: writeConnectFileHeader has fwrite error");
466 
467  // write version number
468  if (!fwrite(&connFileVersion_,sizeof(float),1,connFileId_))
469  KERNEL_ERROR("ConnectionMonitorCore: writeConnectFileHeader has fwrite error");
470 
471  // write connection id
472  if (!fwrite(&connId_,sizeof(short int),1,connFileId_))
473  KERNEL_ERROR("ConnectionMonitor: writeConnectFileHeader has fwrite error");
474 
475  // write pre group info: group id and Grid3D dimensions
476  Grid3D gridPre = snn_->getGroupGrid3D(grpIdPre_);
477  if (!fwrite(&grpIdPre_,sizeof(int),1,connFileId_))
478  KERNEL_ERROR("ConnectionMonitor: writeConnectFileHeader has fwrite error");
479  if (!fwrite(&(gridPre.numX),sizeof(int),1,connFileId_))
480  KERNEL_ERROR("ConnectionMonitor: writeConnectFileHeader has fwrite error");
481  if (!fwrite(&(gridPre.numY),sizeof(int),1,connFileId_))
482  KERNEL_ERROR("ConnectionMonitor: writeConnectFileHeader has fwrite error");
483  if (!fwrite(&(gridPre.numZ),sizeof(int),1,connFileId_))
484  KERNEL_ERROR("ConnectionMonitor: writeConnectFileHeader has fwrite error");
485 
486  // write post group info: group id and # neurons
487  Grid3D gridPost = snn_->getGroupGrid3D(grpIdPost_);
488  if (!fwrite(&grpIdPost_,sizeof(int),1,connFileId_))
489  KERNEL_ERROR("ConnectionMonitor: writeConnectFileHeader has fwrite error");
490  if (!fwrite(&(gridPost.numX),sizeof(int),1,connFileId_))
491  KERNEL_ERROR("ConnectionMonitor: writeConnectFileHeader has fwrite error");
492  if (!fwrite(&(gridPost.numY),sizeof(int),1,connFileId_))
493  KERNEL_ERROR("ConnectionMonitor: writeConnectFileHeader has fwrite error");
494  if (!fwrite(&(gridPost.numZ),sizeof(int),1,connFileId_))
495  KERNEL_ERROR("ConnectionMonitor: writeConnectFileHeader has fwrite error");
496 
497  // write number of synapses
498  if (!fwrite(&nSynapses_,sizeof(int),1,connFileId_))
499  KERNEL_ERROR("ConnectionMonitor: writeConnectFileHeader has fwrite error");
500 
501  // write synapse type (fixed=false, plastic=true)
502  if (!fwrite(&isPlastic_,sizeof(bool),1,connFileId_))
503  KERNEL_ERROR("ConnectionMonitor: writeConnectFileHeader has fwrite error");
504 
505  // write minWt and maxWt
506  if (!fwrite(&minWt_,sizeof(float),1,connFileId_))
507  KERNEL_ERROR("ConnectionMonitorCore: writeConnectFileHeader has fwrite error");
508  if (!fwrite(&maxWt_,sizeof(float),1,connFileId_))
509  KERNEL_ERROR("ConnectionMonitorCore: writeConnectFileHeader has fwrite error");
510 
511 
512  // \TODO: write delays
513 
514  needToWriteFileHeader_ = false;
515 }
516 
517 void ConnectionMonitorCore::writeConnectFileSnapshot(int simTimeMs, std::vector< std::vector<float> > wts) {
518  // don't write if we have already written this timestamp to file (or file doesn't exist)
519  if ((long long)simTimeMs <= wtTimeWrite_ || connFileId_==NULL) {
520  return;
521  }
522 
523  wtTimeWrite_ = (long long)simTimeMs;
524 
525  // write time stamp
526  if (!fwrite(&wtTimeWrite_,sizeof(long long),1,connFileId_))
527  KERNEL_ERROR("ConnectionMonitor: writeConnectFileSnapshot has fwrite error");
528 
529  // write all weights
530  for (int i=0; i<nNeurPre_; i++) {
531  for (int j=0; j<nNeurPost_; j++) {
532  if (!fwrite(&wts[i][j],sizeof(float),1,connFileId_)) {
533  KERNEL_ERROR("ConnectionMonitor: writeConnectFileSnapshot has fwrite error");
534  }
535  }
536  }
537 }
ConnectionMonitorCore::setUpdateTimeIntervalSec
void setUpdateTimeIntervalSec(int intervalSec)
sets time update interval (seconds) for periodically storing weights to file
Definition: connection_monitor_core.cpp:431
SNN::getGroupNumNeurons
int getGroupNumNeurons(int gGrpId)
Definition: snn.h:558
connection_monitor_core.h
ConnectionMonitorCore::getNumWeightsInRange
int getNumWeightsInRange(double minVal, double maxVal)
returns number of weights with values in range e[minVal,maxVal] (inclusive)
Definition: connection_monitor_core.cpp:260
ConnectionMonitorCore::calcWeightChanges
std::vector< std::vector< float > > calcWeightChanges()
calculates weight changes since last snapshot and reports them in 2D weight change matrix
Definition: connection_monitor_core.cpp:140
ConnectionMonitorCore::getMinWeight
float getMinWeight(bool getCurrent=false)
returns min weight in the connection (getCurrent=false: RangeWeight.min, true: current smallest)
Definition: connection_monitor_core.cpp:214
SNN::isConnectionPlastic
bool isConnectionPlastic(short int connId)
returns whether synapses in connection are fixed (false) or plastic (true)
Definition: snn_manager.cpp:4883
ConnectionMonitorCore::getTimeMsCurrentSnapshot
long int getTimeMsCurrentSnapshot()
returns the timestamp of the current snapshot (not necessarily CARLsim::getSimTime)
Definition: connection_monitor_core.h:122
ConnectionMonitorCore::print
void print()
prints current weight state as 2D matrix (non-existent synapses: NAN, existent but zero weigth: 0....
Definition: connection_monitor_core.cpp:311
ConnectionMonitorCore::ConnectionMonitorCore
ConnectionMonitorCore(SNN *snn, int monitorId, short int connId, int grpIdPre, int grpIdPost)
constructor, created by CARLsim::setConnectionMonitor
Definition: connection_monitor_core.cpp:61
SNN::getConnectConfig
ConnectConfig getConnectConfig(short int connectId)
required for homeostasis
Definition: snn_manager.cpp:1716
Grid3D::numX
int numX
Definition: carlsim_datastructures.h:547
ConnectionMonitorCore::printSparse
void printSparse(int neurPostId=ALL, int maxConn=100, int connPerLine=4, bool storeNewSnapshot=true)
Definition: connection_monitor_core.cpp:341
ConnectionMonitorCore::getNumWeightsWithValue
int getNumWeightsWithValue(double value)
returns number of weights that have a certain value
Definition: connection_monitor_core.cpp:287
ConnectionMonitorCore::getMaxWeight
float getMaxWeight(bool getCurrent=false)
returns max weight in the connection (getCurrent=false: RangeWeight.max, true: current largest)
Definition: connection_monitor_core.cpp:189
ConnectionMonitorCore::clear
void clear()
deletes data from the 2D weight matrix
Definition: connection_monitor_core.cpp:156
ALL
#define ALL
CARLsim common definitions.
Definition: carlsim_definitions.h:55
snn_definitions.h
SNN::getWeightMatrix2D
std::vector< std::vector< float > > getWeightMatrix2D(short int connId)
Definition: snn_manager.cpp:6232
ConnectionMonitorCore::getNumWeightsChanged
int getNumWeightsChanged(double minAbsChanged=1e-5)
returns number of weights with >=minAbsChanged weight change since last snapshot
Definition: connection_monitor_core.cpp:240
KERNEL_ERROR
#define KERNEL_ERROR(formatc,...)
Definition: snn_definitions.h:109
ConnectionMonitorCore::~ConnectionMonitorCore
~ConnectionMonitorCore()
destructor, cleans up all the memory upon object deletion
Definition: connection_monitor_core.cpp:120
KERNEL_INFO
#define KERNEL_INFO(formatc,...)
Definition: snn_definitions.h:113
Grid3D::numY
int numY
Definition: carlsim_datastructures.h:547
ConnectionMonitorCore::getFanOut
int getFanOut(int neurPreId)
returns number of outgoing synapses of pre-synaptic neuron
Definition: connection_monitor_core.cpp:178
SNN::getLogFpErr
const FILE * getLogFpErr()
returns file pointer to error log
Definition: snn.h:515
ConnectionMonitorCore::getNumSynapses
int getNumSynapses()
returns number of synapses that exist in the connection
Definition: connection_monitor_core.h:110
SNN::getLogFpInf
const FILE * getLogFpInf()
function writes population weights from gIDpre to gIDpost to file fname in binary.
Definition: snn.h:513
Grid3D
A struct to arrange neurons on a 3D grid (a primitive cubic Bravais lattice with cubic side length 1)
Definition: carlsim_datastructures.h:489
ConnectConfig_s
The configuration of a connection.
Definition: snn_datastructures.h:119
ConnectionMonitorCore::setConnectFileId
void setConnectFileId(FILE *connFileId)
sets pointer to connection file
Definition: connection_monitor_core.cpp:414
SNN::getNumSynapticConnections
int getNumSynapticConnections(short int connectionId)
gets number of connections associated with a connection ID
Definition: snn_manager.cpp:1948
SNN::getSimTime
int getSimTime()
Definition: snn.h:580
SNN::getLogFpDeb
const FILE * getLogFpDeb()
returns file pointer to debug log
Definition: snn.h:517
SNN::getGroupName
std::string getGroupName(int grpId)
Definition: snn_manager.cpp:1864
ConnectionMonitorCore::getTotalAbsWeightChange
double getTotalAbsWeightChange()
returns absolute sum of all weight changes since last snapshot
Definition: connection_monitor_core.cpp:297
ConnectConfig_s::maxWt
float maxWt
Definition: snn_datastructures.h:124
snn.h
ConnectionMonitorCore::writeConnectFileSnapshot
void writeConnectFileSnapshot(int simTimeMs, std::vector< std::vector< float > > wts)
writes each snapshot to connect file
Definition: connection_monitor_core.cpp:517
SNN
Contains all of CARLsim's core functionality.
Definition: snn.h:114
ConnectionMonitorCore::getTimeMsSinceLastSnapshot
long int getTimeMsSinceLastSnapshot()
returns the time passed between current and last snapshot
Definition: connection_monitor_core.h:128
ConnectionMonitorCore::init
void init()
Definition: connection_monitor_core.cpp:84
Grid3D::numZ
int numZ
Definition: carlsim_datastructures.h:547
ConnectionMonitorCore::getFanIn
int getFanIn(int neurPostId)
returns number of incoming synapses to post-synaptic neuron
Definition: connection_monitor_core.cpp:166
SNN::getGroupGrid3D
Grid3D getGroupGrid3D(int grpId)
Definition: snn_manager.cpp:1845
ConnectionMonitorCore::takeSnapshot
std::vector< std::vector< float > > takeSnapshot()
Definition: connection_monitor_core.cpp:449
SNN::getLogFpLog
const FILE * getLogFpLog()
returns file pointer to log file
Definition: snn.h:519