CARLsim  5.0.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 * CARLsim5: HK, JX, KC
45 *
46 * CARLsim available from http://socsci.uci.edu/~jkrichma/CARLsim/
47 * Ver 12/31/2016
48 */
49 
50 #ifndef _CONN_MON_H_
51 #define _CONN_MON_H_
52 
53 #include <vector> // std::vector
54 #include <carlsim_definitions.h> // ALL
55 
56 class ConnectionMonitorCore; // forward declaration of implementation
57 
150  public:
157  ConnectionMonitor(ConnectionMonitorCore* connMonCorePtr);
158 
166 
167  // +++++ PUBLIC METHODS: +++++++++++++++++++++++++++++++++++++++++++++++//
168 
187  std::vector< std::vector<float> > calcWeightChanges();
188 
196  short int getConnectId();
197 
204  int getFanIn(int neurPostId);
205 
212  int getFanOut(int neurPreId);
213 
231  double getMaxWeight(bool getCurrent=false);
232 
250  double getMinWeight(bool getCurrent=false);
251 
258  int getNumNeuronsPre();
259 
266  int getNumNeuronsPost();
267 
274  int getNumSynapses();
275 
289  int getNumWeightsChanged(double minAbsChanged=1e-5);
290 
308  int getNumWeightsInRange(double minValue, double maxValue);
309 
330  int getNumWeightsWithValue(double value);
331 
352  double getPercentWeightsInRange(double minValue, double maxValue);
353 
374  double getPercentWeightsWithValue(double value);
375 
376 
392  double getPercentWeightsChanged(double minAbsChanged=1e-5);
393 
402  long int getTimeMsCurrentSnapshot();
403 
411  long int getTimeMsLastSnapshot();
412 
422  long int getTimeMsSinceLastSnapshot();
423 
433  double getTotalAbsWeightChange();
434 
450  void print();
451 
472  void printSparse(int neurPostId=ALL, int maxConn=100, int connPerLine=4);
473 
488  void setUpdateTimeIntervalSec(int intervalSec);
489 
506  std::vector< std::vector<float> > takeSnapshot();
507 
508 private:
510  ConnectionMonitorCore* connMonCorePtr_;
511 };
512 
513 #endif
ConnectionMonitor::getPercentWeightsWithValue
double getPercentWeightsWithValue(double value)
Returns the percentage of weights in the connection with a particular value.
Definition: connection_monitor.cpp:134
ConnectionMonitor::setUpdateTimeIntervalSec
void setUpdateTimeIntervalSec(int intervalSec)
Sets the time interval (seconds) for writing snapshots to file.
Definition: connection_monitor.cpp:167
ConnectionMonitor::getPercentWeightsChanged
double getPercentWeightsChanged(double minAbsChanged=1e-5)
Returns the percentage of weights that have changed since the last snapshot.
Definition: connection_monitor.cpp:126
ConnectionMonitor::~ConnectionMonitor
~ConnectionMonitor()
ConnectionMonitor destructor.
Definition: connection_monitor.cpp:60
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:115
ConnectionMonitor::getTimeMsSinceLastSnapshot
long int getTimeMsSinceLastSnapshot()
Returns the timestamp difference of the current and last snapshot.
Definition: connection_monitor.cpp:146
ConnectionMonitor::getNumNeuronsPost
int getNumNeuronsPost()
Returns the number of post-synaptic neurons.
Definition: connection_monitor.cpp:93
ConnectionMonitorCore
Definition: connection_monitor_core.h:68
ConnectionMonitor::getTimeMsCurrentSnapshot
long int getTimeMsCurrentSnapshot()
Returns the timestamp of the current snapshot (ms since beginning of simulation)
Definition: connection_monitor.cpp:138
ConnectionMonitor::print
void print()
Prints the current weight state as a 2D matrix (pre x post)
Definition: connection_monitor.cpp:154
ConnectionMonitor::getNumWeightsWithValue
int getNumWeightsWithValue(double value)
Returns the number of weights in the connection with a particular value.
Definition: connection_monitor.cpp:121
ConnectionMonitor::getTimeMsLastSnapshot
long int getTimeMsLastSnapshot()
Returns the timestamp of the last snapshot (ms since beginning of simulation)
Definition: connection_monitor.cpp:142
ConnectionMonitor::getFanIn
int getFanIn(int neurPostId)
Returns the number of incoming synapses for a specific post-synaptic neuron.
Definition: connection_monitor.cpp:75
ConnectionMonitor::getConnectId
short int getConnectId()
Returns the connection ID that this ConnectionMonitor is managing.
Definition: connection_monitor.cpp:71
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:158
ALL
#define ALL
CARLsim common definitions.
Definition: carlsim_definitions.h:56
ConnectionMonitor::getPercentWeightsInRange
double getPercentWeightsInRange(double minValue, double maxValue)
Returns the percentage of weights whose values are within some range (inclusive)
Definition: connection_monitor.cpp:130
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:67
ConnectionMonitor::getTotalAbsWeightChange
double getTotalAbsWeightChange()
Returns the absolute sum of all the weight changes since the last snapshot.
Definition: connection_monitor.cpp:150
ConnectionMonitor::getNumSynapses
int getNumSynapses()
Returns the number of allocated synapses.
Definition: connection_monitor.cpp:105
ConnectionMonitor::getNumNeuronsPre
int getNumNeuronsPre()
Returns the number of pre-synaptic neurons.
Definition: connection_monitor.cpp:89
ConnectionMonitor::takeSnapshot
std::vector< std::vector< float > > takeSnapshot()
Takes a snapshot of the current weight state.
Definition: connection_monitor.cpp:174
ConnectionMonitor
Class ConnectionMonitor.
Definition: connection_monitor.h:149
ConnectionMonitor::getMaxWeight
double getMaxWeight(bool getCurrent=false)
Returns the max weight in the connection.
Definition: connection_monitor.cpp:97
ConnectionMonitor::getNumWeightsChanged
int getNumWeightsChanged(double minAbsChanged=1e-5)
Returns the number of weights that have changed since the last snapshot.
Definition: connection_monitor.cpp:109
ConnectionMonitor::getMinWeight
double getMinWeight(bool getCurrent=false)
Returns the min weight in the connection.
Definition: connection_monitor.cpp:101
carlsim_definitions.h
ConnectionMonitor::ConnectionMonitor
ConnectionMonitor(ConnectionMonitorCore *connMonCorePtr)
ConnectionMonitor constructor.
Definition: connection_monitor.cpp:56
ConnectionMonitor::getFanOut
int getFanOut(int neurPreId)
Returns the number of outgoing synapses for a specific pre-synaptic neuron.
Definition: connection_monitor.cpp:82