NEST main@caf0ae8
 
Loading...
Searching...
No Matches
rate_transformer_node.h
Go to the documentation of this file.
1/*
2 * rate_transformer_node.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_TRANSFORMER_NODE_H
24#define RATE_TRANSFORMER_NODE_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 "recordables_map.h"
39#include "ring_buffer.h"
41
42namespace nest
43{
44
45/* BeginUserDocs: neuron, rate
46
47Short description
48+++++++++++++++++
49
50Rate neuron that sums up incoming rates and applies a nonlinearity specified via the template
51
52Description
53+++++++++++
54
55Base class for rate transformer model of the form
56
57.. math::
58
59 X_i(t) = \phi( \sum w_{ij} \cdot \psi( X_j(t-d_{ij}) ) )
60
61The rate transformer node simply applies the nonlinearity specified in the
62input-function of the template class to all incoming inputs. The boolean
63parameter ``linear_summation`` determines whether the input function is applied to
64the summed up incoming connections (True, default value, input
65represents phi) or to each input individually (False, input represents psi).
66
67An important application is to provide the possibility to
68apply different nonlinearities to different incoming connections of the
69same rate neuron by connecting the sending rate neurons to the
70rate transformer node and connecting the rate transformer node to the
71receiving rate neuron instead of using a direct connection.
72Please note that for instantaneous rate connections the rate arrives
73one time step later at the receiving rate neurons as with a direct connection.
74
75Weights on connections from and to the ``rate_transformer_node`` are
76handled as usual. Delays are honored on incoming and outgoing
77connections.
78
79Receives
80++++++++
81
82InstantaneousRateConnectionEvent, DelayedRateConnectionEvent
83
84Sends
85+++++
86
87InstantaneousRateConnectionEvent, DelayedRateConnectionEvent
88
89Parameters
90++++++++++
91
92Only the parameter ``linear_summation`` and the parameters from the class ``Nonlinearities`` can be set in the
93status dictionary.
94
95Examples using this model
96+++++++++++++++++++++++++
97
98.. listexamples:: rate_transformer_node
99
100EndUserDocs */
101
102template < class TNonlinearities >
104{
105
106public:
107 typedef Node base;
108
111
121 using Node::handle;
124
126 void handle( DelayedRateConnectionEvent& ) override;
127 void handle( DataLoggingRequest& ) override;
128
129 size_t handles_test_event( InstantaneousRateConnectionEvent&, size_t ) override;
130 size_t handles_test_event( DelayedRateConnectionEvent&, size_t ) override;
131 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
132
133 void
137 void
141
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
152 bool update_( Time const&, const long, const long, const bool );
153
154 void update( Time const&, const long, const long ) override;
155 bool wfr_update( Time const&, const long, const long ) override;
156
157 // The next two classes need to be friends to access the State_ class/member
158 friend class RecordablesMap< rate_transformer_node< TNonlinearities > >;
159 friend class UniversalDataLogger< rate_transformer_node< TNonlinearities > >;
160
161 // ----------------------------------------------------------------
162
167 {
173
174 Parameters_();
175
176 void get( Dictionary& ) const;
177
178 void set( const Dictionary&, Node* node );
179 };
180
181 // ----------------------------------------------------------------
182
186 struct State_
187 {
188 double rate_;
189
190 State_();
191
192 void get( Dictionary& ) const;
193
199 void set( const Dictionary&, Node* node );
200 };
201
202 // ----------------------------------------------------------------
203
207 struct Buffers_
208 {
211
212 // buffer for rate vector received by DelayRateConnection
214
215 // buffer for rate vector received by RateConnection
216 std::vector< double > instant_rates_;
217
218 // remembers y_values from last wfr_update
219 std::vector< double > last_y_values;
220
222 UniversalDataLogger< rate_transformer_node > logger_;
223 };
224
225 // ----------------------------------------------------------------
226
227
229 double
230 get_rate_() const
231 {
232 return S_.rate_;
233 }
234
235 // ----------------------------------------------------------------
236
240
243};
244
245template < class TNonlinearities >
246inline void
247rate_transformer_node< TNonlinearities >::update( Time const& origin, const long from, const long to )
248{
249 update_( origin, from, to, false );
250}
251
252template < class TNonlinearities >
253inline bool
254rate_transformer_node< TNonlinearities >::wfr_update( Time const& origin, const long from, const long to )
255{
256 State_ old_state = S_; // save state before wfr update
257 const bool wfr_tol_exceeded = update_( origin, from, to, true );
258 S_ = old_state; // restore old state
259
260 return not wfr_tol_exceeded;
261}
262
263template < class TNonlinearities >
264inline size_t
266{
267 if ( receptor_type != 0 )
268 {
269 throw UnknownReceptorType( receptor_type, get_name() );
270 }
271 return 0;
272}
273
274template < class TNonlinearities >
275inline size_t
277{
278 if ( receptor_type != 0 )
279 {
280 throw UnknownReceptorType( receptor_type, get_name() );
281 }
282 return 0;
283}
284
285template < class TNonlinearities >
286inline size_t
288{
289 if ( receptor_type != 0 )
290 {
291 throw UnknownReceptorType( receptor_type, get_name() );
292 }
293 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
294}
295
296template < class TNonlinearities >
297inline void
299{
300 P_.get( d );
301 S_.get( d );
303 d[ names::recordables ] = recordablesMap_.get_list();
304
305 nonlinearities_.get( d );
306}
307
308template < class TNonlinearities >
309inline void
311{
312 Parameters_ ptmp = P_; // temporary copy in case of errors
313 ptmp.set( d, this ); // throws if BadProperty
314 State_ stmp = S_; // temporary copy in case of errors
315 stmp.set( d, this ); // throws if BadProperty
316
317 // We now know that (stmp) is consistent. We do not
318 // write it back to (S_) before we are also sure that
319 // the properties to be set in the parent class are internally
320 // consistent.
322
323 // if we get here, temporaries contain consistent set of properties
324 P_ = ptmp;
325 S_ = stmp;
326
327 nonlinearities_.set( d, this );
328}
329
330} // namespace
331
332#endif /* #ifndef RATE_TRANSFORMER_NODE_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_transformer_node.h:104
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition rate_transformer_node.h:298
rate_transformer_node()
Definition rate_transformer_node_impl.h:123
TNonlinearities nonlinearities_
Definition rate_transformer_node.h:150
State_ S_
Definition rate_transformer_node.h:238
void update(Time const &, const long, const long) override
Advance the state of the node in time through the given interval.
Definition rate_transformer_node.h:247
void init_buffers_() override
Configure persistent internal data structures.
Definition rate_transformer_node_impl.h:148
size_t handles_test_event(InstantaneousRateConnectionEvent &, size_t) override
Definition rate_transformer_node.h:265
bool update_(Time const &, const long, const long, const bool)
Definition rate_transformer_node_impl.h:174
static RecordablesMap< rate_transformer_node< TNonlinearities > > recordablesMap_
Mapping of recordables names to access functions.
Definition rate_transformer_node.h:242
Buffers_ B_
Definition rate_transformer_node.h:239
void sends_secondary_event(InstantaneousRateConnectionEvent &) override
Required to check, if source neuron may send a SecondaryEvent.
Definition rate_transformer_node.h:134
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition rate_transformer_node.h:310
Parameters_ P_
Definition rate_transformer_node.h:237
Node base
Definition rate_transformer_node.h:107
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition rate_transformer_node_impl.h:163
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_transformer_node.h:254
double get_rate_() const
Read out the rate.
Definition rate_transformer_node.h:230
void sends_secondary_event(DelayedRateConnectionEvent &) override
Required to check, if source neuron may send a SecondaryEvent.
Definition rate_transformer_node.h:138
void handle(InstantaneousRateConnectionEvent &) override
Handler for rate neuron events.
Definition rate_transformer_node_impl.h:260
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_transformer_node.h:208
std::vector< double > instant_rates_
Definition rate_transformer_node.h:216
std::vector< double > last_y_values
Definition rate_transformer_node.h:219
RingBuffer delayed_rates_
Definition rate_transformer_node.h:213
UniversalDataLogger< rate_transformer_node > logger_
Logger for all analog data.
Definition rate_transformer_node.h:222
Independent parameters of the model.
Definition rate_transformer_node.h:167
bool linear_summation_
Target of non-linearity.
Definition rate_transformer_node.h:172
Parameters_()
Sets default parameter values.
Definition rate_transformer_node_impl.h:62
void get(Dictionary &) const
Store current values in dictionary.
Definition rate_transformer_node_impl.h:79
void set(const Dictionary &, Node *node)
Definition rate_transformer_node_impl.h:86
State variables of the model.
Definition rate_transformer_node.h:187
void get(Dictionary &) const
Definition rate_transformer_node_impl.h:93
double rate_
Rate.
Definition rate_transformer_node.h:188
State_()
Default initialization.
Definition rate_transformer_node_impl.h:68
void set(const Dictionary &, Node *node)
Set values from dictionary.
Definition rate_transformer_node_impl.h:100