Auryn simulator  v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
Functions
sim_brunel2k_pl.cpp File Reference

Implementation of the Brunel (2000) network with added STDP as implemented in NEST. More...

#include "auryn.h"
Include dependency graph for sim_brunel2k_pl.cpp:

Functions

int main (int ac, char *av[])
 

Detailed Description

Implementation of the Brunel (2000) network with added STDP as implemented in NEST.

This simulates the network from Brunel, N. (2000). Dynamics of sparsely connected networks of excitatory and inhibitory spiking neurons. J Comput Neurosci 8, 183–208. as implemented in the NEST examples (https://github.com/nest/nest-simulator/tree/master/examples/nest).

This file contains the network without plasticity. However, the same network was implemented with and without weight-dependent STDP for performance comparison with NEST. The results are published in Zenke, F., and Gerstner, W. (2014). Limits to high-speed simulations of spiking neural networks using general-purpose computers. Front Neuroinform 8, 76.

Function Documentation

◆ main()

int main ( int  ac,
char *  av[] 
)
45  {
46  string dir = ".";
47 
48  std::stringstream oss;
49  string strbuf ;
50  string msg;
51 
52  NeuronID ne = 8000;
53  NeuronID ni = 2000;
54 
55  NeuronID nrec = 50;
56 
57  double w = 0.1e-3; // 0.1mV PSC size
58  double wext = 0.1e-3;
59  double sparseness = 0.1;
60  double simtime = 1.;
61 
62  double lambda = 1e-2;
63  // For the benchmark this value was changed to 1e-9 to
64  // avoid frequency changes during the simulation. Otherwise
65  // lambda should be in the order of 1e-2 - 1e-3.
66  double gamma = 5.0;
67  double poisson_rate = 20.0e3;
68 
69  string load = "";
70  string save = "";
71 
72  string fwmat_ee = "";
73  string fwmat_ei = "";
74  string fwmat_ie = "";
75  string fwmat_ii = "";
76 
77  int errcode = 0;
78 
79 
80 
81  try {
82 
83  po::options_description desc("Allowed options");
84  desc.add_options()
85  ("help", "produce help message")
86  ("simtime", po::value<double>(), "duration of simulation")
87  ("gamma", po::value<double>(), "gamma factor for inhibitory weight")
88  ("lambda", po::value<double>(), "learning rate")
89  ("nu", po::value<double>(), "the external firing rate nu")
90  ("dir", po::value<string>(), "dir from file")
91  ("load", po::value<string>(), "load from file")
92  ("save", po::value<string>(), "save to file")
93  ("fee", po::value<string>(), "file with EE connections")
94  ("fei", po::value<string>(), "file with EI connections")
95  ("fie", po::value<string>(), "file with IE connections")
96  ("fii", po::value<string>(), "file with II connections")
97  ;
98 
99  po::variables_map vm;
100  po::store(po::parse_command_line(ac, av, desc), vm);
101  po::notify(vm);
102 
103  if (vm.count("help")) {
104  std::cout << desc << "\n";
105  return 1;
106  }
107 
108  if (vm.count("simtime")) {
109  simtime = vm["simtime"].as<double>();
110  }
111 
112  if (vm.count("gamma")) {
113  gamma = vm["gamma"].as<double>();
114  }
115 
116  if (vm.count("lambda")) {
117  lambda = vm["lambda"].as<double>();
118  }
119 
120  if (vm.count("nu")) {
121  poisson_rate = vm["nu"].as<double>();
122  }
123 
124  if (vm.count("dir")) {
125  dir = vm["dir"].as<string>();
126  }
127 
128  if (vm.count("load")) {
129  load = vm["load"].as<string>();
130  }
131 
132  if (vm.count("save")) {
133  save = vm["save"].as<string>();
134  }
135 
136  if (vm.count("fee")) {
137  fwmat_ee = vm["fee"].as<string>();
138  }
139 
140  if (vm.count("fie")) {
141  fwmat_ie = vm["fie"].as<string>();
142  }
143 
144  if (vm.count("fei")) {
145  fwmat_ei = vm["fei"].as<string>();
146  }
147 
148  if (vm.count("fii")) {
149  fwmat_ii = vm["fii"].as<string>();
150  }
151  }
152  catch(std::exception& e) {
153  std::cerr << "error: " << e.what() << "\n";
154  return 1;
155  }
156  catch(...) {
157  std::cerr << "Exception of unknown type!\n";
158  }
159 
160  auryn_init(ac, av);
161  oss << dir << "/brunel." << sys->mpi_rank() << ".";
162  string outputfile = oss.str();
163 
164  logger->msg("Setting up neuron groups ...",PROGRESS,true);
165  IafPscDeltaGroup * neurons_e = new IafPscDeltaGroup( ne );
166  neurons_e->set_tau_mem(20.0e-3);
167  neurons_e->set_tau_ref(2.0e-3);
168  neurons_e->e_rest = 0e-3;
169  neurons_e->e_reset = 10e-3;
170  neurons_e->thr = 20e-3;
171 
172  IafPscDeltaGroup * neurons_i = new IafPscDeltaGroup( ni );
173  neurons_i->set_tau_mem(20.0e-3);
174  neurons_i->set_tau_ref(2.0e-3);
175  neurons_i->e_rest = 0e-3;
176  neurons_i->e_reset = 10e-3;
177  neurons_i->thr = 20e-3;
178 
179  logger->msg("Setting up Poisson input ...",PROGRESS,true);
180  // The traditional way to implement the network is with
181  // independent Poisson noise.
182  PoissonStimulator * pstim_e
183  = new PoissonStimulator( neurons_e, poisson_rate, wext );
184  PoissonStimulator * pstim_i
185  = new PoissonStimulator( neurons_i, poisson_rate, wext );
186 
187  // The following would give correlated poisson noise from a single
188  // population of Poisson Neurons.
189  // PoissonGroup * poisson
190  // = new PoissonGroup( ne, poisson_rate );
191  // SparseConnection * cone
192  // = new SparseConnection(poisson,neurons_e, w, sparseness, MEM );
193  // SparseConnection * coni
194  // = new SparseConnection(poisson,neurons_i, w, sparseness, MEM );
195 
196  // This would be a solution where independend Poisson spikes
197  // are used from two PoissonGroups.
198  // PoissonGroup * pstim_e
199  // = new PoissonGroup( ne, poisson_rate*ne*sparseness );
200  // IdentityConnection * ide
201  // = new IdentityConnection(pstim_e,neurons_e, w, MEM );
202  // PoissonGroup * pstim_i
203  // = new PoissonGroup( ni, poisson_rate*ne*sparseness );
204  // IdentityConnection * idi
205  // = new IdentityConnection(pstim_i,neurons_i, w, MEM );
206 
207 
208  logger->msg("Setting up E connections ...",PROGRESS,true);
209  STDPwdConnection * con_ee
210  = new STDPwdConnection(
211  neurons_e,
212  neurons_e,
213  w,
214  sparseness
215  );
216  con_ee->set_transmitter(MEM);
217  con_ee->set_name("E->E");
218  con_ee->set_max_weight(3*w);
219  con_ee->set_alpha(2.02);
220  con_ee->set_lambda(lambda);
221 
222  SparseConnection * con_ei
223  = new SparseConnection( neurons_e,neurons_i,w,sparseness,MEM);
224 
225  logger->msg("Setting up I connections ...",PROGRESS,true);
226  SparseConnection * con_ii
227  = new SparseConnection( neurons_i,neurons_i,-gamma*w,sparseness,MEM);
228  SparseConnection * con_ie
229  = new SparseConnection( neurons_i,neurons_e,-gamma*w,sparseness,MEM);
230 
231  msg = "Setting up monitors ...";
232  logger->msg(msg,PROGRESS,true);
233 
234  std::stringstream filename;
235  filename << outputfile << "e.ras";
236  SpikeMonitor * smon_e = new SpikeMonitor( neurons_e, filename.str().c_str(), nrec);
237 
238  filename.str("");
239  filename.clear();
240  filename << outputfile << "i.ras";
241  SpikeMonitor * smon_i = new SpikeMonitor( neurons_i, filename.str().c_str(), nrec);
242 
243  // filename.str("");
244  // filename.clear();
245  // filename << outputfile << "syn";
246  // WeightMonitor * wmon = new WeightMonitor( con_ee, filename.str() );
247  // wmon->add_equally_spaced(1000);
248 
249  // filename.str("");
250  // filename.clear();
251  // filename << outputfile << "mem";
252  // StateMonitor * smon = new StateMonitor( neurons_e, 13, "mem", filename.str() );
253 
254  RateChecker * chk = new RateChecker( neurons_e , 0.1 , 1000. , 100e-3);
255 
256  if ( !load.empty() ) {
257  sys->load_network_state(load);
258  }
259 
260  if ( !fwmat_ee.empty() ) con_ee->load_from_complete_file(fwmat_ee);
261  if ( !fwmat_ei.empty() ) con_ei->load_from_complete_file(fwmat_ei);
262  if ( !fwmat_ie.empty() ) con_ie->load_from_complete_file(fwmat_ie);
263  if ( !fwmat_ii.empty() ) con_ii->load_from_complete_file(fwmat_ii);
264 
265  // con_ee->prune();
266  // con_ei->prune();
267  // con_ie->prune();
268  // con_ii->prune();
269 
270  // logger->msg("Running sanity check ...",PROGRESS,true);
271  con_ee->sanity_check();
272  con_ei->sanity_check();
273  con_ie->sanity_check();
274  con_ii->sanity_check();
275 
276  logger->msg("Simulating ..." ,PROGRESS,true);
277  if (!sys->run(simtime,true))
278  errcode = 1;
279 
280  if ( !save.empty() ) {
281  sys->save_network_state(save);
282  }
283 
284 
285  if (errcode)
286  auryn_abort(errcode);
287 
288 
289  logger->msg("Freeing ..." ,PROGRESS,true);
290  auryn_free();
291  return errcode;
292 }
AurynFloat thr
Definition: IafPscDeltaGroup.h:57
void auryn_free()
Cleanly shuts down Auryn simulation environment.
Definition: auryn_global.cpp:107
Current based synapse. Adds the transmitted quantity directly to membrane voltage.
Definition: auryn_definitions.h:143
Stimulator class to inject timeseries of currents NeuronGroups.
Definition: PoissonStimulator.h:47
void set_alpha(AurynWeight a)
Definition: STDPwdConnection.cpp:172
unsigned int mpi_rank()
Returns current rank.
Definition: System.cpp:1009
void load_network_state(std::string basename)
Loads network state from a netstate file.
Definition: System.cpp:812
void set_tau_ref(AurynFloat tau_ref)
Definition: IafPscDeltaGroup.cpp:64
A Checker class that tracks population firing rate as a moving average and breaks a run if it goes ou...
Definition: RateChecker.h:59
virtual bool load_from_complete_file(string filename)
Loads weight matrix from a single file.
Definition: SparseConnection.cpp:921
The base class to create sparse random connections.
Definition: SparseConnection.h:66
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
AurynFloat e_reset
Definition: IafPscDeltaGroup.h:57
The standard Monitor object to record spikes from a SpikingGroup and write them to a text file...
Definition: SpikeMonitor.h:52
void sanity_check()
Quick an dirty function that checks if all units on the local rank are connected. ...
Definition: SparseConnection.cpp:537
Conductance based neuron model with absolute refractoriness as used in Vogels and Abbott 2005...
Definition: IafPscDeltaGroup.h:38
void set_lambda(AurynWeight l)
Definition: STDPwdConnection.cpp:179
AurynFloat e_rest
Definition: IafPscDeltaGroup.h:57
void auryn_abort(int errcode)
Terminates Auryn simulation abnormally.
Definition: auryn_global.cpp:113
System * sys
Global pointer to instance of System which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:37
Doublet STDP All-to-All as implemented in NEST as stdp_synapse_hom.
Definition: STDPwdConnection.h:47
void auryn_init(int ac, char *av[], string dir, string simulation_name, string logfile_prefix, LogMessageType filelog_level, LogMessageType consolelog_level)
Initalizes MPI and the Auryn simulation environment.
Definition: auryn_global.cpp:84
void set_tau_mem(AurynFloat taum)
Definition: IafPscDeltaGroup.cpp:108
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
Definition: Logger.h:41
void set_max_weight(AurynWeight w)
Sets maximum weight (for plastic connections).
Definition: STDPwdConnection.cpp:200
void save_network_state(std::string basename)
Saves network state to a netstate file.
Definition: System.cpp:694
void set_transmitter(AurynStateVector *ptr)
Same as set_target.
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
void set_name(std::string name)
Set name of connection.
Definition: Connection.cpp:82
Here is the call graph for this function: