62 #if defined(WIN32) || defined(WIN64)
66 #define fmin (std::min)
67 #define fmax (std::max)
73 #define isnan(x) _isnan(x)
77 #define isinf(x) (!_finite(x))
81 #define srand48(x) srand(x)
85 #define drand48() (double(rand())/RAND_MAX)
89 #define INFINITY (DBL_MAX+DBL_MAX)
90 #define NAN (INFINITY-INFINITY)
111 class GroupMonitorCore;
112 class ConnectionMonitorCore;
113 class ConnectionGeneratorCore;
114 class SpikeGeneratorCore;
252 short int connect(
int grpId1,
int grpId2,
const std::string& connType,
const RangeWeight& wt,
float connProb,
254 float mulSynFast=1.0f,
float mulSynSlow=1.0f);
273 bool synWtType=
SYN_FIXED,
int maxM=0,
int maxPreM=0);
281 int createGroup(
const std::string& grpName,
int nNeur,
int neurType);
363 void setConductances(
bool isSet,
int tdAMPA,
int tdNMDA,
int tdGABAa,
int tdGABAb);
385 void setConductances(
bool isSet,
int tdAMPA,
int trNMDA,
int tdNMDA,
int tdGABAa,
int trGABAb,
int tdGABAb);
415 void setHomeostasis(
int grpId,
bool isSet,
float homeoScale,
float avgTimeScale);
458 void setNeuronParameters(
int grpId,
float izh_a,
float izh_a_sd,
float izh_b,
float izh_b_sd,
459 float izh_c,
float izh_c_sd,
float izh_d,
float izh_d_sd);
484 void setNeuromodulator(
int grpId,
float baseDP,
float tauDP,
float base5HT,
float tau5HT,
485 float baseACh,
float tauACh,
float baseNE,
float tauNE);
496 float tauACh = 100.0f,
float tauNE = 100.0f);
507 void setSTDP(
int grpId,
bool isSet);
518 void setSTDP(
int grpId,
bool isSet,
stdpType_t type,
float alphaPlus,
float tauPlus,
float alphaMinus,
float tauMinus);
529 void setESTDP(
int grpId,
bool isSet);
570 void setISTDP(
int grpId,
bool isSet);
631 void setSTP(
int grpId,
bool isSet,
float STP_U,
float STP_tau_u,
float STP_tau_x);
654 void setSTP(
int grpId,
bool isSet);
678 int runNetwork(
int nSec,
int nMsec=0,
bool printRunSummary=
true,
bool copyState=
false);
712 void saveSimulation(
const std::string& fileName,
bool saveSynapseInfo=
true);
748 void setLogsFpCustom(FILE* fpInf=NULL, FILE* fpErr=NULL, FILE* fpDeb=NULL, FILE* fpLog=NULL);
776 void biasWeights(
short int connId,
float bias,
bool updateWeightRange=
false);
840 void scaleWeights(
short int connId,
float scale,
bool updateWeightRange=
false);
1085 void setWeight(
short int connId,
int neurIdPre,
int neurIdPost,
float weight,
bool updateWeightRange=
false);
1171 uint8_t*
getDelays(
int gIDpre,
int gIDpost,
int& Npre,
int& Npost, uint8_t* delays=NULL);
1612 bool existsGrpId(
int grpId);
1614 void handleUserWarnings();
1616 void printSimulationSpecs();
1621 #if defined(WIN32) || defined(WIN64)
1622 static HANDLE gpuAllocationLock;
1624 static pthread_mutex_t gpuAllocationLock;
1629 std::string netName_;
1637 unsigned int numConnections_;
1638 std::vector<std::string> userWarnings_;
1640 std::vector<int> grpIds_;
1641 std::vector<SpikeGeneratorCore*> spkGen_;
1642 std::vector<ConnectionGeneratorCore*> connGen_;
1644 bool hasSetHomeoALL_;
1645 bool hasSetHomeoBaseFiringALL_;
1646 bool hasSetSTDPALL_;
1648 bool hasSetConductances_;
1660 float def_STDP_alphaLTP_;
1661 float def_STDP_tauLTP_;
1662 float def_STDP_alphaLTD_;
1663 float def_STDP_tauLTD_;
1664 float def_STDP_betaLTP_;
1665 float def_STDP_betaLTD_;
1666 float def_STDP_lambda_;
1667 float def_STDP_delta_;
1670 float def_STP_U_exc_;
1671 float def_STP_tau_u_exc_;
1672 float def_STP_tau_x_exc_;
1673 float def_STP_U_inh_;
1674 float def_STP_tau_u_inh_;
1675 float def_STP_tau_x_inh_;
1678 float def_homeo_scale_;
1679 float def_homeo_avgTimeScale_;
1682 std::string def_save_fileName_;
1683 bool def_save_synapseInfo_;
Class for generating Poisson spike trains.
A struct for retrieving neuromodulator information of a group.
model is run on a single CPU core
int getNumGroups()
returns the number of groups in the network
void setDefaultConductanceTimeConstants(int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb, int tdGABAb)
Sets default values for conductance time constants.
void setSTDP(int grpId, bool isSet)
Sets default STDP mode and params.
int createSpikeGeneratorGroup(const std::string &grpName, int nNeur, int neurType)
creates a spike generator group
int getGroupNumNeurons(int grpId)
returns the number of neurons of a group specified by grpId
carlsimState_t getCARLsimState()
Returns the current CARLsim state.
const FILE * getLogFpDeb()
returns file pointer to debug log
int getNumNeuronsRegInh()
returns the total number of regular (Izhikevich) inhibitory neurons
int getNumNeuronsReg()
returns the total number of regular (Izhikevich) neurons
void setESTDP(int grpId, bool isSet)
Sets default E-STDP mode and parameters.
int createGroup(const std::string &grpName, int nNeur, int neurType)
creates a group of Izhikevich spiking neurons
CARLsim User Interface This class provides a user interface to the public sections of CARLsimCore sou...
void setLogFile(const std::string &fileName)
Sets the name of the log file.
void setISTDP(int grpId, bool isSet)
Sets default I-STDP mode and parameters.
A struct to assign a timing-based E-STDP curve.
GroupNeuromodulatorInfo_t getGroupNeuromodulatorInfo(int grpId)
returns the neuromodulator information of a group specified by grpId
const FILE * getLogFpInf()
returns file pointer to info log
void resetSpikeCounter(int grpId)
reset Spike Counter to zero
short int connect(int grpId1, int grpId2, const std::string &connType, const RangeWeight &wt, float connProb, const RangeDelay &delay=RangeDelay(1), const RadiusRF &radRF=RadiusRF(-1), bool synWtType=SYN_FIXED, float mulSynFast=1.0f, float mulSynSlow=1.0f)
Connects a presynaptic to a postsynaptic group using fixed/plastic weights and a range of delay value...
#define MAX_NUM_CUDA_DEVICES
void loadSimulation(FILE *fid)
Loads a simulation (and network state) from file. The file pointer fid must point to a valid CARLsim ...
void setDefaultHomeostasisParams(float homeoScale, float avgTimeScale)
Sets default homeostasis params.
int getGroupEndNeuronId(int grpId)
returns the last neuron id of a groupd specified by grpId
const FILE * getLogFpErr()
returns file pointer to error log
void setWeightAndWeightChangeUpdate(updateInterval_t wtANDwtChangeUpdateInterval, bool enableWtChangeDecay, float wtChangeDecay=0.9f)
Sets the weight and weight change update parameters.
void setHomeoBaseFiringRate(int grpId, float baseFiring, float baseFiringSD=0.0f)
Sets the homeostatic target firing rate (enforced through homeostatic synaptic scaling) ...
int getNumNeuronsRegExc()
returns the total number of regular (Izhikevich) excitatory neurons
void setDefaultSTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, stdpType_t stdpType)
sets default STDP params
int getNumPostSynapses()
returns the total number of allocated post-synaptic connections in the network
void setDefaultISTDPparams(float betaLTP, float betaLTD, float lambda, float delta, stdpType_t stdpType)
sets default values for I-STDP params
int getNumNeuronsGen()
returns the total number of spike generator neurons
A struct to arrange neurons on a 3D grid (a primitive cubic Bravais lattice with cubic side length 1)...
void setNeuromodulator(int grpId, float baseDP, float tauDP, float base5HT, float tau5HT, float baseACh, float tauACh, float baseNE, float tauNE)
Sets baseline concentration and decay time constant of neuromodulators (DP, 5HT, ACh, NE) for a neuron group.
bool isExcitatoryGroup(int grpId)
returns
void setConductances(bool isSet)
Sets default values for conduction decay and rise times or disables COBA alltogether.
void setupNetwork(bool removeTempMemory=true)
build the network
bool isInhibitoryGroup(int grpId)
returns
struct to assign a pulse I-STDP curve
int runNetwork(int nSec, int nMsec=0, bool printRunSummary=true, bool copyState=false)
run the simulation for time=(nSec*seconds + nMsec*milliseconds)
ConnectionMonitor * setConnectionMonitor(int grpIdPre, int grpIdPost, const std::string &fname)
Sets a connection monitor for a group, custom ConnectionMonitor class.
uint32_t getSimTimeSec()
returns
std::vector< float > getConductanceGABAa(int grpId)
gets GABAa vector of a group
int getNumNeurons()
returns the total number of allocated neurons in the network
void setSpikeRate(int grpId, PoissonRate *spikeRate, int refPeriod=1)
Sets a spike rate.
std::vector< float > getConductanceGABAb(int grpId)
gets GABAb vector of a group
void setHomeostasis(int grpId, bool isSet, float homeoScale, float avgTimeScale)
Sets custom values for implementation of homeostatic synaptic scaling.
void setSpikeCounter(int grpId, int recordDur=-1)
A SpikeCounter keeps track of the number of spikes per neuron in a group.
std::string getGroupName(int grpId)
gets group name
std::vector< float > getConductanceAMPA(int grpId)
gets AMPA vector of a group
int getNumNeuronsGenExc()
returns the total number of excitatory spike generator neurons
int getGroupId(std::string grpName)
finds the ID of the group with name grpName
Point3D getNeuronLocation3D(int neurId)
returns the 3D location a neuron codes for
a range struct for synaptic delays
void biasWeights(short int connId, float bias, bool updateWeightRange=false)
Adds a constant bias to the weight of every synapse in the connection.
simMode_t getSimMode()
returns the current simulation mode
int getNumConnections()
Returns the number of connections (pairs of pre-post groups) in the network.
int getGroupStartNeuronId(int grpId)
returns the first neuron id of a groupd specified by grpId
Grid3D getGroupGrid3D(int grpId)
returns the 3D grid struct of a group
void setDefaultSTPparams(int neurType, float STP_U, float STP_tau_u, float STP_tau_x)
Sets default values for STP params U, tau_u, and tau_x of a neuron group (pre-synaptically) ...
int getNumSynapticConnections(short int connectionId)
returns the number of connections associated with a connection ID
void setWeight(short int connId, int neurIdPre, int neurIdPost, float weight, bool updateWeightRange=false)
Sets the weight value of a specific synapse.
int getNumPreSynapses()
returns the total number of allocated pre-synaptic connections in the network
uint32_t getSimTimeMsec()
returns
int getNumNeuronsGenInh()
returns the total number of inhibitory spike generator neurons
A struct to assign exponential STDP curves.
void setDefaultESTDPparams(float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, stdpType_t stdpType)
sets default values for E-STDP params
std::vector< float > getConductanceNMDA(int grpId)
gets NMDA vector of a group
CARLsim(const std::string &netName="SNN", simMode_t simMode=CPU_MODE, loggerMode_t loggerMode=USER, int ithGPU=0, int randSeed=-1)
CARLsim constructor. Creates a new instance of class CARLsim. All input arguments are optional...
GroupMonitor * setGroupMonitor(int grpId, const std::string &fname)
Sets a group monitor for a group, custom GroupMonitor class.
void writePopWeights(std::string fname, int gIDpre, int gIDpost)
function writes population weights from gIDpre to gIDpost to file fname in binary.
void setSTP(int grpId, bool isSet, float STP_U, float STP_tau_u, float STP_tau_x)
Sets STP params U, tau_u, and tau_x of a neuron group (pre-synaptically)
a range struct for synaptic weight magnitudes
void setDefaultSaveOptions(std::string fileName, bool saveSynapseInfo)
Sets default options for save file.
void setSpikeGenerator(int grpId, SpikeGenerator *spikeGen)
Associates a SpikeGenerator object with a group.
const FILE * getLogFpLog()
returns file pointer to log file
updateInterval_t
Update frequency for weights.
A struct for retrieving STDP related information of a group.
GroupSTDPInfo_t getGroupSTDPInfo(int grpId)
returns the stdp information of a group specified by grpId
RangeDelay getDelayRange(short int connId)
returns the RangeDelay struct for a specific connection ID
SpikeMonitor * setSpikeMonitor(int grpId, const std::string &fileName)
Sets a Spike Monitor for a groups, prints spikes to binary file.
int * getSpikeCounter(int grpId)
Returns the number of spikes per neuron for a certain group.
SpikeMonitor * getSpikeMonitor(int grpId)
returns pointer to previously allocated SpikeMonitor object, NULL else
uint64_t getSimTime()
returns
bool isPoissonGroup(int grpId)
returns
uint8_t * getDelays(int gIDpre, int gIDpost, int &Npre, int &Npost, uint8_t *delays=NULL)
gets delays
User mode, for experiment-oriented simulations.
carlsimState_t
CARLsim states.
void setLogsFpCustom(FILE *fpInf=NULL, FILE *fpErr=NULL, FILE *fpDeb=NULL, FILE *fpLog=NULL)
Sets the file pointers for all log files in CUSTOM mode.
RangeWeight getWeightRange(short int connId)
returns the RangeWeight struct for a specific connection ID
void setNeuronParameters(int grpId, float izh_a, float izh_a_sd, float izh_b, float izh_b_sd, float izh_c, float izh_c_sd, float izh_d, float izh_d_sd)
Sets Izhikevich params a, b, c, and d with as mean +- standard deviation.
void scaleWeights(short int connId, float scale, bool updateWeightRange=false)
Multiplies the weight of every synapse in the connection with a scaling factor.
void saveSimulation(const std::string &fileName, bool saveSynapseInfo=true)
Saves important simulation and network infos to file.
void setExternalCurrent(int grpId, const std::vector< float > ¤t)
Sets the amount of current (mA) to inject into a group.
loggerMode_t
Logger modes.
A struct to specify the receptive field (RF) radius in 3 dimensions.