NEST main@caf0ae8
 
Loading...
Searching...
No Matches
stdp_pl_synapse_hom.h
Go to the documentation of this file.
1/*
2 * stdp_pl_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_PL_SYNAPSE_HOM_H
24#define STDP_PL_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 with power law
41
42Description
43+++++++++++
44
45``stdp_pl_synapse`` is a connector to create synapses with spike time
46dependent plasticity using homoegeneous parameters (as defined in :footcite:p:`Morrison2007c`).
47
48Parameters
49++++++++++
50
51========= ====== ====================================================
52 tau_plus ms Time constant of STDP window, potentiation
53 (tau_minus defined in postsynaptic neuron)
54 lambda real Learning rate
55 alpha real Asymmetry parameter (scales depressing increments as
56 alpha*lambda)
57 mu real Weight dependence exponent, potentiation
58========= ====== ====================================================
59
60The parameters can only be set by SetDefaults and apply to all synapses of
61the model.
62
63.. warning::
64
65 This synaptic plasticity rule does not take
66 :ref:`precise spike timing <sim_precise_spike_times>` into
67 account. When calculating the weight update, the precise spike time part
68 of the timestamp is ignored.
69
70References
71++++++++++
72
73.. footbibliography::
74
75Transmits
76+++++++++
77
78SpikeEvent
79
80See also
81++++++++
82
83stdp_synapse, tsodyks_synapse, static_synapse
84
85Examples using this model
86+++++++++++++++++++++++++
87
88.. listexamples:: stdp_pl_synapse_hom
89
90EndUserDocs */
91
97{
98
99public:
105
109 void get_status( Dictionary& d ) const;
110
114 void set_status( const Dictionary& d, ConnectorModel& cm );
115
116 // data members common to all connections
117 double tau_plus_;
119 double lambda_;
120 double alpha_;
121 double mu_;
122};
123
124
129void register_stdp_pl_synapse_hom( const std::string& name );
130
131template < typename targetidentifierT >
132class stdp_pl_synapse_hom : public Connection< targetidentifierT >
133{
134
135public:
138
142
148
155
156 // Explicitly declare all methods inherited from the dependent base
157 // ConnectionBase. This avoids explicit name prefixes in all places these
158 // functions are used. Since ConnectionBase depends on the template parameter,
159 // they are not automatically found in the base class.
164
168 void get_status( Dictionary& d ) const;
169
173 void set_status( const Dictionary& d, ConnectorModel& cm );
174
179 bool send( Event& e, size_t t, const STDPPLHomCommonProperties& );
180
182 {
183 public:
184 // Ensure proper overriding of overloaded virtual functions.
185 // Return values from functions are ignored.
187 size_t
188 handles_test_event( SpikeEvent&, size_t ) override
189 {
190 return invalid_port;
191 }
192 };
193
194 /*
195 * This function calls check_connection on the sender and checks if the
196 * receiver accepts the event type and receptor type requested by the sender.
197 * Node::check_connection() will either confirm the receiver port by returning
198 * true or false if the connection should be ignored.
199 * We have to override the base class' implementation, since for STDP
200 * connections we have to call register_stdp_pl_connection on the target
201 * neuron to inform the Archiver to collect spikes for this connection.
202 *
203 * \param s The source node
204 * \param r The target node
205 * \param receptor_type The ID of the requested receptor type
206 */
207 void
208 check_connection( Node& s, Node& t, size_t receptor_type, const CommonPropertiesType& )
209 {
210 ConnTestDummyNode dummy_target;
211
212 ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
213
215 }
216
217 void
218 set_weight( double w )
219 {
220 weight_ = w;
221 }
222
223private:
224 double
225 facilitate_( double w, double kplus, const STDPPLHomCommonProperties& cp )
226 {
227 return w + ( cp.lambda_ * std::pow( w, cp.mu_ ) * kplus );
228 }
229
230 double
231 depress_( double w, double kminus, const STDPPLHomCommonProperties& cp )
232 {
233 double new_w = w - ( cp.lambda_ * cp.alpha_ * w * kminus );
234 return new_w > 0.0 ? new_w : 0.0;
235 }
236
237 // data members of each connection
238 double weight_;
239 double Kplus_;
241};
242
243template < typename targetidentifierT >
245
246//
247// Implementation of class stdp_pl_synapse_hom.
248//
249
255template < typename targetidentifierT >
256inline bool
258{
259 // synapse STDP depressing/facilitation dynamics
260
261 const double t_spike = e.get_stamp().get_ms();
262
263 // t_lastspike_ = 0 initially
264
265 Node* target = get_target( t );
266
267 double dendritic_delay = get_delay();
268
269 // get spike history in relevant range (t1, t2] from postsynaptic neuron
270 std::deque< histentry >::iterator start;
271 std::deque< histentry >::iterator finish;
272 target->get_history( t_lastspike_ - dendritic_delay, t_spike - dendritic_delay, &start, &finish );
273
274 // facilitation due to postsynaptic spikes since last pre-synaptic spike
275 double minus_dt;
276 while ( start != finish )
277 {
278 minus_dt = t_lastspike_ - ( start->t_ + dendritic_delay );
279 start++;
280 // get_history() should make sure that
281 // start->t_ > t_lastspike - dendritic_delay, i.e. minus_dt < 0
282 assert( minus_dt < -1.0 * kernel().connection_manager.get_stdp_eps() );
283 weight_ = facilitate_( weight_, Kplus_ * std::exp( minus_dt * cp.tau_plus_inv_ ), cp );
284 }
285
286 // depression due to new pre-synaptic spike
287 weight_ = depress_( weight_, target->get_K_value( t_spike - dendritic_delay ), cp );
288
289 e.set_receiver( *target );
290 e.set_weight( weight_ );
291 e.set_delay_steps( get_delay_steps() );
292 e.set_rport( get_rport() );
293 e();
294
295 Kplus_ = Kplus_ * std::exp( ( t_lastspike_ - t_spike ) * cp.tau_plus_inv_ ) + 1.0;
296
297 t_lastspike_ = t_spike;
298
299 return true;
300}
301
302template < typename targetidentifierT >
305 , weight_( 1.0 )
306 , Kplus_( 0.0 )
307 , t_lastspike_( 0.0 )
308{
309}
310
311template < typename targetidentifierT >
312void
314{
315
316 // base class properties, different for individual synapse
317 ConnectionBase::get_status( d );
318 d[ names::weight ] = weight_;
319
320 // own properties, different for individual synapse
321 d[ names::Kplus ] = Kplus_;
322 d[ names::size_of ] = static_cast< long >( sizeof( *this ) );
323}
324
325template < typename targetidentifierT >
326void
328{
329 // base class properties
330 ConnectionBase::set_status( d, cm );
331 d.update_value( names::weight, weight_ );
332
333 d.update_value( names::Kplus, Kplus_ );
334}
335
336} // of namespace nest
337
338#endif // of #ifndef STDP_PL_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_pl_synapse_hom.
Definition stdp_pl_synapse_hom.h:97
STDPPLHomCommonProperties()
Default constructor.
Definition stdp_pl_synapse_hom.cpp:45
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties from the values given in dictionary.
Definition stdp_pl_synapse_hom.cpp:67
void get_status(Dictionary &d) const
Get all properties and put them into a dictionary.
Definition stdp_pl_synapse_hom.cpp:56
double alpha_
Definition stdp_pl_synapse_hom.h:120
double tau_plus_
Definition stdp_pl_synapse_hom.h:117
double lambda_
Definition stdp_pl_synapse_hom.h:119
double tau_plus_inv_
1 / tau_plus for efficiency
Definition stdp_pl_synapse_hom.h:118
double mu_
Definition stdp_pl_synapse_hom.h:121
Event for spike information.
Definition event.h:418
Definition stdp_pl_synapse_hom.h:182
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition stdp_pl_synapse_hom.h:188
Definition stdp_pl_synapse_hom.h:133
static constexpr ConnectionModelProperties properties
Definition stdp_pl_synapse_hom.h:139
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition stdp_pl_synapse_hom.h:313
double t_lastspike_
Definition stdp_pl_synapse_hom.h:240
void check_connection(Node &s, Node &t, size_t receptor_type, const CommonPropertiesType &)
Definition stdp_pl_synapse_hom.h:208
double weight_
Definition stdp_pl_synapse_hom.h:238
STDPPLHomCommonProperties CommonPropertiesType
Definition stdp_pl_synapse_hom.h:136
double get_delay() const
Return the delay of the connection in ms.
Definition connection.h:172
double depress_(double w, double kminus, const STDPPLHomCommonProperties &cp)
Definition stdp_pl_synapse_hom.h:231
stdp_pl_synapse_hom(const stdp_pl_synapse_hom &)=default
Copy constructor from a property object.
double Kplus_
Definition stdp_pl_synapse_hom.h:239
stdp_pl_synapse_hom & operator=(const stdp_pl_synapse_hom &)=default
bool send(Event &e, size_t t, const STDPPLHomCommonProperties &)
Send an event to the receiver of this connection.
Definition stdp_pl_synapse_hom.h:257
void set_weight(double w)
Definition stdp_pl_synapse_hom.h:218
double facilitate_(double w, double kplus, const STDPPLHomCommonProperties &cp)
Definition stdp_pl_synapse_hom.h:225
stdp_pl_synapse_hom()
Default Constructor.
Definition stdp_pl_synapse_hom.h:303
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition stdp_pl_synapse_hom.h:327
Connection< targetidentifierT > ConnectionBase
Definition stdp_pl_synapse_hom.h:137
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_pl_synapse_hom(const std::string &name)
Class representing an STDP connection with homogeneous parameters, i.e.
Definition stdp_pl_synapse_hom.cpp:35
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