CARLsim  3.1.3
CARLsim: a GPU-accelerated SNN simulator
carlsim.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/6/2015
40  */
41 
42 #ifndef _CARLSIM_H_
43 #define _CARLSIM_H_
44 
45 #include <stdint.h> // uint64_t, uint32_t, etc.
46 #include <string> // std::string
47 #include <vector> // std::vector
48 
49 #include <callback.h>
50 #include <carlsim_definitions.h>
52 #include <carlsim_datastructures.h>
53 
54 // include the following core functionalities instead of forward-declaring, so that the user only needs to include
55 // carlsim.h
56 #include <poisson_rate.h>
57 #include <spike_monitor.h>
58 #include <connection_monitor.h>
59 #include <group_monitor.h>
60 #include <linear_algebra.h>
61 
62 // Cross-platform definition (Linux, Windows)
63 #if defined(WIN32) || defined(WIN64)
64  #include <Windows.h>
65 
66  #include <algorithm>
67  #define fmin (std::min)
68  #define fmax (std::max)
69 
70  #include <float.h>
71  #include <time.h>
72 
73  #ifndef isnan
74  #define isnan(x) _isnan(x)
75  #endif
76 
77  #ifndef isinf
78  #define isinf(x) (!_finite(x))
79  #endif
80 
81  #ifndef srand48
82  #define srand48(x) srand(x)
83  #endif
84 
85  #ifndef drand48
86  #define drand48() (double(rand())/RAND_MAX)
87  #endif
88 
89  #ifdef _MSC_VER
90  #define INFINITY (DBL_MAX+DBL_MAX)
91  #define NAN (INFINITY-INFINITY)
92  #endif
93 #else
94  #include <interactive_spikegen.h>
95  #include <pre_post_group_spikegen.h>
96  #include <periodic_spikegen.h>
97  #include <spikegen_from_file.h>
98  #include <spikegen_from_vector.h>
99  #include <simple_weight_tuner.h>
100  #include <visual_stimulus.h>
101  #include <stopwatch.h>
102 
103  #include <pthread.h>
104 #endif
105 
106 // \TODO: complete documentation
107 
108 
109 class CpuSNN; // forward-declaration of implementation
110 class GroupMonitorCore;
111 class ConnectionMonitorCore;
112 class ConnectionGeneratorCore;
113 class SpikeGeneratorCore;
114 
141 class CARLsim {
142 public:
143  // +++++ PUBLIC METHODS: CONSTRUCTOR / DESTRUCTOR +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
144 
178  CARLsim(const std::string& netName="SNN", simMode_t simMode=CPU_MODE, loggerMode_t loggerMode=USER, int ithGPU=0,
179  int randSeed=-1);
180  ~CARLsim();
181 
182 
183 
184  // +++++ PUBLIC METHODS: SETTING UP A SIMULATION ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
185 
251  short int connect(int grpId1, int grpId2, const std::string& connType, const RangeWeight& wt, float connProb,
252  const RangeDelay& delay=RangeDelay(1), const RadiusRF& radRF=RadiusRF(-1), bool synWtType=SYN_FIXED,
253  float mulSynFast=1.0f, float mulSynSlow=1.0f);
254 
262  short int connect(int grpId1, int grpId2, ConnectionGenerator* conn, bool synWtType=SYN_FIXED, int maxM=0,
263  int maxPreM=0);
264 
271  short int connect(int grpId1, int grpId2, ConnectionGenerator* conn, float mulSynFast, float mulSynSlow,
272  bool synWtType=SYN_FIXED, int maxM=0,int maxPreM=0);
273 
274 
282  short int connectCompartments(int grpIdLower, int grpIdUpper);
283 
289  int createGroup(const std::string& grpName, int nNeur, int neurType);
290 
312  int createGroup(const std::string& grpName, const Grid3D& grid, int neurType);
313 
319  int createSpikeGeneratorGroup(const std::string& grpName, int nNeur, int neurType);
320 
337  int createSpikeGeneratorGroup(const std::string& grpName, const Grid3D& grid, int neurType);
338 
339 
353  void setConductances(bool isSet);
354 
371  void setConductances(bool isSet, int tdAMPA, int tdNMDA, int tdGABAa, int tdGABAb);
372 
393  void setConductances(bool isSet, int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb, int tdGABAb);
394 
423  void setHomeostasis(int grpId, bool isSet, float homeoScale, float avgTimeScale);
424 
439  void setHomeostasis(int grpId, bool isSet);
440 
458  void setHomeoBaseFiringRate(int grpId, float baseFiring, float baseFiringSD=0.0f);
459 
460  /*
461  * \brief Sets the integration method for the simulation
462  *
463  * This function specifies the integration method for the simulation. Currently, the chosen integration method
464  * will apply to all neurons in the network.
465  *
466  * The basic simulation time step is 1ms, meaning that spike times cannot be retrieved with sub-millisecond
467  * precision. However, the integration time step can be lower than 1ms, which is specified by numStepsPerMs.
468  * A numStepsPerMs set to 10 would take 10 integration steps per 1ms simulation time step.
469  *
470  * By default, the simulation will use Forward-Euler with an integration step of 0.5ms (i.e.,
471  * <tt>numStepsPerMs</tt>=2).
472  *
473  * Currently CARLsim supports the following integration methods:
474  * - FORWARD_EULER: The most basic, forward-Euler method. Suggested value for <tt>numStepsPerMs</tt>: >= 2.
475  * - RUNGE_KUTTA4: Fourth-order Runge-Kutta (aka classical Runge-Kutta, aka RK4).
476  * Suggested value for <tt>numStepsPerMs</tt>: >= 10.
477  *
478  * \STATE ::CONFIG_STATE
479  * \param[in] method the integration method to use
480  * \param[in] numStepsPerMs the number of integration steps per 1ms simulation time step
481  *
482  * \note Note that the higher numStepsPerMs the slower the simulation may be, due to increased computational load.
483  * \since v3.1
484  */
485  void setIntegrationMethod(integrationMethod_t method, int numStepsPerMs);
486 
493  void setNeuronParameters(int grpId, float izh_a, float izh_a_sd, float izh_b, float izh_b_sd,
494  float izh_c, float izh_c_sd, float izh_d, float izh_d_sd);
495 
502  void setNeuronParameters(int grpId, float izh_a, float izh_b, float izh_c, float izh_d);
503 
523  void setNeuronParameters(int grpId, float izh_C, float izh_k, float izh_vr, float izh_vt,
524  float izh_a, float izh_b, float izh_vpeak, float izh_c, float izh_d);
525 
555  void setNeuronParameters(int grpId, float izh_C, float izh_C_sd, float izh_k, float izh_k_sd,
556  float izh_vr, float izh_vr_sd, float izh_vt, float izh_vt_sd,
557  float izh_a, float izh_a_sd, float izh_b, float izh_b_sd,
558  float izh_vpeak, float izh_vpeak_sd, float izh_c, float izh_c_sd,
559  float izh_d, float izh_d_sd);
560 
570  void setCompartmentParameters(int grpId, float couplingUp, float couplingDown);
571 
587  void setNeuromodulator(int grpId, float baseDP, float tauDP, float base5HT, float tau5HT,
588  float baseACh, float tauACh, float baseNE, float tauNE);
589 
598  void setNeuromodulator(int grpId, float tauDP = 100.0f, float tau5HT = 100.0f,
599  float tauACh = 100.0f, float tauNE = 100.0f);
600 
610  void setSTDP(int grpId, bool isSet);
611 
621  void setSTDP(int grpId, bool isSet, stdpType_t type, float alphaPlus, float tauPlus, float alphaMinus, float tauMinus);
622 
632  void setESTDP(int grpId, bool isSet);
633 
647  void setESTDP(int grpId, bool isSet, stdpType_t type, ExpCurve curve);
648 
662  void setESTDP(int grpId, bool isSet, stdpType_t type, TimingBasedCurve curve);
663 
673  void setISTDP(int grpId, bool isSet);
674 
688  void setISTDP(int grpId, bool isSet, stdpType_t type, ExpCurve curve);
689 
703  void setISTDP(int grpId, bool isSet, stdpType_t type, PulseCurve curve);
704 
734  void setSTP(int grpId, bool isSet, float STP_U, float STP_tau_u, float STP_tau_x);
735 
757  void setSTP(int grpId, bool isSet);
758 
767  void setWeightAndWeightChangeUpdate(updateInterval_t wtANDwtChangeUpdateInterval, bool enableWtChangeDecay, float wtChangeDecay=0.9f);
768 
769 
770  // +++++ PUBLIC METHODS: RUNNING A SIMULATION ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
771 
781  int runNetwork(int nSec, int nMsec=0, bool printRunSummary=true, bool copyState=false);
782 
789  void setupNetwork(bool removeTempMemory = true);
790 
791  // +++++ PUBLIC METHODS: LOGGING / PLOTTING +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
792 
793  const FILE* getLogFpInf();
794  const FILE* getLogFpErr();
795  const FILE* getLogFpDeb();
796  const FILE* getLogFpLog();
797 
815  void saveSimulation(const std::string& fileName, bool saveSynapseInfo=true);
816 
831  void setLogFile(const std::string& fileName);
832 
851  void setLogsFpCustom(FILE* fpInf=NULL, FILE* fpErr=NULL, FILE* fpDeb=NULL, FILE* fpLog=NULL);
852 
853 
854 
855  // +++++ PUBLIC METHODS: INTERACTING WITH A SIMULATION ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
856 
879  void biasWeights(short int connId, float bias, bool updateWeightRange=false);
880 
900  void loadSimulation(FILE* fid);
901 
919  void resetSpikeCounter(int grpId);
920 
943  void scaleWeights(short int connId, float scale, bool updateWeightRange=false);
944 
977  ConnectionMonitor* setConnectionMonitor(int grpIdPre, int grpIdPost, const std::string& fname);
978 
1016  void setExternalCurrent(int grpId, const std::vector<float>& current);
1017 
1046  void setExternalCurrent(int grpId, float current);
1047 
1054  GroupMonitor* setGroupMonitor(int grpId, const std::string& fname);
1055 
1080  void setSpikeCounter(int grpId, int recordDur=-1);
1081 
1101  void setSpikeGenerator(int grpId, SpikeGenerator* spikeGen);
1102 
1145  SpikeMonitor* setSpikeMonitor(int grpId, const std::string& fileName);
1146 
1164  void setSpikeRate(int grpId, PoissonRate* spikeRate, int refPeriod=1);
1165 
1193  void setWeight(short int connId, int neurIdPre, int neurIdPost, float weight, bool updateWeightRange=false);
1194 
1216  void startTesting(bool updateWeights=true);
1217 
1230  void stopTesting();
1231 
1238  void writePopWeights(std::string fname, int gIDpre, int gIDpost);
1239 
1240 
1241 
1242  // +++++ PUBLIC METHODS: GETTERS / SETTERS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
1243 
1259  carlsimState_t getCARLsimState() { return carlsimState_; }
1260 
1268  std::vector<float> getConductanceAMPA(int grpId);
1269 
1277  std::vector<float> getConductanceNMDA(int grpId);
1278 
1286  std::vector<float> getConductanceGABAa(int grpId);
1287 
1295  std::vector<float> getConductanceGABAb(int grpId);
1296 
1308  RangeDelay getDelayRange(short int connId);
1309 
1316  uint8_t* getDelays(int gIDpre, int gIDpost, int& Npre, int& Npost, uint8_t* delays=NULL);
1317 
1330  Grid3D getGroupGrid3D(int grpId);
1331 
1338  int getGroupId(std::string grpName);
1339 
1346  std::string getGroupName(int grpId);
1347 
1366  Point3D getNeuronLocation3D(int neurId);
1367 
1389  Point3D getNeuronLocation3D(int grpId, int relNeurId);
1390 
1398 
1408  int getNumConnections();
1409 
1416  int getNumSynapticConnections(short int connectionId);
1417 
1425  int getNumGroups();
1426 
1434  int getNumNeurons();
1435 
1443  int getNumNeuronsReg();
1444 
1452  int getNumNeuronsRegExc();
1453 
1461  int getNumNeuronsRegInh();
1462 
1470  int getNumNeuronsGen();
1471 
1479  int getNumNeuronsGenExc();
1480 
1488  int getNumNeuronsGenInh();
1489 
1496  int getNumPreSynapses();
1497 
1504  int getNumPostSynapses();
1505 
1512  int getGroupStartNeuronId(int grpId);
1513 
1520  int getGroupEndNeuronId(int grpId);
1521 
1528  int getGroupNumNeurons(int grpId);
1529 
1537  GroupSTDPInfo_t getGroupSTDPInfo(int grpId);
1538 
1548 
1558 
1565  uint64_t getSimTime();
1566 
1573  uint32_t getSimTimeSec();
1574 
1581  uint32_t getSimTimeMsec();
1582 
1623  int* getSpikeCounter(int grpId);
1624 
1636  SpikeMonitor* getSpikeMonitor(int grpId);
1637 
1649  RangeWeight getWeightRange(short int connId);
1650 
1660  bool isConnectionPlastic(short int connId);
1661 
1671  bool isGroupWithHomeostasis(int grpId);
1672 
1679  bool isExcitatoryGroup(int grpId);
1680 
1687  bool isInhibitoryGroup(int grpId);
1688 
1695  bool isPoissonGroup(int grpId);
1696 
1697  // +++++ PUBLIC METHODS: SET DEFAULTS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
1698 
1710  void setDefaultConductanceTimeConstants(int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb, int tdGABAb);
1711 
1718  void setDefaultHomeostasisParams(float homeoScale, float avgTimeScale);
1719 
1726  void setDefaultSaveOptions(std::string fileName, bool saveSynapseInfo);
1727 
1736  void setDefaultSTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, stdpType_t stdpType);
1737 
1746  void setDefaultESTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, stdpType_t stdpType);
1747 
1756  void setDefaultISTDPparams(float betaLTP, float betaLTD, float lambda, float delta, stdpType_t stdpType);
1757 
1779  void setDefaultSTPparams(int neurType, float STP_U, float STP_tau_u, float STP_tau_x);
1780 
1781 
1782 private:
1783  // +++++ PRIVATE METHODS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
1784 
1785  void CARLsimInit();
1786 
1787  bool existsGrpId(int grpId);
1788 
1789  void handleUserWarnings();
1790 
1791  void printSimulationSpecs();
1792 
1793  // +++++ PRIVATE STATIC PROPERTIES ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
1794  static bool gpuAllocation[MAX_NUM_CUDA_DEVICES];
1795  static std::string gpuOccupiedBy[MAX_NUM_CUDA_DEVICES];
1796 #if defined(WIN32) || defined(WIN64)
1797  static HANDLE gpuAllocationLock;
1798 #else
1799  static pthread_mutex_t gpuAllocationLock;
1800 #endif
1801  // +++++ PRIVATE PROPERTIES +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
1802 
1803  CpuSNN* snn_;
1804  std::string netName_;
1805  int randSeed_;
1806  simMode_t simMode_;
1807  loggerMode_t loggerMode_;
1808  int ithGPU_;
1809  bool enablePrint_;
1810  bool copyState_;
1811 
1813  std::vector<std::vector<int> > connSyn_;
1814 
1817  std::vector<std::vector<int> > connComp_;
1818 
1819  unsigned int numConnections_;
1820  std::vector<std::string> userWarnings_; // !< an accumulated list of user warnings
1821 
1822  std::vector<int> grpIds_;
1823  std::vector<bool> grpNeurParams_;
1824  std::vector<SpikeGeneratorCore*> spkGen_;
1825  std::vector<ConnectionGeneratorCore*> connGen_;
1826 
1827  bool hasSetHomeoALL_;
1828  bool hasSetHomeoBaseFiringALL_;
1829  bool hasSetSTDPALL_;
1830  bool hasSetSTPALL_;
1831  bool hasSetConductances_;
1832  carlsimState_t carlsimState_;
1833 
1834  int def_tdAMPA_;
1835  int def_trNMDA_;
1836  int def_tdNMDA_;
1837  int def_tdGABAa_;
1838  int def_trGABAb_;
1839  int def_tdGABAb_;
1840 
1841  // all default values for STDP
1842  stdpType_t def_STDP_type_;
1843  float def_STDP_alphaLTP_;
1844  float def_STDP_tauLTP_;
1845  float def_STDP_alphaLTD_;
1846  float def_STDP_tauLTD_;
1847  float def_STDP_betaLTP_;
1848  float def_STDP_betaLTD_;
1849  float def_STDP_lambda_;
1850  float def_STDP_delta_;
1851 
1852  // all default values for STP
1853  float def_STP_U_exc_;
1854  float def_STP_tau_u_exc_;
1855  float def_STP_tau_x_exc_;
1856  float def_STP_U_inh_;
1857  float def_STP_tau_u_inh_;
1858  float def_STP_tau_x_inh_;
1859 
1860  // all default values for homeostasis
1861  float def_homeo_scale_;
1862  float def_homeo_avgTimeScale_;
1863 
1864  // all default values for save file
1865  std::string def_save_fileName_;
1866  bool def_save_synapseInfo_;
1867 };
1868 #endif
Class for generating Poisson spike trains.
Definition: poisson_rate.h:84
A struct for retrieving neuromodulator information of a group.
model is run on a single CPU core
int getNumGroups()
returns the number of groups in the network
void setDefaultConductanceTimeConstants(int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb, int tdGABAb)
Sets default values for conductance time constants.
void setSTDP(int grpId, bool isSet)
Sets default STDP mode and params.
int createSpikeGeneratorGroup(const std::string &grpName, int nNeur, int neurType)
creates a spike generator group
int getGroupNumNeurons(int grpId)
returns the number of neurons of a group specified by grpId
carlsimState_t getCARLsimState()
Returns the current CARLsim state.
Definition: carlsim.h:1259
const FILE * getLogFpDeb()
returns file pointer to debug log
int getNumNeuronsRegInh()
returns the total number of regular (Izhikevich) inhibitory neurons
int getNumNeuronsReg()
returns the total number of regular (Izhikevich) neurons
void setESTDP(int grpId, bool isSet)
Sets default E-STDP mode and parameters.
int createGroup(const std::string &grpName, int nNeur, int neurType)
creates a group of Izhikevich spiking neurons
CARLsim User Interface This class provides a user interface to the public sections of CARLsimCore sou...
Definition: carlsim.h:141
void setLogFile(const std::string &fileName)
Sets the name of the log file.
void setISTDP(int grpId, bool isSet)
Sets default I-STDP mode and parameters.
A struct to assign a timing-based E-STDP curve.
GroupNeuromodulatorInfo_t getGroupNeuromodulatorInfo(int grpId)
returns the neuromodulator information of a group specified by grpId
const FILE * getLogFpInf()
returns file pointer to info log
void resetSpikeCounter(int grpId)
reset Spike Counter to zero
short int connect(int grpId1, int grpId2, const std::string &connType, const RangeWeight &wt, float connProb, const RangeDelay &delay=RangeDelay(1), const RadiusRF &radRF=RadiusRF(-1), bool synWtType=SYN_FIXED, float mulSynFast=1.0f, float mulSynSlow=1.0f)
Connects a presynaptic to a postsynaptic group using fixed/plastic weights and a range of delay value...
#define MAX_NUM_CUDA_DEVICES
void loadSimulation(FILE *fid)
Loads a simulation (and network state) from file. The file pointer fid must point to a valid CARLsim ...
#define SYN_FIXED
void setDefaultHomeostasisParams(float homeoScale, float avgTimeScale)
Sets default homeostasis params.
void startTesting(bool updateWeights=true)
Enters a testing phase in which all weight changes are disabled.
a point in 3D space
int getGroupEndNeuronId(int grpId)
returns the last neuron id of a groupd specified by grpId
const FILE * getLogFpErr()
returns file pointer to error log
Class SpikeMonitor.
void setWeightAndWeightChangeUpdate(updateInterval_t wtANDwtChangeUpdateInterval, bool enableWtChangeDecay, float wtChangeDecay=0.9f)
Sets the weight and weight change update parameters.
void setHomeoBaseFiringRate(int grpId, float baseFiring, float baseFiringSD=0.0f)
Sets the homeostatic target firing rate (enforced through homeostatic synaptic scaling) ...
int getNumNeuronsRegExc()
returns the total number of regular (Izhikevich) excitatory neurons
void setCompartmentParameters(int grpId, float couplingUp, float couplingDown)
Sets coupling constants G_u and G_d for hte compartment.
void setDefaultSTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, stdpType_t stdpType)
sets default STDP params
void stopTesting()
Exits a testing phase, making weight changes possible again.
int getNumPostSynapses()
returns the total number of allocated post-synaptic connections in the network
void setDefaultISTDPparams(float betaLTP, float betaLTD, float lambda, float delta, stdpType_t stdpType)
sets default values for I-STDP params
int getNumNeuronsGen()
returns the total number of spike generator neurons
A struct to arrange neurons on a 3D grid (a primitive cubic Bravais lattice with cubic side length 1)...
void setNeuromodulator(int grpId, float baseDP, float tauDP, float base5HT, float tau5HT, float baseACh, float tauACh, float baseNE, float tauNE)
Sets baseline concentration and decay time constant of neuromodulators (DP, 5HT, ACh, NE) for a neuron group.
void setIntegrationMethod(integrationMethod_t method, int numStepsPerMs)
bool isExcitatoryGroup(int grpId)
returns
void setConductances(bool isSet)
Sets default values for conduction decay and rise times or disables COBA alltogether.
void setupNetwork(bool removeTempMemory=true)
build the network
bool isInhibitoryGroup(int grpId)
returns
struct to assign a pulse I-STDP curve
stdpType_t
STDP flavors.
int getMaxNumCompConnections()
Returns the maximum number of allowed compartmental connections per group.
int runNetwork(int nSec, int nMsec=0, bool printRunSummary=true, bool copyState=false)
run the simulation for time=(nSec*seconds + nMsec*milliseconds)
ConnectionMonitor * setConnectionMonitor(int grpIdPre, int grpIdPost, const std::string &fname)
Sets a connection monitor for a group, custom ConnectionMonitor class.
uint32_t getSimTimeSec()
returns
std::vector< float > getConductanceGABAa(int grpId)
gets GABAa vector of a group
int getNumNeurons()
returns the total number of allocated neurons in the network
void setSpikeRate(int grpId, PoissonRate *spikeRate, int refPeriod=1)
Sets a spike rate.
std::vector< float > getConductanceGABAb(int grpId)
gets GABAb vector of a group
void setHomeostasis(int grpId, bool isSet, float homeoScale, float avgTimeScale)
Sets custom values for implementation of homeostatic synaptic scaling.
void setSpikeCounter(int grpId, int recordDur=-1)
A SpikeCounter keeps track of the number of spikes per neuron in a group.
Class GroupMonitor.
Definition: group_monitor.h:96
std::string getGroupName(int grpId)
gets group name
std::vector< float > getConductanceAMPA(int grpId)
gets AMPA vector of a group
int getNumNeuronsGenExc()
returns the total number of excitatory spike generator neurons
int getGroupId(std::string grpName)
finds the ID of the group with name grpName
integrationMethod_t
Integration methods.
Point3D getNeuronLocation3D(int neurId)
returns the 3D location a neuron codes for
a range struct for synaptic delays
void biasWeights(short int connId, float bias, bool updateWeightRange=false)
Adds a constant bias to the weight of every synapse in the connection.
simMode_t getSimMode()
returns the current simulation mode
int getNumConnections()
Returns the number of connections (pairs of pre-post groups) in the network.
int getGroupStartNeuronId(int grpId)
returns the first neuron id of a groupd specified by grpId
Grid3D getGroupGrid3D(int grpId)
returns the 3D grid struct of a group
void setDefaultSTPparams(int neurType, float STP_U, float STP_tau_u, float STP_tau_x)
Sets default values for STP params U, tau_u, and tau_x of a neuron group (pre-synaptically) ...
int getNumSynapticConnections(short int connectionId)
returns the number of connections associated with a connection ID
void setWeight(short int connId, int neurIdPre, int neurIdPost, float weight, bool updateWeightRange=false)
Sets the weight value of a specific synapse.
int getNumPreSynapses()
returns the total number of allocated pre-synaptic connections in the network
uint32_t getSimTimeMsec()
returns
int getNumNeuronsGenInh()
returns the total number of inhibitory spike generator neurons
A struct to assign exponential STDP curves.
void setDefaultESTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, stdpType_t stdpType)
sets default values for E-STDP params
std::vector< float > getConductanceNMDA(int grpId)
gets NMDA vector of a group
CARLsim(const std::string &netName="SNN", simMode_t simMode=CPU_MODE, loggerMode_t loggerMode=USER, int ithGPU=0, int randSeed=-1)
CARLsim constructor. Creates a new instance of class CARLsim. All input arguments are optional...
Class ConnectionMonitor.
GroupMonitor * setGroupMonitor(int grpId, const std::string &fname)
Sets a group monitor for a group, custom GroupMonitor class.
void writePopWeights(std::string fname, int gIDpre, int gIDpost)
Writes population weights from gIDpre to gIDpost to file fname in binary.
simMode_t
simulation mode
void setSTP(int grpId, bool isSet, float STP_U, float STP_tau_u, float STP_tau_x)
Sets STP params U, tau_u, and tau_x of a neuron group (pre-synaptically)
a range struct for synaptic weight magnitudes
void setDefaultSaveOptions(std::string fileName, bool saveSynapseInfo)
Sets default options for save file.
void setSpikeGenerator(int grpId, SpikeGenerator *spikeGen)
Associates a SpikeGenerator object with a group.
const FILE * getLogFpLog()
returns file pointer to log file
updateInterval_t
Update frequency for weights.
A struct for retrieving STDP related information of a group.
GroupSTDPInfo_t getGroupSTDPInfo(int grpId)
returns the stdp information of a group specified by grpId
RangeDelay getDelayRange(short int connId)
returns the RangeDelay struct for a specific connection ID
SpikeMonitor * setSpikeMonitor(int grpId, const std::string &fileName)
Sets a Spike Monitor for a groups, prints spikes to binary file.
int * getSpikeCounter(int grpId)
Returns the number of spikes per neuron for a certain group.
SpikeMonitor * getSpikeMonitor(int grpId)
returns pointer to previously allocated SpikeMonitor object, NULL else
bool isConnectionPlastic(short int connId)
Returns whether a connection is fixed or plastic.
short int connectCompartments(int grpIdLower, int grpIdUpper)
make a compartmental connection between two compartmentally enabled groups
uint64_t getSimTime()
returns
bool isPoissonGroup(int grpId)
returns
uint8_t * getDelays(int gIDpre, int gIDpost, int &Npre, int &Npost, uint8_t *delays=NULL)
gets delays
User mode, for experiment-oriented simulations.
carlsimState_t
CARLsim states.
void setLogsFpCustom(FILE *fpInf=NULL, FILE *fpErr=NULL, FILE *fpDeb=NULL, FILE *fpLog=NULL)
Sets the file pointers for all log files in CUSTOM mode.
RangeWeight getWeightRange(short int connId)
returns the RangeWeight struct for a specific connection ID
void setNeuronParameters(int grpId, float izh_a, float izh_a_sd, float izh_b, float izh_b_sd, float izh_c, float izh_c_sd, float izh_d, float izh_d_sd)
Sets Izhikevich params a, b, c, and d with as mean +- standard deviation.
void scaleWeights(short int connId, float scale, bool updateWeightRange=false)
Multiplies the weight of every synapse in the connection with a scaling factor.
void saveSimulation(const std::string &fileName, bool saveSynapseInfo=true)
Saves important simulation and network infos to file.
void setExternalCurrent(int grpId, const std::vector< float > &current)
Sets the amount of current (mA) to inject into a group.
loggerMode_t
Logger modes.
A struct to specify the receptive field (RF) radius in 3 dimensions.
bool isGroupWithHomeostasis(int grpId)
Returns whether a group has homeostasis enabled.