NEST main@caf0ae8
 
Loading...
Searching...
No Matches
stdp_synapse_hom.h
Go to the documentation of this file.
1/*
2 * stdp_synapse_hom.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 STDP_SYNAPSE_HOM_H
24#define STDP_SYNAPSE_HOM_H
25
26// C++ includes:
27#include <cmath>
28
29// Includes from nestkernel:
30#include "connection.h"
31
32namespace nest
33{
34
35/* BeginUserDocs: synapse, chemical, functional, stdp
36
37Short description
38+++++++++++++++++
39
40Synapse type for spike-timing dependent plasticity using homogeneous parameters
41
42Description
43+++++++++++
44
45``stdp_synapse_hom`` is a connector to create synapses with spike time
46dependent plasticity (as defined in :footcite:p:`Guetig2003`). Here the weight dependence
47exponent can be set separately for potentiation and depression.
48
49 Parameters controlling plasticity are identical for all synapses of the
50 model, reducing the memory required per synapse considerably.
51
52Examples:
53
54* multiplicative STDP :footcite:p:`Rubin2001` mu_plus = mu_minus = 1.0
55* additive STDP :footcite:p:`Song2000` mu_plus = mu_minus = 0.0
56* Guetig STDP :footcite:p:`Guetig2003` mu_plus = mu_minus = [0.0,1.0]
57* van Rossum STDP :footcite:p:`vanRossum2000` mu_plus = 0.0 mu_minus = 1.0
58
59.. warning::
60
61 This synaptic plasticity rule does not take
62 :ref:`precise spike timing <sim_precise_spike_times>` into
63 account. When calculating the weight update, the precise spike time part
64 of the timestamp is ignored.
65
66Parameters
67++++++++++
68
69========= ======= ======================================================
70 tau_plus ms Time constant of STDP window, potentiation
71 (tau_minus defined in postsynaptic neuron)
72 lambda real Step size
73 alpha real Asymmetry parameter (scales depressing increments as
74 alpha*lambda)
75 mu_plus real Weight dependence exponent, potentiation
76 mu_minus real Weight dependence exponent, depression
77 Wmax real Maximum allowed weight
78========= ======= ======================================================
79
80The parameters are common to all synapses of the model and must be set using
81SetDefaults on the synapse model.
82
83Transmits
84+++++++++
85
86SpikeEvent
87
88References
89++++++++++
90
91.. footbibliography::
92
93See also
94++++++++
95
96tsodyks_synapse, static_synapse
97
98Examples using this model
99+++++++++++++++++++++++++
100
101.. listexamples:: stdp_synapse_hom
102
103EndUserDocs */
104
111{
112
113public:
119
123 void get_status( Dictionary& d ) const;
124
128 void set_status( const Dictionary& d, ConnectorModel& cm );
129
130 // data members common to all connections
131 double tau_plus_;
132 double lambda_;
133 double alpha_;
134 double mu_plus_;
135 double mu_minus_;
136 double Wmax_;
137};
138
139
144void register_stdp_synapse_hom( const std::string& name );
145
146template < typename targetidentifierT >
147class stdp_synapse_hom : public Connection< targetidentifierT >
148{
149
150public:
153
157
163
170
171
172 // Explicitly declare all methods inherited from the dependent base
173 // ConnectionBase. This avoids explicit name prefixes in all places these
174 // functions are used. Since ConnectionBase depends on the template parameter,
175 // they are not automatically found in the base class.
180
184 void get_status( Dictionary& d ) const;
185
189 void set_status( const Dictionary& d, ConnectorModel& cm );
190
195 bool send( Event& e, size_t t, const STDPHomCommonProperties& );
196
197 void
198 set_weight( double w )
199 {
200 weight_ = w;
201 }
202
203
205 {
206 public:
207 // Ensure proper overriding of overloaded virtual functions.
208 // Return values from functions are ignored.
210 size_t
211 handles_test_event( SpikeEvent&, size_t ) override
212 {
213 return invalid_port;
214 }
215 };
216
217 /*
218 * This function calls check_connection on the sender and checks if the
219 * receiver accepts the event type and receptor type requested by the sender.
220 * Node::check_connection() will either confirm the receiver port by returning
221 * true or false if the connection should be ignored.
222 * We have to override the base class' implementation, since for STDP
223 * connections we have to call register_stdp_connection on the target neuron
224 * to inform the Archiver to collect spikes for this connection.
225 *
226 * \param s The source node
227 * \param r The target node
228 * \param receptor_type The ID of the requested receptor type
229 */
230 void
231 check_connection( Node& s, Node& t, size_t receptor_type, const CommonPropertiesType& )
232 {
233 ConnTestDummyNode dummy_target;
234 ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
235
237 }
238
239private:
240 double
241 facilitate_( double w, double kplus, const STDPHomCommonProperties& cp )
242 {
243 double norm_w = ( w / cp.Wmax_ ) + ( cp.lambda_ * std::pow( 1.0 - ( w / cp.Wmax_ ), cp.mu_plus_ ) * kplus );
244 return norm_w < 1.0 ? norm_w * cp.Wmax_ : cp.Wmax_;
245 }
246
247 double
248 depress_( double w, double kminus, const STDPHomCommonProperties& cp )
249 {
250 double norm_w = ( w / cp.Wmax_ ) - ( cp.alpha_ * cp.lambda_ * std::pow( w / cp.Wmax_, cp.mu_minus_ ) * kminus );
251 return norm_w > 0.0 ? norm_w * cp.Wmax_ : 0.0;
252 }
253
254 // data members of each connection
255 double weight_;
256 double Kplus_;
258};
259
260template < typename targetidentifierT >
262
263//
264// Implementation of class stdp_synapse_hom.
265//
266
267template < typename targetidentifierT >
270 , weight_( 1.0 )
271 , Kplus_( 0.0 )
272 , t_lastspike_( 0.0 )
273{
274}
275
281template < typename targetidentifierT >
282inline bool
284{
285 // synapse STDP depressing/facilitation dynamics
286
287 const double t_spike = e.get_stamp().get_ms();
288
289 // t_lastspike_ = 0 initially
290
291 Node* target = get_target( t );
292 double dendritic_delay = get_delay();
293
294 // get spike history in relevant range (t1, t2] from postsynaptic neuron
295 std::deque< histentry >::iterator start;
296 std::deque< histentry >::iterator finish;
297 target->get_history( t_lastspike_ - dendritic_delay, t_spike - dendritic_delay, &start, &finish );
298 // facilitation due to postsynaptic spikes since last pre-synaptic spike
299 double minus_dt;
300 while ( start != finish )
301 {
302 minus_dt = t_lastspike_ - ( start->t_ + dendritic_delay );
303 ++start;
304 // get_history() should make sure that
305 // start->t_ > t_lastspike - dendritic_delay, i.e. minus_dt < 0
306 assert( minus_dt < -1.0 * kernel().connection_manager.get_stdp_eps() );
307 weight_ = facilitate_( weight_, Kplus_ * std::exp( minus_dt / cp.tau_plus_ ), cp );
308 }
309
310 // depression due to new pre-synaptic spike
311 weight_ = depress_( weight_, target->get_K_value( t_spike - dendritic_delay ), cp );
312
313 e.set_receiver( *target );
314 e.set_weight( weight_ );
315 e.set_delay_steps( get_delay_steps() );
316 e.set_rport( get_rport() );
317 e();
318
319 Kplus_ = Kplus_ * std::exp( ( t_lastspike_ - t_spike ) / cp.tau_plus_ ) + 1.0;
320
321 t_lastspike_ = t_spike;
322
323 return true;
324}
325
326template < typename targetidentifierT >
327void
329{
330
331 // base class properties, different for individual synapse
332 ConnectionBase::get_status( d );
333 d[ names::weight ] = weight_;
334
335 // own properties, different for individual synapse
336 d[ names::Kplus ] = Kplus_;
337 d[ names::size_of ] = static_cast< long >( sizeof( *this ) );
338}
339
340template < typename targetidentifierT >
341void
343{
344 // base class properties
345 ConnectionBase::set_status( d, cm );
346 d.update_value( names::weight, weight_ );
347
348 d.update_value( names::Kplus, Kplus_ );
349}
350
351} // of namespace nest
352
353#endif // of #ifndef STDP_SYNAPSE_HOM_H
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
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
Class containing the common properties for all synapses of type stdp_synapse_hom.
Definition stdp_synapse_hom.h:111
double tau_plus_
Definition stdp_synapse_hom.h:131
double alpha_
Definition stdp_synapse_hom.h:133
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties from the values given in dictionary.
Definition stdp_synapse_hom.cpp:65
void get_status(Dictionary &d) const
Get all properties and put them into a dictionary.
Definition stdp_synapse_hom.cpp:52
STDPHomCommonProperties()
Default constructor.
Definition stdp_synapse_hom.cpp:40
double Wmax_
Definition stdp_synapse_hom.h:136
double mu_plus_
Definition stdp_synapse_hom.h:134
double lambda_
Definition stdp_synapse_hom.h:132
double mu_minus_
Definition stdp_synapse_hom.h:135
Event for spike information.
Definition event.h:418
Definition stdp_synapse_hom.h:205
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition stdp_synapse_hom.h:211
Definition stdp_synapse_hom.h:148
stdp_synapse_hom & operator=(const stdp_synapse_hom &)=default
STDPHomCommonProperties CommonPropertiesType
Definition stdp_synapse_hom.h:151
stdp_synapse_hom(const stdp_synapse_hom &)=default
Copy constructor from a property object.
double Kplus_
Definition stdp_synapse_hom.h:256
Connection< targetidentifierT > ConnectionBase
Definition stdp_synapse_hom.h:152
void check_connection(Node &s, Node &t, size_t receptor_type, const CommonPropertiesType &)
Definition stdp_synapse_hom.h:231
double get_delay() const
Return the delay of the connection in ms.
Definition connection.h:172
void set_weight(double w)
Definition stdp_synapse_hom.h:198
double t_lastspike_
Definition stdp_synapse_hom.h:257
double depress_(double w, double kminus, const STDPHomCommonProperties &cp)
Definition stdp_synapse_hom.h:248
static constexpr ConnectionModelProperties properties
Definition stdp_synapse_hom.h:154
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition stdp_synapse_hom.h:328
bool send(Event &e, size_t t, const STDPHomCommonProperties &)
Send an event to the receiver of this connection.
Definition stdp_synapse_hom.h:283
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition stdp_synapse_hom.h:342
stdp_synapse_hom()
Default Constructor.
Definition stdp_synapse_hom.h:268
double facilitate_(double w, double kplus, const STDPHomCommonProperties &cp)
Definition stdp_synapse_hom.h:241
double weight_
Definition stdp_synapse_hom.h:255
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 Kplus("Kplus")
const std::string weight("weight")
const std::string size_of("sizeof")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_stdp_synapse_hom(const std::string &name)
Class representing an STDP connection with homogeneous parameters, i.e.
Definition stdp_synapse_hom.cpp:34
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