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

Macros

#define N_REC_WEIGHTS   5000
 

Functions

int main (int ac, char *av[])
 Example program using LPTripletConnection. More...
 

Macro Definition Documentation

◆ N_REC_WEIGHTS

#define N_REC_WEIGHTS   5000

Function Documentation

◆ main()

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

Example program using LPTripletConnection.

This example is a clone of sim_background in which all functionality for weight decay was removed. Instead of using TripletConnection, this piece of code serves as and example program using LPTripletConnection instead which is an example for a synapse model with two state variables. In LPTripletConnection all weight updates are low-pass filtered. The delay introduced by this filtering should worsen the stabiltity situation as in comparison to what can be observed in sim_background.

41 {
42 
43  double w = 0.16;
44  double w_ext = w;
45  double wmax = 1.0;
46 
47  double w_ee = w;
48  double w_ei = w;
49 
50  double gamma = 1.0;
51  double w_ie = gamma;
52  double w_ii = gamma;
53 
54  NeuronID ne = 20000;
55  NeuronID ni = ne/4;
56 
57 
58  double sparseness = 0.05;
59  double kappa = 3.;
60 
61  bool quiet = false;
62  bool scaling = false;
63  bool wmatdump = false;
64  bool loadbalance = false;
65 
66  bool wall = false;
67 
68  double tau_chk = 100e-3;
69  double simtime = 3600.;
70  double stimtime = simtime;
71  double wmat_interval = 600.;
72 
73  double ampa_nmda_ratio = 1.0;
74  double wstim = 0.1;
75 
76  NeuronID psize = 200;
77  NeuronID hsize = 100;
78  NeuronID offset = 0;
79 
80  string patfile = "";
81  string prefile = "";
82  string currentfile = "";
83 
84  double stimfreq = 10;
85 
86  bool corr = false;
87  int plen = 3;
88  int hlen = 3;
89 
90  double ampl = 1.0;
91  bool recall = false;
92  bool decay = false;
93  bool adapt = false;
94  bool noisyweights = false;
95  bool switchweights = false;
96  bool ei_plastic = false;
97 
98  double bg_rate = 2;
99  bool fast = false;
100  AurynWeight wdecay = w;
101  double tau_decay = 3600.;
102 
103  double tau_hom = 50.;
104  double eta = 1;
105  double onperiod = 2;
106  double offperiod = 30;
107  double scale = 1;
108 
109  int n_strengthen = 0;
110 
111  std::vector<Connection*> corr_connections;
112  std::string dir = ".";
113  std::string stimfile = "";
114  std::string label = "";
115  std::string infilename = "";
116 
117  const char * file_prefix = "bg2";
118  char strbuf [255];
119  std::string msg;
120 
121  int errcode = 0;
122 
123  try {
124 
125  po::options_description desc("Allowed options");
126  desc.add_options()
127  ("help", "produce help message")
128  ("quiet", "quiet mode")
129  ("scaling", "scaling mode")
130  ("balance", "activate load balance")
131  ("load", po::value<std::string>(), "input weight matrix")
132  ("patfile", po::value<std::string>(), "pattern file for StimulusGroup")
133  ("prefile", po::value<std::string>(), "pattern file for loading patterns")
134  ("onperiod", po::value<double>(), "mean stimulus on period")
135  ("offperiod", po::value<double>(), "mean stimulus off period")
136  ("wmat", "wmat dump mode")
137  ("eta", po::value<double>(), "learning rate")
138  ("bgrate", po::value<double>(), "PoissonGroup external firing rate")
139  ("sparseness", po::value<double>(), "overall network sparseness")
140  ("scale", po::value<double>(), "learning rate")
141  ("tau_hom", po::value<double>(), "homeostatic time constant")
142  ("kappa", po::value<double>(), "target rate")
143  ("simtime", po::value<double>(), "simulation time")
144  ("dir", po::value<std::string>(), "output dir")
145  ("label", po::value<std::string>(), "output label")
146  ("wee", po::value<double>(), "wee")
147  ("wei", po::value<double>(), "wei")
148  ("wie", po::value<double>(), "wie")
149  ("wii", po::value<double>(), "wii")
150  ("wmax", po::value<double>(), "wmax")
151  ("ampa", po::value<double>(), "ampa nmda ratio")
152  ("strengthen", po::value<int>(), "connections to strengthen by 10")
153  ("ne", po::value<int>(), "no of exc units")
154  ("stimfile", po::value<std::string>(), "stimulus ras file")
155  ("wstim", po::value<double>(), "weight of stimulus connections")
156  ("stimtime", po::value<double>(), "time of stimulus on")
157  ("decay", "decay triplet connections")
158  ("corr", "add correlated inputs")
159  ("ampl", po::value<double>(), "recall stim amplitude")
160  ("psize", po::value<int>(), "block size for correlated inputs")
161  ("plen", po::value<int>(), "number of blocks feed-forward")
162  ("hsize", po::value<int>(), "block size for correlated inputs (hebbian assembly)")
163  ("hlen", po::value<int>(), "number of blocks Hebbian")
164  ("offset", po::value<int>(), " offset for corr stim")
165  ("recall", "add correlated inputs to first patterns")
166  ("stimfreq", po::value<double>(), "CorrelatedPoissonGroup frequency default = 100")
167  ("dconstant", po::value<double>(), "decay time constant for decaying triplet connections")
168  ("wdecay", po::value<double>(), "wdecay for decay triplet connections")
169  ("chk", po::value<double>(), "checker time constant")
170  ("adapt", "adapting excitatory neurons")
171  ("wall", "enable monitoring of wall clock time")
172  ("noisyweights", "enables noisyweights for mean field checks")
173  ("switchweights", "switches first weights in each weight matrix")
174  ("fast", "turn off some of the monitors to run faster")
175  ("eiplastic", "make EI connection plastic")
176  ;
177 
178  po::variables_map vm;
179  po::store(po::parse_command_line(ac, av, desc), vm);
180  po::notify(vm);
181 
182  if (vm.count("help")) {
183  std::cout << desc << "\n";
184  return 1;
185  }
186 
187  if (vm.count("quiet")) {
188  quiet = true;
189  }
190 
191  if (vm.count("scaling")) {
192  scaling = true;
193  }
194 
195  if (vm.count("balance")) {
196  std::cout << "load balancing active" << std::endl;
197  loadbalance = true;
198  }
199 
200  if (vm.count("load")) {
201  std::cout << "load from matrix "
202  << vm["load"].as<std::string>() << ".\n";
203  infilename = vm["load"].as<std::string>();
204  }
205 
206  if (vm.count("patfile")) {
207  std::cout << "PatternFile is "
208  << vm["patfile"].as<std::string>() << ".\n";
209  patfile = vm["patfile"].as<std::string>();
210  }
211 
212  if (vm.count("prefile")) {
213  std::cout << "Preload patternfile is "
214  << vm["prefile"].as<std::string>() << ".\n";
215  prefile = vm["prefile"].as<std::string>();
216  }
217 
218  if (vm.count("wmat")) {
219  wmatdump = true;
220  std::cout << "wmat dump mode" << std::endl;
221  }
222 
223  if (vm.count("onperiod")) {
224  std::cout << "onperiod set to "
225  << vm["onperiod"].as<double>() << ".\n";
226  onperiod = vm["onperiod"].as<double>();
227  }
228 
229  if (vm.count("offperiod")) {
230  std::cout << "offperiod set to "
231  << vm["offperiod"].as<double>() << ".\n";
232  offperiod = vm["offperiod"].as<double>();
233  }
234 
235  if (vm.count("eta")) {
236  std::cout << "eta set to "
237  << vm["eta"].as<double>() << ".\n";
238  eta = vm["eta"].as<double>();
239  }
240 
241  if (vm.count("bgrate")) {
242  std::cout << "bgrate set to "
243  << vm["bgrate"].as<double>() << ".\n";
244  bg_rate = vm["bgrate"].as<double>();
245  }
246 
247  if (vm.count("sparseness")) {
248  std::cout << "sparseness set to "
249  << vm["sparseness"].as<double>() << ".\n";
250  sparseness = vm["sparseness"].as<double>();
251  }
252 
253  if (vm.count("scale")) {
254  std::cout << "scale set to "
255  << vm["scale"].as<double>() << ".\n";
256  scale = vm["scale"].as<double>();
257  }
258 
259  if (vm.count("tau_hom")) {
260  std::cout << "tau_hom set to "
261  << vm["tau_hom"].as<double>() << ".\n";
262  tau_hom = vm["tau_hom"].as<double>();
263  }
264 
265  if (vm.count("kappa")) {
266  std::cout << "kappa set to "
267  << vm["kappa"].as<double>() << ".\n";
268  kappa = vm["kappa"].as<double>();
269  }
270 
271  if (vm.count("simtime")) {
272  std::cout << "simtime set to "
273  << vm["simtime"].as<double>() << ".\n";
274  simtime = vm["simtime"].as<double>();
275  stimtime = simtime;
276  }
277 
278  if (vm.count("dir")) {
279  std::cout << "dir set to "
280  << vm["dir"].as<std::string>() << ".\n";
281  dir = vm["dir"].as<std::string>();
282  }
283 
284  if (vm.count("label")) {
285  std::cout << "label set to "
286  << vm["label"].as<std::string>() << ".\n";
287  label = vm["label"].as<std::string>();
288  }
289 
290  if (vm.count("wee")) {
291  std::cout << "wee set to "
292  << vm["wee"].as<double>() << ".\n";
293  w_ee = vm["wee"].as<double>();
294  }
295 
296  if (vm.count("wei")) {
297  std::cout << "wei set to "
298  << vm["wei"].as<double>() << ".\n";
299  w_ei = vm["wei"].as<double>();
300  }
301 
302  if (vm.count("wie")) {
303  std::cout << "wie set to "
304  << vm["wie"].as<double>() << ".\n";
305  w_ie = vm["wie"].as<double>();
306  }
307 
308  if (vm.count("wii")) {
309  std::cout << "wii set to "
310  << vm["wii"].as<double>() << ".\n";
311  w_ii = vm["wii"].as<double>();
312  }
313 
314  if (vm.count("wmax")) {
315  std::cout << "wmax set to "
316  << vm["wmax"].as<double>() << ".\n";
317  wmax = vm["wmax"].as<double>();
318  }
319 
320  if (vm.count("ampa")) {
321  std::cout << "ampa set to "
322  << vm["ampa"].as<double>() << ".\n";
323  ampa_nmda_ratio = vm["ampa"].as<double>();
324  }
325 
326  if (vm.count("strengthen")) {
327  std::cout << "strengthen set to "
328  << vm["strengthen"].as<int>() << ".\n";
329  n_strengthen = vm["strengthen"].as<int>();
330  }
331 
332  if (vm.count("ne")) {
333  std::cout << "ne set to "
334  << vm["ne"].as<int>() << ".\n";
335  ne = vm["ne"].as<int>();
336  ni = ne/4;
337  }
338 
339  if (vm.count("stimfile")) {
340  std::cout << "stimfile set to "
341  << vm["stimfile"].as<std::string>() << ".\n";
342  stimfile = vm["stimfile"].as<std::string>();
343  }
344 
345  if (vm.count("wstim")) {
346  std::cout << "wstim set to "
347  << vm["wstim"].as<double>() << ".\n";
348  wstim = vm["wstim"].as<double>();
349  }
350 
351  if (vm.count("stimtime")) {
352  std::cout << "stimtime set to "
353  << vm["stimtime"].as<double>() << ".\n";
354  stimtime = vm["stimtime"].as<double>();
355  }
356 
357  if (vm.count("corr")) {
358  std::cout << "enabling corr " << std::endl;
359  corr = true;
360  }
361 
362  if (vm.count("ampl")) {
363  std::cout << "ampl set to "
364  << vm["ampl"].as<double>() << ".\n";
365  ampl = vm["ampl"].as<double>();
366  }
367 
368  if (vm.count("psize")) {
369  std::cout << "psize set to "
370  << vm["psize"].as<int>() << ".\n";
371  psize = vm["psize"].as<int>();
372  }
373 
374  if (vm.count("plen")) {
375  std::cout << "plen set to "
376  << vm["plen"].as<int>() << ".\n";
377  plen = vm["plen"].as<int>();
378  }
379 
380  if (vm.count("hsize")) {
381  std::cout << "hsize set to "
382  << vm["hsize"].as<int>() << ".\n";
383  hsize = vm["hsize"].as<int>();
384  }
385 
386  if (vm.count("hlen")) {
387  std::cout << "hlen set to "
388  << vm["hlen"].as<int>() << ".\n";
389  hlen = vm["hlen"].as<int>();
390  }
391 
392  if (vm.count("offset")) {
393  std::cout << "offset set to "
394  << vm["offset"].as<int>() << ".\n";
395  offset = vm["offset"].as<int>();
396  }
397 
398  if (vm.count("recall")) {
399  std::cout << "enabling recall " << std::endl;
400  recall = true;
401  }
402 
403  if (vm.count("stimfreq")) {
404  std::cout << "stimfreq set to "
405  << vm["stimfreq"].as<double>() << ".\n";
406  stimfreq = vm["stimfreq"].as<double>();
407  }
408 
409  if (vm.count("decay")) {
410  std::cout << "weight decay on " << std::endl;
411  decay = true;
412  }
413 
414  if (vm.count("dconstant")) {
415  std::cout << "dconstant set to "
416  << vm["dconstant"].as<double>() << ".\n";
417  tau_decay = vm["dconstant"].as<double>();
418  }
419 
420  if (vm.count("wdecay")) {
421  std::cout << "wdecay set to "
422  << vm["wdecay"].as<double>() << ".\n";
423  wdecay = vm["wdecay"].as<double>();
424  }
425 
426  if (vm.count("chk")) {
427  std::cout << "chk set to "
428  << vm["chk"].as<double>() << ".\n";
429  tau_chk = vm["chk"].as<double>();
430  }
431 
432  if (vm.count("adapt")) {
433  std::cout << "adaptation on " << std::endl;
434  adapt = true;
435  }
436 
437  if (vm.count("wall")) {
438  std::cout << "real time wall clock monitoring enabled " << std::endl;
439  wall = true;
440  }
441 
442  if (vm.count("noisyweights")) {
443  std::cout << "noisyweights on " << std::endl;
444  noisyweights = true;
445  }
446 
447  if (vm.count("switchweights")) {
448  std::cout << "switchweights on " << std::endl;
449  switchweights = true;
450  }
451 
452  if (vm.count("fast")) {
453  std::cout << "fast on " << std::endl;
454  fast = true;
455  }
456 
457  if (vm.count("eiplastic")) {
458  std::cout << "eiplastic on " << std::endl;
459  ei_plastic = true;
460  }
461  }
462  catch(std::exception& e) {
463  std::cerr << "error: " << e.what() << "\n";
464  return 1;
465  }
466  catch(...) {
467  std::cerr << "Exception of unknown type!\n";
468  }
469 
470  if (scale != 1.) {
471  eta *= scale;
472  tau_hom /= scale;
473  simtime /= scale;
474  std::cout << "scaled by " << scale << std::endl;
475  }
476 
477  double primetime = 3*tau_hom;
478 
479 
480  sprintf(strbuf, "%s/%s_e%.2et%.2f%s", dir.c_str(), file_prefix, eta, tau_hom, label.c_str());
481  std::string logfile_prefix = strbuf;
482 
483  auryn_init(ac, av, dir=".", "", logfile_prefix);
484 
485  logger->msg("Setting up neuron groups ...",PROGRESS,true);
486 
487 
488  NeuronGroup * neurons_e;
489  if ( adapt ) {
490  neurons_e = new AIFGroup(ne);
491  ((AIFGroup*)neurons_e)->set_ampa_nmda_ratio(ampa_nmda_ratio);
492  ((AIFGroup*)neurons_e)->dg_adapt1=1.0;
493  } else {
494  if ( loadbalance )
495  neurons_e = new IFGroup(ne);
496  else
497  neurons_e = new IFGroup(ne);
498  ((IFGroup*)neurons_e)->set_ampa_nmda_ratio(ampa_nmda_ratio);
499  }
500  IFGroup * neurons_i = new IFGroup(ni);
501 
502  // initialize membranes
503  neurons_i->set_tau_mem(10e-3);
504  neurons_e->random_mem(-60e-3,10e-3);
505  neurons_i->random_mem(-60e-3,10e-3);
506 
507  ((IFGroup*)neurons_i)->set_ampa_nmda_ratio(ampa_nmda_ratio);
508 
509 
510  SpikingGroup * poisson = new PoissonGroup(2500,bg_rate);
511  SparseConnection * con_exte = new SparseConnection(poisson, neurons_e, w_ext, sparseness, GLUT);
512 
513  msg = "Setting up I connections ...";
514  logger->msg(msg,PROGRESS,true);
515  SparseConnection * con_ie = new SparseConnection(neurons_i,neurons_e,
516  w_ie,sparseness,GABA);
517  SparseConnection * con_ii = new SparseConnection(neurons_i,neurons_i,
518  w_ii,sparseness,GABA);
519 
520  msg = "Setting up E connections ...";
521  logger->msg(msg,PROGRESS,true);
522  SparseConnection * con_ei;
523  if ( !ei_plastic ) {
524  con_ei = new SparseConnection(neurons_e,neurons_i,
525  w_ei, sparseness,GLUT);
526  } else {
527  if (infilename.empty()) {
528  con_ei = new LPTripletConnection(neurons_e,neurons_i,
529  w_ei, sparseness,
530  tau_hom, eta, kappa, wmax, GLUT);
531  } else {
532  std::string str;
533  str = infilename;
534  str += ".ei.wmat";
535  std::stringstream oss;
536  oss << "Loading weight matrix from " << str;
537  logger->msg(oss.str(),PROGRESS,true);
538  con_ei = new LPTripletConnection(neurons_e,neurons_i,
539  str.c_str(),
540  tau_hom, eta, kappa, wmax, GLUT);
541  }
542  }
543 
544  LPTripletConnection * con_ee;
545 
546  if (infilename.empty()) {
547  con_ee = new LPTripletConnection(neurons_e,neurons_e,
548  w_ee, sparseness,
549  tau_hom, eta, kappa, wmax, GLUT);
550 
551  // con_ee->set_min_weight(wmin);
552  if ( noisyweights )
553  con_ee->random_data(w_ee,w_ee/4);
554  for ( int i = 0 ; i < n_strengthen ; ++i ) {
555  con_ee->set_data(i,i*(wmax/n_strengthen));
556  }
557  }
558  else {
559  string str;
560  str = infilename;
561  str += ".wmat";
562  std::stringstream oss;
563  oss << "Loading weight matrix from " << str;
564  logger->msg(oss.str(),PROGRESS,true);
565  con_ee = new LPTripletConnection(neurons_e,neurons_e,
566  str.c_str(),tau_hom,eta,kappa,wmax,GLUT);
567 
568 
569  sprintf(strbuf, "%s.e.nstate", infilename.c_str());
570  neurons_e->load_from_file(strbuf);
571  sprintf(strbuf, "%s.i.nstate", infilename.c_str());
572  neurons_i->load_from_file(strbuf);
573 
574  // primetime = 0;
575  }
576 
577  // SparseConnection * con_exti = new SparseConnection(sys, poisson, neurons_i, w_ext, sparseness, GLUT);
578 
579  msg = "Initializing traces ...";
580  logger->msg(msg,PROGRESS,true);
581  con_ee->set_hom_trace(kappa);
582  con_ee->seed(23);
583 
584  // TODO
585  // con_ee->w->set_col(0,2*w_ee);
586 
587  msg = "Setting up monitors ...";
588  logger->msg(msg,PROGRESS,true);
589 
590  if (wmatdump) {
591  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.weight", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank());
592  WeightMatrixMonitor * wmatmon = new WeightMatrixMonitor( con_ee, strbuf , wmat_interval );
593  }
594 
595  if ( !fast ) {
596  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.syn", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank());
597  WeightMonitor * wmon = new WeightMonitor( con_ee, strbuf, 10 );
598  for ( int i = 0 ; i < 5 ; ++i ) {
599  for ( int j = 0 ; j < 5 ; ++j ) {
600  std::vector<neuron_pair> sublist = con_ee->get_block(i*psize,(i+1)*psize,j*psize,(j+1)*psize);
601  wmon->add_to_list(sublist);
602  }
603  }
604 
605  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.%c.ras", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank(), 'e');
606  SpikeMonitor * smon_e = new SpikeMonitor( neurons_e, strbuf , 2500);
607 
608  // sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.%c.ras", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank(), 'p');
609  // SpikeMonitor * smon_p = new SpikeMonitor( poisson, strbuf , 2500);
610  }
611 
612  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.%c.prate", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank(), 'e');
613  PopulationRateMonitor * pmon_e = new PopulationRateMonitor( neurons_e, strbuf, 1.0 );
614 
615  if ( wall ) {
616  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.rt", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank());
617  RealTimeMonitor * rtmon = new RealTimeMonitor( strbuf );
618  }
619 
620  // sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.%c.prate", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank(), 'i');
621  // PopulationRateMonitor * pmon_i = new PopulationRateMonitor( neurons_i, strbuf, 1.0 );
622 
623  // sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.%c.mem", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank(), 'e');
624  // VoltageMonitor * vmon_e = new VoltageMonitor( neurons_e, 33, strbuf );
625 
626  // sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.%c.ras", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank(), 'i');
627  // SpikeMonitor * smon_i = new SpikeMonitor( neurons_i, strbuf , 500);
628 
629  RateChecker * chk = new RateChecker( neurons_e , 0.1 , 20.*kappa , tau_chk);
630 
631 
632 
633  if ( scaling && (errcode==0) ) {
634  std::stringstream oss;
635  oss << "Changing cell input ... ";
636  logger->msg(oss.str(),PROGRESS,true);
637 
638  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.pat", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank());
639  PatternMonitor * patmon = new PatternMonitor(neurons_e,strbuf,patfile.c_str(), 10, 1.);
640  PatternStimulator * patstim = new PatternStimulator(neurons_e,currentfile.c_str(),patfile.c_str());
641 
642  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.scal", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank());
643  WeightMonitor * wmon_scal = new WeightMonitor( con_ee, 0, 0, strbuf, 1, ELEMENTLIST);
644  wmon_scal->add_to_list( con_ee->get_pre_partners(0) );
645  wmon_scal->add_to_list( con_ee->get_pre_partners(10) );
646 
647  }
648 
649  // if ( corr ) {
650  // sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.%c.pat", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank(), 'c');
651  // PatternMonitor * pmon_c = new PatternMonitor( neurons_e, strbuf,corr_pat_file.c_str() );
652  // }
653 
654  const double amplitude_fwd = 9.0*ampl;
655  const double amplitude_heb = 3.0*ampl;
656 
657  CorrelatedPoissonGroup * corr_e;
658  CorrelatedPoissonGroup * corr_e2;
659 
660  NeuronID extsize = 500;
661  double strength = 0.2;
662 
663  if ( corr ) {
664 
665  std::stringstream oss;
666  oss << "Activating correlated input ... ";
667  logger->msg(oss.str(),PROGRESS,true);
668 
669  if (eta > 0)
670  con_ee->stdp_active = true;
671 
672 
673  if ( psize*plen ) {
674  corr_e = new CorrelatedPoissonGroup(extsize*plen,stimfreq,extsize,10e-3);
675  corr_e->set_amplitude(amplitude_fwd);
676  corr_e->set_timescale(5e-3);
677  // IdentityConnection * con_corr_e = new IdentityConnection(corr_e,neurons_e,w);
678  SparseConnection * con_corr_e = new SparseConnection(corr_e,neurons_e,GLUT);
679  con_corr_e->allocate_manually( plen*extsize*psize*sparseness*1.05 );
680  con_corr_e->w->clear();
681  for ( int i = 0 ; i < plen ; ++i )
682  con_corr_e->connect_block_random(w,sparseness,(i)*extsize,offset+(i+1)*extsize,(i)*psize,offset+(i+1)*psize);
683  con_corr_e->finalize();
684  corr_connections.push_back(con_corr_e);
685  SparseConnection * con_corr_i = new SparseConnection(corr_e,neurons_i,w*strength,sparseness*plen*psize/ni,GLUT);
686 
687  // set up Weight monitor
688  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.%c.ras", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank(), 'c');
689  SpikeMonitor * smon_c = new SpikeMonitor( corr_e, strbuf , psize );
690  }
691 
692  if ( hsize*hlen ) {
693  corr_e2 = new CorrelatedPoissonGroup(extsize*hlen,stimfreq,extsize,10);
694  corr_e2->set_amplitude(amplitude_heb);
695  corr_e2->set_timescale(100e-3);
696  SparseConnection * con_corr_e2 = new SparseConnection(corr_e2,neurons_e,GLUT);
697  con_corr_e2->allocate_manually( hlen*extsize*hsize*sparseness*1.05 );
698  con_corr_e2->w->clear();
699  for ( int i = 0 ; i < hlen ; ++i )
700  con_corr_e2->connect_block_random(w,sparseness,(i)*extsize,(i+1)*extsize,offset+(i)*hsize+plen*psize,offset+(i+1)*hsize+plen*psize);
701  con_corr_e2->finalize();
702  corr_connections.push_back(con_corr_e2);
703  SparseConnection * con_corr_i2 = new SparseConnection(corr_e2,neurons_i,w*strength,sparseness*hlen*hsize/ni,GLUT);
704  }
705 
706  // disabling external random input
707  con_exte->set_block(0,2500,0,plen*psize+hlen*hsize,0.0);
708 
709  } else {
710  if ( recall ) {
711 
712  std::stringstream oss;
713  oss << "Activating recall input ... ";
714  logger->msg(oss.str(),PROGRESS,true);
715 
716  if ( psize*plen ) {
717  corr_e = new CorrelatedPoissonGroup(extsize*plen,stimfreq,extsize,10e-3);
718  corr_e->set_amplitude(amplitude_fwd);
719  corr_e->set_timescale(5e-3);
720  // IdentityConnection * con_corr_e = new IdentityConnection(corr_e,neurons_e,w);
721  SparseConnection * con_corr_e = new SparseConnection(corr_e,neurons_e,GLUT);
722  con_corr_e->allocate_manually( plen*extsize*psize*sparseness*1.05 );
723  con_corr_e->w->clear();
724  for ( int i = 0 ; i < plen ; ++i )
725  con_corr_e->connect_block_random(w,sparseness,(i)*extsize,offset+(i+1)*extsize,(i)*psize,offset+(i+1)*psize);
726  con_corr_e->finalize();
727  corr_connections.push_back(con_corr_e);
728  // SparseConnection * con_corr_i = new SparseConnection(corr_e,neurons_i,w*strength,sparseness*plen*psize/ni,GLUT);
729 
730  // set up Weight monitor
731  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.%c.ras", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank(), 'c');
732  SpikeMonitor * smon_c = new SpikeMonitor( corr_e, strbuf , psize );
733  }
734 
735  if ( hsize*hlen ) {
736  corr_e2 = new CorrelatedPoissonGroup(extsize*hlen,stimfreq,extsize,10);
737  corr_e2->set_amplitude(amplitude_heb);
738  corr_e2->set_timescale(100e-3);
739  SparseConnection * con_corr_e2 = new SparseConnection(corr_e2,neurons_e,GLUT);
740  con_corr_e2->allocate_manually( hlen*extsize*hsize*sparseness*1.05 );
741  con_corr_e2->w->clear();
742  for ( int i = 0 ; i < hlen ; ++i )
743  con_corr_e2->connect_block_random(w,sparseness,(i)*extsize,(i+1)*extsize,offset+(i)*hsize+plen*psize,offset+(i+1)*hsize+plen*psize);
744  con_corr_e2->finalize();
745  corr_connections.push_back(con_corr_e2);
746  // SparseConnection * con_corr_i2 = new SparseConnection(corr_e2,neurons_i,w*strength,sparseness*hlen*hsize/ni,GLUT);
747  }
748 
749  // disabling external random input
750  // con_exte->set_block(0,2500,psize,2*psize,0.0);
751  }
752  }
753 
754 // preload patterns
755 if ( prefile != "" ) {
756  logger->msg("Preloading patterns ...",PROGRESS,true);
757  // con_ee->random_data(w_ee,w_ee);
758  con_ee->load_patterns(prefile, wmax, true, false);
759  // con_ee->sparse_set_data(0.9,0);
760 }
761 
762 // adding patterns
763 if ( patfile != "" ) {
764  logger->msg("Preparing stimulus ...",PROGRESS,true);
765  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.stim", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank());
766  StimulusGroup * stimgroup = new StimulusGroup(ne,patfile,strbuf);
767  stimgroup->set_mean_on_period(onperiod);
768  stimgroup->set_mean_off_period(offperiod);
769  IdentityConnection * con_stim = new IdentityConnection(stimgroup,neurons_e,w_ext);
770 }
771 
772  if (primetime>0) {
773  msg = "Priming ...";
774  logger->msg(msg,PROGRESS,true);
775  con_ee->stdp_active = false;
776  sys->run(primetime,true);
777  }
778 
779  if ( corr || recall ) {
780  if ( psize*plen )
781  corr_e->set_target_amplitude(amplitude_fwd);
782  if ( hsize*hlen )
783  corr_e2->set_target_amplitude(amplitude_heb);
784  }
785 
786  logger->msg("Simulating ...",PROGRESS,true);
787  if (eta > 0) {
788  con_ee->stdp_active = true;
789  }
790 
791  if (!sys->run(simtime,true))
792  errcode = 1;
793 
794 
795 
796  if (!fast) {
797  logger->msg("Saving neurons state ...",PROGRESS,true);
798  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.e.nstate", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank());
799  neurons_e->write_to_file(strbuf);
800  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.i.nstate", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank());
801  neurons_i->write_to_file(strbuf);
802 
803  logger->msg("Saving weight matrix ...",PROGRESS,true);
804  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.wmat", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank());
805  con_ee->write_to_file(strbuf);
806 
807  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.ei.wmat", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank());
808  con_ei->write_to_file(strbuf);
809 
810  for ( int i = 0 ; i < corr_connections.size() ; ++i ) {
811  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.%d.wmat", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), i, sys->mpi_rank());
812  corr_connections[i]->write_to_file(strbuf);
813  }
814  }
815 
816 
817  // save lifetime
818  sprintf(strbuf, "%s/%s_e%.2et%.2f%s.%d.lifetime", dir.c_str(), file_prefix, eta, tau_hom, label.c_str(), sys->mpi_rank());
819  std::ofstream killfile;
820  killfile.open(strbuf);
821  killfile << sys->get_time()-primetime << std::endl;
822  killfile.close();
823 
824  if (errcode) {
825  auryn_abort(errcode);
826  }
827 
828  logger->msg("Freeing ...",PROGRESS,true);
829  auryn_free();
830 
831  return errcode;
832 }
void auryn_free()
Cleanly shuts down Auryn simulation environment.
Definition: auryn_global.cpp:107
Implements triplet STDP in which weight updates are low-pass filtered.
Definition: LPTripletConnection.h:40
void set_block(NeuronID lo_row, NeuronID hi_row, NeuronID lo_col, NeuronID hi_col, AurynWeight weight)
Sets all weights of existing connections in a block spanned by the first 4 parameters to the value gi...
Definition: SparseConnection.cpp:307
void set_timescale(AurynDouble scale)
Definition: CorrelatedPoissonGroup.cpp:175
Standard Glutamatergic (excitatory) transmission.
Definition: auryn_definitions.h:139
virtual bool load_from_file(const char *filename)
Reads current states of SpikingGroup to human-readible textfile if implemented in derived class...
Definition: SpikingGroup.cpp:585
void random_mem(AurynState mean=-60e-3, AurynState sigma=5e-3)
Definition: NeuronGroup.cpp:81
ForwardMatrix * w
A pointer that points per default to the ComplexMatrix that stores the connectinos.
Definition: SparseConnection.h:147
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
void set_target_amplitude(AurynDouble ampl)
Definition: CorrelatedPoissonGroup.cpp:169
Abstract base class of all objects producing spikes.
Definition: SpikingGroup.h:67
AurynFloat AurynWeight
Unit of synaptic weights.
Definition: auryn_definitions.h:159
void set_amplitude(AurynDouble ampl)
Definition: CorrelatedPoissonGroup.cpp:163
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
Monitor class to record population firing rates.
Definition: PatternMonitor.h:47
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
void connect_block_random(AurynWeight weight, AurynDouble sparseness, NeuronID lo_row, NeuronID hi_row, NeuronID lo_col, NeuronID hi_col, bool skip_diag=false)
Underlying sparse fill method.
Definition: SparseConnection.cpp:360
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
Saves the weight matrix of a given connection in regular time intervals.
Definition: WeightMatrixMonitor.h:41
A PoissonGroup with multiple subpopulations that co-modulate their firing rate according to an Ornste...
Definition: CorrelatedPoissonGroup.h:48
void clear()
Clears matrix.
Definition: ComplexMatrix.h:460
void auryn_abort(int errcode)
Terminates Auryn simulation abnormally.
Definition: auryn_global.cpp:113
void allocate_manually(AurynLong expected_size)
Is used whenever memory has to be allocated manually. Automatically adjusts for number of ranks and f...
Definition: SparseConnection.cpp:192
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
The Monitor records from selected synapses stored in a list. This is the default behavior.
Definition: WeightMonitor.h:47
A simple extension of IFGroup with spike triggered adaptation.
Definition: AIFGroup.h:37
Provides a poisson stimulus at random intervals in one or more predefined subsets of the group that a...
Definition: StimulusGroup.h:50
AurynDouble get_time()
Gets the current system time in [s].
Definition: System.cpp:226
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
Stimulator class to inject timeseries of currents to patterns (subpopulations) of neurons...
Definition: PatternStimulator.h:44
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
virtual void finalize()
Finalizes connection after random or manual initialization of the weights.
Definition: SparseConnection.cpp:499
bool write_to_file(ForwardMatrix *m, string filename)
Writes rank specific weight matrix on the same rank to a file.
Definition: SparseConnection.cpp:690
Monitor class to record population firing rates.
Definition: PopulationRateMonitor.h:46
virtual bool write_to_file(const char *filename)
Writes current states of SpikingGroup to human-readible textfile if implemented in derived class...
Definition: SpikingGroup.cpp:549
Monitors the evolution of a single or a set of weights.
Definition: WeightMonitor.h:65
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
Implements the standard integrate and file model used in Auryn.
Definition: IFGroup.h:47
Provides a unity matrix like connectivity.
Definition: IdentityConnection.h:47
Here is the call graph for this function: