NEST main@caf0ae8
 
Loading...
Searching...
No Matches
rate_neuron_ipn.h
Go to the documentation of this file.
1/*
2 * rate_neuron_ipn.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_IPN_H
24#define RATE_NEURON_IPN_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 input noise
52
53Description
54+++++++++++
55
56Base class for rate model with input noise of the form
57
58.. math::
59
60 \tau dX_i(t) = [ - \lambda X_i(t) + \mu
61 + \phi( \sum w_{ij} \cdot \psi( X_j(t-d_{ij}) ) ) ] dt
62 + [ \sqrt{\tau} \cdot \sigma ] dW_{i}(t)
63
64or
65
66.. math::
67
68 \tau dX_i(t) = [ - \lambda 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 + \text{mult_coupling_in}( X_i(t) ) \cdot \\
72 \phi( \sum w^{ < 0 }_{ij} \cdot \psi( X_j(t-d_{ij}) ) ) ] dt \\
73 + [ \sqrt{\tau} \cdot \sigma ] dW_{i}(t)
74
75This template class needs to be instantiated with a class
76containing the following functions:
77
78- ``input`` (nonlinearity that is applied to the input, either psi or phi)
79- ``mult_coupling_ex`` (factor of multiplicative coupling for excitatory input)
80- ``mult_coupling_in`` (factor of multiplicative coupling for inhibitory input)
81
82The boolean parameter ``linear_summation`` determines whether the input function
83is applied to the summed up incoming connections (True, default value, input
84represents phi) or to each input individually (False, input represents psi).
85In case of multiplicative coupling the nonlinearity is applied separately
86to the summed excitatory and inhibitory inputs if ``linear_summation=True``.
87
88See also :footcite:p:`Hahne2017`.
89
90References
91++++++++++
92
93.. footbibliography::
94
95See also
96++++++++
97
98lin_rate, tanh_rate, threshold_lin_rate
99
100Examples using this model
101+++++++++++++++++++++++++
102
103.. listexamples:: rate_neuron_ipn
104
105EndUserDocs */
106
107template < class TNonlinearities >
109{
110
111public:
112 typedef Node base;
113
116
122 using Node::handle;
125
127 void handle( DelayedRateConnectionEvent& ) override;
128 void handle( DataLoggingRequest& ) override;
129
130 size_t handles_test_event( InstantaneousRateConnectionEvent&, size_t ) override;
131 size_t handles_test_event( DelayedRateConnectionEvent&, size_t ) override;
132 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
133
134 void
138 void
142
143 void get_status( Dictionary& ) const override;
144 void set_status( const Dictionary& ) override;
145
146private:
147 void init_buffers_() override;
148 void pre_run_hook() override;
149
150 TNonlinearities nonlinearities_;
151
155 bool update_( Time const&, const long, const long, const bool );
156
157 void update( Time const&, const long, const long ) override;
158 bool wfr_update( Time const&, const long, const long ) override;
159
160 // The next two classes need to be friends to access the State_ class/member
161 friend class RecordablesMap< rate_neuron_ipn< TNonlinearities > >;
162 friend class UniversalDataLogger< rate_neuron_ipn< TNonlinearities > >;
163
164 // ----------------------------------------------------------------
165
170 {
172 double tau_;
173
175 double lambda_;
176
178 double sigma_;
179
181 double mu_;
182
185
191
198
201
202 Parameters_();
203
204 void get( Dictionary& ) const;
205
206 void set( const Dictionary&, Node* node );
207 };
208
209 // ----------------------------------------------------------------
210
214 struct State_
215 {
216 double rate_;
217 double noise_;
218
219 State_();
220
221 void get( Dictionary& ) const;
222
228 void set( const Dictionary&, Node* node );
229 };
230
231 // ----------------------------------------------------------------
232
236 struct Buffers_
237 {
240
242 // RateConnectionDelayed from excitatory neurons
244 // RateConnectionDelayed from inhibitory neurons
245 std::vector< double > instant_rates_ex_;
246 // by RateConnectionInstantaneous from excitatory neurons
247 std::vector< double > instant_rates_in_;
248 // by RateConnectionInstantaneous from inhibitory neurons
249 std::vector< double > last_y_values;
250 std::vector< double > random_numbers;
251 // order to apply the same random
252 // numbers in each iteration when wfr
253 // is used
254 UniversalDataLogger< rate_neuron_ipn > logger_;
255 };
256
257 // ----------------------------------------------------------------
258
263 {
264 // propagators
265 double P1_;
266 double P2_;
267
268 // propagator for noise
270
272 };
273
275 double
276 get_rate_() const
277 {
278 return S_.rate_;
279 }
280
282 double
284 {
285 return S_.noise_;
286 }
287
288 // ----------------------------------------------------------------
289
294
297};
298
299template < class TNonlinearities >
300inline void
301rate_neuron_ipn< TNonlinearities >::update( Time const& origin, const long from, const long to )
302{
303 update_( origin, from, to, false );
304}
305
306template < class TNonlinearities >
307inline bool
308rate_neuron_ipn< TNonlinearities >::wfr_update( Time const& origin, const long from, const long to )
309{
310 State_ old_state = S_; // save state before wfr update
311 const bool wfr_tol_exceeded = update_( origin, from, to, true );
312 S_ = old_state; // restore old state
313
314 return not wfr_tol_exceeded;
315}
316
317template < class TNonlinearities >
318inline size_t
320{
321 if ( receptor_type != 0 )
322 {
323 throw UnknownReceptorType( receptor_type, get_name() );
324 }
325 return 0;
326}
327
328template < class TNonlinearities >
329inline size_t
331{
332 if ( receptor_type != 0 )
333 {
334 throw UnknownReceptorType( receptor_type, get_name() );
335 }
336 return 0;
337}
338
339template < class TNonlinearities >
340inline size_t
342{
343 if ( receptor_type != 0 )
344 {
345 throw UnknownReceptorType( receptor_type, get_name() );
346 }
347 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
348}
349
350template < class TNonlinearities >
351inline void
353{
354 P_.get( d );
355 S_.get( d );
357 d[ names::recordables ] = recordablesMap_.get_list();
358
359 nonlinearities_.get( d );
360}
361
362template < class TNonlinearities >
363inline void
365{
366 Parameters_ ptmp = P_; // temporary copy in case of errors
367 ptmp.set( d, this ); // throws if BadProperty
368 State_ stmp = S_; // temporary copy in case of errors
369 stmp.set( d, this ); // throws if BadProperty
370
371 // We now know that (ptmp, stmp) are consistent. We do not
372 // write them back to (P_, S_) before we are also sure that
373 // the properties to be set in the parent class are internally
374 // consistent.
376
377 // if we get here, temporaries contain consistent set of properties
378 P_ = ptmp;
379 S_ = stmp;
380
381 nonlinearities_.set( d, this );
382}
383
384} // namespace
385
386#endif /* #ifndef RATE_NEURON_IPN_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_ipn.h:109
double get_noise_() const
Read out the noise.
Definition rate_neuron_ipn.h:283
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_ipn.h:308
void init_buffers_() override
Configure persistent internal data structures.
Definition rate_neuron_ipn_impl.h:211
bool update_(Time const &, const long, const long, const bool)
This is the actual update function.
Definition rate_neuron_ipn_impl.h:263
rate_neuron_ipn()
Definition rate_neuron_ipn_impl.h:184
State_ S_
Definition rate_neuron_ipn.h:291
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition rate_neuron_ipn.h:364
Node base
Definition rate_neuron_ipn.h:112
Parameters_ P_
Definition rate_neuron_ipn.h:290
Buffers_ B_
Definition rate_neuron_ipn.h:293
Variables_ V_
Definition rate_neuron_ipn.h:292
void sends_secondary_event(InstantaneousRateConnectionEvent &) override
Required to check, if source neuron may send a SecondaryEvent.
Definition rate_neuron_ipn.h:135
double get_rate_() const
Read out the rate.
Definition rate_neuron_ipn.h:276
void sends_secondary_event(DelayedRateConnectionEvent &) override
Required to check, if source neuron may send a SecondaryEvent.
Definition rate_neuron_ipn.h:139
static RecordablesMap< rate_neuron_ipn< TNonlinearities > > recordablesMap_
Mapping of recordables names to access functions.
Definition rate_neuron_ipn.h:296
TNonlinearities nonlinearities_
Definition rate_neuron_ipn.h:150
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition rate_neuron_ipn.h:352
size_t handles_test_event(InstantaneousRateConnectionEvent &, size_t) override
Definition rate_neuron_ipn.h:319
void update(Time const &, const long, const long) override
Advance the state of the node in time through the given interval.
Definition rate_neuron_ipn.h:301
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition rate_neuron_ipn_impl.h:235
void handle(InstantaneousRateConnectionEvent &) override
Handler for rate neuron events.
Definition rate_neuron_ipn_impl.h:392
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_ipn.h:237
RingBuffer delayed_rates_ex_
buffer for rate vector received by
Definition rate_neuron_ipn.h:241
std::vector< double > instant_rates_in_
buffer for rate vector received
Definition rate_neuron_ipn.h:247
std::vector< double > instant_rates_ex_
buffer for rate vector received
Definition rate_neuron_ipn.h:245
std::vector< double > random_numbers
remembers the random_numbers in
Definition rate_neuron_ipn.h:250
RingBuffer delayed_rates_in_
buffer for rate vector received by
Definition rate_neuron_ipn.h:243
std::vector< double > last_y_values
remembers y_values from last wfr_update
Definition rate_neuron_ipn.h:249
UniversalDataLogger< rate_neuron_ipn > logger_
Logger for all analog data.
Definition rate_neuron_ipn.h:254
Independent parameters of the model.
Definition rate_neuron_ipn.h:170
double rectify_rate_
Minimum rate.
Definition rate_neuron_ipn.h:184
double lambda_
Passive decay rate in ms.
Definition rate_neuron_ipn.h:175
double tau_
Time constant in ms.
Definition rate_neuron_ipn.h:172
void get(Dictionary &) const
Store current values in dictionary.
Definition rate_neuron_ipn_impl.h:87
double mu_
Mean input.
Definition rate_neuron_ipn.h:181
Parameters_()
Sets default parameter values.
Definition rate_neuron_ipn_impl.h:61
double sigma_
Noise parameter.
Definition rate_neuron_ipn.h:178
bool linear_summation_
Target of non-linearity.
Definition rate_neuron_ipn.h:190
void set(const Dictionary &, Node *node)
Definition rate_neuron_ipn_impl.h:105
bool mult_coupling_
use multiplicative coupling? Default is false
Definition rate_neuron_ipn.h:200
bool rectify_output_
Should the rate be rectified?.
Definition rate_neuron_ipn.h:197
State variables of the model.
Definition rate_neuron_ipn.h:215
State_()
Default initialization.
Definition rate_neuron_ipn_impl.h:75
void set(const Dictionary &, Node *node)
Set values from dictionary.
Definition rate_neuron_ipn_impl.h:162
double noise_
Noise.
Definition rate_neuron_ipn.h:217
double rate_
Rate.
Definition rate_neuron_ipn.h:216
void get(Dictionary &) const
Definition rate_neuron_ipn_impl.h:154
Internal variables of the model.
Definition rate_neuron_ipn.h:263
normal_distribution normal_dist_
normal distribution
Definition rate_neuron_ipn.h:271
double P2_
Definition rate_neuron_ipn.h:266
double P1_
Definition rate_neuron_ipn.h:265
double input_noise_factor_
Definition rate_neuron_ipn.h:269