NEST main@caf0ae8
 
Loading...
Searching...
No Matches
inhomogeneous_poisson_generator.h
Go to the documentation of this file.
1/*
2 * inhomogeneous_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 INHOMOGENEOUS_POISSON_GENERATOR_H
24#define INHOMOGENEOUS_POISSON_GENERATOR_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 "random_generators.h"
34#include "ring_buffer.h"
35#include "stimulation_device.h"
36
37namespace nest
38{
39
40/* BeginUserDocs: device, generator
41
42Short description
43+++++++++++++++++
44
45Provides Poisson spike trains at a piecewise constant rate
46
47Description
48+++++++++++
49
50The inhomogeneous Poisson generator provides Poisson spike trains at a
51piecewise constant rate to the connected node(s). The rate of the process
52is changed at the specified times. The unit of the instantaneous rate
53is spikes/s. By default, each target of the generator will receive
54a different spike train.
55
56.. include:: ../models/stimulation_device.rst
57
58rate_times
59 Times at which rate changes (list of ms)
60
61rate_values
62 Rate of Poisson spike train (list of spikes/s)
63
64allow_offgrid_times
65 If false, spike times will be rounded to the nearest step if they
66 are less than tic/2 from the step, otherwise NEST reports an
67 error. If true, spike times are rounded to the nearest step if
68 within tic/2 from the step, otherwise they are rounded up to the
69 *end* of the step. Default: false
70
71Set parameters from a stimulation backend
72~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73
74The parameters in this stimulation device can be updated with input
75coming from a stimulation backend. The data structure used for the
76update holds one value for each of the parameters mentioned above.
77The indexing is as follows:
78
79 0. rate_times
80 1. rate_values
81
82Receives
83++++++++
84
85DataLoggingRequest
86
87Sends
88+++++
89
90SpikeEvent
91
92See also
93++++++++
94
95sinusoidal_poisson_generator, step_current_generator
96
97Examples using this model
98+++++++++++++++++++++++++
99
100.. listexamples:: inhomogeneous_poisson_generator
101
102EndUserDocs */
103
104void register_inhomogeneous_poisson_generator( const std::string& name );
105
107{
108
109public:
112
118 using Node::event_hook;
119
120 size_t send_test_event( Node&, size_t, synindex, bool ) override;
121
122 void get_status( Dictionary& ) const override;
123 void set_status( const Dictionary& ) override;
124
125 StimulationDevice::Type get_type() const override;
126 void set_data_from_stimulation_backend( std::vector< double >& input_param ) override;
127
128
129private:
130 void init_state_() override;
131 void init_buffers_() override;
132 void pre_run_hook() override;
133
134 void update( Time const&, const long, const long ) override;
135 void event_hook( DSSpikeEvent& ) override;
136
137 struct Buffers_;
138
139 /*
140 * Store independent parameters of the model.
141 */
143 {
144 std::vector< Time > rate_times_;
145 std::vector< double > rate_values_;
146
149
150 Parameters_();
152
154 void get( Dictionary& ) const;
156 void set( const Dictionary&, Buffers_&, Node* );
158 void assert_valid_rate_time_and_insert( const double t );
159 };
160
161 // ------------------------------------------------------------
162
163 struct Buffers_
164 {
165 size_t idx_;
166 double rate_;
167 };
168
169 // ------------------------------------------------------------
170
176
177 // ------------------------------------------------------------
178
182};
183
184inline size_t
186 size_t receptor_type,
187 synindex syn_id,
188 bool dummy_target )
189{
191
192 // to ensure correct overloading resolution, we need explicit event types
193 // therefore, we need to duplicate the code here
194 if ( dummy_target )
195 {
196 DSSpikeEvent e;
197 e.set_sender( *this );
198 return target.handles_test_event( e, receptor_type );
199 }
200 else
201 {
202 SpikeEvent e;
203 e.set_sender( *this );
204 return target.handles_test_event( e, receptor_type );
205 }
206}
207
208
209inline void
215
216inline void
218{
219 Parameters_ ptmp = P_; // temporary copy in case of errors
220
221 ptmp.set( d, B_, this ); // throws if BadProperty
222 // We now know that ptmp is consistent. We do not write it back
223 // to P_ before we are also sure that the properties to be set
224 // in the parent class are internally consistent.
226
227 // if we get here, temporaries contain consistent set of properties
228 P_ = ptmp;
229}
230
236
237} // namespace
238
239#endif // INHOMOGENEOUS_POISSON_GENERATOR_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
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
Definition nest_time.h:135
Definition inhomogeneous_poisson_generator.h:107
void set_data_from_stimulation_backend(std::vector< double > &input_param) override
Definition inhomogeneous_poisson_generator.cpp:294
inhomogeneous_poisson_generator()
Definition inhomogeneous_poisson_generator.cpp:195
size_t send_test_event(Node &, size_t, synindex, bool) override
Send an event to the receiving_node passed as an argument.
Definition inhomogeneous_poisson_generator.h:185
StimulationDevice::Type get_type() const override
Definition inhomogeneous_poisson_generator.h:232
Parameters_ P_
Definition inhomogeneous_poisson_generator.h:179
void update(Time const &, const long, const long) override
Advance the state of the node in time through the given interval.
Definition inhomogeneous_poisson_generator.cpp:240
void init_buffers_() override
Configure persistent internal data structures.
Definition inhomogeneous_poisson_generator.cpp:221
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition inhomogeneous_poisson_generator.cpp:229
void event_hook(DSSpikeEvent &) override
Modify Event object parameters during event delivery.
Definition inhomogeneous_poisson_generator.cpp:277
Variables_ V_
Definition inhomogeneous_poisson_generator.h:181
Buffers_ B_
Definition inhomogeneous_poisson_generator.h:180
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition inhomogeneous_poisson_generator.h:217
void init_state_() override
Configure state variables depending on runtime information.
Definition inhomogeneous_poisson_generator.cpp:215
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition inhomogeneous_poisson_generator.h:210
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_inhomogeneous_poisson_generator(const std::string &name)
Definition inhomogeneous_poisson_generator.cpp:42
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Definition inhomogeneous_poisson_generator.h:164
double rate_
current amplitude
Definition inhomogeneous_poisson_generator.h:166
size_t idx_
index of current amplitude
Definition inhomogeneous_poisson_generator.h:165
Definition inhomogeneous_poisson_generator.h:143
bool allow_offgrid_times_
Allow and round up rate times not on steps;.
Definition inhomogeneous_poisson_generator.h:148
Parameters_(const Parameters_ &, Buffers_ &)
Store current values in dictionary.
void set(const Dictionary &, Buffers_ &, Node *)
Align rate time to grid if necessary and insert it into rate_times_.
Definition inhomogeneous_poisson_generator.cpp:116
std::vector< Time > rate_times_
Definition inhomogeneous_poisson_generator.h:144
void get(Dictionary &) const
Set values from dictionary.
Definition inhomogeneous_poisson_generator.cpp:64
Parameters_()
Sets default parameter values.
Definition inhomogeneous_poisson_generator.cpp:51
std::vector< double > rate_values_
Definition inhomogeneous_poisson_generator.h:145
void assert_valid_rate_time_and_insert(const double t)
Definition inhomogeneous_poisson_generator.cpp:80
Definition inhomogeneous_poisson_generator.h:172
poisson_distribution poisson_dist_
poisson distribution
Definition inhomogeneous_poisson_generator.h:173
double h_
Definition inhomogeneous_poisson_generator.h:174