CARLsim  4.1.0
CARLsim: a GPU-accelerated SNN simulator
carlsim.cpp
Go to the documentation of this file.
1 /* * Copyright (c) 2016 Regents of the University of California. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions
5 * are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * 3. The names of its contributors may not be used to endorse or promote
15 * products derived from this software without specific prior written
16 * permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * *********************************************************************************************** *
31 * CARLsim
32 * created by: (MDR) Micah Richert, (JN) Jayram M. Nageswaran
33 * maintained by:
34 * (MA) Mike Avery <averym@uci.edu>
35 * (MB) Michael Beyeler <mbeyeler@uci.edu>,
36 * (KDC) Kristofor Carlson <kdcarlso@uci.edu>
37 * (TSC) Ting-Shuo Chou <tingshuc@uci.edu>
38 * (HK) Hirak J Kashyap <kashyaph@uci.edu>
39 *
40 * CARLsim v1.0: JM, MDR
41 * CARLsim v2.0/v2.1/v2.2: JM, MDR, MA, MB, KDC
42 * CARLsim3: MB, KDC, TSC
43 * CARLsim4: TSC, HK
44 *
45 * CARLsim available from http://socsci.uci.edu/~jkrichma/CARLsim/
46 * Ver 12/31/2016
47 */
48 
49 #include <carlsim.h>
50 #include <user_errors.h>
51 
52 //#include <callback.h>
53 
54 
55 
56 #include <callback_core.h>
57 
58 #include <iostream> // std::cout, std::endl
59 #include <sstream> // std::stringstream
60 #include <algorithm> // std::find, std::transform
61 
62 #include <snn.h>
63 
64 // includes for mkdir
65 #if CREATE_SPIKEDIR_IF_NOT_EXISTS
66  #if defined(WIN32) || defined(WIN64)
67  #else
68  #include <sys/stat.h>
69  #include <errno.h>
70  #include <libgen.h>
71  #endif
72 #endif
73 
74 // NOTE: Conceptual code documentation should go in carlsim.h. Do not include extensive high-level documentation here,
75 // but do document your code.
76 
77 
78 
80 public:
81  // +++++ PUBLIC METHODS: SETUP / TEAR-DOWN ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
82 
83  Impl(CARLsim* sim, const std::string& netName, SimMode prferredSimMode, LoggerMode loggerMode, int randSeed) {
84  netName_ = netName;
85  loggerMode_ = loggerMode;
86  preferredSimMode_ = prferredSimMode;
87  randSeed_ = randSeed;
88  enablePrint_ = false;
89  copyState_ = false;
90 
91  numConnections_ = 0;
92 
93  hasSetHomeoALL_ = false;
94  hasSetHomeoBaseFiringALL_ = false;
95  hasSetSTDPALL_ = false;
96  hasSetSTPALL_ = false;
97  hasSetConductances_ = false;
98  carlsimState_ = CONFIG_STATE;
99 
100  sim_ = sim;
101  snn_ = NULL;
102 
103  CARLsimInit(); // move everything else out of constructor
104  }
105 
106  ~Impl() {
107  // save simulation
108  if (carlsimState_ == SETUP_STATE || carlsimState_ == RUN_STATE)
109  saveSimulation(def_save_fileName_,def_save_synapseInfo_);
110 
111  // deallocate all dynamically allocated structures
112  for (int i=0; i<spkGen_.size(); i++) {
113  if (spkGen_[i]!=NULL)
114  delete spkGen_[i];
115  spkGen_[i]=NULL;
116  }
117  for (int i=0; i<connGen_.size(); i++) {
118  if (connGen_[i]!=NULL)
119  delete connGen_[i];
120  connGen_[i]=NULL;
121  }
122  if (snn_!=NULL)
123  delete snn_;
124  snn_=NULL;
125  }
126 
127 
128  // +++++++++ PUBLIC METHODS: SETTING UP A SIMULATION ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
129 
130  // Connects a presynaptic to a postsynaptic group using one of the primitive types
131  short int connect(int grpId1, int grpId2, const std::string& connType, const RangeWeight& wt, float connProb,
132  const RangeDelay& delay, const RadiusRF& radRF, bool synWtType, float mulSynFast, float mulSynSlow)
133  {
134  std::string funcName = "connect(\""+getGroupName(grpId1)+"\",\""+getGroupName(grpId2)+"\")";
135  std::stringstream grpId1str; grpId1str << "Group Id " << grpId1;
136  std::stringstream grpId2str; grpId2str << "Group Id " << grpId2;
137  UserErrors::assertTrue(grpId1!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, grpId1str.str()); // grpId can't be ALL
138  UserErrors::assertTrue(grpId2!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, grpId2str.str());
139  UserErrors::assertTrue(!isPoissonGroup(grpId2), UserErrors::WRONG_NEURON_TYPE, funcName, grpId2str.str() +
140  " is PoissonGroup, connect");
141  UserErrors::assertTrue(wt.max>=0.0f, UserErrors::CANNOT_BE_NEGATIVE, funcName, "wt.max");
142  UserErrors::assertTrue(wt.min>=0.0f, UserErrors::CANNOT_BE_NEGATIVE, funcName, "wt.min");
143  UserErrors::assertTrue(wt.init>=0.0f, UserErrors::CANNOT_BE_NEGATIVE, funcName, "wt.init");
144  UserErrors::assertTrue(connProb>=0.0f && connProb<=1.0f, UserErrors::MUST_BE_IN_RANGE, funcName,
145  "Connection Probability connProb", "[0,1]");
146  UserErrors::assertTrue(delay.min>0, UserErrors::MUST_BE_POSITIVE, funcName, "delay.min");
147  UserErrors::assertTrue(connType.compare("one-to-one")!=0
148  || connType.compare("one-to-one")==0 && getGroupNumNeurons(grpId1) == getGroupNumNeurons(grpId2),
149  UserErrors::MUST_BE_IDENTICAL, funcName, "For type \"one-to-one\", number of neurons in pre and post");
150  UserErrors::assertTrue(connType.compare("gaussian")!=0
151  || connType.compare("gaussian")==0 && (radRF.radX>-1 || radRF.radY>-1 || radRF.radZ>-1),
152  UserErrors::CANNOT_BE_NEGATIVE, funcName, "Receptive field radius for type \"gaussian\"");
153  UserErrors::assertTrue(synWtType==SYN_PLASTIC || synWtType==SYN_FIXED && wt.init==wt.max,
154  UserErrors::MUST_BE_IDENTICAL, funcName, "For fixed synapses, initWt and maxWt");
155  UserErrors::assertTrue(mulSynFast>=0.0f, UserErrors::CANNOT_BE_NEGATIVE, funcName, "mulSynFast");
156  UserErrors::assertTrue(mulSynSlow>=0.0f, UserErrors::CANNOT_BE_NEGATIVE, funcName, "mulSynSlow");
157 
159  "CONFIG.");
160  assert(++numConnections_ <= MAX_CONN_PER_SNN);
161 
162  // throw a warning if "one-to-one" is used in combination with a non-zero RF
163  if (connType.compare("one-to-one")==0 && (radRF.radX>0 || radRF.radY>0 || radRF.radZ>0)) {
164  userWarnings_.push_back("RadiusRF>0 will be ignored for connection type \"one-to-one\"");
165  }
166 
167  // TODO: enable support for non-zero min
168  if (fabs(wt.min)>1e-15) {
169  std::cerr << funcName << ": " << wt << ". Non-zero minimum weights are not yet supported.\n" << std::endl;
170  assert(false);
171  }
172 
173  // groups cannot be both chemically (synaptically) and electrically (compartmentally) connected
174  UserErrors::assertTrue(std::find(connComp_[grpId1].begin(), connComp_[grpId1].end(), grpId2) ==
175  connComp_[grpId1].end(), UserErrors::CANNOT_BE_CONN_SYN_AND_COMP, funcName,
176  grpId1str.str() + " and " + grpId2str.str());
177 
178  UserErrors::assertTrue(std::find(connComp_[grpId2].begin(), connComp_[grpId2].end(), grpId1) ==
179  connComp_[grpId2].end(), UserErrors::CANNOT_BE_CONN_SYN_AND_COMP, funcName,
180  grpId1str.str() + " and " + grpId2str.str());
181 
182  // add synaptic connection to 2D matrix
183  connSyn_[grpId1].push_back(grpId2);
184 
185  return snn_->connect(grpId1, grpId2, connType, wt.init, wt.max, connProb, delay.min, delay.max,
186  radRF, mulSynFast, mulSynSlow, synWtType);
187  }
188 
189  // custom connectivity profile
190  short int connect(int grpId1, int grpId2, ConnectionGenerator* conn, bool synWtType) {
191  std::string funcName = "connect(\""+getGroupName(grpId1)+"\",\""+getGroupName(grpId2)+"\")";
192  std::stringstream grpId1str; grpId1str << ". Group Id " << grpId1;
193  std::stringstream grpId2str; grpId2str << ". Group Id " << grpId2;
194  UserErrors::assertTrue(grpId1!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, grpId1str.str()); // grpId can't be ALL
195  UserErrors::assertTrue(grpId2!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, grpId2str.str());
196  UserErrors::assertTrue(!isPoissonGroup(grpId2), UserErrors::WRONG_NEURON_TYPE, funcName, grpId2str.str() +
197  " is PoissonGroup, connect");
198  UserErrors::assertTrue(conn!=NULL, UserErrors::CANNOT_BE_NULL, funcName, "ConnectionGenerator* conn");
199 
200  UserErrors::assertTrue(carlsimState_==CONFIG_STATE, UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "CONFIG.");
201  assert(++numConnections_ <= MAX_CONN_PER_SNN);
202 
203  // groups cannot be both chemically (synaptically) and electrically (compartmentally) connected
204  UserErrors::assertTrue(std::find(connComp_[grpId1].begin(), connComp_[grpId1].end(), grpId2) ==
205  connComp_[grpId1].end(), UserErrors::CANNOT_BE_CONN_SYN_AND_COMP, funcName,
206  grpId1str.str() + " and " + grpId2str.str());
207  UserErrors::assertTrue(std::find(connComp_[grpId2].begin(), connComp_[grpId2].end(), grpId1) ==
208  connComp_[grpId2].end(), UserErrors::CANNOT_BE_CONN_SYN_AND_COMP, funcName,
209  grpId1str.str() + " and " + grpId2str.str());
210 
211  // add synaptic connection to 2D matrix
212  connSyn_[grpId1].push_back(grpId2);
213 
214  // TODO: check for sign of weights
215  // ConnectionGeneratorCore* CGC = new ConnectionGeneratorCore(this, conn);
216  ConnectionGeneratorCore* CGC = new ConnectionGeneratorCore(sim_, conn);
217  connGen_.push_back(CGC);
218  return snn_->connect(grpId1, grpId2, CGC, 1.0f, 1.0f, synWtType);
219  }
220 
221  // custom connectivity profile
222  short int connect(int grpId1, int grpId2, ConnectionGenerator* conn, float mulSynFast, float mulSynSlow,
223  bool synWtType)
224  {
225  std::string funcName = "connect(\""+getGroupName(grpId1)+"\",\""+getGroupName(grpId2)+"\")";
226  std::stringstream grpId1str; grpId1str << ". Group Id " << grpId1;
227  std::stringstream grpId2str; grpId2str << ". Group Id " << grpId2;
228  UserErrors::assertTrue(grpId1!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, grpId1str.str()); // grpId can't be ALL
229  UserErrors::assertTrue(grpId2!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, grpId2str.str());
230  UserErrors::assertTrue(!isPoissonGroup(grpId2), UserErrors::WRONG_NEURON_TYPE, funcName, grpId2str.str() +
231  " is PoissonGroup, connect");
232  UserErrors::assertTrue(conn!=NULL, UserErrors::CANNOT_BE_NULL, funcName);
233  UserErrors::assertTrue(mulSynFast>=0.0f, UserErrors::CANNOT_BE_NEGATIVE, funcName, "mulSynFast");
234  UserErrors::assertTrue(mulSynSlow>=0.0f, UserErrors::CANNOT_BE_NEGATIVE, funcName, "mulSynSlow");
236  funcName, "CONFIG.");
237  assert(++numConnections_ <= MAX_CONN_PER_SNN);
238 
239  // groups cannot be both chemically (synaptically) and electrically (compartmentally) connected
240  UserErrors::assertTrue(std::find(connComp_[grpId1].begin(), connComp_[grpId1].end(), grpId2) ==
241  connComp_[grpId1].end(), UserErrors::CANNOT_BE_CONN_SYN_AND_COMP, funcName,
242  grpId1str.str() + " and " + grpId2str.str());
243  UserErrors::assertTrue(std::find(connComp_[grpId2].begin(), connComp_[grpId2].end(), grpId1) ==
244  connComp_[grpId2].end(), UserErrors::CANNOT_BE_CONN_SYN_AND_COMP, funcName,
245  grpId1str.str() + " and " + grpId2str.str());
246 
247  // add synaptic connection to 2D matrix
248  connSyn_[grpId1].push_back(grpId2);
249 
250  // ConnectionGeneratorCore* CGC = new ConnectionGeneratorCore(this, conn);
251  ConnectionGeneratorCore* CGC = new ConnectionGeneratorCore(sim_, conn);
252  connGen_.push_back(CGC);
253  return snn_->connect(grpId1, grpId2, CGC, mulSynFast, mulSynSlow, synWtType);
254  }
255 
256  short int connectCompartments(int grpIdLower, int grpIdUpper) {
257  std::stringstream funcName; funcName << "connectCompartments(" << grpIdLower << "," << grpIdUpper << ")";
258 
259  // grpIDs must be valid, cannot be identical
260  std::stringstream grpIdLowerStr; grpIdLowerStr << "Group Id " << grpIdLower;
261  std::stringstream grpIdUpperStr; grpIdUpperStr << "Group Id " << grpIdUpper;
262  UserErrors::assertTrue(grpIdLower >= 0 && grpIdLower<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
263  grpIdLowerStr.str(), "[0,getNumGroups()]");
264  UserErrors::assertTrue(grpIdUpper >= 0 && grpIdUpper<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
265  grpIdUpperStr.str(), "[0,getNumGroups()]");
266  UserErrors::assertTrue(grpIdLower != grpIdUpper, UserErrors::CANNOT_BE_IDENTICAL, funcName.str(),
267  grpIdLowerStr.str() + " and " + grpIdUpperStr.str());
268 
269  // groups cannot be spike generators
271  grpIdLowerStr.str() + " is PoissonGroup, connectCompartments");
273  grpIdUpperStr.str() + " is PoissonGroup, connectCompartments");
274 
275  // groups must have the same size
277  UserErrors::MUST_BE_IDENTICAL, funcName.str(), "Sizes of " + grpIdLowerStr.str() + " and " +
278  grpIdUpperStr.str());
279 
280  // groups must be located on the same partition
281  UserErrors::assertTrue(groupPrefNetIds_.at(grpIdLower) == groupPrefNetIds_.at(grpIdUpper),
282  UserErrors::MUST_BE_IDENTICAL, funcName.str(), "Preferred partions of " + grpIdLowerStr.str() + " and " +
283  grpIdUpperStr.str());
284 
285  // groups cannot be both chemically (synaptically) and electrically (compartmentally) connected
286  UserErrors::assertTrue(std::find(connSyn_[grpIdLower].begin(), connSyn_[grpIdLower].end(), grpIdUpper) ==
287  connSyn_[grpIdLower].end(), UserErrors::CANNOT_BE_CONN_SYN_AND_COMP, funcName.str(),
288  grpIdLowerStr.str() + " and " + grpIdUpperStr.str());
289  UserErrors::assertTrue(std::find(connSyn_[grpIdUpper].begin(), connSyn_[grpIdUpper].end(), grpIdLower) ==
290  connSyn_[grpIdUpper].end(), UserErrors::CANNOT_BE_CONN_SYN_AND_COMP, funcName.str(),
291  grpIdLowerStr.str() + " and " + grpIdUpperStr.str());
292 
293  // groups cannot be connected twice (order doesn't matter)
294  UserErrors::assertTrue(std::find(connComp_[grpIdLower].begin(), connComp_[grpIdLower].end(), grpIdUpper) ==
295  connComp_[grpIdLower].end(), UserErrors::CANNOT_BE_CONN_TWICE, funcName.str(),
296  grpIdLowerStr.str() + " and " + grpIdUpperStr.str());
297  UserErrors::assertTrue(std::find(connComp_[grpIdUpper].begin(), connComp_[grpIdUpper].end(), grpIdLower) ==
298  connComp_[grpIdUpper].end(), UserErrors::CANNOT_BE_CONN_TWICE, funcName.str(),
299  grpIdLowerStr.str() + " and " + grpIdUpperStr.str());
300 
301  // groups can have at most getMaxNumCompConnections() connections
303  funcName.str(), "Number of compartmental connections for group " + grpIdLowerStr.str(),
304  "[0,getMaxNumCompConnections()");
306  funcName.str(), "Number of compartmental connections for group " + grpIdUpperStr.str(),
307  "[0,getMaxNumCompConnections()");
308 
309  // add compartment connection to 2D matrix (both ways)
310  connComp_[grpIdLower].push_back(grpIdUpper);
311  connComp_[grpIdUpper].push_back(grpIdLower);
312 
313  return snn_->connectCompartments(grpIdLower, grpIdUpper);
314  }
315 
316  // create group of Izhikevich spiking neurons on 1D grid
317  int createGroup(const std::string& grpName, int nNeur, int neurType, int preferredPartition, ComputingBackend preferredBackend) {
318  return createGroup(grpName, Grid3D(nNeur,1,1), neurType, preferredPartition, preferredBackend);
319  }
320 
321  // create group of LIF spiking neurons on 1D grid
322  int createGroupLIF(const std::string& grpName, int nNeur, int neurType, int preferredPartition = ANY, ComputingBackend preferredBackend = CPU_CORES){
323  return createGroupLIF(grpName, Grid3D(nNeur,1,1), neurType, preferredPartition, preferredBackend);
324  }
325 
326  // create a group of Izhikevich spiking neurons on 3D grid
327  int createGroup(const std::string& grpName, const Grid3D& grid, int neurType, int preferredPartition, ComputingBackend preferredBackend) {
328  std::string funcName = "createGroup(\""+grpName+"\")";
330  funcName, "CONFIG.");
331  UserErrors::assertTrue(grid.numX>0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grid.numX");
332  UserErrors::assertTrue(grid.numY>0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grid.numY");
333  UserErrors::assertTrue(grid.numZ>0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grid.numZ");
334 
335  // if user has called any set functions with grpId=ALL, and is now adding another group, previously set properties
336  // will not apply to newly added group
337  if (hasSetSTPALL_)
338  userWarnings_.push_back("Make sure to call setSTP on group "+grpName);
339  if (hasSetSTDPALL_)
340  userWarnings_.push_back("Make sure to call setSTDP on group "+grpName);
341  if (hasSetHomeoALL_)
342  userWarnings_.push_back("Make sure to call setHomeostasis on group "+grpName);
343  if (hasSetHomeoBaseFiringALL_)
344  userWarnings_.push_back("Make sure to call setHomeoBaseFiringRate on group "+grpName);
345 
346  int grpId = snn_->createGroup(grpName.c_str(), grid, neurType, preferredPartition, preferredBackend);
347  grpIds_.push_back(grpId); // keep track of all groups
348 
349  int partitionOffset = 0;
350  if (preferredBackend == CPU_CORES)
351  partitionOffset = MAX_NUM_CUDA_DEVICES;
352  else if (preferredBackend == GPU_CORES)
353  partitionOffset = 0;
354  int prefPartition = preferredPartition + partitionOffset;
355  groupPrefNetIds_.insert(std::pair<int, int>(grpId, prefPartition));
356 
357  // extend 2D connection matrices to number of groups
358  connSyn_.resize(grpIds_.size());
359  connComp_.resize(grpIds_.size());
360 
361  return grpId;
362  }
363 
364  // create a group of LIF spiking neurons on 3D grid
365  int createGroupLIF(const std::string& grpName, const Grid3D& grid, int neurType, int preferredPartition, ComputingBackend preferredBackend) {
366  std::string funcName = "createGroupLIF(\""+grpName+"\")";
368  funcName, "CONFIG.");
369  UserErrors::assertTrue(grid.numX>0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grid.numX");
370  UserErrors::assertTrue(grid.numY>0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grid.numY");
371  UserErrors::assertTrue(grid.numZ>0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grid.numZ");
372 
373  // if user has called any set functions with grpId=ALL, and is now adding another group, previously set properties
374  // will not apply to newly added group
375  if (hasSetSTPALL_)
376  userWarnings_.push_back("Make sure to call setSTP on group "+grpName);
377  if (hasSetSTDPALL_)
378  userWarnings_.push_back("Make sure to call setSTDP on group "+grpName);
379  if (hasSetHomeoALL_)
380  userWarnings_.push_back("Make sure to call setHomeostasis on group "+grpName);
381  if (hasSetHomeoBaseFiringALL_)
382  userWarnings_.push_back("Make sure to call setHomeoBaseFiringRate on group "+grpName);
383 
384  int grpId = snn_->createGroupLIF(grpName.c_str(), grid, neurType, preferredPartition, preferredBackend);
385  grpIds_.push_back(grpId); // keep track of all groups
386 
387  int partitionOffset = 0;
388  if (preferredBackend == CPU_CORES)
389  partitionOffset = MAX_NUM_CUDA_DEVICES;
390  else if (preferredBackend == GPU_CORES)
391  partitionOffset = 0;
392  int prefPartition = preferredPartition + partitionOffset;
393  groupPrefNetIds_.insert(std::pair<int, int>(grpId, prefPartition));
394 
395  // extend 2D connection matrices to number of groups
396  connSyn_.resize(grpIds_.size());
397  connComp_.resize(grpIds_.size());
398 
399  return grpId;
400  }
401 
402  // create group of spike generators on 1D grid
403  int createSpikeGeneratorGroup(const std::string& grpName, int nNeur, int neurType, int preferredPartition, ComputingBackend preferredBackend) {
404  return createSpikeGeneratorGroup(grpName, Grid3D(nNeur,1,1), neurType, preferredPartition, preferredBackend);
405  }
406 
407  // create group of spike generators on 3D grid
408  int createSpikeGeneratorGroup(const std::string& grpName, const Grid3D& grid, int neurType, int preferredPartition, ComputingBackend preferredBackend) {
409  std::string funcName = "createSpikeGeneratorGroup(\""+grpName+"\")";
411  funcName, "CONFIG.");
412  UserErrors::assertTrue(grid.numX>0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grid.numX");
413  UserErrors::assertTrue(grid.numY>0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grid.numY");
414  UserErrors::assertTrue(grid.numZ>0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grid.numZ");
415 
416  int grpId = snn_->createSpikeGeneratorGroup(grpName.c_str(),grid,neurType, preferredPartition, preferredBackend);
417  grpIds_.push_back(grpId); // keep track of all groups
418 
419  // extend 2D connection matrices to number of groups
420  connSyn_.resize(grpIds_.size());
421  connComp_.resize(grpIds_.size());
422 
423  return grpId;
424  }
425 
426  void setCompartmentParameters(int grpId, float couplingUp, float couplingDown) {
427  std::string funcName = "setCompartmentParameters(\"" + getGroupName(grpId) + "\")";
429  "CONFIG.");
430 
431  snn_->setCompartmentParameters(grpId, couplingUp, couplingDown);
432  }
433 
434 
435  // set conductance values, use defaults
436  void setConductances(bool isSet) {
437  std::stringstream funcName; funcName << "setConductances(" << isSet << ")";
439  funcName.str(), "CONFIG.");
440  hasSetConductances_ = true;
441 
442  if (isSet) { // enable conductances, use default values
443  snn_->setConductances(true,def_tdAMPA_,0,def_tdNMDA_,def_tdGABAa_,0,def_tdGABAb_);
444  } else { // disable conductances
445  snn_->setConductances(false,0,0,0,0,0,0);
446  }
447  }
448 
449  // set conductances values, CUSTOM
450  void setConductances(bool isSet, int tdAMPA, int tdNMDA, int tdGABAa, int tdGABAb) {
451  std::stringstream funcName; funcName << "setConductances(" << isSet << "," << tdAMPA << "," << tdNMDA << ","
452  << tdGABAa << "," << tdGABAb << ")";
453  UserErrors::assertTrue(!isSet||tdAMPA>0, UserErrors::MUST_BE_POSITIVE, funcName.str(), "tdAMPA");
454  UserErrors::assertTrue(!isSet||tdNMDA>0, UserErrors::MUST_BE_POSITIVE, funcName.str(), "tdNMDA");
455  UserErrors::assertTrue(!isSet||tdGABAa>0, UserErrors::MUST_BE_POSITIVE, funcName.str(), "tdGABAa");
456  UserErrors::assertTrue(!isSet||tdGABAb>0, UserErrors::MUST_BE_POSITIVE, funcName.str(), "trGABAb");
458  funcName.str(),"CONFIG.");
459  hasSetConductances_ = true;
460 
461  if (isSet) { // enable conductances, use custom values
462  snn_->setConductances(true,tdAMPA,0,tdNMDA,tdGABAa,0,tdGABAb);
463  } else { // disable conductances
464  snn_->setConductances(false,0,0,0,0,0,0);
465  }
466  }
467 
468  // set conductances values, custom
469  void setConductances(bool isSet, int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb,
470  int tdGABAb)
471  {
472  std::stringstream funcName; funcName << "setConductances(" << isSet << "," << tdAMPA << "," << trNMDA << "," <<
473  tdNMDA << "," << tdGABAa << "," << trGABAb << "," << tdGABAb << ")";
474  UserErrors::assertTrue(!isSet||tdAMPA>0, UserErrors::MUST_BE_POSITIVE, funcName.str(), "tdAMPA");
475  UserErrors::assertTrue(!isSet||trNMDA>=0, UserErrors::CANNOT_BE_NEGATIVE, funcName.str(), "trNMDA");
476  UserErrors::assertTrue(!isSet||tdNMDA>0, UserErrors::MUST_BE_POSITIVE, funcName.str(), "tdNMDA");
477  UserErrors::assertTrue(!isSet||tdGABAa>0, UserErrors::MUST_BE_POSITIVE, funcName.str(), "tdGABAa");
478  UserErrors::assertTrue(!isSet||trGABAb>=0, UserErrors::CANNOT_BE_NEGATIVE, funcName.str(), "trGABAb");
479  UserErrors::assertTrue(!isSet||tdGABAb>0, UserErrors::MUST_BE_POSITIVE, funcName.str(), "trGABAb");
480  UserErrors::assertTrue(trNMDA!=tdNMDA, UserErrors::CANNOT_BE_IDENTICAL, funcName.str(), "trNMDA and tdNMDA");
481  UserErrors::assertTrue(trGABAb!=tdGABAb, UserErrors::CANNOT_BE_IDENTICAL, funcName.str(),
482  "trGABAb and tdGABAb");
484  funcName.str(), "CONFIG.");
485  hasSetConductances_ = true;
486 
487  if (isSet) { // enable conductances, use custom values
488  snn_->setConductances(true,tdAMPA,trNMDA,tdNMDA,tdGABAa,trGABAb,tdGABAb);
489  } else { // disable conductances
490  snn_->setConductances(false,0,0,0,0,0,0);
491  }
492  }
493 
494  // set default homeostasis params
495  void setHomeostasis(int grpId, bool isSet) {
496  std::string funcName = "setHomeostasis(\""+getGroupName(grpId)+"\")";
497  UserErrors::assertTrue(!isSet || isSet && !isPoissonGroup(grpId), UserErrors::WRONG_NEURON_TYPE, funcName,
498  funcName);
500  funcName, "CONFIG.");
501 
502  hasSetHomeoALL_ = grpId==ALL; // adding groups after this will not have homeostasis set
503 
504  if (isSet) { // enable homeostasis, use default values
505  snn_->setHomeostasis(grpId,true,def_homeo_scale_,def_homeo_avgTimeScale_);
506  if (grpId!=ALL && hasSetHomeoBaseFiringALL_)
507  userWarnings_.push_back("Make sure to call setHomeoBaseFiringRate on group "
508  + getGroupName(grpId));
509  } else { // disable conductances
510  snn_->setHomeostasis(grpId,false,0.0f,0.0f);
511  }
512  }
513 
514  // set custom homeostasis params for group
515  void setHomeostasis(int grpId, bool isSet, float homeoScale, float avgTimeScale) {
516  std::string funcName = "setHomeostasis(\""+getGroupName(grpId)+"\")";
517  UserErrors::assertTrue(!isSet || isSet && !isPoissonGroup(grpId), UserErrors::WRONG_NEURON_TYPE, funcName,
518  funcName);
520  "CONFIG.");
521 
522  hasSetHomeoALL_ = grpId==ALL; // adding groups after this will not have homeostasis set
523 
524  if (isSet) { // enable homeostasis, use default values
525  snn_->setHomeostasis(grpId,true,homeoScale,avgTimeScale);
526  if (grpId!=ALL && hasSetHomeoBaseFiringALL_)
527  userWarnings_.push_back("Make sure to call setHomeoBaseFiringRate on group "
528  + getGroupName(grpId));
529  } else { // disable conductances
530  snn_->setHomeostasis(grpId,false,0.0f,0.0f);
531  }
532  }
533 
534  // set a homeostatic target firing rate (enforced through homeostatic synaptic scaling)
535  void setHomeoBaseFiringRate(int grpId, float baseFiring, float baseFiringSD) {
536  std::string funcName = "setHomeoBaseFiringRate(\""+getGroupName(grpId)+"\")";
539  funcName, " Must call setHomeostasis first.");
541  "CONFIG.");
542 
543  hasSetHomeoBaseFiringALL_ = grpId==ALL; // adding groups after this will not have base firing set
544 
545  snn_->setHomeoBaseFiringRate(grpId, baseFiring, baseFiringSD);
546  }
547 
548  // sets integration method (FORWARD_EULER, RUNGE_KUTTA4, etc.) and integration step
549  void setIntegrationMethod(integrationMethod_t method, int numStepsPerMs) {
550  std::string funcName = "setIntegrationMethod()";
552  "CONFIG.");
553  UserErrors::assertTrue((numStepsPerMs >= 1) && (numStepsPerMs <= 100), UserErrors::MUST_BE_IN_RANGE, funcName,
554  "numStepsPerMs", "[1, 100]");
555 
556  snn_->setIntegrationMethod(method, numStepsPerMs);
557 
558  //std::cout << "numStepsPerMs is (in interface): " + numStepsPerMs << std::endl;
559  }
560 
561  // set neuron parameters for Izhikevich neuron, with standard deviations
562  void setNeuronParameters(int grpId, float izh_a, float izh_a_sd, float izh_b, float izh_b_sd,
563  float izh_c, float izh_c_sd, float izh_d, float izh_d_sd)
564  {
565  std::string funcName = "setNeuronParameters(\""+getGroupName(grpId)+"\")";
568  "CONFIG.");
569 
570  // wrapper identical to core func
571  snn_->setNeuronParameters(grpId, izh_a, izh_a_sd, izh_b, izh_b_sd, izh_c, izh_c_sd, izh_d, izh_d_sd);
572  }
573 
574  // set neuron parameters for Izhikevich neuron
575  void setNeuronParameters(int grpId, float izh_a, float izh_b, float izh_c, float izh_d) {
576  std::string funcName = "setNeuronParameters(\""+getGroupName(grpId)+"\")";
579  funcName, "CONFIG.");
580 
581  // set standard deviations of Izzy params to zero
582  snn_->setNeuronParameters(grpId, izh_a, 0.0f, izh_b, 0.0f, izh_c, 0.0f, izh_d, 0.0f);
583  }
584 
585  void setNeuronParameters(int grpId, float izh_C, float izh_k, float izh_vr, float izh_vt,
586  float izh_a, float izh_b, float izh_vpeak, float izh_c, float izh_d)
587  {
588  std::string funcName = "setNeuronParameters(\"" + getGroupName(grpId) + "\")";
590  UserErrors::assertTrue(carlsimState_ == CONFIG_STATE, UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "CONFIG.");
591  UserErrors::assertTrue(izh_C > 0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "izh_C");
592 
593  // set standard deviations of Izzy params to zero
594  snn_->setNeuronParameters(grpId, izh_C, 0.0f, izh_k, 0.0f, izh_vr, 0.0f, izh_vt, 0.0f,
595  izh_a, 0.0f, izh_b, 0.0f, izh_vpeak, 0.0f, izh_c, 0.0f, izh_d, 0.0f);
596  }
597 
598 
599  void setNeuronParameters(int grpId, float izh_C, float izh_C_sd, float izh_k, float izh_k_sd,
600  float izh_vr, float izh_vr_sd, float izh_vt, float izh_vt_sd,
601  float izh_a, float izh_a_sd, float izh_b, float izh_b_sd,
602  float izh_vpeak, float izh_vpeak_sd, float izh_c, float izh_c_sd,
603  float izh_d, float izh_d_sd)
604  {
605  std::string funcName = "setNeuronParameters(\"" + getGroupName(grpId) + "\")";
607  UserErrors::assertTrue(carlsimState_ == CONFIG_STATE, UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "CONFIG.");
608  UserErrors::assertTrue(izh_C > 0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "izh_C");
609 
610  // wrapper identical to core func
611  snn_->setNeuronParameters(grpId, izh_C, izh_C_sd, izh_k, izh_k_sd, izh_vr, izh_vr_sd, izh_vt, izh_vt_sd,
612  izh_a, izh_a_sd, izh_b, izh_b_sd, izh_vpeak, izh_vpeak_sd, izh_c, izh_c_sd, izh_d, izh_d_sd);
613  }
614 
615  // set neuron parameters for LIF spiking neuron
616  void setNeuronParametersLIF(int grpId, int tau_m, int tau_ref, float vTh, float vReset, const RangeRmem& rMem)
617  {
618  std::string funcName = "setNeuronParametersLIF(\"" + getGroupName(grpId) + "\")";
620  UserErrors::assertTrue(carlsimState_ == CONFIG_STATE, UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "CONFIG.");
621 
622  UserErrors::assertTrue(tau_m >= 0 , UserErrors::CANNOT_BE_NEGATIVE, funcName, "tau_m");
623  UserErrors::assertTrue(tau_ref >= 0 , UserErrors::CANNOT_BE_NEGATIVE, funcName, "tau_ref");
624 
625  UserErrors::assertTrue(vReset < vTh , UserErrors::CANNOT_BE_LARGER, funcName, "vReset");
626 
627  UserErrors::assertTrue(rMem.minRmem >= 0.0f , UserErrors::CANNOT_BE_NEGATIVE, funcName, "rangeRmem.minRmem");
628  UserErrors::assertTrue(rMem.minRmem <= rMem.maxRmem , UserErrors::CANNOT_BE_LARGER, funcName, "rangeRmem.minRmem");
629 
630  // wrapper identical to core func
631  snn_->setNeuronParametersLIF(grpId, tau_m, tau_ref, vTh, vReset,rMem.minRmem, rMem.maxRmem);
632  }
633 
634  // set parameters for each neuronmodulator
635  void setNeuromodulator(int grpId, float baseDP, float tauDP, float base5HT, float tau5HT, float baseACh,
636  float tauACh, float baseNE, float tauNE)
637  {
638  std::string funcName = "setNeuromodulator(\""+getGroupName(grpId)+"\")";
648  funcName, "CONFIG.");
649 
650  snn_->setNeuromodulator(grpId, baseDP, tauDP, base5HT, tau5HT, baseACh, tauACh, baseNE, tauNE);
651  }
652 
653  void setNeuromodulator(int grpId,float tauDP, float tau5HT, float tauACh, float tauNE) {
654  std::string funcName = "setNeuromodulator(\""+getGroupName(grpId)+"\")";
660  funcName, "CONFIG.");
661 
662  snn_->setNeuromodulator(grpId, 1.0f, tauDP, 1.0f, tau5HT, 1.0f, tauACh, 1.0f, tauNE);
663  }
664 
665  // set STDP, default, wrapper function
666  void setSTDP(int grpId, bool isSet) {
667  setESTDP(grpId, isSet);
668  }
669 
670  // set STDP, custom, wrapper function
671  void setSTDP(int grpId, bool isSet, STDPType type, float alphaPlus, float tauPlus, float alphaMinus,
672  float tauMinus)
673  {
674  setESTDP(grpId, isSet, type, ExpCurve(alphaPlus, tauPlus, alphaMinus, tauMinus));
675  }
676 
677  // set ESTDP, default
678  void setESTDP(int grpId, bool isSet) {
679  std::string funcName = "setESTDP(\""+getGroupName(grpId)+"\")";
680  UserErrors::assertTrue(!isSet || isSet && !isPoissonGroup(grpId), UserErrors::WRONG_NEURON_TYPE, funcName,
681  funcName);
683  funcName, "CONFIG.");
684 
685  hasSetSTDPALL_ = grpId==ALL; // adding groups after this will not have conductances set
686 
687  if (isSet) { // enable STDP, use default values and type
688  snn_->setESTDP(grpId, true, def_STDP_type_, EXP_CURVE, def_STDP_alphaLTP_, def_STDP_tauLTP_,
689  def_STDP_alphaLTD_, def_STDP_tauLTD_, 0.0f);
690  } else { // disable STDP
691  snn_->setESTDP(grpId, false, UNKNOWN_STDP, UNKNOWN_CURVE, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f);
692  }
693  }
694 
695  // set ESTDP by stdp curve
696  void setESTDP(int grpId, bool isSet, STDPType type, ExpCurve curve) {
697  std::string funcName = "setESTDP(\""+getGroupName(grpId)+","+stdpType_string[type]+"\")";
698  UserErrors::assertTrue(!isSet || isSet && !isPoissonGroup(grpId), UserErrors::WRONG_NEURON_TYPE, funcName,
699  funcName);
702  funcName, "CONFIG.");
703 
704  hasSetSTDPALL_ = grpId==ALL; // adding groups after this will not have conductances set
705 
706  if (isSet) { // enable STDP, use custom values
707  snn_->setESTDP(grpId, true, type, curve.stdpCurve, curve.alphaPlus, curve.tauPlus, curve.alphaMinus,
708  curve.tauMinus, 0.0f);
709  } else { // disable STDP and DA-STDP as well
710  snn_->setESTDP(grpId, false, UNKNOWN_STDP, UNKNOWN_CURVE, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f);
711  }
712  }
713 
714  // set ESTDP by stdp curve
715  void setESTDP(int grpId, bool isSet, STDPType type, TimingBasedCurve curve) {
716  std::string funcName = "setESTDP(\""+getGroupName(grpId)+","+stdpType_string[type]+"\")";
717  UserErrors::assertTrue(!isSet || isSet && !isPoissonGroup(grpId), UserErrors::WRONG_NEURON_TYPE, funcName,
718  funcName);
721  funcName, "CONFIG.");
722 
723  hasSetSTDPALL_ = grpId==ALL; // adding groups after this will not have conductances set
724 
725  if (isSet) { // enable STDP, use custom values
726  snn_->setESTDP(grpId, true, type, curve.stdpCurve, curve.alphaPlus, curve.tauPlus, curve.alphaMinus,
727  curve.tauMinus, curve.gamma);
728  } else { // disable STDP and DA-STDP as well
729  snn_->setESTDP(grpId, false, UNKNOWN_STDP, UNKNOWN_CURVE, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f);
730  }
731  }
732 
733  // set ISTDP, default
734  void setISTDP(int grpId, bool isSet) {
735  std::string funcName = "setISTDP(\""+getGroupName(grpId)+"\")";
736  UserErrors::assertTrue(!isSet || isSet && !isPoissonGroup(grpId), UserErrors::WRONG_NEURON_TYPE, funcName,
737  funcName);
739  funcName, "CONFIG.");
740 
741  hasSetSTDPALL_ = grpId==ALL; // adding groups after this will not have conductances set
742 
743  if (isSet) { // enable STDP, use default values and types
744  snn_->setISTDP(grpId, true, def_STDP_type_, PULSE_CURVE, def_STDP_betaLTP_, def_STDP_betaLTD_,
745  def_STDP_lambda_, def_STDP_delta_);
746  } else { // disable STDP
747  snn_->setISTDP(grpId, false, UNKNOWN_STDP, UNKNOWN_CURVE, 0.0f, 0.0f, 1.0f, 1.0f);
748  }
749  }
750 
751  // set ISTDP by stdp curve
752  void setISTDP(int grpId, bool isSet, STDPType type, ExpCurve curve) {
753  std::string funcName = "setISTDP(\""+getGroupName(grpId)+","+stdpType_string[type]+"\")";
754  UserErrors::assertTrue(!isSet || isSet && !isPoissonGroup(grpId), UserErrors::WRONG_NEURON_TYPE, funcName,
755  funcName);
758  funcName, "CONFIG.");
759 
760  hasSetSTDPALL_ = grpId==ALL; // adding groups after this will not have conductances set
761 
762  if (isSet) { // enable STDP, use custom values
763  snn_->setISTDP(grpId, true, type, curve.stdpCurve, curve.alphaPlus, curve.alphaMinus, curve.tauPlus,
764  curve.tauMinus);
765  } else { // disable STDP and DA-STDP as well
766  snn_->setISTDP(grpId, false, UNKNOWN_STDP, UNKNOWN_CURVE, 0.0f, 0.0f, 1.0f, 1.0f);
767  }
768  }
769 
770  // set ISTDP by stdp curve
771  void setISTDP(int grpId, bool isSet, STDPType type, PulseCurve curve) {
772  std::string funcName = "setISTDP(\""+getGroupName(grpId)+","+stdpType_string[type]+"\")";
773  UserErrors::assertTrue(!isSet || isSet && !isPoissonGroup(grpId), UserErrors::WRONG_NEURON_TYPE, funcName,
774  funcName);
777  funcName, "CONFIG.");
778 
779  hasSetSTDPALL_ = grpId==ALL; // adding groups after this will not have conductances set
780 
781  if (isSet) { // enable STDP, use custom values
782  snn_->setISTDP(grpId, true, type, curve.stdpCurve, curve.betaLTP, curve.betaLTD, curve.lambda, curve.delta);
783  } else { // disable STDP and DA-STDP as well
784  snn_->setISTDP(grpId, false, UNKNOWN_STDP, UNKNOWN_CURVE, 0.0f, 0.0f, 1.0f, 1.0f);
785  }
786  }
787 
788  // set STP, default
789  void setSTP(int grpId, bool isSet) {
790  std::string funcName = "setSTP(\""+getGroupName(grpId)+"\")";
792  funcName, "CONFIG.");
793 
794  hasSetSTPALL_ = grpId==ALL; // adding groups after this will not have conductances set
795 
796  if (isSet) { // enable STDP, use default values
798  funcName, "setSTP");
799 
800  if (isExcitatoryGroup(grpId))
801  snn_->setSTP(grpId,true,def_STP_U_exc_,def_STP_tau_u_exc_,def_STP_tau_x_exc_);
802  else if (isInhibitoryGroup(grpId))
803  snn_->setSTP(grpId,true,def_STP_U_inh_,def_STP_tau_u_inh_,def_STP_tau_x_inh_);
804  else {
805  // some error message
806  }
807  } else { // disable STDP
808  snn_->setSTP(grpId,false,0.0f,0.0f,0.0f);
809  }
810  }
811 
812  // set STP, custom
813  void setSTP(int grpId, bool isSet, float STP_U, float STP_tau_u, float STP_tau_x) {
814  std::string funcName = "setSTP(\""+getGroupName(grpId)+"\")";
816  funcName, "CONFIG.");
817 
818  hasSetSTPALL_ = grpId==ALL; // adding groups after this will not have conductances set
819 
820  if (isSet) { // enable STDP, use default values
822  funcName,"setSTP");
823 
824  snn_->setSTP(grpId,true,STP_U,STP_tau_u,STP_tau_x);
825  } else { // disable STDP
826  snn_->setSTP(grpId,false,0.0f,0.0f,0.0f);
827  }
828  }
829 
830  void setWeightAndWeightChangeUpdate(UpdateInterval wtANDwtChangeUpdateInterval, bool enableWtChangeDecay,
831  float wtChangeDecay)
832  {
833  std::string funcName = "setWeightAndWeightChangeUpdate()";
834  UserErrors::assertTrue(wtChangeDecay > 0.0f, UserErrors::MUST_BE_POSITIVE, funcName);
835  UserErrors::assertTrue(wtChangeDecay < 1.0f, UserErrors::CANNOT_BE_LARGER, funcName);
837  funcName, "CONFIG.");
838 
839  snn_->setWeightAndWeightChangeUpdate(wtANDwtChangeUpdateInterval, enableWtChangeDecay, wtChangeDecay);
840  }
841 
842 
843  // +++++++++ PUBLIC METHODS: RUNNING A SIMULATION +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
844 
845  // run network with custom options
846  int runNetwork(int nSec, int nMsec, bool printRunSummary) {
847  std::string funcName = "runNetwork()";
848  UserErrors::assertTrue(carlsimState_ == SETUP_STATE || carlsimState_ == RUN_STATE,
849  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "SETUP or RUN.");
850 
851  // run some checks before running network for the first time
852  if (carlsimState_ != RUN_STATE) {
853  // if user hasn't called setConductances, set to false and disp warning
854  if (!hasSetConductances_) {
855  userWarnings_.push_back("setConductances has not been called. Setting simulation mode to CUBA.");
856  }
857 
858  // make sure user didn't provoque any user warnings
859  handleUserWarnings();
860  }
861 
862  carlsimState_ = RUN_STATE;
863 
864  return snn_->runNetwork(nSec, nMsec, printRunSummary);
865  }
866 
867  // setup network with custom options
868  void setupNetwork() {
869  std::string funcName = "setupNetwork()";
871  funcName, "CONFIG.");
872 
873  carlsimState_ = SETUP_STATE;
874  snn_->setupNetwork();
875  }
876 
877 
878  // +++++++++ PUBLIC METHODS: LOGGING / PLOTTING +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
879 
880  const FILE* getLogFpInf() { return snn_->getLogFpInf(); }
881  const FILE* getLogFpErr() { return snn_->getLogFpErr(); }
882  const FILE* getLogFpDeb() { return snn_->getLogFpDeb(); }
883  const FILE* getLogFpLog() { return snn_->getLogFpLog(); }
884 
885  void saveSimulation(const std::string& fileName, bool saveSynapseInfo) {
886  FILE* fpSave = fopen(fileName.c_str(),"wb");
887  std::string funcName = "saveSimulation()";
889  UserErrors::assertTrue(carlsimState_ == SETUP_STATE || carlsimState_ == RUN_STATE,
890  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "SETUP or RUN.");
891 
892  snn_->saveSimulation(fpSave,saveSynapseInfo);
893 
894  fclose(fpSave);
895  }
896 
897  void setLogFile(const std::string& fileName) {
898  std::string funcName = "setLogFile("+fileName+")";
899  UserErrors::assertTrue(loggerMode_!=CUSTOM,UserErrors::CANNOT_BE_SET_TO, funcName, "Logger mode", "CUSTOM");
900 
901  FILE* fpLog = NULL;
902  std::string fileNameNonConst = fileName;
903  std::transform(fileNameNonConst.begin(), fileNameNonConst.end(), fileNameNonConst.begin(), ::tolower);
904  if (fileNameNonConst=="null") {
905 #if defined(WIN32) || defined(WIN64)
906  fpLog = fopen("nul","w");
907 #else
908  fpLog = fopen("/dev/null","w");
909 #endif
910  } else {
911  fpLog = fopen(fileName.c_str(),"w");
912  }
913  UserErrors::assertTrue(fpLog!=NULL, UserErrors::FILE_CANNOT_OPEN, funcName, fileName);
914 
915  // change only CARLsim log file pointer (use NULL as code for leaving the others unchanged)
916  snn_->setLogsFp(NULL, NULL, NULL, fpLog);
917  }
918 
919  // set new file pointer for all files in CUSTOM mode
920  void setLogsFpCustom(FILE* fpInf, FILE* fpErr, FILE* fpDeb, FILE* fpLog) {
921  UserErrors::assertTrue(loggerMode_==CUSTOM,UserErrors::MUST_BE_SET_TO,"setLogsFpCustom","Logger mode","CUSTOM");
922 
923  snn_->setLogsFp(fpInf,fpErr,fpDeb,fpLog);
924  }
925 
926 
927  // +++++++++ PUBLIC METHODS: INTERACTING WITH A SIMULATION ++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
928 
929  // adds a constant bias to the weight of every synapse in the connection
930  void biasWeights(short int connId, float bias, bool updateWeightRange) {
931  std::stringstream funcName; funcName << "biasWeights(" << connId << "," << bias << "," << updateWeightRange <<
932  ")";
933  UserErrors::assertTrue(carlsimState_==SETUP_STATE || carlsimState_==RUN_STATE,
934  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName.str(), funcName.str(), "SETUP or RUN.");
935  UserErrors::assertTrue(connId>=0 && connId<getNumConnections(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
936  "connId", "[0,getNumConnections()]");
937 
938  snn_->biasWeights(connId, bias, updateWeightRange);
939  }
940 
941  void startTesting(bool updateWeights) {
942  std::string funcName = "startTesting()";
943  UserErrors::assertTrue(carlsimState_==SETUP_STATE || carlsimState_==RUN_STATE,
944  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "SETUP or RUN.");
945  snn_->startTesting(updateWeights);
946  }
947 
948  void stopTesting() {
949  std::string funcName = "stopTesting()";
950  UserErrors::assertTrue(carlsimState_==SETUP_STATE || carlsimState_==RUN_STATE,
951  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "SETUP or RUN.");
952  snn_->stopTesting();
953  }
954 
955  // reads network state from file
956  void loadSimulation(FILE* fid) {
957  std::string funcName = "loadSimulation()";
959  funcName, "CONFIG.");
960 
961  snn_->loadSimulation(fid);
962  }
963 
964  // scales the weight of every synapse in the connection with a scaling factor
965  void scaleWeights(short int connId, float scale, bool updateWeightRange) {
966  std::stringstream funcName; funcName << "scaleWeights(" << connId << "," << scale << "," << updateWeightRange
967  << ")";
968  UserErrors::assertTrue(carlsimState_==SETUP_STATE || carlsimState_==RUN_STATE,
969  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName.str(), funcName.str(), "SETUP or RUN.");
970  UserErrors::assertTrue(connId>=0 && connId<getNumConnections(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
971  "connId", "[0,getNumConnections()]");
972  UserErrors::assertTrue(scale>=0.0f, UserErrors::CANNOT_BE_NEGATIVE, funcName.str(), "Scaling factor");
973 
974  snn_->scaleWeights(connId, scale, updateWeightRange);
975  }
976 
977  // set spike monitor for group and write spikes to file
978  ConnectionMonitor* setConnectionMonitor(int grpIdPre, int grpIdPost, const std::string& fname) {
979  std::string funcName = "setConnectionMonitor(\"" + getGroupName(grpIdPre) + "\",\"" + getGroupName(grpIdPost)
980  + "\",\"" + fname + "\")";
981  UserErrors::assertTrue(grpIdPre!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, "grpIdPre");
982  UserErrors::assertTrue(grpIdPost!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, "grpIdPost");
983  UserErrors::assertTrue(grpIdPre>=0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grpIdPre");
984  UserErrors::assertTrue(grpIdPost>=0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grpIdPost");
986  funcName, "SETUP.");
987 
988  FILE* fid;
989  std::string fileName = fname;
990  std::transform(fileName.begin(), fileName.end(), fileName.begin(), ::tolower);
991  if (fileName == "null") {
992  // user does not want a binary file created
993  fid = NULL;
994  } else {
995  // try to open spike file
996  if (fileName == "default") {
997  fileName = "results/conn_" + snn_->getGroupName(grpIdPre) + "_" + snn_->getGroupName(grpIdPost) + ".dat";
998  } else {
999  fileName = fname;
1000  }
1001 
1002  fid = fopen(fileName.c_str(),"wb");
1003  if (fid == NULL) {
1004  // file could not be opened
1005  // default case: print error and exit
1006  std::string fileError = " Double-check file permissions and make sure directory exists.";
1007  UserErrors::assertTrue(false, UserErrors::FILE_CANNOT_OPEN, funcName, fileName, fileError);
1008  }
1009  }
1010 
1011  // return ConnectionMonitor object
1012  return snn_->setConnectionMonitor(grpIdPre, grpIdPost, fid);
1013 }
1014 
1015  void setExternalCurrent(int grpId, const std::vector<float>& current) {
1016  std::string funcName = "setExternalCurrent(\""+getGroupName(grpId)+"\")";
1017  UserErrors::assertTrue(grpId!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, "grpId");
1019  "current.size()", "number of neurons in the group.");
1021  UserErrors::assertTrue(carlsimState_==SETUP_STATE || carlsimState_==RUN_STATE,
1022  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "SETUP or RUN.");
1023 
1024  snn_->setExternalCurrent(grpId, current);
1025  }
1026 
1027  void setExternalCurrent(int grpId, float current) {
1028  std::string funcName = "setExternalCurrent(\""+getGroupName(grpId)+"\")";
1029  UserErrors::assertTrue(grpId!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, "grpId");
1031  UserErrors::assertTrue(carlsimState_==SETUP_STATE || carlsimState_==RUN_STATE,
1032  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "SETUP or RUN.");
1033 
1034  std::vector<float> vecCurrent(getGroupNumNeurons(grpId), current);
1035  snn_->setExternalCurrent(grpId, vecCurrent);
1036  }
1037 
1038  // set group monitor for a group
1039  GroupMonitor* setGroupMonitor(int grpId, const std::string& fname) {
1040  std::string funcName = "setGroupMonitor(\""+getGroupName(grpId)+"\",\""+fname+"\")";
1041  UserErrors::assertTrue(grpId!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, "grpId"); // grpId can't be ALL
1042  UserErrors::assertTrue(grpId>=0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grpId"); // grpId can't be negative
1043  UserErrors::assertTrue(carlsimState_==CONFIG_STATE || carlsimState_==SETUP_STATE,
1044  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "CONFIG or SETUP.");
1045 
1046  FILE* fid;
1047  std::string fileName = fname;
1048  std::transform(fileName.begin(), fileName.end(), fileName.begin(), ::tolower);
1049  if (fileName == "null") {
1050  // user does not want a binary file created
1051  fid = NULL;
1052  } else {
1053  // try to open spike file
1054  if (fileName == "default") {
1055  fileName = "results/grp_" + snn_->getGroupName(grpId) + ".dat";
1056  } else {
1057  fileName = fname;
1058  }
1059 
1060  fid = fopen(fileName.c_str(),"wb");
1061  if (fid == NULL) {
1062  // file could not be opened
1063  // default case: print error and exit
1064  std::string fileError = " Double-check file permissions and make sure directory exists.";
1065  UserErrors::assertTrue(false, UserErrors::FILE_CANNOT_OPEN, funcName, fileName, fileError);
1066  }
1067  }
1068 
1069  // return GroupMonitor object
1070  return snn_->setGroupMonitor(grpId, fid);
1071  }
1072 
1073  // sets up a spike generator
1074  void setSpikeGenerator(int grpId, SpikeGenerator* spikeGenFunc) {
1075  std::string funcName = "setSpikeGenerator(\""+getGroupName(grpId)+"\")";
1076  UserErrors::assertTrue(grpId!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, "grpId"); // groupId can't be ALL
1078  UserErrors::assertTrue(spikeGenFunc!=NULL, UserErrors::CANNOT_BE_NULL, funcName);
1080  funcName, "CONFIG.");
1081 
1082  // SpikeGeneratorCore* SGC = new SpikeGeneratorCore(this, spikeGenFunc);
1083  SpikeGeneratorCore* SGC = new SpikeGeneratorCore(sim_, spikeGenFunc);
1084  spkGen_.push_back(SGC);
1085  snn_->setSpikeGenerator(grpId, SGC);
1086  }
1087 
1088  // set spike monitor for group and write spikes to file
1089  SpikeMonitor* setSpikeMonitor(int grpId, const std::string& fileName) {
1090  std::string funcName = "setSpikeMonitor(\""+getGroupName(grpId)+"\",\""+fileName+"\")";
1091  UserErrors::assertTrue(grpId!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, "grpId"); // grpId can't be ALL
1092  UserErrors::assertTrue(grpId>=0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grpId"); // grpId can't be negative
1093  UserErrors::assertTrue(carlsimState_==CONFIG_STATE || carlsimState_==SETUP_STATE,
1094  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "CONFIG or SETUP.");
1095 
1096  FILE* fid;
1097  std::string fileNameLower = fileName;
1098  std::transform(fileNameLower.begin(), fileNameLower.end(), fileNameLower.begin(), ::tolower);
1099  if (fileNameLower == "null") {
1100  // user does not want a binary file created
1101  fid = NULL;
1102  } else {
1103  // try to open spike file
1104  if (fileNameLower == "default") {
1105  std::string fileNameDefault = "results/spk_" + snn_->getGroupName(grpId) + ".dat";
1106  fid = fopen(fileNameDefault.c_str(),"wb");
1107  if (fid==NULL) {
1108  std::string fileError = " Make sure results/ exists.";
1109  UserErrors::assertTrue(false, UserErrors::FILE_CANNOT_OPEN, funcName, fileNameDefault, fileError);
1110  }
1111  } else {
1112  fid = fopen(fileName.c_str(),"wb");
1113  if (fid==NULL) {
1114  std::string fileError = " Double-check file permissions and make sure directory exists.";
1115  UserErrors::assertTrue(false, UserErrors::FILE_CANNOT_OPEN, funcName, fileName, fileError);
1116  }
1117  }
1118  }
1119 
1120  // return SpikeMonitor object
1121  return snn_->setSpikeMonitor(grpId, fid);
1122  }
1123 
1124  // set neuron monitor for group and write neuron state values (voltage, recovery, and total current values) to file
1125  NeuronMonitor* setNeuronMonitor(int grpId, const std::string& fileName) {
1126  std::string funcName = "setNeuronMonitor(\"" + getGroupName(grpId) + "\",\"" + fileName + "\")";
1127  UserErrors::assertTrue(grpId != ALL, UserErrors::ALL_NOT_ALLOWED, funcName, "grpId"); // grpId can't be ALL
1128  UserErrors::assertTrue(grpId >= 0, UserErrors::CANNOT_BE_NEGATIVE, funcName, "grpId"); // grpId can't be negative
1129  UserErrors::assertTrue(carlsimState_ == CONFIG_STATE,
1130  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "CONFIG.");
1131 
1132  FILE* fid;
1133  std::string fileNameLower = fileName;
1134  std::transform(fileNameLower.begin(), fileNameLower.end(), fileNameLower.begin(), ::tolower);
1135  if (fileNameLower == "null") {
1136  // user does not want a binary file created
1137  fid = NULL;
1138  }
1139  else {
1140  // try to open spike file
1141  if (fileNameLower == "default") {
1142  std::string fileNameDefault = "results/n_" + snn_->getGroupName(grpId) + ".dat";
1143  fid = fopen(fileNameDefault.c_str(), "wb");
1144  if (fid == NULL) {
1145  std::string fileError = " Make sure results/ exists.";
1146  UserErrors::assertTrue(false, UserErrors::FILE_CANNOT_OPEN, funcName, fileNameDefault, fileError);
1147  }
1148  }
1149  else {
1150  fid = fopen(fileName.c_str(), "wb");
1151  if (fid == NULL) {
1152  std::string fileError = " Double-check file permissions and make sure directory exists.";
1153  UserErrors::assertTrue(false, UserErrors::FILE_CANNOT_OPEN, funcName, fileName, fileError);
1154  }
1155  }
1156  }
1157 
1158  // return NeuronMonitor object
1159  return snn_->setNeuronMonitor(grpId, fid);
1160  }
1161 
1162  // assign spike rate to poisson group
1163  void setSpikeRate(int grpId, PoissonRate* spikeRate, int refPeriod) {
1164  std::string funcName = "setSpikeRate()";
1165  UserErrors::assertTrue(carlsimState_==SETUP_STATE || carlsimState_==RUN_STATE,
1166  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "SETUP or RUN.");
1169  funcName, "PoissonRate length and the number of neurons in the group");
1170  // FIXME: make sure spikeRate->isOnGPU() consistent with simulation mode
1171  //UserErrors::assertTrue(!spikeRate->isOnGPU() || spikeRate->isOnGPU()&&getSimMode()==GPU_MODE,
1172  // UserErrors::CAN_ONLY_BE_CALLED_IN_MODE, funcName, "PoissonRate on GPU", "GPU_MODE.");
1173 
1174  snn_->setSpikeRate(grpId, spikeRate, refPeriod);
1175  }
1176 
1177  void setWeight(short int connId, int neurIdPre, int neurIdPost, float weight, bool updateWeightRange) {
1178  std::stringstream funcName; funcName << "setWeight(" << connId << "," << neurIdPre << "," << neurIdPost << ","
1179  << updateWeightRange << ")";
1180  UserErrors::assertTrue(carlsimState_==SETUP_STATE || carlsimState_==RUN_STATE,
1181  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName.str(), funcName.str(), "SETUP or RUN.");
1183  funcName.str(), "connectionId", "[0,getNumConnections()]");
1184  UserErrors::assertTrue(weight>=0.0f, UserErrors::CANNOT_BE_NEGATIVE, funcName.str(), "Weight value");
1185 
1186  snn_->setWeight(connId, neurIdPre, neurIdPost, weight, updateWeightRange);
1187  }
1188 
1189 
1190  // +++++++++ PUBLIC METHODS: SETTERS / GETTERS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
1191 
1192  CARLsimState getCARLsimState() { return carlsimState_; }
1193 
1194  std::vector<float> getConductanceAMPA(int grpId) {
1195  std::string funcName = "getConductanceAMPA()";
1197  funcName, funcName, "RUN.");
1198  UserErrors::assertTrue(grpId!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, "grpId");
1199  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName, "grpId",
1200  "[0,getNumGroups()]");
1201 
1202  return snn_->getConductanceAMPA(grpId);
1203  }
1204 
1205  std::vector<float> getConductanceNMDA(int grpId) {
1206  std::string funcName = "getConductanceNMDA()";
1208  funcName, funcName, "RUN.");
1209  UserErrors::assertTrue(grpId!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, "grpId");
1210  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName, "grpId",
1211  "[0,getNumGroups()]");
1212 
1213  return snn_->getConductanceNMDA(grpId);
1214  }
1215 
1216  std::vector<float> getConductanceGABAa(int grpId) {
1217  std::string funcName = "getConductanceGABAa()";
1219  funcName, funcName, "RUN.");
1220  UserErrors::assertTrue(grpId!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, "grpId");
1221  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName, "grpId",
1222  "[0,getNumGroups()]");
1223 
1224  return snn_->getConductanceGABAa(grpId);
1225  }
1226 
1227  std::vector<float> getConductanceGABAb(int grpId) {
1228  std::string funcName = "getConductanceGABAb()";
1230  funcName, funcName, "RUN.");
1231  UserErrors::assertTrue(grpId!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName, "grpId");
1232  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName, "grpId",
1233  "[0,getNumGroups()]");
1234 
1235  return snn_->getConductanceGABAb(grpId);
1236  }
1237 
1238  RangeDelay getDelayRange(short int connId) {
1239  std::stringstream funcName; funcName << "getDelayRange(" << connId << ")";
1240  UserErrors::assertTrue(connId>=0 && connId<getNumConnections(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1241  "connId", "[0,getNumConnections()]");
1242 
1243  return snn_->getDelayRange(connId);
1244  }
1245 
1246  // \TODO bad API design (return allocated memory space)
1247  uint8_t* getDelays(int gIDpre, int gIDpost, int& Npre, int& Npost) {
1248  std::string funcName = "getDelays()";
1249  UserErrors::assertTrue(carlsimState_ == SETUP_STATE || carlsimState_ == RUN_STATE,
1250  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "SETUP or RUN.");
1251  UserErrors::assertTrue(gIDpre>=0 && gIDpre<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName, "gIDpre",
1252  "[0,getNumGroups()]");
1253  UserErrors::assertTrue(gIDpost>=0 && gIDpost<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName, "gIDpre",
1254  "[0,getNumGroups()]");
1255 
1256  return snn_->getDelays(gIDpre,gIDpost,Npre,Npost);
1257  }
1258 
1259  Grid3D getGroupGrid3D(int grpId) {
1260  std::stringstream funcName; funcName << "getGroupGrid3D(" << grpId << ")";
1261  UserErrors::assertTrue(grpId!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName.str(), "grpId");
1262  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1263  "grpId", "[0,getNumGroups()]");
1264 
1265  return snn_->getGroupGrid3D(grpId);
1266  }
1267 
1268  int getGroupId(std::string grpName) {
1269  return snn_->getGroupId(grpName);
1270  }
1271 
1272  std::string getGroupName(int grpId) {
1273  std::stringstream funcName; funcName << "getGroupName(" << grpId << ")";
1274  UserErrors::assertTrue(grpId==ALL || grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1275  "grpId", "[0,getNumGroups()] or must be ALL.");
1276 
1277  return snn_->getGroupName(grpId);
1278  }
1279 
1280  int getGroupStartNeuronId(int grpId) {
1281  std::stringstream funcName; funcName << "getGroupStartNeuronId(" << grpId << ")";
1282  UserErrors::assertTrue(carlsimState_ == SETUP_STATE || carlsimState_ == RUN_STATE,
1283  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName.str(), funcName.str(), "SETUP or RUN.");
1284  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(), "grpId",
1285  "[0,getNumGroups()]");
1286 
1287  return snn_->getGroupStartNeuronId(grpId);
1288  }
1289 
1290  int getGroupEndNeuronId(int grpId) {
1291  std::stringstream funcName; funcName << "getGroupEndNeuronId(" << grpId << ")";
1292  UserErrors::assertTrue(carlsimState_ == SETUP_STATE || carlsimState_ == RUN_STATE,
1293  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName.str(), funcName.str(), "SETUP or RUN.");
1294  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(), "grpId",
1295  "[0,getNumGroups()]");
1296 
1297  return snn_->getGroupEndNeuronId(grpId);
1298  }
1299 
1300  int getGroupNumNeurons(int grpId) {
1301  std::stringstream funcName; funcName << "getGroupNumNeurons(" << grpId << ")";
1302  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(), "grpId",
1303  "[0,getNumGroups()]");
1304 
1305  return snn_->getGroupNumNeurons(grpId);
1306  }
1307 
1309  std::stringstream funcName; funcName << "getNeuronLocation3D(" << neurId << ")";
1310  UserErrors::assertTrue(carlsimState_ == SETUP_STATE || carlsimState_ == RUN_STATE,
1311  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName.str(), funcName.str(), "SETUP or RUN.");
1312  UserErrors::assertTrue(neurId!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName.str(), "neurId");
1313  UserErrors::assertTrue(neurId>=0 && neurId<getNumNeurons(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1314  "neurId", "[0,getNumNeurons()]");
1315 
1316  return snn_->getNeuronLocation3D(neurId);
1317  }
1318 
1319  Point3D getNeuronLocation3D(int grpId, int relNeurId) {
1320  std::stringstream funcName; funcName << "getNeuronLocation3D(" << grpId << "," << relNeurId << ")";
1321  UserErrors::assertTrue(relNeurId!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName.str(), "neurId");
1322  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1323  "grpId", "[0,getNumGroups()]");
1325  funcName.str(), "relNeurId", "[0,getGroupNumNeurons()]");
1326 
1327  return snn_->getNeuronLocation3D(grpId, relNeurId);
1328  }
1329 
1330  int getNumConnections() { return snn_->getNumConnections(); }
1332 
1333  int getNumGroups() { return snn_->getNumGroups(); }
1334  int getNumNeurons() { return snn_->getNumNeurons(); }
1335  int getNumNeuronsReg() { return snn_->getNumNeuronsReg(); }
1336  int getNumNeuronsRegExc() { return snn_->getNumNeuronsRegExc(); }
1337  int getNumNeuronsRegInh() { return snn_->getNumNeuronsRegInh(); }
1338  int getNumNeuronsGen() { return snn_->getNumNeuronsGen(); }
1339  int getNumNeuronsGenExc() { return snn_->getNumNeuronsGenExc(); }
1340  int getNumNeuronsGenInh() { return snn_->getNumNeuronsGenInh(); }
1341 
1342  int getNumSynapticConnections(short int connectionId) {
1343  std::stringstream funcName; funcName << "getNumConnections(" << connectionId << ")";
1344  UserErrors::assertTrue(carlsimState_ == SETUP_STATE || carlsimState_ == RUN_STATE,
1345  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName.str(), funcName.str(), "SETUP or RUN.");
1346  UserErrors::assertTrue(connectionId!=ALL, UserErrors::ALL_NOT_ALLOWED, funcName.str(), "connectionId");
1347  UserErrors::assertTrue(connectionId>=0 && connectionId<getNumConnections(), UserErrors::MUST_BE_IN_RANGE,
1348  funcName.str(), "connectionId", "[0,getNumSynapticConnections()]");
1349  return snn_->getNumSynapticConnections(connectionId);
1350  }
1351 
1353  std::string funcName = "getNumSynapses()";
1354  UserErrors::assertTrue(carlsimState_ == SETUP_STATE || carlsimState_ == RUN_STATE,
1355  UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "SETUP or RUN.");
1356 
1357  return snn_->getNumSynapses();
1358  }
1359 
1361  std::stringstream funcName; funcName << "getGroupSTDPInfo(" << grpId << ")";
1362  UserErrors::assertTrue(grpId >= 0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1363  "grpId", "[0,getNumGroups()]");
1364 
1365  return snn_->getGroupSTDPInfo(grpId);
1366  }
1367 
1369  std::stringstream funcName; funcName << "getGroupNeuromodulatorInfo(" << grpId << ")";
1370  UserErrors::assertTrue(grpId >= 0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1371  "grpId", "[0,getNumGroups()]");
1372  return snn_->getGroupNeuromodulatorInfo(grpId);
1373  }
1374 
1375  int getSimTime() { return snn_->getSimTime(); }
1376  int getSimTimeSec() { return snn_->getSimTimeSec(); }
1377  int getSimTimeMsec() { return snn_->getSimTimeMs(); }
1378 
1379  // returns pointer to existing SpikeMonitor object, NULL else
1381  std::stringstream funcName; funcName << "getSpikeMonitor(" << grpId << ")";
1382  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1383  "grpId", "[0,getNumGroups()]");
1384 
1385  return snn_->getSpikeMonitor(grpId);
1386  }
1387 
1388  RangeWeight getWeightRange(short int connId) {
1389  std::stringstream funcName; funcName << "getWeightRange(" << connId << ")";
1390  UserErrors::assertTrue(connId>=0 && connId<getNumConnections(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1391  "connId", "[0,getNumConnections()]");
1392 
1393  return snn_->getWeightRange(connId);
1394  }
1395 
1396  bool isConnectionPlastic(short int connId) {
1397  std::stringstream funcName; funcName << "isConnectionPlastic(" << connId << ")";
1398  UserErrors::assertTrue(connId>=0 && connId<getNumConnections(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1399  "connId", "[0,getNumConnections()]");
1400 
1401  return snn_->isConnectionPlastic(connId);
1402  }
1403 
1404  bool isGroupWithHomeostasis(int grpId) {
1405  std::stringstream funcName; funcName << "isGroupWithHomeostasis(" << grpId << ")";
1406  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1407  "connId", "[0,getNumGroups()]");
1408 
1409  return snn_->isGroupWithHomeostasis(grpId);
1410  }
1411 
1412  bool isExcitatoryGroup(int grpId) {
1413  std::stringstream funcName; funcName << "isExcitatoryGroup(" << grpId << ")";
1414  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1415  "connId", "[0,getNumGroups()]");
1416 
1417  return snn_->isExcitatoryGroup(grpId);
1418  }
1419 
1420  bool isInhibitoryGroup(int grpId) {
1421  std::stringstream funcName; funcName << "isInhibitoryGroup(" << grpId << ")";
1422  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1423  "connId", "[0,getNumGroups()]");
1424 
1425  return snn_->isInhibitoryGroup(grpId);
1426  }
1427 
1428  bool isPoissonGroup(int grpId) {
1429  std::stringstream funcName; funcName << "isPoissonGroup(" << grpId << ")";
1430  UserErrors::assertTrue(grpId>=0 && grpId<getNumGroups(), UserErrors::MUST_BE_IN_RANGE, funcName.str(),
1431  "connId", "[0,getNumGroups()]");
1432 
1433  return snn_->isPoissonGroup(grpId);
1434  }
1435 
1436 
1437  // +++++++++ PUBLIC METHODS: SET DEFAULTS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
1438 
1439  // set default values for conductance decay times
1440  void setDefaultConductanceTimeConstants(int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb,
1441  int tdGABAb)
1442  {
1443  std::stringstream funcName; funcName << "setDefaultConductanceTimeConstants(" << tdAMPA << "," << trNMDA <<
1444  "," << tdNMDA << "," << tdGABAa << "," << trGABAb << "," << tdGABAb << ")";
1445  UserErrors::assertTrue(tdAMPA>0, UserErrors::MUST_BE_POSITIVE, funcName.str(), "tdAMPA");
1446  UserErrors::assertTrue(trNMDA>=0, UserErrors::CANNOT_BE_NEGATIVE, funcName.str(), "trNMDA");
1447  UserErrors::assertTrue(tdNMDA>0, UserErrors::MUST_BE_POSITIVE, funcName.str(), "tdNMDA");
1448  UserErrors::assertTrue(tdGABAa>0, UserErrors::MUST_BE_POSITIVE, funcName.str(), "tdGABAa");
1449  UserErrors::assertTrue(trGABAb>=0, UserErrors::CANNOT_BE_NEGATIVE, funcName.str(), "trGABAb");
1450  UserErrors::assertTrue(tdGABAb>0, UserErrors::MUST_BE_POSITIVE, funcName.str(), "tdGABAb");
1451  UserErrors::assertTrue(trNMDA!=tdNMDA, UserErrors::CANNOT_BE_IDENTICAL, funcName.str(), "trNMDA and tdNMDA");
1452  UserErrors::assertTrue(trGABAb!=tdGABAb, UserErrors::CANNOT_BE_IDENTICAL, funcName.str(),
1453  "trGABAb and tdGABAb");
1455  "CONFIG.");
1456 
1457  def_tdAMPA_ = tdAMPA;
1458  def_trNMDA_ = trNMDA;
1459  def_tdNMDA_ = tdNMDA;
1460  def_tdGABAa_ = tdGABAa;
1461  def_trGABAb_ = trGABAb;
1462  def_tdGABAb_ = tdGABAb;
1463  }
1464 
1465  void setDefaultHomeostasisParams(float homeoScale, float avgTimeScale) {
1466  std::string funcName = "setDefaultHomeostasisparams()";
1468  funcName, "CONFIG.");
1469  assert(avgTimeScale>0); // TODO make nice
1470 
1471  def_homeo_scale_ = homeoScale;
1472  def_homeo_avgTimeScale_ = avgTimeScale;
1473  }
1474 
1475  void setDefaultSaveOptions(std::string fileName, bool saveSynapseInfo) {
1476  std::string funcName = "setDefaultSaveOptions()";
1478  funcName, "CONFIG.");
1479 
1480  def_save_fileName_ = fileName;
1481  def_save_synapseInfo_ = saveSynapseInfo;
1482 
1483  // try to open save file to make sure we have permission (so the user immediately knows about the error and
1484  // doesn't have to wait until their simulation run has ended)
1485  FILE* fpTry = fopen(def_save_fileName_.c_str(),"wb");
1486  UserErrors::assertTrue(fpTry!=NULL,UserErrors::FILE_CANNOT_OPEN,"Default save file",def_save_fileName_);
1487  fclose(fpTry);
1488  }
1489 
1490  // wrapper function, set default values for E-STDP params
1491  void setDefaultSTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, STDPType stdpType) {
1492  setDefaultESTDPparams(alphaPlus, tauPlus, alphaMinus, tauMinus, stdpType);
1493  }
1494 
1495  // set default values for E-STDP params
1496  void setDefaultESTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, STDPType stdpType) {
1497  std::string funcName = "setDefaultESTDPparams()";
1498  UserErrors::assertTrue(carlsimState_==CONFIG_STATE, UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "CONFIG.");
1499  UserErrors::assertTrue(tauPlus > 0, UserErrors::MUST_BE_POSITIVE, funcName, "tauPlus");
1500  UserErrors::assertTrue(tauMinus > 0, UserErrors::MUST_BE_POSITIVE, funcName, "tauMinus");
1501  switch(stdpType) {
1502  case STANDARD:
1503  def_STDP_type_ = STANDARD;
1504  break;
1505  case DA_MOD:
1506  def_STDP_type_ = DA_MOD;
1507  break;
1508  default:
1509  stdpType=UNKNOWN_STDP;
1511  break;
1512  }
1513  def_STDP_alphaLTP_ = alphaPlus;
1514  def_STDP_tauLTP_ = tauPlus;
1515  def_STDP_alphaLTD_ = alphaMinus;
1516  def_STDP_tauLTD_ = tauMinus;
1517  }
1518 
1519 // set default values for I-STDP params
1520  void setDefaultISTDPparams(float betaLTP, float betaLTD, float lambda, float delta, STDPType stdpType) {
1521  std::string funcName = "setDefaultISTDPparams()";
1522  UserErrors::assertTrue(carlsimState_==CONFIG_STATE, UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "CONFIG.");
1523  UserErrors::assertTrue(betaLTP > 0, UserErrors::MUST_BE_POSITIVE, funcName);
1524  UserErrors::assertTrue(betaLTD > 0, UserErrors::MUST_BE_POSITIVE, funcName);
1527  switch(stdpType) {
1528  case STANDARD:
1529  def_STDP_type_ = STANDARD;
1530  break;
1531  case DA_MOD:
1532  def_STDP_type_ = DA_MOD;
1533  break;
1534  default:
1535  stdpType=UNKNOWN_STDP;
1537  break;
1538  }
1539  def_STDP_betaLTP_ = betaLTP;
1540  def_STDP_betaLTD_ = betaLTD;
1541  def_STDP_lambda_ = lambda;
1542  def_STDP_delta_ = delta;
1543  }
1544 
1545 // set default STP values for an EXCITATORY_NEURON or INHIBITORY_NEURON
1546  void setDefaultSTPparams(int neurType, float STP_U, float STP_tau_u, float STP_tau_x) {
1547  std::string funcName = "setDefaultSTPparams()";
1549  funcName);
1550  UserErrors::assertTrue(carlsimState_==CONFIG_STATE, UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "CONFIG.");
1551 
1552  assert(STP_tau_u>0.0f);
1553  assert(STP_tau_x>0.0f);
1554 
1555  switch (neurType) {
1556  case EXCITATORY_NEURON:
1557  def_STP_U_exc_ = STP_U;
1558  def_STP_tau_u_exc_ = STP_tau_u;
1559  def_STP_tau_x_exc_ = STP_tau_x;
1560  break;
1561  case INHIBITORY_NEURON:
1562  def_STP_U_inh_ = STP_U;
1563  def_STP_tau_u_inh_ = STP_tau_u;
1564  def_STP_tau_x_inh_ = STP_tau_x;
1565  break;
1566  default:
1567  // some error message instead of assert
1569  break;
1570  }
1571  }
1572 
1573 
1574 private:
1575  // +++++ PRIVATE METHODS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
1576 
1577  // unsafe computations that would otherwise go in constructor
1578  void CARLsimInit() {
1579  bool gpuAllocationResult = false;
1580  std::string funcName = "CARLsimInit()";
1581 
1582  UserErrors::assertTrue(loggerMode_!=UNKNOWN_LOGGER,UserErrors::CANNOT_BE_UNKNOWN,"CARLsim()","Logger mode");
1583 
1584  // init SNN object
1585  snn_ = new SNN(netName_, preferredSimMode_, loggerMode_, randSeed_);
1586 
1587  // set default time constants for synaptic current decay
1588  // TODO: add ref
1589  setDefaultConductanceTimeConstants(5, 0, 150, 6, 0, 150);
1590 
1591  // set default values for STDP params
1592  // \deprecated
1593  // \TODO: replace with STDP structs
1594  setDefaultESTDPparams(0.001f, 20.0f, -0.0012f, 20.0f, STANDARD);
1595  setDefaultISTDPparams(0.001f, 0.0012f, 12.0f, 40.0f, STANDARD);
1596 
1597  // set default values for STP params
1598  // Misha Tsodyks and Si Wu (2013) Short-term synaptic plasticity. Scholarpedia, 8(10):3153., revision #136920
1599  setDefaultSTPparams(EXCITATORY_NEURON, 0.45f, 50.0f, 750.0f);
1600  setDefaultSTPparams(INHIBITORY_NEURON, 0.15f, 750.0f, 50.0f);
1601 
1602  // set default homeostasis params
1603  // Ref: Carlson, et al. (2013). Proc. of IJCNN 2013.
1604  setDefaultHomeostasisParams(0.1f, 10.0f);
1605 
1606  // set default save sim params
1607  // TODO: when we run executable from local dir, put save file in results/
1608  setDefaultSaveOptions("results/sim_"+netName_+".dat",false);
1609 
1610  connSyn_.clear();
1611  connComp_.clear();
1612  }
1613 
1614 
1615  // check whether grpId exists in grpIds_
1616  bool existsGrpId(int grpId) {
1617  return std::find(grpIds_.begin(), grpIds_.end(), grpId)!=grpIds_.end();
1618  }
1619 
1620  // print all user warnings, continue only after user input
1621  void handleUserWarnings() {
1622  if (userWarnings_.size()) {
1623  for (int i=0; i<userWarnings_.size(); i++) {
1624  CARLSIM_WARN("runNetwork()",userWarnings_[i].c_str());
1625  }
1626 
1627  fprintf(stdout,"Ignore warnings and continue? Y/n ");
1628  char ignoreWarn = std::cin.get();
1629  if (std::cin.fail() || ignoreWarn!='y' && ignoreWarn!='Y') {
1630  fprintf(stdout,"Exiting...\n");
1631  exit(1);
1632  }
1633  }
1634  }
1635 
1636 
1637  // +++++ PRIVATE STATIC PROPERTIES ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
1638 
1639  static bool gpuAllocation[MAX_NUM_CUDA_DEVICES];
1640  static std::string gpuOccupiedBy[MAX_NUM_CUDA_DEVICES];
1641 #if defined(WIN32) || defined(WIN64)
1642  static HANDLE gpuAllocationLock;
1643 #else
1644  static pthread_mutex_t gpuAllocationLock;
1645 #endif
1646 
1647 
1648  // +++++ PRIVATE PROPERTIES +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
1649 
1650  CARLsim* sim_;
1651  SNN* snn_;
1652  std::string netName_;
1653  int randSeed_;
1654  LoggerMode loggerMode_;
1655  SimMode preferredSimMode_;
1656  bool enablePrint_;
1657  bool copyState_;
1658 
1660  std::vector<std::vector<int> > connSyn_;
1663  std::vector<std::vector<int> > connComp_;
1664 
1665  std::map<int, int> groupPrefNetIds_;
1666 
1667  unsigned int numConnections_;
1668  std::vector<std::string> userWarnings_; // !< an accumulated list of user warnings
1669 
1670  std::vector<int> grpIds_;
1671  std::vector<SpikeGeneratorCore*> spkGen_;
1672  std::vector<ConnectionGeneratorCore*> connGen_;
1673 
1674  bool hasSetHomeoALL_;
1675  bool hasSetHomeoBaseFiringALL_;
1676  bool hasSetSTDPALL_;
1677  bool hasSetSTPALL_;
1678  bool hasSetConductances_;
1679  CARLsimState carlsimState_;
1680 
1681  int def_tdAMPA_;
1682  int def_trNMDA_;
1683  int def_tdNMDA_;
1684  int def_tdGABAa_;
1685  int def_trGABAb_;
1686  int def_tdGABAb_;
1687 
1688  // all default values for STDP
1689  STDPType def_STDP_type_;
1690  float def_STDP_alphaLTP_;
1691  float def_STDP_tauLTP_;
1692  float def_STDP_alphaLTD_;
1693  float def_STDP_tauLTD_;
1694  float def_STDP_betaLTP_;
1695  float def_STDP_betaLTD_;
1696  float def_STDP_lambda_;
1697  float def_STDP_delta_;
1698 
1699  // all default values for STP
1700  float def_STP_U_exc_;
1701  float def_STP_tau_u_exc_;
1702  float def_STP_tau_x_exc_;
1703  float def_STP_U_inh_;
1704  float def_STP_tau_u_inh_;
1705  float def_STP_tau_x_inh_;
1706 
1707  // all default values for homeostasis
1708  float def_homeo_scale_;
1709  float def_homeo_avgTimeScale_;
1710 
1711  // all default values for save file
1712  std::string def_save_fileName_;
1713  bool def_save_synapseInfo_;
1714 };
1715 
1716 
1717 
1718 
1719 // ****************************************************************************************************************** //
1720 // CARLSIM API IMPLEMENTATION
1721 // ****************************************************************************************************************** //
1722 
1723 // initialize static properties
1724 bool CARLsim::Impl::gpuAllocation[MAX_NUM_CUDA_DEVICES] = {false};
1725 std::string CARLsim::Impl::gpuOccupiedBy[MAX_NUM_CUDA_DEVICES];
1726 
1727 #if defined(WIN32) || defined(WIN64)
1728 HANDLE CARLsim::Impl::gpuAllocationLock = CreateMutex(NULL, FALSE, NULL);
1729 #else
1730 pthread_mutex_t CARLsim::Impl::gpuAllocationLock = PTHREAD_MUTEX_INITIALIZER;
1731 #endif
1732 
1733 // constructor / destructor
1734 CARLsim::CARLsim(const std::string& netName, SimMode preferredSimMode, LoggerMode loggerMode, int ithGPUs, int randSeed) :
1735 _impl( new Impl(this, netName, preferredSimMode, loggerMode, randSeed) ) {}
1736 CARLsim::~CARLsim() { delete _impl; }
1737 
1738 // connect with primitive type
1739 short int CARLsim::connect(int grpId1, int grpId2, const std::string& connType, const RangeWeight& wt, float connProb,
1740  const RangeDelay& delay, const RadiusRF& radRF, bool synWtType, float mulSynFast, float mulSynSlow) {
1741  return _impl->connect(grpId1, grpId2, connType, wt, connProb, delay, radRF, synWtType, mulSynFast, mulSynSlow);
1742 }
1743 
1744 // connect with custom ConnectionGenerator (short)
1745 // TODO: don't need two versions of this... make it (grpId1, grpId2, conn, synWtType, mulSynFast, mulSynSlow)
1746 short int CARLsim::connect(int grpId1, int grpId2, ConnectionGenerator* conn, bool synWtType) {
1747  return _impl->connect(grpId1, grpId2, conn, synWtType);
1748 }
1749 short int CARLsim::connect(int grpId1, int grpId2, ConnectionGenerator* conn, float mulSynFast, float mulSynSlow,
1750  bool synWtType)
1751 {
1752  return _impl->connect(grpId1, grpId2, conn, mulSynFast, mulSynSlow, synWtType);
1753 }
1754 
1755 short int CARLsim::connectCompartments(int grpIdLower, int grpIdUpper) {
1756  return _impl->connectCompartments(grpIdLower, grpIdUpper);
1757 }
1758 
1759 // create group with / without grid
1760 int CARLsim::createGroup(const std::string& grpName, const Grid3D& grid, int neurType, int preferredPartition, ComputingBackend preferredBackend) {
1761  return _impl->createGroup(grpName, grid, neurType, preferredPartition, preferredBackend);
1762 }
1763 int CARLsim::createGroup(const std::string& grpName, int nNeur, int neurType, int preferredPartition, ComputingBackend preferredBackend) {
1764  return _impl->createGroup(grpName, nNeur, neurType, preferredPartition, preferredBackend);
1765 }
1766 
1767 // create LIF group with / without grid
1768 int CARLsim::createGroupLIF(const std::string& grpName, const Grid3D& grid, int neurType, int preferredPartition, ComputingBackend preferredBackend) {
1769  return _impl->createGroupLIF(grpName, grid, neurType, preferredPartition, preferredBackend);
1770 }
1771 int CARLsim::createGroupLIF(const std::string& grpName, int nNeur, int neurType, int preferredPartition, ComputingBackend preferredBackend) {
1772  return _impl->createGroupLIF(grpName, nNeur, neurType, preferredPartition, preferredBackend);
1773 }
1774 
1775 // create spike gen group with / without grid
1776 int CARLsim::createSpikeGeneratorGroup(const std::string& grpName, const Grid3D& grid, int neurType, int preferredPartition, ComputingBackend preferredBackend) {
1777  return _impl->createSpikeGeneratorGroup(grpName, grid, neurType, preferredPartition, preferredBackend);
1778 }
1779 int CARLsim::createSpikeGeneratorGroup(const std::string& grpName, int nNeur, int neurType, int preferredPartition, ComputingBackend preferredBackend) {
1780  return _impl->createSpikeGeneratorGroup(grpName, nNeur, neurType, preferredPartition, preferredBackend);
1781 }
1782 
1783 void CARLsim::setCompartmentParameters(int grpId, float couplingUp, float couplingDown) {
1784  _impl->setCompartmentParameters(grpId, couplingUp, couplingDown);
1785 }
1786 
1787 // set conductances
1788 void CARLsim::setConductances(bool isSet) {
1789  _impl->setConductances(isSet);
1790 }
1791 void CARLsim::setConductances(bool isSet, int tdAMPA, int tdNMDA, int tdGABAa, int tdGABAb) {
1792  _impl->setConductances(isSet, tdAMPA, tdNMDA, tdGABAa, tdGABAb);
1793 }
1794 void CARLsim::setConductances(bool isSet, int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb, int tdGABAb) {
1795  _impl->setConductances(isSet, tdAMPA, trNMDA, tdNMDA, tdGABAa, trGABAb, tdGABAb);
1796 }
1797 
1798 // set homeostasis params
1799 void CARLsim::setHomeostasis(int grpId, bool isSet, float homeoScale, float avgTimeScale) {
1800  _impl->setHomeostasis(grpId, isSet, homeoScale, avgTimeScale);
1801 }
1802 void CARLsim::setHomeostasis(int grpId, bool isSet) {
1803  _impl->setHomeostasis(grpId, isSet);
1804 }
1805 void CARLsim::setHomeoBaseFiringRate(int grpId, float baseFiring, float baseFiringSD) {
1806  _impl->setHomeoBaseFiringRate(grpId, baseFiring, baseFiringSD);
1807 }
1808 
1810 {
1811  _impl->setIntegrationMethod(method, numStepsPerMs);
1812 }
1813 
1814 // set neuron params
1815 void CARLsim::setNeuronParameters(int grpId, float izh_a, float izh_a_sd, float izh_b, float izh_b_sd, float izh_c,
1816  float izh_c_sd, float izh_d, float izh_d_sd)
1817 {
1818  _impl->setNeuronParameters(grpId, izh_a, izh_a_sd, izh_b, izh_b_sd, izh_c, izh_c_sd, izh_d, izh_d_sd);
1819 }
1820 void CARLsim::setNeuronParameters(int grpId, float izh_a, float izh_b, float izh_c, float izh_d) {
1821  _impl->setNeuronParameters(grpId, izh_a, izh_b, izh_c, izh_d);
1822 }
1823 
1824 void CARLsim::setNeuronParameters(int grpId, float izh_C, float izh_k, float izh_vr, float izh_vt,
1825  float izh_a, float izh_b, float izh_vpeak, float izh_c, float izh_d)
1826 {
1827  _impl->setNeuronParameters(grpId, izh_C, izh_k, izh_vr, izh_vt, izh_a, izh_b, izh_vpeak, izh_c, izh_d);
1828 }
1829 
1830 void CARLsim::setNeuronParameters(int grpId, float izh_C, float izh_C_sd, float izh_k, float izh_k_sd,
1831  float izh_vr, float izh_vr_sd, float izh_vt, float izh_vt_sd,
1832  float izh_a, float izh_a_sd, float izh_b, float izh_b_sd,
1833  float izh_vpeak, float izh_vpeak_sd, float izh_c, float izh_c_sd,
1834  float izh_d, float izh_d_sd)
1835 {
1836  _impl->setNeuronParameters(grpId, izh_C, izh_C_sd, izh_k, izh_k_sd, izh_vr, izh_vr_sd, izh_vt, izh_vt_sd,
1837  izh_a, izh_a_sd, izh_b, izh_b_sd, izh_vpeak, izh_vpeak_sd, izh_c, izh_c_sd, izh_d, izh_d_sd);
1838 }
1839 
1840 void CARLsim::setNeuronParametersLIF(int grpId, int tau_m, int tau_ref, float vTh, float vReset, const RangeRmem& rMem)
1841 {
1842  _impl->setNeuronParametersLIF(grpId, tau_m, tau_ref, vTh, vReset, rMem);
1843 }
1844 
1845 void CARLsim::setNeuromodulator(int grpId, float baseDP, float tauDP, float base5HT, float tau5HT, float baseACh,
1846  float tauACh, float baseNE, float tauNE)
1847 {
1848  _impl->setNeuromodulator(grpId, baseDP, tauDP, base5HT, tau5HT, baseACh, tauACh, baseNE, tauNE);
1849 }
1850 
1851 // sets default neuromodulators
1852 void CARLsim::setNeuromodulator(int grpId, float tauDP, float tau5HT, float tauACh, float tauNE) {
1853  _impl->setNeuromodulator(grpId, tauDP, tau5HT, tauACh, tauNE);
1854 }
1855 
1856 // Sets default STDP mode and params
1857 void CARLsim::setSTDP(int grpId, bool isSet) { _impl->setSTDP(grpId, isSet); }
1858 
1859 // Sets STDP params for a group, custom
1860 void CARLsim::setSTDP(int grpId, bool isSet, STDPType type, float alphaPlus, float tauPlus, float alphaMinus,
1861  float tauMinus)
1862 {
1863  _impl->setSTDP(grpId, isSet, type, alphaPlus, tauPlus, alphaMinus, tauMinus);
1864 }
1865 
1866 // Sets default E-STDP mode and parameters
1867 void CARLsim::setESTDP(int grpId, bool isSet) { _impl->setESTDP(grpId, isSet); }
1868 
1869 // Sets E-STDP with the exponential curve
1870 void CARLsim::setESTDP(int grpId, bool isSet, STDPType type, ExpCurve curve) {
1871  _impl->setESTDP(grpId, isSet, type, curve);
1872 }
1873 
1874 // Sets E-STDP with the timing-based curve
1875 void CARLsim::setESTDP(int grpId, bool isSet, STDPType type, TimingBasedCurve curve) {
1876  _impl->setESTDP(grpId, isSet, type, curve);
1877 }
1878 
1879 // Sets default I-STDP mode and parameters
1880 void CARLsim::setISTDP(int grpId, bool isSet) { _impl->setESTDP(grpId, isSet); }
1881 
1882 // Sets I-STDP with the exponential curve
1883 void CARLsim::setISTDP(int grpId, bool isSet, STDPType type, ExpCurve curve) {
1884  _impl->setISTDP(grpId, isSet, type, curve);
1885 }
1886 
1887 // Sets I-STDP with the pulse curve
1888 void CARLsim::setISTDP(int grpId, bool isSet, STDPType type, PulseCurve curve) {
1889  _impl->setISTDP(grpId, isSet, type, curve);
1890 }
1891 
1892 // Sets STP params U, tau_u, and tau_x of a neuron group (pre-synaptically)
1893 void CARLsim::setSTP(int grpId, bool isSet, float STP_U, float STP_tau_u, float STP_tau_x) {
1894  _impl->setSTP(grpId, isSet, STP_U, STP_tau_u, STP_tau_x);
1895 }
1896 
1897 // Sets STP params U, tau_u, and tau_x of a neuron group (pre-synaptically) using default values
1898 void CARLsim::setSTP(int grpId, bool isSet) { _impl->setSTP(grpId, isSet); }
1899 
1900 // Sets the weight and weight change update parameters
1901 void CARLsim::setWeightAndWeightChangeUpdate(UpdateInterval wtANDwtChangeUpdateInterval, bool enableWtChangeDecay,
1902  float wtChangeDecay)
1903 {
1904  _impl->setWeightAndWeightChangeUpdate(wtANDwtChangeUpdateInterval, enableWtChangeDecay, wtChangeDecay);
1905 }
1906 
1907 
1908 // run the simulation for time=(nSec*seconds + nMsec*milliseconds)
1909 int CARLsim::runNetwork(int nSec, int nMsec, bool printRunSummary) {
1910  return _impl->runNetwork(nSec, nMsec, printRunSummary);
1911 }
1912 
1913 // build the network
1915 
1916 const FILE* CARLsim::getLogFpInf() { return _impl->getLogFpInf(); }
1917 const FILE* CARLsim::getLogFpErr() { return _impl->getLogFpErr(); }
1918 const FILE* CARLsim::getLogFpDeb() { return _impl->getLogFpDeb(); }
1919 const FILE* CARLsim::getLogFpLog() { return _impl->getLogFpLog(); }
1920 
1921 // Saves important simulation and network infos to file.
1922 void CARLsim::saveSimulation(const std::string& fileName, bool saveSynapseInfo) {
1923  _impl->saveSimulation(fileName, saveSynapseInfo);
1924 }
1925 
1926 // Sets the name of the log file
1927 void CARLsim::setLogFile(const std::string& fileName) { _impl->setLogFile(fileName); }
1928 
1929 // Sets the file pointers for all log files in CUSTOM mode
1930 void CARLsim::setLogsFpCustom(FILE* fpInf, FILE* fpErr, FILE* fpDeb, FILE* fpLog) {
1931  _impl->setLogsFpCustom(fpInf, fpErr, fpDeb, fpLog);
1932 }
1933 
1934 
1935 // Adds a constant bias to the weight of every synapse in the connection
1936 void CARLsim::biasWeights(short int connId, float bias, bool updateWeightRange) {
1937  _impl->biasWeights(connId, bias, updateWeightRange);
1938 }
1939 
1940 // Loads a simulation (and network state) from file. The file pointer fid must point to a
1941 void CARLsim::loadSimulation(FILE* fid) { _impl->loadSimulation(fid); }
1942 
1943 // Multiplies the weight of every synapse in the connection with a scaling factor
1944 void CARLsim::scaleWeights(short int connId, float scale, bool updateWeightRange) {
1945  _impl->scaleWeights(connId, scale, updateWeightRange);
1946 }
1947 
1948 // Sets a connection monitor for a group, custom ConnectionMonitor class
1949 ConnectionMonitor* CARLsim::setConnectionMonitor(int grpIdPre, int grpIdPost, const std::string& fname) {
1950  return _impl->setConnectionMonitor(grpIdPre, grpIdPost, fname);
1951 }
1952 
1953 // Sets the amount of current (mA) to inject into a group
1954 void CARLsim::setExternalCurrent(int grpId, const std::vector<float>& current) {
1955  _impl->setExternalCurrent(grpId, current);
1956 }
1957 
1958 // Sets the amount of current (mA) to inject to each neuron in a group
1959 void CARLsim::setExternalCurrent(int grpId, float current) { _impl->setExternalCurrent(grpId, current); }
1960 
1961 // Sets a group monitor for a group, custom GroupMonitor class
1962 GroupMonitor* CARLsim::setGroupMonitor(int grpId, const std::string& fname) {
1963  return _impl->setGroupMonitor(grpId, fname);
1964 }
1965 
1966 // Associates a SpikeGenerator object with a group
1967 void CARLsim::setSpikeGenerator(int grpId, SpikeGenerator* spikeGenFunc) {
1968  _impl->setSpikeGenerator(grpId, spikeGenFunc);
1969 }
1970 
1971 // Sets a Spike Monitor for a groups, prints spikes to binary file
1972 SpikeMonitor* CARLsim::setSpikeMonitor(int grpId, const std::string& fileName) {
1973  return _impl->setSpikeMonitor(grpId, fileName);
1974 }
1975 
1976 // Sets a Neuron Monitor for a groups, prints neuron state values (voltage, recovery, and total current values) to binary file
1977 NeuronMonitor* CARLsim::setNeuronMonitor(int grpId, const std::string& fileName) {
1978  return _impl->setNeuronMonitor(grpId, fileName);
1979 }
1980 
1981 // Sets a spike rate
1982 void CARLsim::setSpikeRate(int grpId, PoissonRate* spikeRate, int refPeriod) {
1983  _impl->setSpikeRate(grpId, spikeRate, refPeriod);
1984 }
1985 
1986 // Sets the weight value of a specific synapse
1987 void CARLsim::setWeight(short int connId, int neurIdPre, int neurIdPost, float weight, bool updateWeightRange) {
1988  _impl->setWeight(connId, neurIdPre, neurIdPost, weight, updateWeightRange);
1989 }
1990 
1991 // Enters a testing phase in which all weight changes are disabled
1992 void CARLsim::startTesting(bool updateWeights) { _impl->startTesting(updateWeights); }
1993 
1994 // Exits a testing phase, making weight changes possible again
1995 void CARLsim::stopTesting() { _impl->stopTesting(); }
1996 
1997 // Returns the current CARLsim state
1999 
2000 // gets AMPA vector of a group
2001 std::vector<float> CARLsim::getConductanceAMPA(int grpId) { return _impl->getConductanceAMPA(grpId); }
2002 
2003 // gets NMDA vector of a group
2004 std::vector<float> CARLsim::getConductanceNMDA(int grpId) { return _impl->getConductanceNMDA(grpId); }
2005 
2006 // gets GABAa vector of a group
2007 std::vector<float> CARLsim::getConductanceGABAa(int grpId) { return _impl->getConductanceGABAa(grpId); }
2008 
2009 // gets GABAb vector of a group
2010 std::vector<float> CARLsim::getConductanceGABAb(int grpId) { return _impl->getConductanceGABAb(grpId); }
2011 
2012 // returns the RangeDelay struct for a specific connection ID
2013 RangeDelay CARLsim::getDelayRange(short int connId) { return _impl->getDelayRange(connId); }
2014 
2015 // gets delays
2016 uint8_t* CARLsim::getDelays(int gIDpre, int gIDpost, int& Npre, int& Npost) {
2017  return _impl->getDelays(gIDpre, gIDpost, Npre, Npost);
2018 }
2019 
2020 // returns the 3D grid struct of a group
2021 Grid3D CARLsim::getGroupGrid3D(int grpId) { return _impl->getGroupGrid3D(grpId); }
2022 
2023 int CARLsim::getGroupId(std::string grpName) { return _impl->getGroupId(grpName); }
2024 
2025 // gets group name
2026 std::string CARLsim::getGroupName(int grpId) { return _impl->getGroupName(grpId); }
2027 
2028 // returns the 3D location a neuron codes for
2029 Point3D CARLsim::getNeuronLocation3D(int neurId) { return _impl->getNeuronLocation3D(neurId); }
2030 
2031 // returns the 3D location a neuron codes for
2032 Point3D CARLsim::getNeuronLocation3D(int grpId, int relNeurId) { return _impl->getNeuronLocation3D(grpId, relNeurId); }
2033 
2034 // Returns the number of connections (pairs of pre-post groups) in the network
2036 
2038 
2039 // returns the number of connections associated with a connection ID
2040 int CARLsim::getNumSynapticConnections(short int connectionId) { return _impl->getNumSynapticConnections(connectionId); }
2041 
2042 // returns the number of groups in the network
2043 int CARLsim::getNumGroups() { return _impl->getNumGroups(); }
2044 
2045 // returns the total number of allocated neurons in the network
2046 int CARLsim::getNumNeurons() { return _impl->getNumNeurons(); }
2047 
2048 // returns the total number of regular (Izhikevich) neurons
2050 
2051 // returns the total number of regular (Izhikevich) excitatory neurons
2053 
2054 // returns the total number of regular (Izhikevich) inhibitory neurons
2056 
2057 // returns the total number of spike generator neurons
2059 
2060 // returns the total number of excitatory spike generator neurons
2062 
2063 // returns the total number of inhibitory spike generator neurons
2065 
2066 // returns the total number of allocated post-synaptic connections in the network
2067 int CARLsim::getNumSynapses() { return _impl->getNumSynapses(); }
2068 
2069 // returns the first neuron id of a groupd specified by grpId
2070 int CARLsim::getGroupStartNeuronId(int grpId) { return _impl->getGroupStartNeuronId(grpId); }
2071 
2072 // returns the last neuron id of a groupd specified by grpId
2073 int CARLsim::getGroupEndNeuronId(int grpId) { return _impl->getGroupEndNeuronId(grpId); }
2074 
2075 // returns the number of neurons of a group specified by grpId
2076 int CARLsim::getGroupNumNeurons(int grpId) { return _impl->getGroupNumNeurons(grpId); }
2077 
2078 // returns the stdp information of a group specified by grpId
2079 GroupSTDPInfo CARLsim::getGroupSTDPInfo(int grpId) { return _impl->getGroupSTDPInfo(grpId); }
2080 
2081 // returns the neuromodulator information of a group specified by grpId
2083  return _impl->getGroupNeuromodulatorInfo(grpId);
2084 }
2085 
2086 int CARLsim::getSimTime() { return _impl->getSimTime(); }
2087 
2088 int CARLsim::getSimTimeSec() { return _impl->getSimTimeSec(); }
2089 
2090 int CARLsim::getSimTimeMsec() { return _impl->getSimTimeMsec(); }
2091 
2092 // returns pointer to previously allocated SpikeMonitor object, NULL else
2093 SpikeMonitor* CARLsim::getSpikeMonitor(int grpId) { return _impl->getSpikeMonitor(grpId); }
2094 
2095 // returns the RangeWeight struct for a specific connection ID
2096 RangeWeight CARLsim::getWeightRange(short int connId) { return _impl->getWeightRange(connId); }
2097 
2098 // Returns whether a connection is fixed or plastic
2099 bool CARLsim::isConnectionPlastic(short int connId) { return _impl->isConnectionPlastic(connId); }
2100 
2101 // Returns whether a group has homeostasis enabled
2102 bool CARLsim::isGroupWithHomeostasis(int grpId) { return _impl->isGroupWithHomeostasis(grpId); }
2103 
2104 bool CARLsim::isExcitatoryGroup(int grpId) { return _impl->isExcitatoryGroup(grpId); }
2105 
2106 bool CARLsim::isInhibitoryGroup(int grpId) { return _impl->isInhibitoryGroup(grpId); }
2107 
2108 bool CARLsim::isPoissonGroup(int grpId) { return _impl->isPoissonGroup(grpId); }
2109 
2110 void CARLsim::setDefaultConductanceTimeConstants(int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb,
2111  int tdGABAb)
2112 {
2113  _impl->setDefaultConductanceTimeConstants(tdAMPA, trNMDA, tdNMDA, tdGABAa, trGABAb, tdGABAb);
2114 }
2115 
2116 // Sets default homeostasis params
2117 void CARLsim::setDefaultHomeostasisParams(float homeoScale, float avgTimeScale) {
2118  _impl->setDefaultHomeostasisParams(homeoScale, avgTimeScale);
2119 }
2120 
2121 // Sets default options for save file
2122 void CARLsim::setDefaultSaveOptions(std::string fileName, bool saveSynapseInfo) {
2123  _impl->setDefaultSaveOptions(fileName, saveSynapseInfo);
2124 }
2125 
2126 // sets default STDP params
2127 void CARLsim::setDefaultSTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, STDPType stdpType) {
2128  _impl->setDefaultSTDPparams(alphaPlus, tauPlus, alphaMinus, tauMinus, stdpType);
2129 }
2130 
2131 // sets default values for E-STDP params
2132 void CARLsim::setDefaultESTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, STDPType stdpType) {
2133  _impl->setDefaultESTDPparams(alphaPlus, tauPlus, alphaMinus, tauMinus, stdpType);
2134 }
2135 
2136 // sets default values for I-STDP params
2137 void CARLsim::setDefaultISTDPparams(float betaLTP, float betaLTD, float lambda, float delta, STDPType stdpType) {
2138  _impl->setDefaultISTDPparams(betaLTP, betaLTD, lambda, delta, stdpType);
2139 }
2140 
2141 // Sets default values for STP params U, tau_u, and tau_x of a neuron group (pre-synaptically)
2142 void CARLsim::setDefaultSTPparams(int neurType, float STP_U, float STP_tau_u, float STP_tau_x) {
2143  _impl->setDefaultSTPparams(neurType, STP_U, STP_tau_u, STP_tau_x);
2144 }
RangeWeight::init
double init
Definition: carlsim_datastructures.h:334
CARLsim::setExternalCurrent
void setExternalCurrent(int grpId, const std::vector< float > &current)
Sets the amount of current (mA) to inject into a group.
Definition: carlsim.cpp:1954
SNN::getNumNeuronsRegInh
int getNumNeuronsRegInh()
Definition: snn.h:572
CARLsim::Impl::getNumNeuronsRegExc
int getNumNeuronsRegExc()
Definition: carlsim.cpp:1336
CARLsim::getNumNeuronsRegExc
int getNumNeuronsRegExc()
returns the total number of regular (Izhikevich) excitatory neurons
Definition: carlsim.cpp:2052
CARLsim::Impl::setDefaultConductanceTimeConstants
void setDefaultConductanceTimeConstants(int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb, int tdGABAb)
Definition: carlsim.cpp:1440
CARLsim::Impl::getSpikeMonitor
SpikeMonitor * getSpikeMonitor(int grpId)
Definition: carlsim.cpp:1380
SNN::getSimTimeSec
int getSimTimeSec()
Definition: snn.h:581
CARLsim::Impl::setConnectionMonitor
ConnectionMonitor * setConnectionMonitor(int grpIdPre, int grpIdPost, const std::string &fname)
Definition: carlsim.cpp:978
CARLsim::Impl::setExternalCurrent
void setExternalCurrent(int grpId, const std::vector< float > &current)
Definition: carlsim.cpp:1015
UserErrors::CANNOT_BE_LARGER
@ CANNOT_BE_LARGER
parameter cannot have larger vaule than some vaule
Definition: user_errors.h:35
CARLsim::createSpikeGeneratorGroup
int createSpikeGeneratorGroup(const std::string &grpName, int nNeur, int neurType, int preferredPartition=ANY, ComputingBackend preferredBackend=CPU_CORES)
creates a spike generator group
Definition: carlsim.cpp:1779
SNN::getGroupNumNeurons
int getGroupNumNeurons(int gGrpId)
Definition: snn.h:558
CARLsim::Impl::setNeuromodulator
void setNeuromodulator(int grpId, float tauDP, float tau5HT, float tauACh, float tauNE)
Definition: carlsim.cpp:653
SNN::setGroupMonitor
GroupMonitor * setGroupMonitor(int grpId, FILE *fid)
sets up a group monitor registered with a callback to process the spikes.
Definition: snn_manager.cpp:1087
SNN::getGroupStartNeuronId
int getGroupStartNeuronId(int gGrpId)
Definition: snn.h:556
SNN::setConductances
void setConductances(bool isSet, int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb, int tdGABAb)
Sets custom values for conductance decay (\tau_decay) or disables conductances alltogether These will...
Definition: snn_manager.cpp:408
RangeDelay::max
int max
Definition: carlsim_datastructures.h:292
RUN_STATE
@ RUN_STATE
run state, where the model is stepped
Definition: carlsim_datastructures.h:262
CARLsim::stopTesting
void stopTesting()
Exits a testing phase, making weight changes possible again.
Definition: carlsim.cpp:1995
SimMode
SimMode
simulation mode
Definition: carlsim_datastructures.h:113
integrationMethod_t
integrationMethod_t
Integration methods.
Definition: carlsim_datastructures.h:132
CARLsim::Impl::isInhibitoryGroup
bool isInhibitoryGroup(int grpId)
Definition: carlsim.cpp:1420
ConnectionGenerator
Definition: callback.h:90
CARLsim::getGroupName
std::string getGroupName(int grpId)
gets group name
Definition: carlsim.cpp:2026
CARLsim::setSTP
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)
Definition: carlsim.cpp:1893
UserErrors::CANNOT_BE_SET_TO
@ CANNOT_BE_SET_TO
parameter cannot be set to
Definition: user_errors.h:40
CARLsim::Impl::setDefaultSTDPparams
void setDefaultSTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, STDPType stdpType)
Definition: carlsim.cpp:1491
SNN::loadSimulation
void loadSimulation(FILE *fid)
Definition: snn_manager.cpp:1000
UserErrors::CANNOT_BE_IDENTICAL
@ CANNOT_BE_IDENTICAL
parameters cannot be identical
Definition: user_errors.h:32
CARLsim::Impl::getGroupEndNeuronId
int getGroupEndNeuronId(int grpId)
Definition: carlsim.cpp:1290
SNN::getNumGroups
int getNumGroups()
Definition: snn.h:568
CARLsim::Impl::getGroupStartNeuronId
int getGroupStartNeuronId(int grpId)
Definition: carlsim.cpp:1280
CARLsim::Impl::setDefaultHomeostasisParams
void setDefaultHomeostasisParams(float homeoScale, float avgTimeScale)
Definition: carlsim.cpp:1465
SNN::setNeuronParametersLIF
void setNeuronParametersLIF(int grpId, int tau_m, int tau_ref, float vTh, float vReset, double minRmem, double maxRmem)
Sets neuron parameters for a group of LIF spiking neurons.
Definition: snn_manager.cpp:574
CARLsim::setDefaultSaveOptions
void setDefaultSaveOptions(std::string fileName, bool saveSynapseInfo)
Sets default options for save file.
Definition: carlsim.cpp:2122
CARLsim::getGroupNeuromodulatorInfo
GroupNeuromodulatorInfo getGroupNeuromodulatorInfo(int grpId)
returns the neuromodulator information of a group specified by grpId
Definition: carlsim.cpp:2082
SNN::biasWeights
void biasWeights(short int connId, float bias, bool updateWeightRange=false)
Definition: snn_manager.cpp:915
CARLsim::setDefaultConductanceTimeConstants
void setDefaultConductanceTimeConstants(int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb, int tdGABAb)
Sets default values for conductance time constants.
Definition: carlsim.cpp:2110
RangeWeight
a range struct for synaptic weight magnitudes
Definition: carlsim_datastructures.h:311
CARLsim::getConductanceGABAb
std::vector< float > getConductanceGABAb(int grpId)
gets GABAb vector of a group
Definition: carlsim.cpp:2010
CARLsim::Impl::isConnectionPlastic
bool isConnectionPlastic(short int connId)
Definition: carlsim.cpp:1396
SpikeMonitor
Class SpikeMonitor.
Definition: spike_monitor.h:119
SNN::connect
short int connect(int gIDpre, int gIDpost, const std::string &_type, float initWt, float maxWt, float prob, uint8_t minDelay, uint8_t maxDelay, RadiusRF radius, float mulSynFast, float mulSynSlow, bool synWtType)
make from each neuron in grpId1 to 'numPostSynapses' neurons in grpId2
Definition: snn_manager.cpp:95
SNN::getNumNeuronsRegExc
int getNumNeuronsRegExc()
Definition: snn.h:571
CARLsim::getNeuronLocation3D
Point3D getNeuronLocation3D(int neurId)
returns the 3D location a neuron codes for
Definition: carlsim.cpp:2029
SNN::saveSimulation
void saveSimulation(FILE *fid, bool saveSynapseInfo=false)
stores the pre and post synaptic neuron ids with the weight and delay
Definition: snn_manager.cpp:1410
CARLsim::Impl::createGroupLIF
int createGroupLIF(const std::string &grpName, int nNeur, int neurType, int preferredPartition=ANY, ComputingBackend preferredBackend=CPU_CORES)
Definition: carlsim.cpp:322
callback_core.h
MAX_CONN_PER_SNN
#define MAX_CONN_PER_SNN
Definition: snn_definitions.h:131
CARLsim::Impl::getNumNeuronsGen
int getNumNeuronsGen()
Definition: carlsim.cpp:1338
CARLsim::runNetwork
int runNetwork(int nSec, int nMsec=0, bool printRunSummary=true)
run the simulation for time=(nSec*seconds + nMsec*milliseconds)
Definition: carlsim.cpp:1909
CARLsim::biasWeights
void biasWeights(short int connId, float bias, bool updateWeightRange=false)
Adds a constant bias to the weight of every synapse in the connection.
Definition: carlsim.cpp:1936
user_errors.h
CARLsim::startTesting
void startTesting(bool updateWeights=true)
Enters a testing phase in which all weight changes are disabled.
Definition: carlsim.cpp:1992
CARLsim::getNumSynapses
int getNumSynapses()
returns the total number of allocated synaptic connections in the network
Definition: carlsim.cpp:2067
CARLsim::setConductances
void setConductances(bool isSet)
Sets default values for conduction decay and rise times or disables COBA alltogether.
Definition: carlsim.cpp:1788
SNN::getNumNeuronsGenExc
int getNumNeuronsGenExc()
Definition: snn.h:574
CARLsim::Impl::setDefaultISTDPparams
void setDefaultISTDPparams(float betaLTP, float betaLTD, float lambda, float delta, STDPType stdpType)
Definition: carlsim.cpp:1520
CARLsim::Impl::setHomeoBaseFiringRate
void setHomeoBaseFiringRate(int grpId, float baseFiring, float baseFiringSD)
Definition: carlsim.cpp:535
SNN::getConductanceGABAa
std::vector< float > getConductanceGABAa(int grpId)
Definition: snn_manager.cpp:1760
SNN::getGroupSTDPInfo
GroupSTDPInfo getGroupSTDPInfo(int grpId)
Definition: snn_manager.cpp:1873
UserErrors::MUST_BE_IDENTICAL
@ MUST_BE_IDENTICAL
parameters must be identical
Definition: user_errors.h:48
RadiusRF::radX
double radX
Definition: carlsim_datastructures.h:372
CARLsim::~CARLsim
~CARLsim()
Definition: carlsim.cpp:1736
CARLsim::getNumNeuronsReg
int getNumNeuronsReg()
returns the total number of regular (Izhikevich) neurons
Definition: carlsim.cpp:2049
SNN::setSpikeGenerator
void setSpikeGenerator(int grpId, SpikeGeneratorCore *spikeGenFunc)
sets up a spike generator
Definition: snn_manager.cpp:1173
CARLsim::Impl::saveSimulation
void saveSimulation(const std::string &fileName, bool saveSynapseInfo)
Definition: carlsim.cpp:885
CARLsim::Impl::loadSimulation
void loadSimulation(FILE *fid)
Definition: carlsim.cpp:956
PulseCurve::stdpCurve
STDPCurve stdpCurve
the type of STDP curve
Definition: carlsim_datastructures.h:660
CARLsim::Impl::setHomeostasis
void setHomeostasis(int grpId, bool isSet)
Definition: carlsim.cpp:495
CARLsim::Impl::runNetwork
int runNetwork(int nSec, int nMsec, bool printRunSummary)
Definition: carlsim.cpp:846
CARLsim::Impl::setLogFile
void setLogFile(const std::string &fileName)
Definition: carlsim.cpp:897
EXP_CURVE
@ EXP_CURVE
standard exponential curve
Definition: carlsim_datastructures.h:178
SNN::runNetwork
int runNetwork(int _nsec, int _nmsec, bool printRunSummary)
run the simulation for n sec
Definition: snn_manager.cpp:793
SNN::setWeightAndWeightChangeUpdate
void setWeightAndWeightChangeUpdate(UpdateInterval wtANDwtChangeUpdateInterval, bool enableWtChangeDecay, float wtChangeDecay)
Sets the weight and weight change update parameters.
Definition: snn_manager.cpp:723
CARLsim::getSimTimeMsec
int getSimTimeMsec()
returns
Definition: carlsim.cpp:2090
CARLsim::Impl::getConductanceAMPA
std::vector< float > getConductanceAMPA(int grpId)
Definition: carlsim.cpp:1194
CARLsim::scaleWeights
void scaleWeights(short int connId, float scale, bool updateWeightRange=false)
reset Spike Counter to zero
Definition: carlsim.cpp:1944
CARLsim::connectCompartments
short int connectCompartments(int grpIdLower, int grpIdUpper)
make a compartmental connection between two compartmentally enabled groups Note: all compartmentally ...
Definition: carlsim.cpp:1755
UserErrors::CAN_ONLY_BE_CALLED_IN_STATE
@ CAN_ONLY_BE_CALLED_IN_STATE
function can only be called in certain state
Definition: user_errors.h:27
SpikeGeneratorCore
used for relaying callback to SpikeGenerator
Definition: callback_core.h:69
CARLsim::Impl
Definition: carlsim.cpp:79
SNN::getNumSynapses
int getNumSynapses()
Definition: snn.h:576
CARLsim::getNumNeurons
int getNumNeurons()
returns the total number of allocated neurons in the network
Definition: carlsim.cpp:2046
UserErrors::MUST_BE_POSITIVE
@ MUST_BE_POSITIVE
parameter must have positive value
Definition: user_errors.h:53
SNN::isConnectionPlastic
bool isConnectionPlastic(short int connId)
returns whether synapses in connection are fixed (false) or plastic (true)
Definition: snn_manager.cpp:4883
CARLsim::setDefaultESTDPparams
void setDefaultESTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, STDPType stdpType)
sets default values for E-STDP params
Definition: carlsim.cpp:2132
CARLsimState
CARLsimState
CARLsim states.
Definition: carlsim_datastructures.h:259
CARLsim::Impl::setLogsFpCustom
void setLogsFpCustom(FILE *fpInf, FILE *fpErr, FILE *fpDeb, FILE *fpLog)
Definition: carlsim.cpp:920
CARLsim::Impl::getConductanceGABAb
std::vector< float > getConductanceGABAb(int grpId)
Definition: carlsim.cpp:1227
RangeRmem::minRmem
double minRmem
Definition: carlsim_datastructures.h:398
CARLsim::Impl::getConductanceNMDA
std::vector< float > getConductanceNMDA(int grpId)
Definition: carlsim.cpp:1205
SNN::setExternalCurrent
void setExternalCurrent(int grpId, const std::vector< float > &current)
injects current (mA) into the soma of every neuron in the group
Definition: snn_manager.cpp:1377
CARLsim::getLogFpDeb
const FILE * getLogFpDeb()
returns file pointer to debug log
Definition: carlsim.cpp:1918
CARLsim::setNeuronParametersLIF
void setNeuronParametersLIF(int grpId, int tau_m, int tau_ref=0, float vTh=1.0f, float vReset=0.0f, const RangeRmem &rMem=RangeRmem(1.0f))
Sets neuron parameters for a group of LIF spiking neurons.
Definition: carlsim.cpp:1840
CARLsim::Impl::setNeuronMonitor
NeuronMonitor * setNeuronMonitor(int grpId, const std::string &fileName)
Definition: carlsim.cpp:1125
CARLsim::setCompartmentParameters
void setCompartmentParameters(int grpId, float couplingUp, float couplingDown)
Sets coupling constants G_u and G_d for the compartment.
Definition: carlsim.cpp:1783
CARLsim::Impl::setDefaultSaveOptions
void setDefaultSaveOptions(std::string fileName, bool saveSynapseInfo)
Definition: carlsim.cpp:1475
CARLsim::Impl::setDefaultESTDPparams
void setDefaultESTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, STDPType stdpType)
Definition: carlsim.cpp:1496
CARLsim::Impl::setSpikeGenerator
void setSpikeGenerator(int grpId, SpikeGenerator *spikeGenFunc)
Definition: carlsim.cpp:1074
SNN::setLogsFp
void setLogsFp(FILE *fpInf=NULL, FILE *fpErr=NULL, FILE *fpDeb=NULL, FILE *fpLog=NULL)
Sets the file pointers for all log files file pointer NULL means don't change it.
Definition: snn_manager.cpp:1671
CARLsim::saveSimulation
void saveSimulation(const std::string &fileName, bool saveSynapseInfo=true)
Saves important simulation and network infos to file.
Definition: carlsim.cpp:1922
CARLsim::Impl::stopTesting
void stopTesting()
Definition: carlsim.cpp:948
CARLsim::getNumGroups
int getNumGroups()
returns the number of groups in the network
Definition: carlsim.cpp:2043
GroupSTDPInfo_s
A struct for retrieving STDP related information of a group.
Definition: carlsim_datastructures.h:411
CARLsim::setLogFile
void setLogFile(const std::string &fileName)
Sets the name of the log file.
Definition: carlsim.cpp:1927
Grid3D::numX
int numX
Definition: carlsim_datastructures.h:547
CARLsim::Impl::getSimTimeSec
int getSimTimeSec()
Definition: carlsim.cpp:1376
CARLsim::setDefaultSTDPparams
void setDefaultSTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, STDPType stdpType)
sets default STDP params
Definition: carlsim.cpp:2127
RangeWeight::max
double max
Definition: carlsim_datastructures.h:334
ConnectionGeneratorCore
used for relaying callback to ConnectionGenerator
Definition: callback_core.h:89
CARLsim::setHomeoBaseFiringRate
void setHomeoBaseFiringRate(int grpId, float baseFiring, float baseFiringSD=0.0f)
Sets the homeostatic target firing rate (enforced through homeostatic synaptic scaling)
Definition: carlsim.cpp:1805
CARLsim::Impl::getGroupSTDPInfo
GroupSTDPInfo getGroupSTDPInfo(int grpId)
Definition: carlsim.cpp:1360
PulseCurve
struct to assign a pulse I-STDP curve
Definition: carlsim_datastructures.h:649
CARLsim::setGroupMonitor
GroupMonitor * setGroupMonitor(int grpId, const std::string &fname)
Sets a group monitor for a group, custom GroupMonitor class.
Definition: carlsim.cpp:1962
PoissonRate
Class for generating Poisson spike trains.
Definition: poisson_rate.h:84
CARLsim::Impl::getLogFpInf
const FILE * getLogFpInf()
Definition: carlsim.cpp:880
CARLsim::Impl::setNeuronParameters
void setNeuronParameters(int grpId, float izh_C, float izh_C_sd, float izh_k, float izh_k_sd, float izh_vr, float izh_vr_sd, float izh_vt, float izh_vt_sd, float izh_a, float izh_a_sd, float izh_b, float izh_b_sd, float izh_vpeak, float izh_vpeak_sd, float izh_c, float izh_c_sd, float izh_d, float izh_d_sd)
Definition: carlsim.cpp:599
CARLsim::Impl::connectCompartments
short int connectCompartments(int grpIdLower, int grpIdUpper)
Definition: carlsim.cpp:256
SNN::getConductanceNMDA
std::vector< float > getConductanceNMDA(int grpId)
Definition: snn_manager.cpp:1740
SNN::setCompartmentParameters
void setCompartmentParameters(int grpId, float couplingUp, float couplingDown)
Coupling constants for the compartment are set using this method.
Definition: snn_manager.cpp:392
CARLsim::Impl::setConductances
void setConductances(bool isSet, int tdAMPA, int tdNMDA, int tdGABAa, int tdGABAb)
Definition: carlsim.cpp:450
EXCITATORY_NEURON
#define EXCITATORY_NEURON
Definition: carlsim_definitions.h:76
CARLsim::setConnectionMonitor
ConnectionMonitor * setConnectionMonitor(int grpIdPre, int grpIdPost, const std::string &fname)
Sets a connection monitor for a group, custom ConnectionMonitor class.
Definition: carlsim.cpp:1949
CARLsim::Impl::setISTDP
void setISTDP(int grpId, bool isSet, STDPType type, ExpCurve curve)
Definition: carlsim.cpp:752
CARLsim::Impl::getDelayRange
RangeDelay getDelayRange(short int connId)
Definition: carlsim.cpp:1238
CARLsim::Impl::setDefaultSTPparams
void setDefaultSTPparams(int neurType, float STP_U, float STP_tau_u, float STP_tau_x)
Definition: carlsim.cpp:1546
SNN::startTesting
void startTesting(bool shallUpdateWeights=true)
enters a testing phase, where all weight updates are disabled
Definition: snn_manager.cpp:6180
MAX_NUM_CUDA_DEVICES
#define MAX_NUM_CUDA_DEVICES
Definition: carlsim_definitions.h:87
UserErrors::MUST_BE_IN_RANGE
@ MUST_BE_IN_RANGE
parameter must be in some range
Definition: user_errors.h:49
SNN::getNumNeuronsGenInh
int getNumNeuronsGenInh()
Definition: snn.h:575
CARLsim::Impl::getGroupId
int getGroupId(std::string grpName)
Definition: carlsim.cpp:1268
CARLsim::Impl::getWeightRange
RangeWeight getWeightRange(short int connId)
Definition: carlsim.cpp:1388
UNKNOWN_LOGGER
@ UNKNOWN_LOGGER
Definition: carlsim_datastructures.h:96
CARLsim::Impl::isPoissonGroup
bool isPoissonGroup(int grpId)
Definition: carlsim.cpp:1428
CARLsim::getNumNeuronsRegInh
int getNumNeuronsRegInh()
returns the total number of regular (Izhikevich) inhibitory neurons
Definition: carlsim.cpp:2055
CARLsim::getGroupStartNeuronId
int getGroupStartNeuronId(int grpId)
returns the first neuron id of a groupd specified by grpId
Definition: carlsim.cpp:2070
SNN::setNeuromodulator
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,...
Definition: snn_manager.cpp:596
CARLsim::Impl::setNeuronParameters
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)
Definition: carlsim.cpp:562
UserErrors::CANNOT_BE_NULL
@ CANNOT_BE_NULL
parameter cannot have NULL value
Definition: user_errors.h:34
CARLsim::getConductanceGABAa
std::vector< float > getConductanceGABAa(int grpId)
gets GABAa vector of a group
Definition: carlsim.cpp:2007
CARLsim::setSpikeRate
void setSpikeRate(int grpId, PoissonRate *spikeRate, int refPeriod=1)
Sets a spike rate.
Definition: carlsim.cpp:1982
CARLsim::setWeight
void setWeight(short int connId, int neurIdPre, int neurIdPost, float weight, bool updateWeightRange=false)
Sets the weight value of a specific synapse.
Definition: carlsim.cpp:1987
CARLsim::setSpikeGenerator
void setSpikeGenerator(int grpId, SpikeGenerator *spikeGenFunc)
A SpikeCounter keeps track of the number of spikes per neuron in a group.
Definition: carlsim.cpp:1967
SNN::getNumNeurons
int getNumNeurons()
Definition: snn.h:569
SNN::setSpikeMonitor
SpikeMonitor * setSpikeMonitor(int gid, FILE *fid)
sets up a spike monitor registered with a callback to process the spikes, there can only be one Spike...
Definition: snn_manager.cpp:1181
PULSE_CURVE
@ PULSE_CURVE
symmetric pulse curve
Definition: carlsim_datastructures.h:179
CARLsim::Impl::getNumNeurons
int getNumNeurons()
Definition: carlsim.cpp:1334
ExpCurve::tauPlus
float tauPlus
the time constant of the exponential curve at pre-post side
Definition: carlsim_datastructures.h:580
PulseCurve::delta
float delta
the range of inhibitory LTD
Definition: carlsim_datastructures.h:664
CARLsim::Impl::setSpikeRate
void setSpikeRate(int grpId, PoissonRate *spikeRate, int refPeriod)
Definition: carlsim.cpp:1163
CARLsim::Impl::startTesting
void startTesting(bool updateWeights)
Definition: carlsim.cpp:941
UserErrors::FILE_CANNOT_OPEN
@ FILE_CANNOT_OPEN
could not open file
Definition: user_errors.h:44
CARLsim::setDefaultISTDPparams
void setDefaultISTDPparams(float betaLTP, float betaLTD, float lambda, float delta, STDPType stdpType)
sets default values for I-STDP params
Definition: carlsim.cpp:2137
CARLsim::Impl::getGroupNeuromodulatorInfo
GroupNeuromodulatorInfo getGroupNeuromodulatorInfo(int grpId)
Definition: carlsim.cpp:1368
CARLsim::Impl::getMaxNumCompConnections
int getMaxNumCompConnections()
Definition: carlsim.cpp:1331
CARLsim::getConductanceAMPA
std::vector< float > getConductanceAMPA(int grpId)
gets AMPA vector of a group
Definition: carlsim.cpp:2001
CARLsim::isExcitatoryGroup
bool isExcitatoryGroup(int grpId)
returns
Definition: carlsim.cpp:2104
TimingBasedCurve
A struct to assign a timing-based E-STDP curve.
Definition: carlsim_datastructures.h:613
CARLsim::getLogFpErr
const FILE * getLogFpErr()
returns file pointer to error log
Definition: carlsim.cpp:1917
UserErrors::CANNOT_BE_CONN_TWICE
@ CANNOT_BE_CONN_TWICE
cannot be connected twice
Definition: user_errors.h:31
CARLsim::setupNetwork
void setupNetwork()
build the network
Definition: carlsim.cpp:1914
RangeRmem::maxRmem
double maxRmem
Definition: carlsim_datastructures.h:398
CARLsim::getGroupSTDPInfo
GroupSTDPInfo getGroupSTDPInfo(int grpId)
returns the stdp information of a group specified by grpId
Definition: carlsim.cpp:2079
CARLsim::Impl::biasWeights
void biasWeights(short int connId, float bias, bool updateWeightRange)
Definition: carlsim.cpp:930
CARLsim::Impl::getNumNeuronsRegInh
int getNumNeuronsRegInh()
Definition: carlsim.cpp:1337
stdpType_string
static const char * stdpType_string[]
Definition: carlsim_datastructures.h:166
CARLSIM_WARN
#define CARLSIM_WARN(where, what)
Definition: carlsim_definitions.h:84
SNN::createGroup
int createGroup(const std::string &grpName, const Grid3D &grid, int neurType, int preferredPartition, ComputingBackend preferredBackend)
Creates a group of Izhikevich spiking neurons.
Definition: snn_manager.cpp:251
TimingBasedCurve::alphaMinus
float alphaMinus
the amplitude of the exponential curve at post-pre side
Definition: carlsim_datastructures.h:628
CARLsim::setISTDP
void setISTDP(int grpId, bool isSet)
Sets default I-STDP mode and parameters.
Definition: carlsim.cpp:1880
SNN::getGroupNeuromodulatorInfo
GroupNeuromodulatorInfo getGroupNeuromodulatorInfo(int grpId)
Definition: snn_manager.cpp:1900
RangeDelay
a range struct for synaptic delays
Definition: carlsim_datastructures.h:278
SNN::getGroupEndNeuronId
int getGroupEndNeuronId(int gGrpId)
Definition: snn.h:557
ExpCurve::stdpCurve
STDPCurve stdpCurve
the type of STDP curve
Definition: carlsim_datastructures.h:578
CARLsim::setNeuronParameters
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.
Definition: carlsim.cpp:1815
PoissonRate::getNumNeurons
int getNumNeurons()
Returns the number of neurons for which to generate Poisson spike trains.
Definition: poisson_rate.cpp:222
UserErrors::WRONG_NEURON_TYPE
@ WRONG_NEURON_TYPE
function cannot be applied to neuron type
Definition: user_errors.h:62
TimingBasedCurve::tauPlus
float tauPlus
the time constant of the exponential curve at pre-post side
Definition: carlsim_datastructures.h:627
CARLsim::setIntegrationMethod
void setIntegrationMethod(integrationMethod_t method, int numStepsPerMs)
Definition: carlsim.cpp:1809
CARLsim::setHomeostasis
void setHomeostasis(int grpId, bool isSet, float homeoScale, float avgTimeScale)
Sets custom values for implementation of homeostatic synaptic scaling.
Definition: carlsim.cpp:1799
CARLsim::Impl::setCompartmentParameters
void setCompartmentParameters(int grpId, float couplingUp, float couplingDown)
Definition: carlsim.cpp:426
SNN::setupNetwork
void setupNetwork()
build the network
Definition: snn_manager.cpp:772
PulseCurve::betaLTD
float betaLTD
the amplitude of inhibitory LTD
Definition: carlsim_datastructures.h:662
SNN::stopTesting
void stopTesting()
exits a testing phase, making weight updates possible again
Definition: snn_manager.cpp:6207
CARLsim::getDelayRange
RangeDelay getDelayRange(short int connId)
returns the RangeDelay struct for a specific connection ID
Definition: carlsim.cpp:2013
CARLsim::Impl::connect
short int connect(int grpId1, int grpId2, ConnectionGenerator *conn, bool synWtType)
Definition: carlsim.cpp:190
GroupMonitor
Class GroupMonitor.
Definition: group_monitor.h:103
CARLsim::getConductanceNMDA
std::vector< float > getConductanceNMDA(int grpId)
gets NMDA vector of a group
Definition: carlsim.cpp:2004
CARLsim::Impl::createGroup
int createGroup(const std::string &grpName, const Grid3D &grid, int neurType, int preferredPartition, ComputingBackend preferredBackend)
Definition: carlsim.cpp:327
ExpCurve::alphaMinus
float alphaMinus
the amplitude of the exponential curve at post-pre side
Definition: carlsim_datastructures.h:581
SNN::setNeuronMonitor
NeuronMonitor * setNeuronMonitor(int gid, FILE *fid)
sets up a neuron monitor registered with a callback to process the neuron state values,...
Definition: snn_manager.cpp:1221
SNN::isPoissonGroup
bool isPoissonGroup(int gGrpId)
Definition: snn.h:622
RangeDelay::min
int min
Definition: carlsim_datastructures.h:292
ALL
#define ALL
CARLsim common definitions.
Definition: carlsim_definitions.h:55
CARLsim::Impl::getLogFpLog
const FILE * getLogFpLog()
Definition: carlsim.cpp:883
CARLsim::getDelays
uint8_t * getDelays(int gIDpre, int gIDpost, int &Npre, int &Npost)
gets delays
Definition: carlsim.cpp:2016
CARLsim::Impl::getSimTimeMsec
int getSimTimeMsec()
Definition: carlsim.cpp:1377
CARLsim::Impl::createSpikeGeneratorGroup
int createSpikeGeneratorGroup(const std::string &grpName, int nNeur, int neurType, int preferredPartition, ComputingBackend preferredBackend)
Definition: carlsim.cpp:403
SNN::getGroupId
int getGroupId(std::string grpName)
Definition: snn_manager.cpp:1852
CARLsim::Impl::getNumGroups
int getNumGroups()
Definition: carlsim.cpp:1333
CARLsim::setSTDP
void setSTDP(int grpId, bool isSet)
Sets default STDP mode and params.
Definition: carlsim.cpp:1857
CARLsim::Impl::createGroupLIF
int createGroupLIF(const std::string &grpName, const Grid3D &grid, int neurType, int preferredPartition, ComputingBackend preferredBackend)
Definition: carlsim.cpp:365
CARLsim::Impl::connect
short int connect(int grpId1, int grpId2, ConnectionGenerator *conn, float mulSynFast, float mulSynSlow, bool synWtType)
Definition: carlsim.cpp:222
CARLsim::getNumSynapticConnections
int getNumSynapticConnections(short int connectionId)
returns the number of connections associated with a connection ID
Definition: carlsim.cpp:2040
ExpCurve::tauMinus
float tauMinus
the time constant of the exponential curve at post-pre side
Definition: carlsim_datastructures.h:582
ComputingBackend
ComputingBackend
computing backend
Definition: carlsim_datastructures.h:147
CARLsim::getLogFpInf
const FILE * getLogFpInf()
returns file pointer to info log
Definition: carlsim.cpp:1916
SNN::getSpikeMonitor
SpikeMonitor * getSpikeMonitor(int grpId)
Returns pointer to existing SpikeMonitor object, NULL else.
Definition: snn_manager.cpp:1959
CARLsim::Impl::setExternalCurrent
void setExternalCurrent(int grpId, float current)
Definition: carlsim.cpp:1027
CARLsim::isInhibitoryGroup
bool isInhibitoryGroup(int grpId)
returns
Definition: carlsim.cpp:2106
SNN::createSpikeGeneratorGroup
int createSpikeGeneratorGroup(const std::string &grpName, const Grid3D &grid, int neurType, int preferredPartition, ComputingBackend preferredBackend)
Creates a spike generator group (dummy-neurons, not Izhikevich spiking neurons)
Definition: snn_manager.cpp:348
Grid3D::numY
int numY
Definition: carlsim_datastructures.h:547
CARLsim::Impl::setupNetwork
void setupNetwork()
Definition: carlsim.cpp:868
SNN::getConductanceAMPA
std::vector< float > getConductanceAMPA(int grpId)
Definition: snn_manager.cpp:1727
SNN::setWeight
void setWeight(short int connId, int neurIdPre, int neurIdPost, float weight, bool updateWeightRange=false)
sets the weight value of a specific synapse
Definition: snn_manager.cpp:1286
MAX_NUM_COMP_CONN
#define MAX_NUM_COMP_CONN
Definition: carlsim_definitions.h:90
TimingBasedCurve::gamma
float gamma
the turn-over point
Definition: carlsim_datastructures.h:630
CARLsim::getSpikeMonitor
SpikeMonitor * getSpikeMonitor(int grpId)
Returns the number of spikes per neuron for a certain group.
Definition: carlsim.cpp:2093
CARLsim::Impl::getLogFpDeb
const FILE * getLogFpDeb()
Definition: carlsim.cpp:882
UNKNOWN_STDP
@ UNKNOWN_STDP
Definition: carlsim_datastructures.h:163
CARLsim::Impl::getGroupNumNeurons
int getGroupNumNeurons(int grpId)
Definition: carlsim.cpp:1300
SNN::getNeuronLocation3D
Point3D getNeuronLocation3D(int neurId)
Definition: snn_manager.cpp:1915
SNN::setIntegrationMethod
void setIntegrationMethod(integrationMethod_t method, int numStepsPerMs)
Sets the integration method and the number of integration steps per 1ms simulation time step.
Definition: snn_manager.cpp:496
SNN::scaleWeights
void scaleWeights(short int connId, float scale, bool updateWeightRange=false)
Definition: snn_manager.cpp:1005
SNN::getLogFpErr
const FILE * getLogFpErr()
returns file pointer to error log
Definition: snn.h:515
CARLsim::Impl::getLogFpErr
const FILE * getLogFpErr()
Definition: carlsim.cpp:881
CARLsim::Impl::setISTDP
void setISTDP(int grpId, bool isSet)
Definition: carlsim.cpp:734
CARLsim::Impl::Impl
Impl(CARLsim *sim, const std::string &netName, SimMode prferredSimMode, LoggerMode loggerMode, int randSeed)
Definition: carlsim.cpp:83
CARLsim::getSimTimeSec
int getSimTimeSec()
returns
Definition: carlsim.cpp:2088
CARLsim
CARLsim User Interface This class provides a user interface to the public sections of CARLsimCore sou...
Definition: carlsim.h:137
CARLsim::Impl::connect
short int connect(int grpId1, int grpId2, const std::string &connType, const RangeWeight &wt, float connProb, const RangeDelay &delay, const RadiusRF &radRF, bool synWtType, float mulSynFast, float mulSynSlow)
Definition: carlsim.cpp:131
CARLsim::getWeightRange
RangeWeight getWeightRange(short int connId)
returns the RangeWeight struct for a specific connection ID
Definition: carlsim.cpp:2096
CARLsim::Impl::setHomeostasis
void setHomeostasis(int grpId, bool isSet, float homeoScale, float avgTimeScale)
Definition: carlsim.cpp:515
Point3D
a point in 3D space
Definition: linear_algebra.h:57
ExpCurve
A struct to assign exponential STDP curves.
Definition: carlsim_datastructures.h:570
PulseCurve::lambda
float lambda
the range of inhibitory LTP
Definition: carlsim_datastructures.h:663
CARLsim::connect
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.0), 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...
Definition: carlsim.cpp:1739
UserErrors::CANNOT_BE_UNKNOWN
@ CANNOT_BE_UNKNOWN
parameter cannot be of type UNKNOWN
Definition: user_errors.h:41
SNN::getSimTimeMs
int getSimTimeMs()
Definition: snn.h:582
CARLsim::Impl::getNumNeuronsGenInh
int getNumNeuronsGenInh()
Definition: carlsim.cpp:1340
CARLsim::Impl::getGroupGrid3D
Grid3D getGroupGrid3D(int grpId)
Definition: carlsim.cpp:1259
DA_MOD
@ DA_MOD
dopamine-modulated STDP, nearest-neighbor
Definition: carlsim_datastructures.h:162
CARLsim::Impl::getNumSynapses
int getNumSynapses()
Definition: carlsim.cpp:1352
SYN_PLASTIC
#define SYN_PLASTIC
Definition: carlsim_definitions.h:60
SNN::getLogFpInf
const FILE * getLogFpInf()
function writes population weights from gIDpre to gIDpost to file fname in binary.
Definition: snn.h:513
CARLsim::isGroupWithHomeostasis
bool isGroupWithHomeostasis(int grpId)
Returns whether a group has homeostasis enabled.
Definition: carlsim.cpp:2102
CARLsim::Impl::getNumConnections
int getNumConnections()
Definition: carlsim.cpp:1330
CARLsim::Impl::setNeuronParameters
void setNeuronParameters(int grpId, float izh_C, float izh_k, float izh_vr, float izh_vt, float izh_a, float izh_b, float izh_vpeak, float izh_c, float izh_d)
Definition: carlsim.cpp:585
Grid3D
A struct to arrange neurons on a 3D grid (a primitive cubic Bravais lattice with cubic side length 1)
Definition: carlsim_datastructures.h:489
CUSTOM
@ CUSTOM
Custom mode, the user can set the location of all the file pointers.
Definition: carlsim_datastructures.h:95
PulseCurve::betaLTP
float betaLTP
the amplitude of inhibitory LTP
Definition: carlsim_datastructures.h:661
SNN::connectCompartments
short int connectCompartments(int grpIdLower, int grpIdUpper)
Definition: snn_manager.cpp:216
SNN::setHomeostasis
void setHomeostasis(int grpId, bool isSet, float homeoScale, float avgTimeScale)
Sets the homeostasis parameters. g is the grpID, enable=true(false) enables(disables) homeostasis,...
Definition: snn_manager.cpp:460
CARLsim::Impl::setGroupMonitor
GroupMonitor * setGroupMonitor(int grpId, const std::string &fname)
Definition: carlsim.cpp:1039
SNN::setSpikeRate
void setSpikeRate(int grpId, PoissonRate *spikeRate, int refPeriod)
Sets the Poisson spike rate for a group. For information on how to set up spikeRate,...
Definition: snn_manager.cpp:1270
SNN::setESTDP
void setESTDP(int grpId, bool isSet, STDPType type, STDPCurve curve, float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, float gamma)
Set the spike-timing-dependent plasticity (STDP) for a neuron group.
Definition: snn_manager.cpp:620
ExpCurve::alphaPlus
float alphaPlus
the amplitude of the exponential curve at pre-post side
Definition: carlsim_datastructures.h:579
CARLsim::Impl::getSimTime
int getSimTime()
Definition: carlsim.cpp:1375
CARLsim::Impl::getDelays
uint8_t * getDelays(int gIDpre, int gIDpost, int &Npre, int &Npost)
Definition: carlsim.cpp:1247
CARLsim::setESTDP
void setESTDP(int grpId, bool isSet)
Sets default E-STDP mode and parameters.
Definition: carlsim.cpp:1867
SETUP_STATE
@ SETUP_STATE
setup state, where the neural network is prepared for execution and monitors are set
Definition: carlsim_datastructures.h:261
CARLsim::Impl::setESTDP
void setESTDP(int grpId, bool isSet, STDPType type, ExpCurve curve)
Definition: carlsim.cpp:696
CARLsim::getGroupGrid3D
Grid3D getGroupGrid3D(int grpId)
returns the 3D grid struct of a group
Definition: carlsim.cpp:2021
CARLsim::getCARLsimState
CARLsimState getCARLsimState()
Writes population weights from gIDpre to gIDpost to file fname in binary.
Definition: carlsim.cpp:1998
CARLsim::Impl::getNumSynapticConnections
int getNumSynapticConnections(short int connectionId)
Definition: carlsim.cpp:1342
LoggerMode
LoggerMode
Logger modes.
Definition: carlsim_datastructures.h:90
CARLsim::getNumNeuronsGenExc
int getNumNeuronsGenExc()
returns the total number of excitatory spike generator neurons
Definition: carlsim.cpp:2061
CARLsim::Impl::createSpikeGeneratorGroup
int createSpikeGeneratorGroup(const std::string &grpName, const Grid3D &grid, int neurType, int preferredPartition, ComputingBackend preferredBackend)
Definition: carlsim.cpp:408
SNN::getNumSynapticConnections
int getNumSynapticConnections(short int connectionId)
gets number of connections associated with a connection ID
Definition: snn_manager.cpp:1948
CARLsim::Impl::setIntegrationMethod
void setIntegrationMethod(integrationMethod_t method, int numStepsPerMs)
Definition: carlsim.cpp:549
CARLsim::Impl::setSpikeMonitor
SpikeMonitor * setSpikeMonitor(int grpId, const std::string &fileName)
Definition: carlsim.cpp:1089
SpikeGenerator
Definition: callback.h:63
RadiusRF::radY
double radY
Definition: carlsim_datastructures.h:372
carlsim.h
TimingBasedCurve::stdpCurve
STDPCurve stdpCurve
the type of STDP curve
Definition: carlsim_datastructures.h:625
CARLsim::Impl::setConductances
void setConductances(bool isSet)
Definition: carlsim.cpp:436
SNN::getNumNeuronsReg
int getNumNeuronsReg()
Definition: snn.h:570
RangeRmem
Struct defines the minimum and maximum membrane resisatnces of the LIF neuron group.
Definition: carlsim_datastructures.h:379
CONFIG_STATE
@ CONFIG_STATE
configuration state, where the neural network is configured
Definition: carlsim_datastructures.h:260
STANDARD
@ STANDARD
standard STDP of Bi & Poo (2001), nearest-neighbor
Definition: carlsim_datastructures.h:161
SNN::getSimTime
int getSimTime()
Definition: snn.h:580
SNN::getLogFpDeb
const FILE * getLogFpDeb()
returns file pointer to debug log
Definition: snn.h:517
CARLsim::getGroupNumNeurons
int getGroupNumNeurons(int grpId)
returns the number of neurons of a group specified by grpId
Definition: carlsim.cpp:2076
SNN::setNeuronParameters
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 the Izhikevich parameters a, b, c, and d of a neuron group.
Definition: snn_manager.cpp:504
NeuronMonitor
Definition: neuron_monitor.h:58
SNN::createGroupLIF
int createGroupLIF(const std::string &grpName, const Grid3D &grid, int neurType, int preferredPartition, ComputingBackend preferredBackend)
Creates a group of LIF spiking neurons.
Definition: snn_manager.cpp:301
CARLsim::Impl::getNumNeuronsReg
int getNumNeuronsReg()
Definition: carlsim.cpp:1335
SYN_FIXED
#define SYN_FIXED
Definition: carlsim_definitions.h:59
CARLsim::Impl::getNeuronLocation3D
Point3D getNeuronLocation3D(int neurId)
Definition: carlsim.cpp:1308
SNN::setHomeoBaseFiringRate
void setHomeoBaseFiringRate(int groupId, float baseFiring, float baseFiringSD)
Sets homeostatic target firing rate (enforced through homeostatic synaptic scaling)
Definition: snn_manager.cpp:480
SNN::isInhibitoryGroup
bool isInhibitoryGroup(int gGrpId)
Definition: snn.h:621
SNN::getGroupName
std::string getGroupName(int grpId)
Definition: snn_manager.cpp:1864
CARLsim::setNeuronMonitor
NeuronMonitor * setNeuronMonitor(int grpId, const std::string &fileName)
Sets a Neuron Monitor for a groups, print voltage, recovery, and total current values to binary file.
Definition: carlsim.cpp:1977
CARLsim::CARLsim
CARLsim(const std::string &netName="SNN", SimMode preferredSimMode=CPU_MODE, LoggerMode loggerMode=USER, int ithGPUs=0, int randSeed=-1)
CARLsim constructor. Creates a new instance of class CARLsim. All input arguments are optional,...
Definition: carlsim.cpp:1734
ConnectionMonitor
Class ConnectionMonitor.
Definition: connection_monitor.h:148
RangeWeight::min
double min
Definition: carlsim_datastructures.h:334
SNN::isGroupWithHomeostasis
bool isGroupWithHomeostasis(int grpId)
returns whether group has homeostasis enabled (true) or not (false)
Definition: snn_manager.cpp:4893
CARLsim::Impl::setSTDP
void setSTDP(int grpId, bool isSet)
Definition: carlsim.cpp:666
CARLsim::isPoissonGroup
bool isPoissonGroup(int grpId)
returns
Definition: carlsim.cpp:2108
CARLsim::loadSimulation
void loadSimulation(FILE *fid)
Loads a simulation (and network state) from file. The file pointer fid must point to a valid CARLsim ...
Definition: carlsim.cpp:1941
CARLsim::setDefaultSTPparams
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)
Definition: carlsim.cpp:2142
CARLsim::Impl::getConductanceGABAa
std::vector< float > getConductanceGABAa(int grpId)
Definition: carlsim.cpp:1216
CARLsim::getNumConnections
int getNumConnections()
Returns the number of connections (pairs of pre-post groups) in the network.
Definition: carlsim.cpp:2035
CARLsim::setLogsFpCustom
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.
Definition: carlsim.cpp:1930
CARLsim::setDefaultHomeostasisParams
void setDefaultHomeostasisParams(float homeoScale, float avgTimeScale)
Sets default homeostasis params.
Definition: carlsim.cpp:2117
snn.h
GPU_CORES
@ GPU_CORES
Definition: carlsim_datastructures.h:149
SNN
Contains all of CARLsim's core functionality.
Definition: snn.h:114
SNN::getConductanceGABAb
std::vector< float > getConductanceGABAb(int grpId)
Definition: snn_manager.cpp:1773
SNN::getWeightRange
RangeWeight getWeightRange(short int connId)
returns RangeWeight struct of a connection
Definition: snn_manager.cpp:2002
UserErrors::MUST_BE_SET_TO
@ MUST_BE_SET_TO
parameter must be set to
Definition: user_errors.h:54
CARLsim::Impl::scaleWeights
void scaleWeights(short int connId, float scale, bool updateWeightRange)
Definition: carlsim.cpp:965
CARLsim::Impl::setISTDP
void setISTDP(int grpId, bool isSet, STDPType type, PulseCurve curve)
Definition: carlsim.cpp:771
CARLsim::Impl::setNeuromodulator
void setNeuromodulator(int grpId, float baseDP, float tauDP, float base5HT, float tau5HT, float baseACh, float tauACh, float baseNE, float tauNE)
Definition: carlsim.cpp:635
CARLsim::Impl::setSTDP
void setSTDP(int grpId, bool isSet, STDPType type, float alphaPlus, float tauPlus, float alphaMinus, float tauMinus)
Definition: carlsim.cpp:671
CARLsim::Impl::setNeuronParametersLIF
void setNeuronParametersLIF(int grpId, int tau_m, int tau_ref, float vTh, float vReset, const RangeRmem &rMem)
Definition: carlsim.cpp:616
GroupNeuromodulatorInfo_s
A struct for retrieving neuromodulator information of a group.
Definition: carlsim_datastructures.h:443
CARLsim::getNumNeuronsGen
int getNumNeuronsGen()
returns the total number of spike generator neurons
Definition: carlsim.cpp:2058
CARLsim::getGroupEndNeuronId
int getGroupEndNeuronId(int grpId)
returns the last neuron id of a groupd specified by grpId
Definition: carlsim.cpp:2073
UserErrors::assertTrue
static void assertTrue(bool statement, errorType errorIfAssertionFails, std::string errorFunc, std::string errorMsgPrefix="", std::string errorMsgSuffix="")
simple wrapper for assert statement
Definition: user_errors.cpp:15
UpdateInterval
UpdateInterval
Update frequency for weights.
Definition: carlsim_datastructures.h:237
SNN::isExcitatoryGroup
bool isExcitatoryGroup(int gGrpId)
Definition: snn.h:620
CARLsim::Impl::getGroupName
std::string getGroupName(int grpId)
Definition: carlsim.cpp:1272
UserErrors::CANNOT_BE_NEGATIVE
@ CANNOT_BE_NEGATIVE
parameter cannot have negative value (opposite to "must be", but includes zero)
Definition: user_errors.h:33
CARLsim::Impl::setESTDP
void setESTDP(int grpId, bool isSet, STDPType type, TimingBasedCurve curve)
Definition: carlsim.cpp:715
UNKNOWN_CURVE
@ UNKNOWN_CURVE
unknown curve type
Definition: carlsim_datastructures.h:181
SNN::getDelays
uint8_t * getDelays(int gGrpIdPre, int gGrpIdPost, int &numPreN, int &numPostN)
Returns the delay information for all synaptic connections between a pre-synaptic and a post-synaptic...
Definition: snn_manager.cpp:1801
CARLsim::setSpikeMonitor
SpikeMonitor * setSpikeMonitor(int grpId, const std::string &fileName)
Sets a Spike Monitor for a groups, prints spikes to binary file.
Definition: carlsim.cpp:1972
UserErrors::CANNOT_BE_CONN_SYN_AND_COMP
@ CANNOT_BE_CONN_SYN_AND_COMP
cannot be both synaptically and compartmentally connected
Definition: user_errors.h:30
CARLsim::Impl::setSTP
void setSTP(int grpId, bool isSet, float STP_U, float STP_tau_u, float STP_tau_x)
Definition: carlsim.cpp:813
UserErrors::ALL_NOT_ALLOWED
@ ALL_NOT_ALLOWED
keyword ALL is not allowed for this variable
Definition: user_errors.h:25
SNN::setISTDP
void setISTDP(int grpId, bool isSet, STDPType type, STDPCurve curve, float ab1, float ab2, float tau1, float tau2)
Set the inhibitory spike-timing-dependent plasticity (STDP) with anti-hebbian curve for a neuron grou...
Definition: snn_manager.cpp:653
SNN::setConnectionMonitor
ConnectionMonitor * setConnectionMonitor(int grpIdPre, int grpIdPost, FILE *fid)
sets up a network monitor registered with a callback to process the spikes.
Definition: snn_manager.cpp:1124
CARLsim::Impl::~Impl
~Impl()
Definition: carlsim.cpp:106
CARLsim::Impl::setSTP
void setSTP(int grpId, bool isSet)
Definition: carlsim.cpp:789
CARLsim::Impl::getNumNeuronsGenExc
int getNumNeuronsGenExc()
Definition: carlsim.cpp:1339
CARLsim::getSimTime
int getSimTime()
returns
Definition: carlsim.cpp:2086
TimingBasedCurve::alphaPlus
float alphaPlus
the amplitude of the exponential curve at pre-post side
Definition: carlsim_datastructures.h:626
Grid3D::numZ
int numZ
Definition: carlsim_datastructures.h:547
CARLsim::setNeuromodulator
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,...
Definition: carlsim.cpp:1845
SNN::getGroupGrid3D
Grid3D getGroupGrid3D(int grpId)
Definition: snn_manager.cpp:1845
CARLsim::setWeightAndWeightChangeUpdate
void setWeightAndWeightChangeUpdate(UpdateInterval wtANDwtChangeUpdateInterval, bool enableWtChangeDecay, float wtChangeDecay=0.9f)
Sets the weight and weight change update parameters.
Definition: carlsim.cpp:1901
CARLsim::Impl::isGroupWithHomeostasis
bool isGroupWithHomeostasis(int grpId)
Definition: carlsim.cpp:1404
CARLsim::Impl::isExcitatoryGroup
bool isExcitatoryGroup(int grpId)
Definition: carlsim.cpp:1412
SNN::setSTP
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) CARLsim implements the short...
Definition: snn_manager.cpp:699
INHIBITORY_NEURON
#define INHIBITORY_NEURON
Definition: carlsim_definitions.h:75
CARLsim::Impl::getCARLsimState
CARLsimState getCARLsimState()
Definition: carlsim.cpp:1192
CARLsim::Impl::getNeuronLocation3D
Point3D getNeuronLocation3D(int grpId, int relNeurId)
Definition: carlsim.cpp:1319
CARLsim::createGroupLIF
int createGroupLIF(const std::string &grpName, int nNeur, int neurType, int preferredPartition=ANY, ComputingBackend preferredBackend=CPU_CORES)
creates a group of Leaky-Integrate-and-Fire (LIF) spiking neurons
Definition: carlsim.cpp:1771
CARLsim::isConnectionPlastic
bool isConnectionPlastic(short int connId)
Returns whether a connection is fixed or plastic.
Definition: carlsim.cpp:2099
CARLsim::Impl::createGroup
int createGroup(const std::string &grpName, int nNeur, int neurType, int preferredPartition, ComputingBackend preferredBackend)
Definition: carlsim.cpp:317
RadiusRF
A struct to specify the receptive field (RF) radius in 3 dimensions.
Definition: carlsim_datastructures.h:363
ANY
#define ANY
used for create* method to specify any GPU or a specific GPU
Definition: carlsim_definitions.h:56
CARLsim::getGroupId
int getGroupId(std::string grpName)
finds the ID of the group with name grpName
Definition: carlsim.cpp:2023
SNN::getDelayRange
RangeDelay getDelayRange(short int connId)
returns the RangeDelay struct of a connection
Definition: snn_manager.cpp:1794
CARLsim::createGroup
int createGroup(const std::string &grpName, int nNeur, int neurType, int preferredPartition=ANY, ComputingBackend preferredBackend=CPU_CORES)
creates a group of Izhikevich spiking neurons
Definition: carlsim.cpp:1763
SNN::getNumNeuronsGen
int getNumNeuronsGen()
Definition: snn.h:573
CARLsim::getMaxNumCompConnections
int getMaxNumCompConnections()
Returns the maximum number of allowed compartmental connections per group.
Definition: carlsim.cpp:2037
CARLsim::Impl::setConductances
void setConductances(bool isSet, int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb, int tdGABAb)
Definition: carlsim.cpp:469
RadiusRF::radZ
double radZ
Definition: carlsim_datastructures.h:372
CARLsim::Impl::setWeightAndWeightChangeUpdate
void setWeightAndWeightChangeUpdate(UpdateInterval wtANDwtChangeUpdateInterval, bool enableWtChangeDecay, float wtChangeDecay)
Definition: carlsim.cpp:830
CARLsim::Impl::setNeuronParameters
void setNeuronParameters(int grpId, float izh_a, float izh_b, float izh_c, float izh_d)
Definition: carlsim.cpp:575
CARLsim::getLogFpLog
const FILE * getLogFpLog()
returns file pointer to log file
Definition: carlsim.cpp:1919
STDPType
STDPType
STDP flavors.
Definition: carlsim_datastructures.h:160
SNN::getNumConnections
int getNumConnections()
Definition: snn.h:565
CARLsim::Impl::setESTDP
void setESTDP(int grpId, bool isSet)
Definition: carlsim.cpp:678
CARLsim::Impl::setWeight
void setWeight(short int connId, int neurIdPre, int neurIdPost, float weight, bool updateWeightRange)
Definition: carlsim.cpp:1177
CARLsim::getNumNeuronsGenInh
int getNumNeuronsGenInh()
returns the total number of inhibitory spike generator neurons
Definition: carlsim.cpp:2064
TimingBasedCurve::tauMinus
float tauMinus
the time constant of the exponential curve at post-pre side
Definition: carlsim_datastructures.h:629
CPU_CORES
@ CPU_CORES
Definition: carlsim_datastructures.h:148
SNN::getLogFpLog
const FILE * getLogFpLog()
returns file pointer to log file
Definition: snn.h:519