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