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

Example simulation which simulates a group of Poisson neurons. More...

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

Functions

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

Detailed Description

Example simulation which simulates a group of Poisson neurons.

Function Documentation

◆ main()

int main ( int  ac,
char *  av[] 
)
34 {
35 
36  string dir = "./";
37  string file_prefix = "poisson";
38 
39  char strbuf [255];
40  string msg;
41 
42  NeuronID size = 1000;
43  unsigned int seed = 1;
44  double kappa = 5.;
45  double simtime = 1.;
46 
47  int errcode = 0;
48 
49  try {
50 
51  po::options_description desc("Allowed options");
52  desc.add_options()
53  ("help", "produce help message")
54  ("simtime", po::value<double>(), "simulation time")
55  ("kappa", po::value<double>(), "poisson group rate")
56  ("dir", po::value<string>(), "output directory")
57  ("size", po::value<int>(), "poisson group size")
58  ("seed", po::value<int>(), "random seed")
59  ;
60 
61  po::variables_map vm;
62  po::store(po::parse_command_line(ac, av, desc), vm);
63  po::notify(vm);
64 
65  if (vm.count("help")) {
66  std::cout << desc << "\n";
67  return 1;
68  }
69 
70  if (vm.count("kappa")) {
71  std::cout << "kappa set to "
72  << vm["kappa"].as<double>() << ".\n";
73  kappa = vm["kappa"].as<double>();
74  }
75 
76  if (vm.count("dir")) {
77  std::cout << "dir set to "
78  << vm["dir"].as<string>() << ".\n";
79  dir = vm["dir"].as<string>();
80  }
81 
82  if (vm.count("simtime")) {
83  std::cout << "simtime set to "
84  << vm["simtime"].as<double>() << ".\n";
85  simtime = vm["simtime"].as<double>();
86  }
87 
88  if (vm.count("size")) {
89  std::cout << "size set to "
90  << vm["size"].as<int>() << ".\n";
91  size = vm["size"].as<int>();
92  }
93 
94  if (vm.count("seed")) {
95  std::cout << "seed set to "
96  << vm["seed"].as<int>() << ".\n";
97  seed = vm["seed"].as<int>();
98  }
99  }
100  catch(std::exception& e) {
101  std::cerr << "error: " << e.what() << "\n";
102  return 1;
103  }
104  catch(...) {
105  std::cerr << "Exception of unknown type!\n";
106  }
107 
108  auryn_init(ac, av);
109  sys->set_master_seed(seed);
110 
111  PoissonGroup * poisson = new PoissonGroup(size,kappa);
112 
113  sprintf(strbuf, "%s/%s.%d.ras", dir.c_str(), file_prefix.c_str(), sys->mpi_rank() );
114  SpikeMonitor * smon_e = new SpikeMonitor( poisson, strbuf, size);
115 
116  sprintf(strbuf, "%s/%s.%d.prate", dir.c_str(), file_prefix.c_str(), sys->mpi_rank() );
117  PopulationRateMonitor * pmon_e = new PopulationRateMonitor( poisson, strbuf, 1.0 );
118 
119  RateChecker * chk = new RateChecker( poisson , -1 , 20.*kappa , 10);
120  if (!sys->run(simtime,false))
121  errcode = 1;
122 
123 
124  if (errcode)
125  auryn_abort(errcode);
126  logger->msg("Freeing ...",PROGRESS,true);
127  auryn_free();
128  return errcode;
129 }
void auryn_free()
Cleanly shuts down Auryn simulation environment.
Definition: auryn_global.cpp:107
unsigned int mpi_rank()
Returns current rank.
Definition: System.cpp:1009
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
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
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
Here is the call graph for this function: