CARLsim  3.1.3
CARLsim: a GPU-accelerated SNN simulator
connection_monitor.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Regents of the University of California. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * 3. The names of its contributors may not be used to endorse or promote
16  * products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * *************************************************************************
32  * CARLsim
33  * created by: (MDR) Micah Richert, (JN) Jayram M. Nageswaran
34  * maintained by: (MA) Mike Avery <averym@uci.edu>, (MB) Michael Beyeler <mbeyeler@uci.edu>,
35  * (KDC) Kristofor Carlson <kdcarlso@uci.edu>
36  * (TSC) Ting-Shuo Chou <tingshuc@uci.edu>
37  *
38  * CARLsim available from http://socsci.uci.edu/~jkrichma/CARLsim/
39  * Ver 5/14/2015
40  */
41 
42 #ifndef _CONN_MON_H_
43 #define _CONN_MON_H_
44 
45 #include <vector> // std::vector
46 #include <carlsim_definitions.h> // ALL
47 #include <stdint.h>
48 
49 class ConnectionMonitorCore; // forward declaration of implementation
50 
143  public:
150  ConnectionMonitor(ConnectionMonitorCore* connMonCorePtr);
151 
159 
160  // +++++ PUBLIC METHODS: +++++++++++++++++++++++++++++++++++++++++++++++//
161 
180  std::vector< std::vector<float> > calcWeightChanges();
181 
189  short int getConnectId();
190 
197  int getFanIn(int neurPostId);
198 
205  int getFanOut(int neurPreId);
206 
224  double getMaxWeight(bool getCurrent=false);
225 
243  double getMinWeight(bool getCurrent=false);
244 
251  int getNumNeuronsPre();
252 
259  int getNumNeuronsPost();
260 
267  int getNumSynapses();
268 
282  int getNumWeightsChanged(double minAbsChanged=1e-5);
283 
301  int getNumWeightsInRange(double minValue, double maxValue);
302 
323  int getNumWeightsWithValue(double value);
324 
345  double getPercentWeightsInRange(double minValue, double maxValue);
346 
367  double getPercentWeightsWithValue(double value);
368 
369 
385  double getPercentWeightsChanged(double minAbsChanged=1e-5);
386 
395  int64_t getTimeMsCurrentSnapshot();
396 
404  int64_t getTimeMsLastSnapshot();
405 
415  int64_t getTimeMsSinceLastSnapshot();
416 
426  double getTotalAbsWeightChange();
427 
443  void print();
444 
465  void printSparse(int neurPostId=ALL, int maxConn=100, int connPerLine=4);
466 
481  void setUpdateTimeIntervalSec(int intervalSec);
482 
499  std::vector< std::vector<float> > takeSnapshot();
500 
501 private:
503  ConnectionMonitorCore* connMonCorePtr_;
504 };
505 
506 #endif
double getPercentWeightsWithValue(double value)
Returns the percentage of weights in the connection with a particular value.
int getNumWeightsInRange(double minValue, double maxValue)
Returns the number of weights in the connection whose values are within some range (inclusive) ...
std::vector< std::vector< float > > takeSnapshot()
Takes a snapshot of the current weight state.
int getNumNeuronsPost()
Returns the number of post-synaptic neurons.
#define ALL
CARLsim common definitions.
ConnectionMonitor(ConnectionMonitorCore *connMonCorePtr)
ConnectionMonitor constructor.
int getNumWeightsWithValue(double value)
Returns the number of weights in the connection with a particular value.
void setUpdateTimeIntervalSec(int intervalSec)
Sets the time interval (seconds) for writing snapshots to file.
~ConnectionMonitor()
ConnectionMonitor destructor.
int64_t getTimeMsCurrentSnapshot()
Returns the timestamp of the current snapshot (ms since beginning of simulation)
void print()
Prints the current weight state as a 2D matrix (pre x post)
void printSparse(int neurPostId=ALL, int maxConn=100, int connPerLine=4)
Prints the current weight state as a sparse list of weights.
int getFanIn(int neurPostId)
Returns the number of incoming synapses for a specific post-synaptic neuron.
std::vector< std::vector< float > > calcWeightChanges()
Reports the weight changes since the last snapshot in a 2D weight matrix (pre x post) ...
short int getConnectId()
Returns the connection ID that this ConnectionMonitor is managing.
int getNumNeuronsPre()
Returns the number of pre-synaptic neurons.
double getPercentWeightsInRange(double minValue, double maxValue)
Returns the percentage of weights whose values are within some range (inclusive)
int getNumSynapses()
Returns the number of allocated synapses.
int64_t getTimeMsSinceLastSnapshot()
Returns the timestamp difference of the current and last snapshot.
double getMaxWeight(bool getCurrent=false)
Returns the max weight in the connection.
int64_t getTimeMsLastSnapshot()
Returns the timestamp of the last snapshot (ms since beginning of simulation)
Class ConnectionMonitor.
double getTotalAbsWeightChange()
Returns the absolute sum of all the weight changes since the last snapshot.
int getFanOut(int neurPreId)
Returns the number of outgoing synapses for a specific pre-synaptic neuron.
double getPercentWeightsChanged(double minAbsChanged=1e-5)
Returns the percentage of weights that have changed since the last snapshot.
int getNumWeightsChanged(double minAbsChanged=1e-5)
Returns the number of weights that have changed since the last snapshot.
double getMinWeight(bool getCurrent=false)
Returns the min weight in the connection.