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

Example simulation which illustrates the use of ParrotGroup. More...

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

Functions

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

Detailed Description

Example simulation which illustrates the use of ParrotGroup.

Function Documentation

◆ main()

int main ( int  ac,
char *  av[] 
)
34 {
35 
36  string dir = "./";
37  string file_prefix = "parrot";
38 
39  string msg;
40 
41  NeuronID size = 1000;
42  unsigned int seed = 1;
43  double kappa = 5.;
44  double simtime = 1.;
45 
46  int errcode = 0;
47 
48  try {
49 
50  po::options_description desc("Allowed options");
51  desc.add_options()
52  ("help", "produce help message")
53  ("simtime", po::value<double>(), "simulation time")
54  ("kappa", po::value<double>(), "poisson group rate")
55  ("dir", po::value<string>(), "output directory")
56  ("size", po::value<int>(), "poisson group size")
57  ("seed", po::value<int>(), "random seed")
58  ;
59 
60  po::variables_map vm;
61  po::store(po::parse_command_line(ac, av, desc), vm);
62  po::notify(vm);
63 
64  if (vm.count("help")) {
65  std::cout << desc << "\n";
66  return 1;
67  }
68 
69  if (vm.count("kappa")) {
70  std::cout << "kappa set to "
71  << vm["kappa"].as<double>() << ".\n";
72  kappa = vm["kappa"].as<double>();
73  }
74 
75  if (vm.count("dir")) {
76  std::cout << "dir set to "
77  << vm["dir"].as<string>() << ".\n";
78  dir = vm["dir"].as<string>();
79  }
80 
81  if (vm.count("simtime")) {
82  std::cout << "simtime set to "
83  << vm["simtime"].as<double>() << ".\n";
84  simtime = vm["simtime"].as<double>();
85  }
86 
87  if (vm.count("size")) {
88  std::cout << "size set to "
89  << vm["size"].as<int>() << ".\n";
90  size = vm["size"].as<int>();
91  }
92 
93  if (vm.count("seed")) {
94  std::cout << "seed set to "
95  << vm["seed"].as<int>() << ".\n";
96  seed = vm["seed"].as<int>();
97  }
98  }
99  catch(std::exception& e) {
100  std::cerr << "error: " << e.what() << "\n";
101  return 1;
102  }
103  catch(...) {
104  std::cerr << "Exception of unknown type!\n";
105  }
106 
107  auryn_init(ac, av);
108  sys->set_master_seed(seed);
110 
111  PoissonGroup * poisson = new PoissonGroup(size,kappa);
112  ParrotGroup * parrot = new ParrotGroup(poisson);
113  parrot->set_delay(20); // sets the axonal delay in units of auryn_timeteps.
114 
115  // Record original spikes before axonal delay
116  SpikeMonitor * smon1 = new SpikeMonitor( poisson, sys->fn("poisson","ras"), size);
117 
118  DelayedSpikeMonitor * dmon1 = new DelayedSpikeMonitor( poisson, sys->fn("poisson2","ras"), size);
119 
120  // Record parrot spikes before axonal delay
121  DelayedSpikeMonitor * smon2 = new DelayedSpikeMonitor( parrot, sys->fn("parrot","ras"), size);
122 
123  // Record original spikes before axonal delay
124  DelayedSpikeMonitor * dmon2 = new DelayedSpikeMonitor( parrot, sys->fn("parrot2","ras"), size);
125 
126  DelayedSpikeMonitor * dsmon1 = new DelayedSpikeMonitor( poisson, sys->fn("poisson","dras"), size);
127  DelayedSpikeMonitor * dsmon2 = new DelayedSpikeMonitor( parrot, sys->fn("parrot","dras"), size);
128 
129  RateChecker * chk = new RateChecker( poisson , -1 , 20.*kappa , 10);
130  if (!sys->run(simtime,false))
131  errcode = 1;
132 
133  if (errcode)
134  auryn_abort(errcode);
135  logger->msg("Freeing ...",PROGRESS,true);
136  auryn_free();
137  return errcode;
138 }
void auryn_free()
Cleanly shuts down Auryn simulation environment.
Definition: auryn_global.cpp:107
void set_delay(int d)
Sets axonal delay for this SpikingGroup.
Definition: SpikingGroup.cpp:345
A SpikingGroup that copies the output of another source SpikingGroup.
Definition: ParrotGroup.h:47
void set_logfile_loglevel(LogMessageType level=NOTIFICATION)
Sets loglevel for file output.
Definition: Logger.cpp:63
SpikeMonitor that reads the delayed spikes as they are received by a postsynaptic neuron...
Definition: DelayedSpikeMonitor.h:49
A Checker class that tracks population firing rate as a moving average and breaks a run if it goes ou...
Definition: RateChecker.h:59
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
Definition: Logger.h:41
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
void set_master_seed(unsigned int seed=123)
Set master seed.
Definition: System.cpp:1014
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 msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
Definition: Logger.h:41
string fn(std::string extension)
Format output file name.
Definition: System.cpp:689
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: