NEST main@caf0ae8
 
Loading...
Searching...
No Matches
rate_neuron_opn.h
Go to the documentation of this file.
1/*
2 * rate_neuron_opn.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 RATE_NEURON_OPN_H
24#define RATE_NEURON_OPN_H
25
26// Generated includes:
27#include "config.h"
28
29// C++ includes:
30#include <string>
31
32// Includes from nestkernel:
33#include "archiving_node.h"
34#include "connection.h"
35#include "event.h"
36#include "nest_types.h"
37#include "node.h"
38#include "random_generators.h"
39#include "recordables_map.h"
40#include "ring_buffer.h"
42
43namespace nest
44{
45
46/* BeginUserDocs: neuron, rate
47
48Short description
49+++++++++++++++++
50
51Base class for rate model with output noise
52
53Description
54+++++++++++
55
56Base class for rate model with output noise of the form
57
58.. math::
59
60 \tau dX_i(t) / dt = - X_i(t) + \mu + \phi( \sum w_{ij} \cdot
61 \psi( X_j(t-d_{ij}) + \sqrt{\tau} \cdot
62 \sigma \cdot \xi_j(t) ) )
63
64or
65
66.. math::
67
68 \tau dX_i(t) / dt = - X_i(t) + \mu
69 + \text{mult_coupling_ex}( X_i(t) ) \cdot \\
70 \phi( \sum w^{ > 0 }_{ij} \cdot \psi( X_j(t-d_{ij}) \\
71 + \sqrt{\tau} \cdot \sigma \cdot \xi_j(t) ) ) \\
72 + \text{mult_coupling_in}( X_i(t) ) \cdot \\
73 \phi( \sum w^{ < 0 }_{ij} \cdot \psi( X_j(t-d_{ij}) \\
74 + \sqrt{\tau} \cdot \sigma \cdot \xi_j(t) ) )
75
76
77Here :math:`xi_j(t)` denotes a Gaussian white noise.
78
79This template class needs to be instantiated with a class
80containing the following functions:
81
82- ``input`` (nonlinearity that is applied to the input, either psi or phi)
83- ``mult_coupling_ex`` (factor of multiplicative coupling for excitatory input)
84- ``mult_coupling_in`` (factor of multiplicative coupling for inhibitory input)
85
86The boolean parameter ``linear_summation`` determines whether the input function
87is applied to the summed up incoming connections (True, default value, input
88represents phi) or to each input individually (False, input represents psi).
89In case of multiplicative coupling the nonlinearity is applied separately
90to the summed excitatory and inhibitory inputs if ``linear_summation=True``.
91
92See also :footcite:p:`Hahne2017`.
93
94References
95++++++++++
96
97.. footbibliography::
98
99See also
100++++++++
101
102lin_rate, tanh_rate, threshold_lin_rate
103
104Examples using this model
105+++++++++++++++++++++++++
106
107.. listexamples:: rate_neuron_opn
108
109EndUserDocs */
110
111template < class TNonlinearities >
113{
114
115public:
116 typedef Node base;
117
120
126 using Node::handle;
129
131 void handle( DelayedRateConnectionEvent& ) override;
132 void handle( DataLoggingRequest& ) override;
133
134 size_t handles_test_event( InstantaneousRateConnectionEvent&, size_t ) override;
135 size_t handles_test_event( DelayedRateConnectionEvent&, size_t ) override;
136 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
137
138 void
142 void
146
147 void get_status( Dictionary& ) const override;
148 void set_status( const Dictionary& ) override;
149
150private:
151 void init_buffers_() override;
152 void pre_run_hook() override;
153
154 TNonlinearities nonlinearities_;
155
159 bool update_( Time const&, const long, const long, const bool );
160
161 void update( Time const&, const long, const long ) override;
162 bool wfr_update( Time const&, const long, const long ) override;
163
164 // The next two classes need to be friends to access the State_ class/member
165 friend class RecordablesMap< rate_neuron_opn< TNonlinearities > >;
166 friend class UniversalDataLogger< rate_neuron_opn< TNonlinearities > >;
167
168 // ----------------------------------------------------------------
169
174 {
176 double tau_;
177
179 double sigma_;
180
182 double mu_;
183
189
192
193 Parameters_();
194
195 void get( Dictionary& ) const;
196
197 void set( const Dictionary&, Node* node );
198 };
199
200 // ----------------------------------------------------------------
201
205 struct State_
206 {
207 double rate_;
208 double noise_;
209 double noisy_rate_;
210
211 State_();
212
213 void get( Dictionary& ) const;
214
220 void set( const Dictionary&, Node* node );
221 };
222
223 // ----------------------------------------------------------------
224
228 struct Buffers_
229 {
232
233
235 // RateConnectionDelayed from excitatory neurons
237 // RateConnectionDelayed from inhibitory neurons
238 std::vector< double > instant_rates_ex_;
239 // by RateConnectionInstantaneous from excitatory neurons
240 std::vector< double > instant_rates_in_;
241 // by RateConnectionInstantaneous
242 std::vector< double > last_y_values;
243 std::vector< double > random_numbers;
244 // order to apply the same random numbers in each iteration when wfr is used
245 UniversalDataLogger< rate_neuron_opn > logger_;
246 };
247
248 // ----------------------------------------------------------------
249
254 {
255 // propagators
256 double P1_;
257 double P2_;
258
259 // factor accounting for piecewise constant implementation of noise
261
263 };
264
266 double
267 get_rate_() const
268 {
269 return S_.rate_;
270 }
271
273 double
275 {
276 return S_.noise_;
277 }
278
280 double
282 {
283 return S_.noisy_rate_;
284 }
285
286 // ----------------------------------------------------------------
287
292
295};
296
297
298template < class TNonlinearities >
299inline void
300rate_neuron_opn< TNonlinearities >::update( Time const& origin, const long from, const long to )
301{
302 update_( origin, from, to, false );
303}
304
305template < class TNonlinearities >
306inline bool
307rate_neuron_opn< TNonlinearities >::wfr_update( Time const& origin, const long from, const long to )
308{
309 State_ old_state = S_; // save state before wfr update
310 const bool wfr_tol_exceeded = update_( origin, from, to, true );
311 S_ = old_state; // restore old state
312
313 return not wfr_tol_exceeded;
314}
315
316template < class TNonlinearities >
317inline size_t
319{
320 if ( receptor_type != 0 )
321 {
322 throw UnknownReceptorType( receptor_type, get_name() );
323 }
324 return 0;
325}
326
327template < class TNonlinearities >
328inline size_t
330{
331 if ( receptor_type != 0 )
332 {
333 throw UnknownReceptorType( receptor_type, get_name() );
334 }
335 return 0;
336}
337
338template < class TNonlinearities >
339inline size_t
341{
342 if ( receptor_type != 0 )
343 {
344 throw UnknownReceptorType( receptor_type, get_name() );
345 }
346 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
347}
348
349template < class TNonlinearities >
350inline void
352{
353 P_.get( d );
354 S_.get( d );
356 d[ names::recordables ] = recordablesMap_.get_list();
357
358 nonlinearities_.get( d );
359}
360
361template < class TNonlinearities >
362inline void
364{
365 Parameters_ ptmp = P_; // temporary copy in case of errors
366 ptmp.set( d, this ); // throws if BadProperty
367 State_ stmp = S_; // temporary copy in case of errors
368 stmp.set( d, this ); // throws if BadProperty
369
370 // We now know that (ptmp, stmp) are consistent. We do not
371 // write them back to (P_, S_) before we are also sure that
372 // the properties to be set in the parent class are internally
373 // consistent.
375
376 // if we get here, temporaries contain consistent set of properties
377 P_ = ptmp;
378 S_ = stmp;
379
380 nonlinearities_.set( d, this );
381}
382
383} // namespace
384
385#endif /* #ifndef RATE_NEURON_OPN_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
A node which archives spike history for the purposes of spike-timing dependent plasticity (STDP)
Definition archiving_node.h:49
void get_status(Dictionary &d) const override
Export properties of the node by setting entries in the status dictionary.
Definition archiving_node.cpp:220
void set_status(const Dictionary &d) override
Change properties of the node according to the entries in the dictionary.
Definition archiving_node.cpp:236
Request data to be logged/logged data to be sent.
Definition event.h:636
Event for rate model connections with delay.
Definition secondary_event.h:331
Event for rate model connections without delay.
Definition secondary_event.h:315
Base class for all NEST network objects.
Definition node.h:99
Map names of recordables to data access functions.
Definition recordables_map.h:61
Buffer Layout.
Definition ring_buffer.h:83
Definition nest_time.h:135
Exception to be thrown if the specified receptor type does not exist in the node.
Definition exceptions.h:417
Definition rate_neuron_opn.h:113
State_ S_
Definition rate_neuron_opn.h:289
double get_rate_() const
Read out the rate.
Definition rate_neuron_opn.h:267
Parameters_ P_
Definition rate_neuron_opn.h:288
double get_noise_() const
Read out the noise.
Definition rate_neuron_opn.h:274
void sends_secondary_event(DelayedRateConnectionEvent &) override
Required to check, if source neuron may send a SecondaryEvent.
Definition rate_neuron_opn.h:143
Buffers_ B_
Definition rate_neuron_opn.h:291
rate_neuron_opn()
Definition rate_neuron_opn_impl.h:169
void update(Time const &, const long, const long) override
Advance the state of the node in time through the given interval.
Definition rate_neuron_opn.h:300
void handle(InstantaneousRateConnectionEvent &) override
Handler for rate neuron events.
Definition rate_neuron_opn_impl.h:365
bool wfr_update(Time const &, const long, const long) override
Advance the state of the node in time through the given interval (see Node::update() for more details...
Definition rate_neuron_opn.h:307
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition rate_neuron_opn.h:363
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition rate_neuron_opn.h:351
double get_noisy_rate_() const
Read out the noisy rate.
Definition rate_neuron_opn.h:281
void sends_secondary_event(InstantaneousRateConnectionEvent &) override
Required to check, if source neuron may send a SecondaryEvent.
Definition rate_neuron_opn.h:139
bool update_(Time const &, const long, const long, const bool)
This is the actual update function.
Definition rate_neuron_opn_impl.h:239
Node base
Definition rate_neuron_opn.h:116
size_t handles_test_event(InstantaneousRateConnectionEvent &, size_t) override
Definition rate_neuron_opn.h:318
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition rate_neuron_opn_impl.h:219
static RecordablesMap< rate_neuron_opn< TNonlinearities > > recordablesMap_
Mapping of recordables names to access functions.
Definition rate_neuron_opn.h:294
Variables_ V_
Definition rate_neuron_opn.h:290
TNonlinearities nonlinearities_
Definition rate_neuron_opn.h:154
void init_buffers_() override
Configure persistent internal data structures.
Definition rate_neuron_opn_impl.h:195
virtual size_t handles_test_event(SpikeEvent &, size_t receptor_type)
Check if the node can handle a particular event and receptor type.
Definition node.cpp:271
virtual void sends_secondary_event(GapJunctionEvent &ge)
Required to check, if source neuron may send a SecondaryEvent.
Definition node.cpp:381
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition node.cpp:265
const std::string recordables("recordables")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
Declarations for base class Node.
Buffers of the model.
Definition rate_neuron_opn.h:229
std::vector< double > random_numbers
remembers the random_numbers in
Definition rate_neuron_opn.h:243
UniversalDataLogger< rate_neuron_opn > logger_
Logger for all analog data.
Definition rate_neuron_opn.h:245
std::vector< double > instant_rates_ex_
buffer for rate vector received
Definition rate_neuron_opn.h:238
RingBuffer delayed_rates_ex_
buffer for rate vector received by
Definition rate_neuron_opn.h:234
std::vector< double > instant_rates_in_
buffer for rate vector received
Definition rate_neuron_opn.h:240
RingBuffer delayed_rates_in_
buffer for rate vector received by
Definition rate_neuron_opn.h:236
std::vector< double > last_y_values
remembers y_values from last wfr_update
Definition rate_neuron_opn.h:242
Independent parameters of the model.
Definition rate_neuron_opn.h:174
bool linear_summation_
Target of non-linearity.
Definition rate_neuron_opn.h:188
double sigma_
Noise parameter.
Definition rate_neuron_opn.h:179
void get(Dictionary &) const
Store current values in dictionary.
Definition rate_neuron_opn_impl.h:85
bool mult_coupling_
use multiplicative coupling? Default is false
Definition rate_neuron_opn.h:191
double tau_
Time constant in ms.
Definition rate_neuron_opn.h:176
Parameters_()
Sets default parameter values.
Definition rate_neuron_opn_impl.h:61
double mu_
Mean input.
Definition rate_neuron_opn.h:182
void set(const Dictionary &, Node *node)
Definition rate_neuron_opn_impl.h:100
State variables of the model.
Definition rate_neuron_opn.h:206
double noisy_rate_
Noisy rate, i.e. rate +noise.
Definition rate_neuron_opn.h:209
double rate_
Rate.
Definition rate_neuron_opn.h:207
void get(Dictionary &) const
Definition rate_neuron_opn_impl.h:138
double noise_
Noise.
Definition rate_neuron_opn.h:208
State_()
Default initialization.
Definition rate_neuron_opn_impl.h:72
void set(const Dictionary &, Node *node)
Set values from dictionary.
Definition rate_neuron_opn_impl.h:147
Internal variables of the model.
Definition rate_neuron_opn.h:254
double P1_
Definition rate_neuron_opn.h:256
double output_noise_factor_
Definition rate_neuron_opn.h:260
normal_distribution normal_dist_
normal distribution
Definition rate_neuron_opn.h:262
double P2_
Definition rate_neuron_opn.h:257