NEST main@caf0ae8
 
Loading...
Searching...
No Matches
poisson_generator_ps.h
Go to the documentation of this file.
1/*
2 * poisson_generator_ps.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_PS_H
24#define POISSON_GENERATOR_PS_H
25
26// C++ includes:
27#include <vector>
28
29// Includes from nestkernel:
30#include "connection.h"
31#include "device_node.h"
32#include "event.h"
33#include "nest_timeconverter.h"
34#include "nest_types.h"
35#include "random_generators.h"
36#include "stimulation_device.h"
37
38namespace nest
39{
40
41/* BeginUserDocs: device, generator, precise
42
43Short description
44+++++++++++++++++
45
46Simulated neuron firing with Poisson process statistics - precise
47spike timing version with arbitrary dead times
48
49Description
50+++++++++++
51
52The ``poisson_generator_ps`` simulates a neuron firing with Poisson
53statistics (with dead time), that is, exponentially distributed interspike
54intervals plus constant dead time, spike events have exact timing,
55that is, they are not constrained to the simulation time grid.
56
57.. note::
58 This generator must be connected to all its targets using the
59 same synapse model. Failure to do so will only be detected at
60 runtime.
61
62.. include:: ../models/stimulation_device.rst
63
64rate
65 Mean firing rate (spikes/s)
66
67dead_time
68 Minimal time between two spikes (ms)
69
70Set parameters from a stimulation backend
71~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72
73The parameters in this stimulation device can be updated with input
74coming from a stimulation backend. The data structure used for the
75update holds one value for each of the parameters mentioned above.
76The indexing is as follows:
77
78 0. dead_time
79 1. rate
80
81Sends
82+++++
83
84SpikeEvent
85
86See also
87++++++++
88
89poisson_generator, parrot_neuron_ps
90
91Examples using this model
92+++++++++++++++++++++++++
93
94.. listexamples:: poisson_generator_ps
95
96EndUserDocs */
97
98void register_poisson_generator_ps( const std::string& name );
99
101{
102
103public:
106
107 bool is_off_grid() const override;
108
109 using Node::event_hook;
110
111 size_t send_test_event( Node&, size_t, synindex, bool ) override;
112
113 void get_status( Dictionary& ) const override;
114 void set_status( const Dictionary& ) override;
115
116 void calibrate_time( const TimeConverter& tc ) override;
117
118 StimulationDevice::Type get_type() const override;
119 void set_data_from_stimulation_backend( std::vector< double >& input_param ) override;
120
121private:
122 void init_state_() override;
123 void init_buffers_() override;
124 void pre_run_hook() override;
125
135 void update( Time const&, const long, const long ) override;
136
142 void event_hook( DSSpikeEvent& ) override;
143
144 // ------------------------------------------------------------
145
150 {
151 double rate_;
152 double dead_time_;
153
161
162 Parameters_();
163
164 void get( Dictionary& ) const;
165 void set( const Dictionary&, Node* node );
166 };
167
168 // ------------------------------------------------------------
169
170 struct Buffers_
171 {
172 typedef std::pair< Time, double > SpikeTime;
173
181 std::vector< SpikeTime > next_spike_;
182 };
183
184 // ------------------------------------------------------------
185
205
206 // ------------------------------------------------------------
207
211};
212
213inline size_t
214poisson_generator_ps::send_test_event( Node& target, size_t receptor_type, synindex syn_id, bool dummy_target )
215{
217
218 if ( dummy_target )
219 {
220 DSSpikeEvent e;
221 e.set_sender( *this );
222 return target.handles_test_event( e, receptor_type );
223 }
224 else
225 {
226 SpikeEvent e;
227 e.set_sender( *this );
228 const size_t p = target.handles_test_event( e, receptor_type );
229 if ( p != invalid_port and not is_model_prototype() )
230 {
231 ++P_.num_targets_; // count number of targets
232 }
233 return p;
234 }
235}
236
237inline void
243
244inline void
246{
247 Parameters_ ptmp = P_; // temporary copy in case of errors
248 ptmp.set( d, this ); // throws if BadProperty
249
250 // If the rate is changed, the event_hook must handle the interval from
251 // the rate change to the first subsequent spike.
252 if ( d.known( names::rate ) )
253 {
255 }
256
257 // We now know that ptmp is consistent. We do not write it back
258 // to P_ before we are also sure that the properties to be set
259 // in the parent class are internally consistent.
261
262 // if we get here, temporaries contain consistent set of properties
263 P_ = ptmp;
264}
265
266inline void
272
273inline bool
275{
276 return true;
277}
278
284
285} // namespace
286
287#endif // POISSON_GENERATOR_PS_H
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
"Callback request event" for use in Device.
Definition event.h:521
Base class for all NEST network objects.
Definition node.h:99
virtual void event_hook(DSSpikeEvent &)
Modify Event object parameters during event delivery.
Definition node.cpp:586
bool is_model_prototype() const
Returns true if node is model prototype.
Definition node.h:1226
Event for spike information.
Definition event.h:418
Base class for common properties of StimulationDevices.
Definition stimulation_device.h:154
void enforce_single_syn_type(synindex)
Throws IllegalConnection if synapse id differs from initial synapse id.
Definition stimulation_device.cpp:62
Type
Device type.
Definition stimulation_device.h:187
@ SPIKE_GENERATOR
Definition stimulation_device.h:189
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition stimulation_device.cpp:125
void get_status(Dictionary &d) const override
Export properties of the node by setting entries in the status dictionary.
Definition stimulation_device.cpp:168
Class to convert times from one representation to another.
Definition nest_timeconverter.h:42
Time from_old_tics(tic_t t_old) const
Converts a given number of tics with respect to old representation into a time object in current repr...
Definition nest_timeconverter.cpp:49
Definition nest_time.h:135
tic_t get_tics() const
Definition nest_time.h:474
static Time neg_inf()
Definition nest_time.h:427
Definition poisson_generator_ps.h:101
Parameters_ P_
Definition poisson_generator_ps.h:208
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition poisson_generator_ps.h:238
void init_state_() override
Configure state variables depending on runtime information.
Definition poisson_generator_ps.cpp:113
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition poisson_generator_ps.cpp:129
Buffers_ B_
Definition poisson_generator_ps.h:210
bool is_off_grid() const override
Returns true if the node sends/receives off-grid events.
Definition poisson_generator_ps.h:274
void update(Time const &, const long, const long) override
Update state.
Definition poisson_generator_ps.cpp:182
void set_data_from_stimulation_backend(std::vector< double > &input_param) override
Definition poisson_generator_ps.cpp:284
size_t send_test_event(Node &, size_t, synindex, bool) override
Send an event to the receiving_node passed as an argument.
Definition poisson_generator_ps.h:214
StimulationDevice::Type get_type() const override
Definition poisson_generator_ps.h:280
poisson_generator_ps()
Definition poisson_generator_ps.cpp:95
Variables_ V_
Definition poisson_generator_ps.h:209
void calibrate_time(const TimeConverter &tc) override
Re-calculate time-based properties of the node.
Definition poisson_generator_ps.h:267
void event_hook(DSSpikeEvent &) override
Send out spikes.
Definition poisson_generator_ps.cpp:210
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition poisson_generator_ps.h:245
void init_buffers_() override
Configure persistent internal data structures.
Definition poisson_generator_ps.cpp:119
const std::string rate("rate")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_poisson_generator_ps(const std::string &name)
Definition poisson_generator_ps.cpp:41
constexpr size_t invalid_port
Value for invalid connection port number.
Definition nest_types.h:141
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Definition poisson_generator_ps.h:171
std::vector< SpikeTime > next_spike_
Time of next spike represented as time stamp and offset, for each target.
Definition poisson_generator_ps.h:181
std::pair< Time, double > SpikeTime
Definition poisson_generator_ps.h:172
Store independent parameters of the model.
Definition poisson_generator_ps.h:150
double dead_time_
dead time [ms]
Definition poisson_generator_ps.h:152
size_t num_targets_
Number of targets.
Definition poisson_generator_ps.h:160
double rate_
process rate [spks/s]
Definition poisson_generator_ps.h:151
void get(Dictionary &) const
Store current values in dictionary.
Definition poisson_generator_ps.cpp:62
Parameters_()
Sets default parameter values.
Definition poisson_generator_ps.cpp:50
void set(const Dictionary &, Node *node)
Set values from dictionary.
Definition poisson_generator_ps.cpp:69
Definition poisson_generator_ps.h:187
Time t_min_active_
start of generator activity in slice
Definition poisson_generator_ps.h:201
exponential_distribution exp_dev_
random deviate generator
Definition poisson_generator_ps.h:189
double inv_rate_ms_
1000.0 / Parameters_.rate_
Definition poisson_generator_ps.h:188
Time t_max_active_
end of generator activity in slice
Definition poisson_generator_ps.h:202