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

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

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

Functions

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

Detailed Description

Implementation of the Brunel (2000) network 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  std::string dir = ".";
47 
48  std::stringstream oss;
49  std::string strbuf ;
50  std::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 gamma = 5.0;
63  double poisson_rate = 20.0e3;
64 
65  std::string load = "";
66  std::string save = "";
67 
68  std::string fwmat_ee = "";
69  std::string fwmat_ei = "";
70  std::string fwmat_ie = "";
71  std::string fwmat_ii = "";
72 
73  int errcode = 0;
74 
75 
76 
77  try {
78 
79  po::options_description desc("Allowed options");
80  desc.add_options()
81  ("help", "produce help message")
82  ("simtime", po::value<double>(), "duration of simulation")
83  ("gamma", po::value<double>(), "gamma factor for inhibitory weight")
84  ("nu", po::value<double>(), "the external firing rate nu")
85  ("dir", po::value<std::string>(), "dir from file")
86  ("load", po::value<std::string>(), "load from file")
87  ("save", po::value<std::string>(), "save to file")
88  ("fee", po::value<std::string>(), "file with EE connections")
89  ("fei", po::value<std::string>(), "file with EI connections")
90  ("fie", po::value<std::string>(), "file with IE connections")
91  ("fii", po::value<std::string>(), "file with II connections")
92  ;
93 
94  po::variables_map vm;
95  po::store(po::parse_command_line(ac, av, desc), vm);
96  po::notify(vm);
97 
98  if (vm.count("help")) {
99  std::cout << desc << "\n";
100  return 1;
101  }
102 
103  if (vm.count("simtime")) {
104  simtime = vm["simtime"].as<double>();
105  }
106 
107  if (vm.count("gamma")) {
108  gamma = vm["gamma"].as<double>();
109  }
110 
111  if (vm.count("nu")) {
112  poisson_rate = vm["nu"].as<double>();
113  }
114 
115  if (vm.count("dir")) {
116  dir = vm["dir"].as<std::string>();
117  }
118 
119  if (vm.count("load")) {
120  load = vm["load"].as<std::string>();
121  }
122 
123  if (vm.count("save")) {
124  save = vm["save"].as<std::string>();
125  }
126 
127  if (vm.count("fee")) {
128  fwmat_ee = vm["fee"].as<std::string>();
129  }
130 
131  if (vm.count("fie")) {
132  fwmat_ie = vm["fie"].as<std::string>();
133  }
134 
135  if (vm.count("fei")) {
136  fwmat_ei = vm["fei"].as<std::string>();
137  }
138 
139  if (vm.count("fii")) {
140  fwmat_ii = vm["fii"].as<std::string>();
141  }
142  }
143  catch(std::exception& e) {
144  std::cerr << "error: " << e.what() << "\n";
145  return 1;
146  }
147  catch(...) {
148  std::cerr << "Exception of unknown type!\n";
149  }
150 
151  auryn_init(ac, av);
152 
153  oss << dir << "/brunel." << sys->mpi_rank() << ".";
154  std::string outputfile = oss.str();
155 
156  //
157  logger->msg("Setting up neuron groups ...",PROGRESS,true);
158  IafPscDeltaGroup * neurons_e = new IafPscDeltaGroup( ne );
159  neurons_e->set_tau_mem(20.0e-3);
160  neurons_e->set_tau_ref(2.0e-3);
161  neurons_e->e_rest = 0e-3;
162  neurons_e->e_reset = 10e-3;
163  neurons_e->thr = 20e-3;
164 
165  IafPscDeltaGroup * neurons_i = new IafPscDeltaGroup( ni );
166  neurons_i->set_tau_mem(20.0e-3);
167  neurons_i->set_tau_ref(2.0e-3);
168  neurons_i->e_rest = 0e-3;
169  neurons_i->e_reset = 10e-3;
170  neurons_i->thr = 20e-3;
171 
172  logger->msg("Setting up Poisson input ...",PROGRESS,true);
173  // The traditional way to implement the network is with
174  // independent Poisson noise.
175  PoissonStimulator * pstim_e
176  = new PoissonStimulator( neurons_e, poisson_rate, wext );
177  PoissonStimulator * pstim_i
178  = new PoissonStimulator( neurons_i, poisson_rate, wext );
179 
180  // The following would give correlated poisson noise from a single
181  // population of Poisson Neurons.
182  // PoissonGroup * poisson
183  // = new PoissonGroup( ne, poisson_rate );
184  // SparseConnection * cone
185  // = new SparseConnection(poisson,neurons_e, w, sparseness, MEM );
186  // SparseConnection * coni
187  // = new SparseConnection(poisson,neurons_i, w, sparseness, MEM );
188 
189  // This would be a solution where independend Poisson spikes
190  // are used from two PoissonGroups.
191  // PoissonGroup * pstim_e
192  // = new PoissonGroup( ne, poisson_rate*ne*sparseness );
193  // IdentityConnection * ide
194  // = new IdentityConnection(pstim_e,neurons_e, w, MEM );
195  // PoissonGroup * pstim_i
196  // = new PoissonGroup( ni, poisson_rate*ne*sparseness );
197  // IdentityConnection * idi
198  // = new IdentityConnection(pstim_i,neurons_i, w, MEM );
199 
200 
201  SparseConnection * con_ee
202  = new SparseConnection( neurons_e,neurons_e,w,sparseness,MEM);
203 
204  SparseConnection * con_ei
205  = new SparseConnection( neurons_e,neurons_i,w,sparseness,MEM);
206 
207  logger->msg("Setting up I connections ...",PROGRESS,true);
208  SparseConnection * con_ii
209  = new SparseConnection( neurons_i,neurons_i,-gamma*w,sparseness,MEM);
210  SparseConnection * con_ie
211  = new SparseConnection( neurons_i,neurons_e,-gamma*w,sparseness,MEM);
212 
213  msg = "Setting up monitors ...";
214  logger->msg(msg,PROGRESS,true);
215 
216  std::stringstream filename;
217  filename << outputfile << "e.ras";
218  SpikeMonitor * smon_e = new SpikeMonitor( neurons_e, filename.str().c_str(), nrec);
219 
220  filename.str("");
221  filename.clear();
222  filename << outputfile << "i.ras";
223  SpikeMonitor * smon_i = new SpikeMonitor( neurons_i, filename.str().c_str(), nrec);
224 
225  // filename.str("");
226  // filename.clear();
227  // filename << outputfile << "syn";
228  // WeightMonitor * wmon = new WeightMonitor( con_ee, filename.str() );
229  // wmon->add_equally_spaced(1000);
230 
231  // filename.str("");
232  // filename.clear();
233  // filename << outputfile << "mem";
234  // StateMonitor * smon = new StateMonitor( neurons_e, 13, "mem", filename.str() );
235 
236  RateChecker * chk = new RateChecker( neurons_e , 0.1 , 1000. , 100e-3);
237 
238  if ( !load.empty() ) {
239  sys->load_network_state(load);
240  }
241 
242  if ( !fwmat_ee.empty() ) con_ee->load_from_complete_file(fwmat_ee);
243  if ( !fwmat_ei.empty() ) con_ei->load_from_complete_file(fwmat_ei);
244  if ( !fwmat_ie.empty() ) con_ie->load_from_complete_file(fwmat_ie);
245  if ( !fwmat_ii.empty() ) con_ii->load_from_complete_file(fwmat_ii);
246 
247  logger->msg("Running sanity check ...",PROGRESS,true);
248  con_ee->sanity_check();
249  con_ei->sanity_check();
250  con_ie->sanity_check();
251  con_ii->sanity_check();
252 
253  logger->msg("Simulating ..." ,PROGRESS,true);
254  if (!sys->run(simtime,true))
255  errcode = 1;
256 
257  if ( !save.empty() ) {
258  sys->save_network_state(save);
259  }
260 
261 
262  if (errcode)
263  auryn_abort(errcode);
264 
265 
266  logger->msg("Freeing ..." ,PROGRESS,true);
267  auryn_free();
268  return errcode;
269 }
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
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
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
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 save_network_state(std::string basename)
Saves network state to a netstate file.
Definition: System.cpp:694
std::string string
Standard library string type which is imported into Auryn namespace.
Definition: auryn_definitions.h:156
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function: