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