CARLsim  3.0.3
CARLsim: a GPU-accelerated SNN simulator
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
carlsim_datastructures.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/21/2014
40  */
41 
42 #ifndef _CARLSIM_DATASTRUCTURES_H_
43 #define _CARLSIM_DATASTRUCTURES_H_
44 
45 #include <ostream> // print struct info
46 #include <user_errors.h> // CARLsim user errors
47 
84  USER,
90 };
91 static const char* loggerMode_string[] = {
92  "USER","DEVELOPER","SHOWTIME","SILENT","CUSTOM","Unknown mode"
93 };
94 
108 enum simMode_t {
112 };
113 static const char* simMode_string[] = {
114  "CPU mode","GPU mode","Unknown mode"
115 };
116 
117 // \TODO: extend documentation, add relevant references
129 };
130 static const char* stdpType_string[] = {
131  "Standard STDP",
132  "Dopamine-modulated STDP",
133  "Unknown mode"
134 };
135 
146 };
147 static const char* stdpCurve_string[] = {
148  "exponential curve",
149  "pulse curve",
150  "timing-based curve",
151  "Unknow curve"
152 };
153 
166  AER,
167 };
168 static const char* spikeMonMode_string[] = {
169  "SpikeCount Mode","SpikeTime Mode"
170 };
171 
188 };
189 static const char* neuromodulator_string[] = {
190  "Dopamine", "Serotonin", "Acetylcholine", "Noradrenaline", "Unknown neuromodulator"
191 };
192 
205 };
206 static const char* updateInterval_string[] = {
207  "10 ms interval", "100 ms interval", "1000 ms interval"
208 };
209 
227 };
228 static const char* carlsimState_string[] = {
229  "Configuration state", "Setup state", "Run state"
230 };
231 
242 struct RangeDelay {
243  RangeDelay(int _val) {
244  min = _val;
245  max = _val;
246  }
247  RangeDelay(int _min, int _max) {
248  UserErrors::assertTrue(_min<=_max, UserErrors::CANNOT_BE_LARGER, "RangeDelay", "minDelay", "maxDelay");
249  min = _min;
250  max = _max;
251  }
252 
253  friend std::ostream& operator<<(std::ostream &strm, const RangeDelay &d) {
254  return strm << "delay=[" << d.min << "," << d.max << "]";
255  }
256  int min,max;
257 };
258 
275 struct RangeWeight {
276  RangeWeight(double _val) {
277  init = _val;
278  max = _val;
279  min = 0;
280  }
281  RangeWeight(double _min, double _max) {
282  UserErrors::assertTrue(_min<=_max, UserErrors::CANNOT_BE_LARGER, "RangeWeight", "minWt", "maxWt");
283  min = _min;
284  init = _min;
285  max = _max;
286  }
287  RangeWeight(double _min, double _init, double _max) {
288  UserErrors::assertTrue(_min<=_init, UserErrors::CANNOT_BE_LARGER, "RangeWeight", "minWt", "initWt");
289  UserErrors::assertTrue(_init<=_max, UserErrors::CANNOT_BE_LARGER, "RangeWeight", "initWt", "maxWt");
290  min = _min;
291  init = _init;
292  max = _max;
293  }
294 
295  friend std::ostream& operator<<(std::ostream &strm, const RangeWeight &w) {
296  return strm << "wt=[" << w.min << "," << w.init << "," << w.max << "]";
297  }
298  double min, init, max;
299 };
300 
327 struct RadiusRF {
328  RadiusRF(double rad) : radX(rad), radY(rad), radZ(rad) {}
329  RadiusRF(double rad_x, double rad_y, double rad_z) : radX(rad_x), radY(rad_y), radZ(rad_z) {}
330 
331  friend std::ostream& operator<<(std::ostream &strm, const RadiusRF &r) {
332  return strm << "RadiusRF=[" << r.radX << "," << r.radY << "," << r.radZ << "]";
333  }
334 
335  const double radX, radY, radZ;
336 };
337 
347 typedef struct GroupSTDPInfo {
348  bool WithSTDP;
349  bool WithESTDP;
350  bool WithISTDP;
363  float GAMMA;
364  float BETA_LTP;
365  float BETA_LTD;
366  float LAMBDA;
367  float DELTA;
369 
379 typedef struct GroupNeuromodulatorInfo {
380  float baseDP;
381  float base5HT;
382  float baseACh;
383  float baseNE;
384  float decayDP;
385  float decay5HT;
386  float decayACh;
387  float decayNE;
389 
425 struct Grid3D {
426  Grid3D(int w) : x(w), y(1), z(1), width(w), height(1), depth(1), columns(1), channels(1), N(w) {
427  UserErrors::assertTrue(w>0, UserErrors::MUST_BE_POSITIVE, "Grid3D", "width");
428  }
429  Grid3D(int w, int h) : x(w), y(h), z(1), width(w), height(h), depth(1), columns(1), channels(1), N(w*h) {
430  UserErrors::assertTrue(w>0, UserErrors::MUST_BE_POSITIVE, "Grid3D", "width");
431  UserErrors::assertTrue(h>0, UserErrors::MUST_BE_POSITIVE, "Grid3D", "height");
432  }
433  Grid3D(int w, int h, int d) : x(w), y(h), z(d), width(w), height(h), depth(d), columns(d), channels(d), N(w*h*d) {
434  UserErrors::assertTrue(w>0, UserErrors::MUST_BE_POSITIVE, "Grid3D", "width");
435  UserErrors::assertTrue(h>0, UserErrors::MUST_BE_POSITIVE, "Grid3D", "height");
436  UserErrors::assertTrue(d>0, UserErrors::MUST_BE_POSITIVE, "Grid3D", "depth");
437  }
438 
439  friend std::ostream& operator<<(std::ostream &strm, const Grid3D &g) {
440  return strm << "Grid3D=[" << g.x << "," << g.y << "," << g.z << "]";
441  }
442 
443  int x, y, z;
446  int N;
447 };
448 
466 struct ExpCurve {
467  ExpCurve(float _alphaPlus, float _tauPlus, float _alphaMinus, float _tauMinus) : alphaPlus(_alphaPlus), tauPlus(_tauPlus), alphaMinus(_alphaMinus), tauMinus(_tauMinus) {
468  UserErrors::assertTrue(_tauPlus > 0.0f, UserErrors::MUST_BE_POSITIVE, "ExpCurve", "tauPlus");
469  UserErrors::assertTrue(_tauMinus > 0.0f, UserErrors::MUST_BE_POSITIVE, "ExpCurve", "tauMinus");
470 
472  }
473 
475  float alphaPlus;
476  float tauPlus;
477  float alphaMinus;
478  float tauMinus;
479 };
480 
510  TimingBasedCurve(float _alphaPlus, float _tauPlus, float _alphaMinus, float _tauMinus, float _gamma) : alphaPlus(_alphaPlus), tauPlus(_tauPlus), alphaMinus(_alphaMinus), tauMinus(_tauMinus) , gamma(_gamma) {
511  UserErrors::assertTrue(_alphaPlus > 0.0f, UserErrors::MUST_BE_POSITIVE, "TimingBasedCurve", "alphaPlus");
512  UserErrors::assertTrue(_alphaMinus < 0.0f, UserErrors::MUST_BE_NEGATIVE, "TimingBasedCurve", "alphaMinus");
513  UserErrors::assertTrue(_tauPlus > 0.0f, UserErrors::MUST_BE_POSITIVE, "TimingBasedCurve", "tauPlus");
514  UserErrors::assertTrue(_tauMinus > 0.0f, UserErrors::MUST_BE_POSITIVE, "TimingBasedCurve", "tauMinus");
515  UserErrors::assertTrue(_gamma > 0.0f, UserErrors::MUST_BE_POSITIVE, "TimingBasedCurve", "gamma");
516  UserErrors::assertTrue(_tauPlus >= _gamma, UserErrors::CANNOT_BE_SMALLER, "TimingBasedCurve", "tauPlus >= gamma");
517 
519  }
520 
522  float alphaPlus;
523  float tauPlus;
524  float alphaMinus;
525  float tauMinus;
526  float gamma;
527 };
528 
545 struct PulseCurve {
546  PulseCurve(float _betaLTP, float _betaLTD, float _lambda, float _delta) : betaLTP(_betaLTP), betaLTD(_betaLTD), lambda(_lambda), delta(_delta) {
547  UserErrors::assertTrue(_betaLTP > 0.0f, UserErrors::MUST_BE_POSITIVE, "PulseCurve", "betaLTP");
548  UserErrors::assertTrue(_betaLTD < 0.0f, UserErrors::MUST_BE_NEGATIVE, "PulseCurve", "betaLTD");
549  UserErrors::assertTrue(_lambda > 0.0f, UserErrors::MUST_BE_POSITIVE, "PulseCurve", "lambda");
550  UserErrors::assertTrue(_delta > 0.0f, UserErrors::MUST_BE_POSITIVE, "PulseCurve", "delta");
551  UserErrors::assertTrue(_lambda < _delta, UserErrors::MUST_BE_SMALLER, "PulseCurve", "lambda < delta");
552 
554  }
555 
557  float betaLTP;
558  float betaLTD;
559  float lambda;
560  float delta;
561 };
562 
563 #endif
A struct for retrieving neuromodulator information of a group.
bool WithSTDP
enable STDP flag
float TAU_PLUS_INV_INB
the inverse of tau plus, if the exponential I-STDP curve is used
PulseCurve(float _betaLTP, float _betaLTD, float _lambda, float _delta)
model is run on a single CPU core
the update interval will be 1000 ms, which is 1Hz update frequency
float baseNE
baseline concentration of Noradrenaline
parameter cannot have smaller vaule than some vaule
Definition: user_errors.h:34
float alphaPlus
the amplitude of the exponential curve at pre-post side
Grid3D(int w, int h)
stdpType_t WithESTDPtype
the type of E-STDP (STANDARD or DA_MOD)
dopamine-modulated STDP, nearest-neighbor
the update interval will be 100 ms, which is 10Hz update frequency
static const char * neuromodulator_string[]
standard STDP of Bi & Poo (2001), nearest-neighbor
float alphaMinus
the amplitude of the exponential curve at post-pre side
spikeMonMode_t
SpikeMonitor mode.
Showtime mode, will only output warnings and errors.
const double radZ
static const char * updateInterval_string[]
A struct to assign a timing-based E-STDP curve.
friend std::ostream & operator<<(std::ostream &strm, const RangeDelay &d)
TimingBasedCurve(float _alphaPlus, float _tauPlus, float _alphaMinus, float _tauMinus, float _gamma)
float TAU_MINUS_INV_INB
the inverse of tau minus, if the exponential I-STDP curve is used
float TAU_MINUS_INV_EXC
the inverse of time constant minus, if the exponential or timing-based E-STDP curve is used ...
float GAMMA
the turn over point if the timing-based E-STDP curve is used
const double radY
float ALPHA_MINUS_EXC
the amplitude of alpha minus, if the exponential or timing-based E-STDP curve is used ...
static const char * simMode_string[]
parameter cannot have larger vaule than some vaule
Definition: user_errors.h:33
bool WithISTDP
enable I-STDP flag
stdpCurve_t stdpCurve
the type of STDP curve
float decayDP
decay rate for Dopaamine
acetylcholine
float decayACh
decay rate for Acetylcholine
RadiusRF(double rad_x, double rad_y, double rad_z)
float base5HT
baseline concentration of Serotonin
float ALPHA_MINUS_INB
the amplitude of alpha minus, if the exponential I-STDP curve is used
float alphaMinus
the amplitude of the exponential curve at post-pre side
setup state, where the neural network is prepared for execution and monitors are set ...
RangeWeight(double _min, double _init, double _max)
float tauPlus
the time constant of the exponential curve at pre-post side
A struct to arrange neurons on a 3D grid (a primitive cubic Bravais lattice with cubic side length 1)...
model is run on a single GPU card
Grid3D(int w, int h, int d)
float betaLTD
the amplitude of inhibitory LTD
struct to assign a pulse I-STDP curve
stdpType_t
STDP flavors.
float lambda
the range of inhibitory LTP
Developer mode, for developing and debugging code.
noradrenaline
const double radX
float betaLTP
the amplitude of inhibitory LTP
RangeDelay(int _min, int _max)
float delta
the range of inhibitory LTD
static const char * carlsimState_string[]
standard exponential curve
static const char * stdpType_string[]
RangeWeight(double _min, double _max)
parameter must be smaller than
Definition: user_errors.h:53
bool WithESTDP
enable E-STDP flag
friend std::ostream & operator<<(std::ostream &strm, const RangeWeight &w)
float tauPlus
the time constant of the exponential curve at pre-post side
float BETA_LTD
the amplitude of inhibitory LTD if the pulse I-STDP curve is used
a range struct for synaptic delays
unknown curve type
friend std::ostream & operator<<(std::ostream &strm, const Grid3D &g)
stdpType_t WithISTDPtype
the type of I-STDP (STANDARD or DA_MOD)
float gamma
the turn-over point
Custom mode, the user can set the location of all the file pointers.
configuration state, where the neural network is configured
float BETA_LTP
the amplitude of inhibitory LTP if the pulse I-STDP curve is used
stdpCurve_t stdpCurve
the type of STDP curve
static void assertTrue(bool statement, errorType errorIfAssertionFails, std::string errorFunc, std::string errorMsgPrefix="", std::string errorMsgSuffix="")
simple wrapper for assert statement
float TAU_PLUS_INV_EXC
the inverse of time constant plus, if the exponential or timing-based E-STDP curve is used ...
A struct to assign exponential STDP curves.
RadiusRF(double rad)
RangeWeight(double _val)
mode in which spike information is collected in AER format
run state, where the model is stepped
neuromodulator_t
GroupMonitor flag.
struct GroupNeuromodulatorInfo GroupNeuromodulatorInfo_t
A struct for retrieving neuromodulator information of a group.
simMode_t
simulation mode
a range struct for synaptic weight magnitudes
updateInterval_t
Update frequency for weights.
float tauMinus
the time constant of the exponential curve at post-pre side
struct GroupSTDPInfo GroupSTDPInfo_t
A struct for retrieving STDP related information of a group.
float decayNE
decay rate for Noradrenaline
A struct for retrieving STDP related information of a group.
stdpCurve_t stdpCurve
the type of STDP curve
float baseACh
baseline concentration of Acetylcholine
stdpCurve_t
STDP curves.
symmetric pulse curve
friend std::ostream & operator<<(std::ostream &strm, const RadiusRF &r)
the update interval will be 10 ms, which is 100Hz update frequency
float decay5HT
decay rate for Serotonin
Silent mode, no output is generated.
static const char * spikeMonMode_string[]
parameter must have negative value
Definition: user_errors.h:47
timing-based curve
static const char * loggerMode_string[]
ExpCurve(float _alphaPlus, float _tauPlus, float _alphaMinus, float _tauMinus)
parameter must have positive value
Definition: user_errors.h:50
stdpCurve_t WithESTDPcurve
the E-STDP curve
User mode, for experiment-oriented simulations.
carlsimState_t
CARLsim states.
float ALPHA_PLUS_EXC
the amplitude of alpha plus, if the exponential or timing-based E-STDP curve is used ...
float baseDP
baseline concentration of Dopamine
float tauMinus
the time constant of the exponential curve at post-pre side
mode in which only spike count information is collected
float alphaPlus
the amplitude of the exponential curve at pre-post side
float ALPHA_PLUS_INB
the amplitude of alpha plus, if the exponential I-STDP curve is used
float DELTA
the range of inhibitory LTD if the pulse I-STDP curve is used
loggerMode_t
Logger modes.
stdpCurve_t WithISTDPcurve
the I-STDP curve
static const char * stdpCurve_string[]
A struct to specify the receptive field (RF) radius in 3 dimensions.
float LAMBDA
the range of inhibitory LTP if the pulse I-STDP curve is used