Auryn simulator  v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
Functions
sim_bg_static.cpp File Reference
#include "auryn.h"
Include dependency graph for sim_bg_static.cpp:

Functions

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

Function Documentation

◆ main()

int main ( int  ac,
char *  av[] 
)
28 {
29 
30  double w = 0.16;
31  double w_ext = w;
32  double wmax = 1.0;
33 
34  double w_ee = w;
35  double w_ei = w;
36 
37  double gamma = 1.0;
38  double w_ie = gamma;
39  double w_ii = gamma;
40 
41  NeuronID ne = 20000;
42  NeuronID ni = ne/4;
43 
44  double sparseness = 0.05;
45 
46  bool quiet = false;
47  bool scaling = false;
48  bool wmatdump = false;
49  double tau_chk = 100e-3;
50  double simtime = 3600.;
51  double stimtime = simtime;
52  double wmat_interval = 600.;
53 
54  double ampa_nmda_ratio = 1.0;
55  double wstim = 0.1;
56 
57  NeuronID psize = 200;
58  NeuronID hsize = 100;
59  NeuronID offset = 0;
60 
61  string patfile = "";
62  string prefile = "";
63  string currentfile = "";
64 
65  double stimfreq = 10;
66 
67  int plen = 3;
68  int hlen = 3;
69 
70  double ampl = 1.0;
71  bool recall = false;
72  bool decay = false;
73  bool adapt = false;
74  bool noisyweights = false;
75  bool switchweights = false;
76  bool ei_plastic = false;
77 
78  double bg_rate = 2;
79  bool fast = false;
80  AurynWeight wdecay = w;
81  double tau_decay = 3600.;
82 
83 
84  string dir = ".";
85  string stimfile = "";
86  string infilename = "";
87 
88  const char * file_prefix = "bg_static";
89  char strbuf [255];
90  string msg;
91 
92  int errcode = 0;
93 
94  try {
95 
96  po::options_description desc("Allowed options");
97  desc.add_options()
98  ("help", "produce help message")
99  ("quiet", "quiet mode")
100  ("bgrate", po::value<double>(), "PoissonGroup external firing rate")
101  ("sparseness", po::value<double>(), "overall network sparseness")
102  ("simtime", po::value<double>(), "simulation time")
103  ("dir", po::value<string>(), "output dir")
104  ("ne", po::value<int>(), "no of exc units")
105  ("adapt", "adapting excitatory neurons")
106  ("fast", "turn off some of the monitors to run faster")
107  ;
108 
109  po::variables_map vm;
110  po::store(po::parse_command_line(ac, av, desc), vm);
111  po::notify(vm);
112 
113  if (vm.count("help")) {
114  std::cout << desc << "\n";
115  return 1;
116  }
117 
118  if (vm.count("quiet")) {
119  quiet = true;
120  }
121 
122  if (vm.count("scaling")) {
123  scaling = true;
124  }
125 
126  if (vm.count("load")) {
127  std::cout << "load from matrix "
128  << vm["load"].as<string>() << ".\n";
129  infilename = vm["load"].as<string>();
130  }
131 
132  if (vm.count("patfile")) {
133  std::cout << "PatternFile is "
134  << vm["patfile"].as<string>() << ".\n";
135  patfile = vm["patfile"].as<string>();
136  }
137 
138  if (vm.count("prefile")) {
139  std::cout << "Preload patternfile is "
140  << vm["prefile"].as<string>() << ".\n";
141  prefile = vm["prefile"].as<string>();
142  }
143 
144  if (vm.count("wmat")) {
145  wmatdump = true;
146  std::cout << "wmat dump mode" << std::endl;
147  }
148 
149  if (vm.count("bgrate")) {
150  std::cout << "bgrate set to "
151  << vm["bgrate"].as<double>() << ".\n";
152  bg_rate = vm["bgrate"].as<double>();
153  }
154 
155  if (vm.count("sparseness")) {
156  std::cout << "sparseness set to "
157  << vm["sparseness"].as<double>() << ".\n";
158  sparseness = vm["sparseness"].as<double>();
159  }
160 
161  if (vm.count("simtime")) {
162  std::cout << "simtime set to "
163  << vm["simtime"].as<double>() << ".\n";
164  simtime = vm["simtime"].as<double>();
165  stimtime = simtime;
166  }
167 
168  if (vm.count("dir")) {
169  std::cout << "dir set to "
170  << vm["dir"].as<string>() << ".\n";
171  dir = vm["dir"].as<string>();
172  }
173 
174  if (vm.count("wee")) {
175  std::cout << "wee set to "
176  << vm["wee"].as<double>() << ".\n";
177  w_ee = vm["wee"].as<double>();
178  }
179 
180  if (vm.count("wei")) {
181  std::cout << "wei set to "
182  << vm["wei"].as<double>() << ".\n";
183  w_ei = vm["wei"].as<double>();
184  }
185 
186  if (vm.count("wie")) {
187  std::cout << "wie set to "
188  << vm["wie"].as<double>() << ".\n";
189  w_ie = vm["wie"].as<double>();
190  }
191 
192  if (vm.count("wii")) {
193  std::cout << "wii set to "
194  << vm["wii"].as<double>() << ".\n";
195  w_ii = vm["wii"].as<double>();
196  }
197 
198  if (vm.count("ampa")) {
199  std::cout << "ampa set to "
200  << vm["ampa"].as<double>() << ".\n";
201  ampa_nmda_ratio = vm["ampa"].as<double>();
202  }
203 
204 
205  if (vm.count("ne")) {
206  std::cout << "ne set to "
207  << vm["ne"].as<int>() << ".\n";
208  ne = vm["ne"].as<int>();
209  ni = ne/4;
210  }
211 
212  if (vm.count("stimfile")) {
213  std::cout << "stimfile set to "
214  << vm["stimfile"].as<string>() << ".\n";
215  stimfile = vm["stimfile"].as<string>();
216  }
217 
218  if (vm.count("chk")) {
219  std::cout << "chk set to "
220  << vm["chk"].as<double>() << ".\n";
221  tau_chk = vm["chk"].as<double>();
222  }
223 
224  if (vm.count("adapt")) {
225  std::cout << "adaptation on " << std::endl;
226  adapt = true;
227  }
228 
229  if (vm.count("fast")) {
230  std::cout << "fast on " << std::endl;
231  fast = true;
232  }
233 
234  }
235  catch(std::exception& e) {
236  std::cerr << "error: " << e.what() << "\n";
237  return 1;
238  }
239  catch(...) {
240  std::cerr << "Exception of unknown type!\n";
241  }
242 
243 
244  auryn_init(ac, av);
245 
246  if (!infilename.empty()) {
247  std::stringstream iss;
248  iss << infilename << "." << sys->mpi_rank();
249  infilename = iss.str();
250  }
251 
252  logger->msg("Setting up neuron groups ...",PROGRESS,true);
253 
254 
255  NeuronGroup * neurons_e;
256  if ( adapt ) {
257  neurons_e = new AIFGroup(ne);
258  ((AIFGroup*)neurons_e)->set_ampa_nmda_ratio(ampa_nmda_ratio);
259  ((AIFGroup*)neurons_e)->dg_adapt1=1.0;
260  } else {
261  neurons_e = new IFGroup(ne);
262  ((IFGroup*)neurons_e)->set_ampa_nmda_ratio(ampa_nmda_ratio);
263  }
264  IFGroup * neurons_i = new IFGroup(ni);
265 
266  // initialize membranes
267  neurons_i->set_tau_mem(10e-3);
268  neurons_e->random_mem(-60e-3,10e-3);
269  neurons_i->random_mem(-60e-3,10e-3);
270 
271  ((IFGroup*)neurons_i)->set_ampa_nmda_ratio(ampa_nmda_ratio);
272 
273 
274  SpikingGroup * poisson = new PoissonGroup(2500,bg_rate);
275  SparseConnection * con_exte = new SparseConnection(poisson, neurons_e, w_ext, sparseness, GLUT);
276 
277  msg = "Setting up I connections ...";
278  logger->msg(msg,PROGRESS,true);
279  SparseConnection * con_ie = new SparseConnection(neurons_i,neurons_e,
280  w_ie,sparseness,GABA);
281  SparseConnection * con_ii = new SparseConnection(neurons_i,neurons_i,
282  w_ii,sparseness,GABA);
283 
284  msg = "Setting up E connections ...";
285  logger->msg(msg,PROGRESS,true);
286  SparseConnection * con_ei = new SparseConnection(neurons_e,neurons_i,
287  w_ee,sparseness,GLUT);
288  SparseConnection * con_ee = new SparseConnection(neurons_e,neurons_e,
289  w_ei,sparseness,GLUT);
290 
291  msg = "Setting up monitors ...";
292  logger->msg(msg,PROGRESS,true);
293 
294 
295  if ( !fast ) {
296  sprintf(strbuf, "%s/bg_static.%d.ras", dir.c_str(), sys->mpi_rank());
297  SpikeMonitor * smon_e = new SpikeMonitor( neurons_e, strbuf , 2500);
298  }
299 
300  sprintf(strbuf, "%s/bg_static.%d.prate", dir.c_str(), sys->mpi_rank());
301  PopulationRateMonitor * pmon_e = new PopulationRateMonitor( neurons_e, strbuf, 1.0 );
302 
303  sprintf(strbuf, "%s/bg_static.%d.rt", dir.c_str(), sys->mpi_rank());
304  RealTimeMonitor * rtmon = new RealTimeMonitor( strbuf );
305 
306  RateChecker * chk = new RateChecker( neurons_e , 0.1 , 20. , tau_chk);
307 
308  logger->msg("Simulating ...",PROGRESS,true);
309 
310  if (!sys->run(simtime,true))
311  errcode = 1;
312 
313 
314  if (errcode) {
315  auryn_abort(errcode);
316  }
317 
318  logger->msg("Freeing ...",PROGRESS,true);
319  auryn_free();
320 
321  return errcode;
322 }
void auryn_free()
Cleanly shuts down Auryn simulation environment.
Definition: auryn_global.cpp:107
Standard Glutamatergic (excitatory) transmission.
Definition: auryn_definitions.h:139
void random_mem(AurynState mean=-60e-3, AurynState sigma=5e-3)
Definition: NeuronGroup.cpp:81
unsigned int mpi_rank()
Returns current rank.
Definition: System.cpp:1009
Monitor class to record the system time in every timestep.
Definition: RealTimeMonitor.h:45
Abstract base class of all objects producing spikes.
Definition: SpikingGroup.h:67
AurynFloat AurynWeight
Unit of synaptic weights.
Definition: auryn_definitions.h:159
A Checker class that tracks population firing rate as a moving average and breaks a run if it goes ou...
Definition: RateChecker.h:59
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
The standard Monitor object to record spikes from a SpikingGroup and write them to a text file...
Definition: SpikeMonitor.h:52
void set_tau_mem(AurynFloat taum)
Sets the membrane time constant.
Definition: IFGroup.cpp:154
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
A SpikingGroup that creates poissonian spikes with a given rate.
Definition: PoissonGroup.h:52
A simple extension of IFGroup with spike triggered adaptation.
Definition: AIFGroup.h: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
Standard Gabaergic (inhibitory) transmission.
Definition: auryn_definitions.h:140
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
Abstract base class for all neuron groups.
Definition: NeuronGroup.h:45
Definition: Logger.h:41
Monitor class to record population firing rates.
Definition: PopulationRateMonitor.h:46
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Implements the standard integrate and file model used in Auryn.
Definition: IFGroup.h:47
Here is the call graph for this function: