examples:sim_poisson
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| examples:sim_poisson [2015/08/26 22:57] – Adds description of command line params zenke | examples:sim_poisson [2016/02/04 17:39] (current) – typo zenke | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| Simulates an array of Poisson processes to illustrate the use of [[manual: | Simulates an array of Poisson processes to illustrate the use of [[manual: | ||
| + | |||
| + | Full source code: [[https:// | ||
| + | |||
| + | |||
| + | ===== Running code ===== | ||
| Running the example program '' | Running the example program '' | ||
| Line 14: | Line 19: | ||
| ===== Visualizing the output ===== | ===== Visualizing the output ===== | ||
| - | Our simulation has written its output (1 second of Poisson spiking from 1000 Poisson neurons firing at 5Hz) to '' | + | Our simulation has written its output (1 second of Poisson spiking from 1000 Poisson neurons firing at 5Hz) to '' |
| If you have gnuplot installed you can take a quick peek using the command line | If you have gnuplot installed you can take a quick peek using the command line | ||
| < | < | ||
| Line 49: | Line 54: | ||
| --size arg poisson group size | --size arg poisson group size | ||
| --seed arg random seed | --seed arg random seed | ||
| - | < | + | </code> |
| As you can see you can easily change a few key parameters of the simulation such as runtime, or the Poisson firing rate. It's always a good idea to export some paramters of your code through command line arguments. How this is done will become clearer in the examples. Things that require less flexibility, | As you can see you can easily change a few key parameters of the simulation such as runtime, or the Poisson firing rate. It's always a good idea to export some paramters of your code through command line arguments. How this is done will become clearer in the examples. Things that require less flexibility, | ||
| Line 87: | Line 92: | ||
| </ | </ | ||
| here '' | here '' | ||
| - | ===== The full program ===== | ||
| - | |||
| - | |||
| - | <code cpp> | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | |||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | |||
| - | #include " | ||
| - | #include " | ||
| - | #include " | ||
| - | #include " | ||
| - | #include " | ||
| - | #include " | ||
| - | #include " | ||
| - | #include " | ||
| - | |||
| - | using namespace std; | ||
| - | |||
| - | namespace po = boost:: | ||
| - | namespace mpi = boost::mpi; | ||
| - | |||
| - | int main(int ac, char* av[]) | ||
| - | { | ||
| - | |||
| - | string dir = " | ||
| - | string file_prefix = " | ||
| - | |||
| - | char strbuf [255]; | ||
| - | string msg; | ||
| - | |||
| - | NeuronID size = 1000; | ||
| - | NeuronID seed = 1; | ||
| - | double kappa = 5.; | ||
| - | double simtime = 10.; | ||
| - | |||
| - | int errcode = 0; | ||
| - | |||
| - | try { | ||
| - | |||
| - | po:: | ||
| - | desc.add_options() | ||
| - | (" | ||
| - | (" | ||
| - | (" | ||
| - | (" | ||
| - | (" | ||
| - | ; | ||
| - | |||
| - | po:: | ||
| - | po:: | ||
| - | po:: | ||
| - | |||
| - | if (vm.count(" | ||
| - | cout << desc << " | ||
| - | return 1; | ||
| - | } | ||
| - | |||
| - | |||
| - | if (vm.count(" | ||
| - | cout << "kappa set to " | ||
| - | << | ||
| - | kappa = vm[" | ||
| - | } | ||
| - | |||
| - | if (vm.count(" | ||
| - | cout << " | ||
| - | << | ||
| - | simtime = vm[" | ||
| - | } | ||
| - | |||
| - | if (vm.count(" | ||
| - | cout << "size set to " | ||
| - | << | ||
| - | size = vm[" | ||
| - | } | ||
| - | |||
| - | if (vm.count(" | ||
| - | cout << "seed set to " | ||
| - | << | ||
| - | seed = vm[" | ||
| - | } | ||
| - | } | ||
| - | catch(exception& | ||
| - | cerr << " | ||
| - | return 1; | ||
| - | } | ||
| - | catch(...) { | ||
| - | cerr << " | ||
| - | } | ||
| - | |||
| - | // BEGIN Global stuff | ||
| - | mpi:: | ||
| - | mpi:: | ||
| - | communicator = &world; | ||
| - | |||
| - | sprintf(strbuf, | ||
| - | string logfile = strbuf; | ||
| - | logger = new Logger(logfile, | ||
| - | |||
| - | sys = new System(& | ||
| - | // END Global stuff | ||
| - | |||
| - | PoissonGroup * poisson = new PoissonGroup(size, | ||
| - | poisson-> | ||
| - | |||
| - | sprintf(strbuf, | ||
| - | SpikeMonitor * smon_e = new SpikeMonitor( poisson, strbuf, size); | ||
| - | |||
| - | sprintf(strbuf, | ||
| - | PopulationRateMonitor * pmon_e = new PopulationRateMonitor( poisson, strbuf, 1.0 ); | ||
| - | |||
| - | RateChecker * chk = new RateChecker( poisson , -1 , 20.*kappa , 10); | ||
| - | if (!sys-> | ||
| - | errcode = 1; | ||
| - | |||
| - | logger-> | ||
| - | delete sys; | ||
| - | |||
| - | if (errcode) | ||
| - | env.abort(errcode); | ||
| - | return errcode; | ||
| - | } | ||
| - | </ | ||
| - | |||
| + | The full source code can be found here [[https:// | ||
examples/sim_poisson.1440629865.txt.gz · Last modified: 2015/08/26 22:57 by zenke
