CARLsim  3.0.3
CARLsim: a GPU-accelerated SNN simulator
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 2/10/2015
40  */
41 
42 #ifndef _CONN_MON_H_
43 #define _CONN_MON_H_
44 
45 #include <vector> // std::vector
46 #include <stdint.h>
47 #include <carlsim_definitions.h> // ALL
48 
49 class ConnectionMonitorCore; // forward declaration of implementation
50 
143  public:
150  ConnectionMonitor(ConnectionMonitorCore* connMonCorePtr);
151 
159 
160  // +++++ PUBLIC METHODS: +++++++++++++++++++++++++++++++++++++++++++++++//
161 
178  std::vector< std::vector<float> > calcWeightChanges();
179 
186  short int getConnectId();
187 
193  int getFanIn(int neurPostId);
194 
200  int getFanOut(int neurPreId);
201 
207  int getNumNeuronsPre();
208 
214  int getNumNeuronsPost();
215 
221  int getNumSynapses();
222 
234  int getNumWeightsChanged(double minAbsChanged=1e-5);
235 
249  double getPercentWeightsChanged(double minAbsChanged=1e-5);
250 
258  int64_t getTimeMsCurrentSnapshot();
259 
266  int64_t getTimeMsLastSnapshot();
267 
276  int64_t getTimeMsSinceLastSnapshot();
277 
285  double getTotalAbsWeightChange();
286 
300  void print();
301 
320  void printSparse(int neurPostId=ALL, int maxConn=100, int connPerLine=4);
321 
336  void setUpdateTimeIntervalSec(int intervalSec);
337 
353  std::vector< std::vector<float> > takeSnapshot();
354 
355 private:
357  ConnectionMonitorCore* connMonCorePtr_;
358 };
359 
360 #endif
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.
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.
int getNumSynapses()
Returns the number of allocated synapses.
int64_t getTimeMsSinceLastSnapshot()
Returns the timestamp difference of the current and last snapshot.
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.