NEST  2.6.0,not_revisioned_source_dir@0
poisson_generator.h
Go to the documentation of this file.
1 /*
2  * poisson_generator.h
3  *
4  * This file is part of NEST.
5  *
6  * Copyright (C) 2004 The NEST Initiative
7  *
8  * NEST is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * NEST is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef POISSON_GENERATOR_H
24 #define POISSON_GENERATOR_H
25 /****************************************/
26 /* class poisson_generator */
27 /* Vers. 1.0 hep */
28 /* Implementation: hep */
29 /****************************************/
30 
31 #include "nest.h"
32 #include "event.h"
33 #include "node.h"
34 #include "stimulating_device.h"
35 #include "connection.h"
36 #include "poisson_randomdev.h"
37 
38 namespace nest
39 {
46 /*BeginDocumentation
47 Name: poisson_generator - simulate neuron firing with Poisson processes statistics.
48 Description:
49  The poisson_generator simulates a neuron that is firing with Poisson statistics,
50  i.e. exponentially distributed interspike intervals. It will generate a _unique_
51  spike train for each of it's targets. If you do not want this behavior and need
52  the same spike train for all targets, you have to use a parrot neuron inbetween
53  the poisson generator and the targets.
54 
55 Parameters:
56  The following parameters appear in the element's status dictionary:
57 
58  rate double - mean firing rate in Hz
59  origin double - Time origin for device timer in ms
60  start double - begin of device application with resp. to origin in ms
61  stop double - end of device application with resp. to origin in ms
62 
63 Sends: SpikeEvent
64 
65 Remarks:
66  A Poisson generator may, especially at high rates, emit more than one
67  spike during a single time step. If this happens, the generator does
68  not actually send out n spikes. Instead, it emits a single spike with
69  n-fold synaptic weight for the sake of efficiency.
70 
71  The design decision to implement the Poisson generator as a device
72  which sends spikes to all connected nodes on every time step and then
73  discards the spikes that should not have happened generating random
74  numbers at the recipient side via an event hook is twofold.
75 
76  On one hand, it leads to the saturation of the messaging network with
77  an enormous amount of spikes, most of which will never get delivered
78  and should not have been generated in the first place.
79 
80  On the other hand, a proper implementation of the Poisson generator
81  needs to provide two basic features: (a) generated spike trains
82  should be IID processes w.r.t. target neurons to which the generator
83  is connected and (b) as long as virtual_num_proc is constant, each
84  neuron should receive an identical Poisson spike train in order to
85  guarantee reproducibility of the simulations across varying machine
86  numbers.
87 
88  Therefore, first, as network()->send sends spikes to all the
89  recipients, differentiation has to happen in the hook, second, the
90  hook can use the RNG from the thread where the recipient neuron sits,
91  which explains the current design of the generator. For details,
92  refer to:
93 
94  http://ken.brainworks.uni-freiburg.de/cgi-bin/mailman/private/nest_developer/2011-January/002977.html
95 
96 SeeAlso: poisson_generator_ps, Device, parrot_neuron
97 */
98 
99  class poisson_generator : public Node
100  {
101 
102  public:
103 
110 
111  bool has_proxies() const {return false;}
112 
117  using Node::event_hook;
118 
120 
121  void get_status(DictionaryDatum &) const;
122  void set_status(const DictionaryDatum &) ;
123 
124  private:
125 
126  void init_state_(const Node&);
127  void init_buffers_();
128  void calibrate();
129 
130  void update(Time const &, const long_t, const long_t);
131  void event_hook(DSSpikeEvent&);
132 
133  // ------------------------------------------------------------
134 
138  struct Parameters_ {
140 
141  Parameters_();
142 
143  void get(DictionaryDatum&) const;
144  void set(const DictionaryDatum&);
145  };
146 
147  // ------------------------------------------------------------
148 
149  struct Variables_ {
151  };
152 
153  // ------------------------------------------------------------
154 
158 
159  };
160 
161  inline
163  {
164  device_.enforce_single_syn_type(syn_id);
165 
166  if ( dummy_target )
167  {
168  DSSpikeEvent e;
169  e.set_sender(*this);
170  return target.handles_test_event(e, receptor_type);
171  }
172  else
173  {
174  SpikeEvent e;
175  e.set_sender(*this);
176  return target.handles_test_event(e, receptor_type);
177  }
178  }
179 
180  inline
182  {
183  P_.get(d);
184  device_.get_status(d);
185  }
186 
187  inline
189  {
190  Parameters_ ptmp = P_; // temporary copy in case of errors
191  ptmp.set(d); // throws if BadProperty
192 
193  // We now know that ptmp is consistent. We do not write it back
194  // to P_ before we are also sure that the properties to be set
195  // in the parent class are internally consistent.
196  device_.set_status(d);
197 
198  // if we get here, temporaries contain consistent set of properties
199  P_ = ptmp;
200  }
201 
202 } // namespace nest
203 
204 #endif
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
Definition: lockptrdatum.h:40
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
double_t rate_
process rate in Hz
Definition: poisson_generator.h:139
Declarations for base class Node.
port send_test_event(Node &, rport, synindex, bool)
Send an event to the receiving_node passed as an argument.
Definition: poisson_generator.h:162
"Callback request event" for use in Device.
Definition: event.h:374
Base class for common properties of Stimulating Devices.
Definition: stimulating_device.h:117
void set_sender(Node &)
Change pointer to sending Node.
Definition: event.h:714
void init_state_(const Node &)
Private function to initialize the state of a node to model defaults.
Definition: poisson_generator.cpp:77
void get_status(DictionaryDatum &) const
Definition: poisson_generator.h:181
librandom::PoissonRandomDev poisson_dev_
Random deviate generator.
Definition: poisson_generator.h:150
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
Definition: poisson_generator.h:149
void update(Time const &, const long_t, const long_t)
Bring the node from state $t$ to $t+n*dt$.
Definition: poisson_generator.cpp:102
StimulatingDevice< SpikeEvent > device_
Definition: poisson_generator.h:155
void set(const DictionaryDatum &)
Set values from dicitonary.
Definition: poisson_generator.cpp:48
Store independent parameters of the model.
Definition: poisson_generator.h:138
Definition: nest_time.h:130
Definition: poisson_generator.h:99
Parameters_()
Sets default parameter values.
Definition: poisson_generator.cpp:34
void event_hook(DSSpikeEvent &)
Modify Event object parameters during event delivery.
Definition: poisson_generator.cpp:120
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
bool has_proxies() const
Returns true if the node has proxies on remote threads.
Definition: poisson_generator.h:111
void calibrate()
Re-calculate dependent parameters of the node.
Definition: poisson_generator.cpp:89
Class PoissonRandomDev Create Poisson distributed random numbers.
Definition: poisson_randomdev.h:103
poisson_generator()
The generator is threaded, so the RNG to use is determined at run-time, depending on thread...
Definition: poisson_generator.cpp:60
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: poisson_generator.cpp:84
Parameters_ P_
Definition: poisson_generator.h:156
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
double double_t
Double precision floating point numbers.
Definition: nest.h:93
virtual port handles_test_event(SpikeEvent &, rport receptor_type)
Check if the node can handle a particular event and receptor type.
Definition: node.cpp:203
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: poisson_generator.cpp:43
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
Default types used by the NEST kernel.
Event for spike information.
Definition: event.h:320
void set_status(const DictionaryDatum &)
Definition: poisson_generator.h:188
Base class for all NEST network objects.
Definition: node.h:96
Variables_ V_
Definition: poisson_generator.h:157
virtual void event_hook(DSSpikeEvent &)
Modify Event object parameters during event delivery.
Definition: node.cpp:301
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
const double e
Definition: numerics.cpp:62