CARLsim  4.1.0
CARLsim: a GPU-accelerated SNN simulator
connection_monitor.h
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 */
48 
49 #ifndef _CONN_MON_H_
50 #define _CONN_MON_H_
51 
52 #include <vector> // std::vector
53 #include <carlsim_definitions.h> // ALL
54 
55 class ConnectionMonitorCore; // forward declaration of implementation
56 
149  public:
156  ConnectionMonitor(ConnectionMonitorCore* connMonCorePtr);
157 
165 
166  // +++++ PUBLIC METHODS: +++++++++++++++++++++++++++++++++++++++++++++++//
167 
186  std::vector< std::vector<float> > calcWeightChanges();
187 
195  short int getConnectId();
196 
203  int getFanIn(int neurPostId);
204 
211  int getFanOut(int neurPreId);
212 
230  double getMaxWeight(bool getCurrent=false);
231 
249  double getMinWeight(bool getCurrent=false);
250 
257  int getNumNeuronsPre();
258 
265  int getNumNeuronsPost();
266 
273  int getNumSynapses();
274 
288  int getNumWeightsChanged(double minAbsChanged=1e-5);
289 
307  int getNumWeightsInRange(double minValue, double maxValue);
308 
329  int getNumWeightsWithValue(double value);
330 
351  double getPercentWeightsInRange(double minValue, double maxValue);
352 
373  double getPercentWeightsWithValue(double value);
374 
375 
391  double getPercentWeightsChanged(double minAbsChanged=1e-5);
392 
401  long int getTimeMsCurrentSnapshot();
402 
410  long int getTimeMsLastSnapshot();
411 
421  long int getTimeMsSinceLastSnapshot();
422 
432  double getTotalAbsWeightChange();
433 
449  void print();
450 
471  void printSparse(int neurPostId=ALL, int maxConn=100, int connPerLine=4);
472 
487  void setUpdateTimeIntervalSec(int intervalSec);
488 
505  std::vector< std::vector<float> > takeSnapshot();
506 
507 private:
509  ConnectionMonitorCore* connMonCorePtr_;
510 };
511 
512 #endif
ConnectionMonitor::getPercentWeightsWithValue
double getPercentWeightsWithValue(double value)
Returns the percentage of weights in the connection with a particular value.
Definition: connection_monitor.cpp:133
ConnectionMonitor::setUpdateTimeIntervalSec
void setUpdateTimeIntervalSec(int intervalSec)
Sets the time interval (seconds) for writing snapshots to file.
Definition: connection_monitor.cpp:166
ConnectionMonitor::getPercentWeightsChanged
double getPercentWeightsChanged(double minAbsChanged=1e-5)
Returns the percentage of weights that have changed since the last snapshot.
Definition: connection_monitor.cpp:125
ConnectionMonitor::~ConnectionMonitor
~ConnectionMonitor()
ConnectionMonitor destructor.
Definition: connection_monitor.cpp:59
ConnectionMonitor::getNumWeightsInRange
int getNumWeightsInRange(double minValue, double maxValue)
Returns the number of weights in the connection whose values are within some range (inclusive)
Definition: connection_monitor.cpp:114
ConnectionMonitor::getTimeMsSinceLastSnapshot
long int getTimeMsSinceLastSnapshot()
Returns the timestamp difference of the current and last snapshot.
Definition: connection_monitor.cpp:145
ConnectionMonitor::getNumNeuronsPost
int getNumNeuronsPost()
Returns the number of post-synaptic neurons.
Definition: connection_monitor.cpp:92
ConnectionMonitorCore
Definition: connection_monitor_core.h:67
ConnectionMonitor::getTimeMsCurrentSnapshot
long int getTimeMsCurrentSnapshot()
Returns the timestamp of the current snapshot (ms since beginning of simulation)
Definition: connection_monitor.cpp:137
ConnectionMonitor::print
void print()
Prints the current weight state as a 2D matrix (pre x post)
Definition: connection_monitor.cpp:153
ConnectionMonitor::getNumWeightsWithValue
int getNumWeightsWithValue(double value)
Returns the number of weights in the connection with a particular value.
Definition: connection_monitor.cpp:120
ConnectionMonitor::getTimeMsLastSnapshot
long int getTimeMsLastSnapshot()
Returns the timestamp of the last snapshot (ms since beginning of simulation)
Definition: connection_monitor.cpp:141
ConnectionMonitor::getFanIn
int getFanIn(int neurPostId)
Returns the number of incoming synapses for a specific post-synaptic neuron.
Definition: connection_monitor.cpp:74
ConnectionMonitor::getConnectId
short int getConnectId()
Returns the connection ID that this ConnectionMonitor is managing.
Definition: connection_monitor.cpp:70
ConnectionMonitor::printSparse
void printSparse(int neurPostId=ALL, int maxConn=100, int connPerLine=4)
Prints the current weight state as a sparse list of weights.
Definition: connection_monitor.cpp:157
ALL
#define ALL
CARLsim common definitions.
Definition: carlsim_definitions.h:55
ConnectionMonitor::getPercentWeightsInRange
double getPercentWeightsInRange(double minValue, double maxValue)
Returns the percentage of weights whose values are within some range (inclusive)
Definition: connection_monitor.cpp:129
ConnectionMonitor::calcWeightChanges
std::vector< std::vector< float > > calcWeightChanges()
Reports the weight changes since the last snapshot in a 2D weight matrix (pre x post)
Definition: connection_monitor.cpp:66
ConnectionMonitor::getTotalAbsWeightChange
double getTotalAbsWeightChange()
Returns the absolute sum of all the weight changes since the last snapshot.
Definition: connection_monitor.cpp:149
ConnectionMonitor::getNumSynapses
int getNumSynapses()
Returns the number of allocated synapses.
Definition: connection_monitor.cpp:104
ConnectionMonitor::getNumNeuronsPre
int getNumNeuronsPre()
Returns the number of pre-synaptic neurons.
Definition: connection_monitor.cpp:88
ConnectionMonitor::takeSnapshot
std::vector< std::vector< float > > takeSnapshot()
Takes a snapshot of the current weight state.
Definition: connection_monitor.cpp:173
ConnectionMonitor
Class ConnectionMonitor.
Definition: connection_monitor.h:148
ConnectionMonitor::getMaxWeight
double getMaxWeight(bool getCurrent=false)
Returns the max weight in the connection.
Definition: connection_monitor.cpp:96
ConnectionMonitor::getNumWeightsChanged
int getNumWeightsChanged(double minAbsChanged=1e-5)
Returns the number of weights that have changed since the last snapshot.
Definition: connection_monitor.cpp:108
ConnectionMonitor::getMinWeight
double getMinWeight(bool getCurrent=false)
Returns the min weight in the connection.
Definition: connection_monitor.cpp:100
carlsim_definitions.h
ConnectionMonitor::ConnectionMonitor
ConnectionMonitor(ConnectionMonitorCore *connMonCorePtr)
ConnectionMonitor constructor.
Definition: connection_monitor.cpp:55
ConnectionMonitor::getFanOut
int getFanOut(int neurPreId)
Returns the number of outgoing synapses for a specific pre-synaptic neuron.
Definition: connection_monitor.cpp:81