CARLsim  3.1.3
CARLsim: a GPU-accelerated SNN simulator
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 
131 };
132 static const char* integrationMethod_string[] = {
133  "Forward-Euler", "4-th order Runge-Kutta", "Unknown integration method"
134 };
135 
136 // \TODO: extend documentation, add relevant references
148 };
149 static const char* stdpType_string[] = {
150  "Standard STDP",
151  "Dopamine-modulated STDP",
152  "Unknown mode"
153 };
154 
165 };
166 static const char* stdpCurve_string[] = {
167  "exponential curve",
168  "pulse curve",
169  "timing-based curve",
170  "Unknow curve"
171 };
172 
185  AER,
186 };
187 static const char* spikeMonMode_string[] = {
188  "SpikeCount Mode","SpikeTime Mode"
189 };
190 
207 };
208 static const char* neuromodulator_string[] = {
209  "Dopamine", "Serotonin", "Acetylcholine", "Noradrenaline", "Unknown neuromodulator"
210 };
211 
224 };
225 static const char* updateInterval_string[] = {
226  "10 ms interval", "100 ms interval", "1000 ms interval"
227 };
228 
246 };
247 static const char* carlsimState_string[] = {
248  "Configuration state", "Setup state", "Run state"
249 };
250 
261 struct RangeDelay {
262  RangeDelay(int _val) {
263  min = _val;
264  max = _val;
265  }
266  RangeDelay(int _min, int _max) {
267  UserErrors::assertTrue(_min<=_max, UserErrors::CANNOT_BE_LARGER, "RangeDelay", "minDelay", "maxDelay");
268  min = _min;
269  max = _max;
270  }
271 
272  friend std::ostream& operator<<(std::ostream &strm, const RangeDelay &d) {
273  return strm << "delay=[" << d.min << "," << d.max << "]";
274  }
275  int min,max;
276 };
277 
294 struct RangeWeight {
295  RangeWeight(double _val) {
296  init = _val;
297  max = _val;
298  min = 0;
299  }
300  RangeWeight(double _min, double _max) {
301  UserErrors::assertTrue(_min<=_max, UserErrors::CANNOT_BE_LARGER, "RangeWeight", "minWt", "maxWt");
302  min = _min;
303  init = _min;
304  max = _max;
305  }
306  RangeWeight(double _min, double _init, double _max) {
307  UserErrors::assertTrue(_min<=_init, UserErrors::CANNOT_BE_LARGER, "RangeWeight", "minWt", "initWt");
308  UserErrors::assertTrue(_init<=_max, UserErrors::CANNOT_BE_LARGER, "RangeWeight", "initWt", "maxWt");
309  min = _min;
310  init = _init;
311  max = _max;
312  }
313 
314  friend std::ostream& operator<<(std::ostream &strm, const RangeWeight &w) {
315  return strm << "wt=[" << w.min << "," << w.init << "," << w.max << "]";
316  }
317  double min, init, max;
318 };
319 
346 struct RadiusRF {
347  RadiusRF(double rad) : radX(rad), radY(rad), radZ(rad) {}
348  RadiusRF(double rad_x, double rad_y, double rad_z) : radX(rad_x), radY(rad_y), radZ(rad_z) {}
349 
350  friend std::ostream& operator<<(std::ostream &strm, const RadiusRF &r) {
351  return strm << "RadiusRF=[" << r.radX << "," << r.radY << "," << r.radZ << "]";
352  }
353 
354  const double radX, radY, radZ;
355 };
356 
366 typedef struct GroupSTDPInfo {
367  bool WithSTDP;
368  bool WithESTDP;
369  bool WithISTDP;
382  float GAMMA;
383  float BETA_LTP;
384  float BETA_LTD;
385  float LAMBDA;
386  float DELTA;
388 
398 typedef struct GroupNeuromodulatorInfo {
399  float baseDP;
400  float base5HT;
401  float baseACh;
402  float baseNE;
403  float decayDP;
404  float decay5HT;
405  float decayACh;
406  float decayNE;
408 
444 struct Grid3D {
445  Grid3D(int w) : x(w), y(1), z(1), width(w), height(1), depth(1), columns(1), channels(1), N(w) {
446  UserErrors::assertTrue(w>0, UserErrors::MUST_BE_POSITIVE, "Grid3D", "width");
447  }
448  Grid3D(int w, int h) : x(w), y(h), z(1), width(w), height(h), depth(1), columns(1), channels(1), N(w*h) {
449  UserErrors::assertTrue(w>0, UserErrors::MUST_BE_POSITIVE, "Grid3D", "width");
450  UserErrors::assertTrue(h>0, UserErrors::MUST_BE_POSITIVE, "Grid3D", "height");
451  }
452  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) {
453  UserErrors::assertTrue(w>0, UserErrors::MUST_BE_POSITIVE, "Grid3D", "width");
454  UserErrors::assertTrue(h>0, UserErrors::MUST_BE_POSITIVE, "Grid3D", "height");
455  UserErrors::assertTrue(d>0, UserErrors::MUST_BE_POSITIVE, "Grid3D", "depth");
456  }
457 
458  friend std::ostream& operator<<(std::ostream &strm, const Grid3D &g) {
459  return strm << "Grid3D=[" << g.x << "," << g.y << "," << g.z << "]";
460  }
461 
462  int x, y, z;
463  int width, height, depth;
464  int columns, channels;
465  int N;
466 };
467 
485 struct ExpCurve {
486  ExpCurve(float _alphaPlus, float _tauPlus, float _alphaMinus, float _tauMinus) : alphaPlus(_alphaPlus), tauPlus(_tauPlus), alphaMinus(_alphaMinus), tauMinus(_tauMinus) {
487  UserErrors::assertTrue(_tauPlus > 0.0f, UserErrors::MUST_BE_POSITIVE, "ExpCurve", "tauPlus");
488  UserErrors::assertTrue(_tauMinus > 0.0f, UserErrors::MUST_BE_POSITIVE, "ExpCurve", "tauMinus");
489 
490  stdpCurve = EXP_CURVE;
491  }
492 
494  float alphaPlus;
495  float tauPlus;
496  float alphaMinus;
497  float tauMinus;
498 };
499 
529  TimingBasedCurve(float _alphaPlus, float _tauPlus, float _alphaMinus, float _tauMinus, float _gamma) : alphaPlus(_alphaPlus), tauPlus(_tauPlus), alphaMinus(_alphaMinus), tauMinus(_tauMinus) , gamma(_gamma) {
530  UserErrors::assertTrue(_alphaPlus > 0.0f, UserErrors::MUST_BE_POSITIVE, "TimingBasedCurve", "alphaPlus");
531  UserErrors::assertTrue(_alphaMinus < 0.0f, UserErrors::MUST_BE_NEGATIVE, "TimingBasedCurve", "alphaMinus");
532  UserErrors::assertTrue(_tauPlus > 0.0f, UserErrors::MUST_BE_POSITIVE, "TimingBasedCurve", "tauPlus");
533  UserErrors::assertTrue(_tauMinus > 0.0f, UserErrors::MUST_BE_POSITIVE, "TimingBasedCurve", "tauMinus");
534  UserErrors::assertTrue(_gamma > 0.0f, UserErrors::MUST_BE_POSITIVE, "TimingBasedCurve", "gamma");
535  UserErrors::assertTrue(_tauPlus >= _gamma, UserErrors::CANNOT_BE_SMALLER, "TimingBasedCurve", "tauPlus >= gamma");
536 
537  stdpCurve = TIMING_BASED_CURVE;
538  }
539 
541  float alphaPlus;
542  float tauPlus;
543  float alphaMinus;
544  float tauMinus;
545  float gamma;
546 };
547 
564 struct PulseCurve {
565  PulseCurve(float _betaLTP, float _betaLTD, float _lambda, float _delta) : betaLTP(_betaLTP), betaLTD(_betaLTD), lambda(_lambda), delta(_delta) {
566  UserErrors::assertTrue(_betaLTP > 0.0f, UserErrors::MUST_BE_POSITIVE, "PulseCurve", "betaLTP");
567  UserErrors::assertTrue(_betaLTD < 0.0f, UserErrors::MUST_BE_NEGATIVE, "PulseCurve", "betaLTD");
568  UserErrors::assertTrue(_lambda > 0.0f, UserErrors::MUST_BE_POSITIVE, "PulseCurve", "lambda");
569  UserErrors::assertTrue(_delta > 0.0f, UserErrors::MUST_BE_POSITIVE, "PulseCurve", "delta");
570  UserErrors::assertTrue(_lambda < _delta, UserErrors::MUST_BE_SMALLER, "PulseCurve", "lambda < delta");
571 
572  stdpCurve = PULSE_CURVE;
573  }
574 
576  float betaLTP;
577  float betaLTD;
578  float lambda;
579  float delta;
580 };
581 
582 #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:36
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 * integrationMethod_string[]
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:35
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:56
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
integrationMethod_t
Integration methods.
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
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:50
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:53
stdpCurve_t WithESTDPcurve
the E-STDP curve
User mode, for experiment-oriented simulations.
static void assertTrue(bool statement, errorType errorIfAssertionFails, const std::string &errorFunc, const std::string &errorMsgPrefix="", const std::string &errorMsgSuffix="")
Checks whether assertion statement is true, else throws error.
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