NEST main@caf0ae8
 
Loading...
Searching...
No Matches
vogels_sprekeler_synapse.h
Go to the documentation of this file.
1/*
2 * vogels_sprekeler_synapse.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 VOGELS_SPREKELER_SYNAPSE_H
24#define VOGELS_SPREKELER_SYNAPSE_H
25
26// C-header for math.h since copysign() is in C99 but not C++98
27#include "connection.h"
28#include <math.h>
29
30namespace nest
31{
32
33/* BeginUserDocs: synapse, chemical, functional, stdp, Vogels
34
35Short description
36+++++++++++++++++
37
38Synapse type for symmetric spike-timing dependent plasticity with constant depression
39
40Description
41+++++++++++
42
43``vogels_sprekeler_synapse`` is a connector to create synapses with symmetric
44spike time dependent plasticity and constant depression (as defined in :footcite:p:`Vogels2011`).
45The learning rule is symmetric, that is, the synapse is strengthened
46irrespective of the order of the pre- and postsynaptic spikes. Each
47pre-synaptic spike also causes a constant depression of the synaptic weight
48which differentiates this rule from other classical STDP rules.
49
50.. warning::
51
52 This synaptic plasticity rule does not take
53 :ref:`precise spike timing <sim_precise_spike_times>` into
54 account. When calculating the weight update, the precise spike time part
55 of the timestamp is ignored.
56
57Parameters
58++++++++++
59
60====== ====== =========================================================
61 tau ms Time constant of STDP window, potentiation
62 Wmax real Maximum allowed weight
63 eta real Learning rate
64 alpha real Constant depression (= 2 * tau * target firing rate in
65 :footcite:p:`Vogels2011`)
66====== ====== =========================================================
67
68Transmits
69+++++++++
70
71SpikeEvent
72
73References
74++++++++++
75
76.. footbibliography::
77
78Examples using this model
79+++++++++++++++++++++++++
80
81.. listexamples:: vogels_sprekeler_synapse
82
83EndUserDocs */
84
85// connections are templates of target identifier type (used for pointer /
86// target index addressing)
87// derived from generic connection template
88
89void register_vogels_sprekeler_synapse( const std::string& name );
90
91template < typename targetidentifierT >
92class vogels_sprekeler_synapse : public Connection< targetidentifierT >
93{
94
95public:
98
102
108
109
116
117 // Explicitly declare all methods inherited from the dependent base
118 // ConnectionBase.
119 // This avoids explicit name prefixes in all places these functions are used.
120 // Since ConnectionBase depends on the template parameter, they are not
121 // automatically
122 // found in the base class.
127
131 void get_status( Dictionary& d ) const;
132
136 void set_status( const Dictionary& d, ConnectorModel& cm );
137
144 bool send( Event& e, size_t t, const CommonSynapseProperties& cp );
145
146
148 {
149 public:
150 // Ensure proper overriding of overloaded virtual functions.
151 // Return values from functions are ignored.
153 size_t
154 handles_test_event( SpikeEvent&, size_t ) override
155 {
156 return invalid_port;
157 }
158 };
159
160 void
161 check_connection( Node& s, Node& t, size_t receptor_type, const CommonPropertiesType& )
162 {
163 ConnTestDummyNode dummy_target;
164
165 ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
166
168 }
169
170 void
171 set_weight( double w )
172 {
173 weight_ = w;
174 }
175
176private:
177 double
178 facilitate_( double w, double kplus )
179 {
180 double new_w = std::abs( w ) + ( eta_ * kplus );
181 return copysign( new_w < std::abs( Wmax_ ) ? new_w : Wmax_, Wmax_ );
182 }
183
184 double
185 depress_( double w )
186 {
187 double new_w = std::abs( w ) - ( alpha_ * eta_ );
188 return copysign( new_w > 0.0 ? new_w : 0.0, Wmax_ );
189 }
190
191 // data members of each connection
192 double weight_;
193 double tau_;
194 double alpha_;
195 double eta_;
196 double Wmax_;
197 double Kplus_;
198
200};
201
202template < typename targetidentifierT >
204
212template < typename targetidentifierT >
213inline bool
215{
216 // synapse STDP depressing/facilitation dynamics
217 double t_spike = e.get_stamp().get_ms();
218 // t_lastspike_ = 0 initially
219
220 // use accessor functions (inherited from Connection< >) to obtain delay and
221 // target
222 Node* target = get_target( t );
223 double dendritic_delay = get_delay();
224
225 // get spike history in relevant range (t1, t2] from postsynaptic neuron
226 std::deque< histentry >::iterator start;
227 std::deque< histentry >::iterator finish;
228 target->get_history( t_lastspike_ - dendritic_delay, t_spike - dendritic_delay, &start, &finish );
229
230 // presynaptic neuron j, postsynaptic neuron i
231 // Facilitation for each postsynaptic spike
232 // Wij = Wij + eta*xj
233 double minus_dt;
234 while ( start != finish )
235 {
236 minus_dt = t_lastspike_ - ( start->t_ + dendritic_delay );
237 ++start;
238 // get_history() should make sure that
239 // start->t_ > t_lastspike - dendritic_delay, i.e. minus_dt < 0
240 assert( minus_dt < -1.0 * kernel().connection_manager.get_stdp_eps() );
241 weight_ = facilitate_( weight_, Kplus_ * std::exp( minus_dt / tau_ ) );
242 }
243
244 // For pre-synaptic spikes
245 // Wij = Wij + eta(xi - alpha)
246 // Facilitation and constant depression
247 // Getting kvalue at required time already for deferred processing, so no
248 // need to transform it to the current time, and so, no exponential required
249 weight_ = facilitate_( weight_, target->get_K_value( t_spike - dendritic_delay ) );
250 weight_ = depress_( weight_ );
251
252 e.set_receiver( *target );
253 e.set_weight( weight_ );
254 // use accessor functions (inherited from Connection< >) to obtain delay in
255 // steps and rport
256 e.set_delay_steps( get_delay_steps() );
257 e.set_rport( get_rport() );
258 e();
259
260 // exponential part for the decay, addition of one for each spike
261 Kplus_ = Kplus_ * std::exp( ( t_lastspike_ - t_spike ) / tau_ ) + 1.0;
262
263 t_lastspike_ = t_spike;
264
265 return true;
266}
267
268
269template < typename targetidentifierT >
272 , weight_( 0.5 )
273 , tau_( 20.0 )
274 , alpha_( 0.12 )
275 , eta_( 0.001 )
276 , Wmax_( 1.0 )
277 , Kplus_( 0.0 )
278 , t_lastspike_( 0.0 )
279{
280}
281
282template < typename targetidentifierT >
283void
285{
286 ConnectionBase::get_status( d );
287 d[ names::weight ] = weight_;
288 d[ names::tau ] = tau_;
289 d[ names::alpha ] = alpha_;
290 d[ names::eta ] = eta_;
291 d[ names::Wmax ] = Wmax_;
292 d[ names::Kplus ] = Kplus_;
293 d[ names::size_of ] = static_cast< long >( sizeof( *this ) );
294}
295
296template < typename targetidentifierT >
297void
299{
300 ConnectionBase::set_status( d, cm );
301 d.update_value( names::weight, weight_ );
302 d.update_value( names::tau, tau_ );
303 d.update_value( names::alpha, alpha_ );
304 d.update_value( names::eta, eta_ );
305 d.update_value( names::Wmax, Wmax_ );
306 d.update_value( names::Kplus, Kplus_ );
307
308 // if the weight_ is not 0, we check to ensure that weight_ and Wmax_ are of
309 // the same sign
310 if ( weight_ != 0 and ( std::signbit( weight_ ) != std::signbit( Wmax_ ) ) )
311 {
312 throw BadProperty( "Weight and Wmax must have same sign." );
313 }
314
315 if ( not( Kplus_ >= 0 ) )
316 {
317 throw BadProperty( "State Kplus must be positive." );
318 }
319}
320} // of namespace nest
321
322#endif // of #ifndef VOGELS_SPREKELER_SYNAPSE_H
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Exception to be thrown if a status parameter is incomplete or inconsistent.
Definition exceptions.h:680
Class containing the common properties for all connections of a certain type.
Definition common_synapse_properties.h:50
Base class for dummy nodes used in connection testing.
Definition connection.h:67
Base class for representing connections.
Definition connection.h:110
void check_connection_(Node &dummy_target, Node &source, Node &target, const size_t receptor_type)
This function calls check_connection() on the sender to check if the receiver accepts the event type ...
Definition connection.h:319
long get_delay_steps() const
Return the delay of the connection in steps.
Definition connection.h:181
Node * get_target(const size_t tid) const
Definition connection.h:239
size_t get_rport() const
Definition connection.h:244
double get_delay() const
Return the delay of the connection in ms.
Definition connection.h:172
Definition connector_model.h:69
Encapsulate information sent between nodes.
Definition event.h:103
Base class for all NEST network objects.
Definition node.h:99
virtual void register_stdp_connection(double, double)
Register a STDP connection.
Definition node.cpp:211
Event for spike information.
Definition event.h:418
Definition vogels_sprekeler_synapse.h:148
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition vogels_sprekeler_synapse.h:154
Definition vogels_sprekeler_synapse.h:93
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition vogels_sprekeler_synapse.h:284
vogels_sprekeler_synapse & operator=(const vogels_sprekeler_synapse &)=default
void set_weight(double w)
Definition vogels_sprekeler_synapse.h:171
static constexpr ConnectionModelProperties properties
Definition vogels_sprekeler_synapse.h:99
double depress_(double w)
Definition vogels_sprekeler_synapse.h:185
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition vogels_sprekeler_synapse.h:298
CommonSynapseProperties CommonPropertiesType
Definition vogels_sprekeler_synapse.h:96
vogels_sprekeler_synapse()
Default Constructor.
Definition vogels_sprekeler_synapse.h:270
double t_lastspike_
Definition vogels_sprekeler_synapse.h:199
void check_connection(Node &s, Node &t, size_t receptor_type, const CommonPropertiesType &)
Definition vogels_sprekeler_synapse.h:161
double get_delay() const
Return the delay of the connection in ms.
Definition connection.h:172
double Wmax_
Definition vogels_sprekeler_synapse.h:196
vogels_sprekeler_synapse(const vogels_sprekeler_synapse &)=default
Copy constructor.
double alpha_
Definition vogels_sprekeler_synapse.h:194
double weight_
Definition vogels_sprekeler_synapse.h:192
double eta_
Definition vogels_sprekeler_synapse.h:195
double tau_
Definition vogels_sprekeler_synapse.h:193
Connection< targetidentifierT > ConnectionBase
Definition vogels_sprekeler_synapse.h:97
double facilitate_(double w, double kplus)
Definition vogels_sprekeler_synapse.h:178
bool send(Event &e, size_t t, const CommonSynapseProperties &cp)
Send an event to the receiver of this connection.
Definition vogels_sprekeler_synapse.h:214
double Kplus_
Definition vogels_sprekeler_synapse.h:197
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
const std::string tau("tau")
const std::string eta("eta")
const std::string alpha("alpha")
const std::string Kplus("Kplus")
const std::string weight("weight")
const std::string size_of("sizeof")
const std::string Wmax("Wmax")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_vogels_sprekeler_synapse(const std::string &name)
Definition vogels_sprekeler_synapse.cpp:32
KernelManager & kernel()
Definition kernel_manager.h:311
ConnectionModelProperties
Definition connector_model.h:49
constexpr size_t invalid_port
Value for invalid connection port number.
Definition nest_types.h:141