NEST main@caf0ae8
 
Loading...
Searching...
No Matches
stdp_triplet_synapse.h
Go to the documentation of this file.
1/*
2 * stdp_triplet_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 STDP_TRIPLET_SYNAPSE_H
24#define STDP_TRIPLET_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
34
35Short description
36+++++++++++++++++
37
38Synapse type with spike-timing dependent plasticity (triplets)
39
40Description
41+++++++++++
42
43``stdp_triplet_synapse`` is a connection with spike time dependent
44plasticity accounting for spike triplet effects (as defined in :footcite:p:`Pfister2006`).
45
46Notes:
47
48- Presynaptic traces ``r_1`` and ``r_2`` of :footcite:p:`Pfister2006` are stored in the connection as
49 ``Kplus`` and ``Kplus_triplet`` and decay with time-constants ``tau_plus`` and
50 ``tau_plus_triplet``, respectively.
51- Postsynaptic traces ``o_1`` and ``o_2`` of :footcite:p:`Pfister2006` are acquired from the postsynaptic
52 neuron states ``Kminus_`` and ``triplet_Kminus_`` which decay on time-constants
53 ``tau_minus`` and ``tau_minus_triplet``, respectively. These two time-constants
54 can be set as properties of the postsynaptic neuron.
55- This version implements the 'all-to-all' spike interaction of :footcite:p:`Pfister2006`. The
56 'nearest-spike' interaction of :footcite:p:`Pfister2006` can currently not be implemented
57 without changing the postsynaptic archiving-node (clip the traces to a
58 maximum of 1).
59
60.. warning::
61
62 This synaptic plasticity rule does not take
63 :ref:`precise spike timing <sim_precise_spike_times>` into
64 account. When calculating the weight update, the precise spike time part
65 of the timestamp is ignored.
66
67Parameters
68++++++++++
69
70================= ====== ===========================================
71 tau_plus real Time constant of short presynaptic trace
72 (tau_plus of :footcite:p:`Pfister2006`)
73 tau_plus_triplet real Time constant of long presynaptic trace
74 (tau_x of :footcite:p:`Pfister2006`)
75 Aplus real Weight of pair potentiation rule
76 (A_plus_2 of :footcite:p:`Pfister2006`)
77 Aplus_triplet real Weight of triplet potentiation rule
78 (A_plus_3 of :footcite:p:`Pfister2006`)
79 Aminus real Weight of pair depression rule
80 (A_minus_2 of :footcite:p:`Pfister2006`)
81 Aminus_triplet real Weight of triplet depression rule
82 (A_minus_3 of :footcite:p:`Pfister2006`)
83 Wmax real Maximum allowed weight
84================= ====== ===========================================
85
86=============== ====== ===========================================
87**States**
88-------------------------------------------------------------------
89 Kplus real Pre-synaptic trace (r_1 of :footcite:p:`Pfister2006`)
90 Kplus_triplet real Triplet pre-synaptic trace (r_2 of :footcite:p:`Pfister2006`)
91=============== ====== ===========================================
92
93Transmits
94+++++++++
95
96SpikeEvent
97
98References
99++++++++++
100
101.. footbibliography::
102
103See also
104++++++++
105
106stdp_triplet_synapse_hpc, stdp_synapse, static_synapse
107
108Examples using this model
109+++++++++++++++++++++++++
110
111.. listexamples:: stdp_triplet_synapse
112
113
114EndUserDocs */
115
116// connections are templates of target identifier type
117// (used for pointer / target index addressing)
118// derived from generic connection template
119
120void register_stdp_triplet_synapse( const std::string& name );
121
122template < typename targetidentifierT >
123class stdp_triplet_synapse : public Connection< targetidentifierT >
124{
125
126public:
129
133
139
146
153
154 // Explicitly declare all methods inherited from the dependent base
155 // ConnectionBase. This avoids explicit name prefixes in all places
156 // these functions are used. Since ConnectionBase depends on the template
157 // parameter, they are not automatically found in the base class.
162
166 void get_status( Dictionary& d ) const;
167
171 void set_status( const Dictionary& d, ConnectorModel& cm );
172
178 bool send( Event& e, size_t t, const CommonSynapseProperties& cp );
179
181 {
182 public:
183 // Ensure proper overriding of overloaded virtual functions.
184 // Return values from functions are ignored.
186 size_t
187 handles_test_event( SpikeEvent&, size_t ) override
188 {
189 return invalid_port;
190 }
191 };
192
193 /*
194 * This function calls check_connection on the sender and checks if the
195 * receiver accepts the event type and receptor type requested by the sender.
196 * Node::check_connection() will either confirm the receiver port by returning
197 * true or false if the connection should be ignored.
198 * We have to override the base class' implementation, since for STDP
199 * connections we have to call register_stdp_connection on the target neuron
200 * to inform the Archiver to collect spikes for this connection.
201 *
202 * \param s The source node
203 * \param r The target node
204 * \param receptor_type The ID of the requested receptor type
205 */
206 void
207 check_connection( Node& s, Node& t, size_t receptor_type, const CommonPropertiesType& )
208 {
209 ConnTestDummyNode dummy_target;
210
211 ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
212
214 }
215
216 void
217 set_weight( double w )
218 {
219 weight_ = w;
220 }
221
222private:
223 inline double
224 facilitate_( double w, double kplus, double ky )
225 {
226 double new_w = std::abs( w ) + kplus * ( Aplus_ + Aplus_triplet_ * ky );
227 return copysign( new_w < std::abs( Wmax_ ) ? new_w : Wmax_, Wmax_ );
228 }
229
230 inline double
231 depress_( double w, double kminus, double Kplus_triplet_ )
232 {
233 double new_w = std::abs( w ) - kminus * ( Aminus_ + Aminus_triplet_ * Kplus_triplet_ );
234 return copysign( new_w > 0.0 ? new_w : 0.0, Wmax_ );
235 }
236
237 // data members of each connection
238 double weight_;
239 double tau_plus_;
241 double Aplus_;
242 double Aminus_;
245 double Kplus_;
247 double Wmax_;
249};
250
251template < typename targetidentifierT >
253
260template < typename targetidentifierT >
261inline bool
263{
264 double t_spike = e.get_stamp().get_ms();
265 double dendritic_delay = get_delay();
266 Node* target = get_target( t );
267
268 // get spike history in relevant range (t1, t2] from postsynaptic neuron
269 std::deque< histentry >::iterator start;
270 std::deque< histentry >::iterator finish;
271 target->get_history( t_lastspike_ - dendritic_delay, t_spike - dendritic_delay, &start, &finish );
272
273 // facilitation due to postsynaptic spikes since last pre-synaptic spike
274 while ( start != finish )
275 {
276 // postsynaptic spike is delayed by dendritic_delay so that
277 // it is effectively late by that much at the synapse.
278 double minus_dt = t_lastspike_ - ( start->t_ + dendritic_delay );
279
280 // subtract 1.0 yields the Kminus_triplet value just prior to
281 // the postsynaptic spike, implementing the t-epsilon in
282 // Pfister et al, 2006
283 double ky = start->Kminus_triplet_ - 1.0;
284 ++start;
285 // get_history() should make sure that
286 // start->t_ > t_lastspike - dendritic_delay, i.e. minus_dt < 0
287 assert( minus_dt < -1.0 * kernel().connection_manager.get_stdp_eps() );
288 weight_ = facilitate_( weight_, Kplus_ * std::exp( minus_dt / tau_plus_ ), ky );
289 }
290
291 // depression due to new pre-synaptic spike
292 Kplus_triplet_ *= std::exp( ( t_lastspike_ - t_spike ) / tau_plus_triplet_ );
293
294 // dendritic delay means we must look back in time by that amount
295 // for determining the K value, because the K value must propagate
296 // out to the synapse
297 weight_ = depress_( weight_, target->get_K_value( t_spike - dendritic_delay ), Kplus_triplet_ );
298
299 Kplus_triplet_ += 1.0;
300 Kplus_ = Kplus_ * std::exp( ( t_lastspike_ - t_spike ) / tau_plus_ ) + 1.0;
301
302 e.set_receiver( *target );
303 e.set_weight( weight_ );
304 e.set_delay_steps( get_delay_steps() );
305 e.set_rport( get_rport() );
306 e();
307
308 t_lastspike_ = t_spike;
309
310 return true;
311}
312
313// Defaults come from Pfister & Gerstner (2006) data fitting and table 3.
314template < typename targetidentifierT >
317 , weight_( 1.0 )
318 , tau_plus_( 16.8 )
319 , tau_plus_triplet_( 101.0 )
320 , Aplus_( 5e-10 )
321 , Aminus_( 7e-3 )
322 , Aplus_triplet_( 6.2e-3 )
323 , Aminus_triplet_( 2.3e-4 )
324 , Kplus_( 0.0 )
325 , Kplus_triplet_( 0.0 )
326 , Wmax_( 100.0 )
327 , t_lastspike_( 0.0 )
328{
329}
330
331template < typename targetidentifierT >
332void
334{
335 ConnectionBase::get_status( d );
336 d[ names::weight ] = weight_;
337 d[ names::tau_plus ] = tau_plus_;
338 d[ names::tau_plus_triplet ] = tau_plus_triplet_;
339 d[ names::Aplus ] = Aplus_;
340 d[ names::Aminus ] = Aminus_;
341 d[ names::Aplus_triplet ] = Aplus_triplet_;
342 d[ names::Aminus_triplet ] = Aminus_triplet_;
343 d[ names::Kplus ] = Kplus_;
344 d[ names::Kplus_triplet ] = Kplus_triplet_;
345 d[ names::Wmax ] = Wmax_;
346}
347
348template < typename targetidentifierT >
349void
351{
352 ConnectionBase::set_status( d, cm );
353 d.update_value( names::weight, weight_ );
354 d.update_value( names::tau_plus, tau_plus_ );
355 d.update_value( names::tau_plus_triplet, tau_plus_triplet_ );
356 d.update_value( names::Aplus, Aplus_ );
357 d.update_value( names::Aminus, Aminus_ );
358 d.update_value( names::Aplus_triplet, Aplus_triplet_ );
359 d.update_value( names::Aminus_triplet, Aminus_triplet_ );
360 d.update_value( names::Kplus, Kplus_ );
361 d.update_value( names::Kplus_triplet, Kplus_triplet_ );
362 d.update_value( names::Wmax, Wmax_ );
363
364 // check if weight_ and Wmax_ has the same sign
365 if ( not( ( ( weight_ >= 0 ) - ( weight_ < 0 ) ) == ( ( Wmax_ >= 0 ) - ( Wmax_ < 0 ) ) ) )
366 {
367 throw BadProperty( "Weight and Wmax must have same sign." );
368 }
369
370 if ( not( Kplus_ >= 0 ) )
371 {
372 throw BadProperty( "State Kplus must be positive." );
373 }
374
375 if ( Kplus_triplet_ < 0 )
376 {
377 throw BadProperty( "State Kplus_triplet must be positive." );
378 }
379}
380
381} // of namespace nest
382
383#endif // of #ifndef STDP_TRIPLET_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 stdp_triplet_synapse.h:181
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition stdp_triplet_synapse.h:187
Definition stdp_triplet_synapse.h:124
double tau_plus_
Definition stdp_triplet_synapse.h:239
void set_weight(double w)
Definition stdp_triplet_synapse.h:217
double tau_plus_triplet_
Definition stdp_triplet_synapse.h:240
double Wmax_
Definition stdp_triplet_synapse.h:247
Connection< targetidentifierT > ConnectionBase
Definition stdp_triplet_synapse.h:128
void check_connection(Node &s, Node &t, size_t receptor_type, const CommonPropertiesType &)
Definition stdp_triplet_synapse.h:207
bool send(Event &e, size_t t, const CommonSynapseProperties &cp)
Send an event to the receiver of this connection.
Definition stdp_triplet_synapse.h:262
double Aplus_triplet_
Definition stdp_triplet_synapse.h:243
double weight_
Definition stdp_triplet_synapse.h:238
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition stdp_triplet_synapse.h:350
double Kplus_triplet_
Definition stdp_triplet_synapse.h:246
double get_delay() const
Return the delay of the connection in ms.
Definition connection.h:172
double Kplus_
Definition stdp_triplet_synapse.h:245
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition stdp_triplet_synapse.h:333
double t_lastspike_
Definition stdp_triplet_synapse.h:248
double facilitate_(double w, double kplus, double ky)
Definition stdp_triplet_synapse.h:224
double depress_(double w, double kminus, double Kplus_triplet_)
Definition stdp_triplet_synapse.h:231
static constexpr ConnectionModelProperties properties
Definition stdp_triplet_synapse.h:130
stdp_triplet_synapse & operator=(const stdp_triplet_synapse &)=default
double Aminus_
Definition stdp_triplet_synapse.h:242
~stdp_triplet_synapse()
Default Destructor.
Definition stdp_triplet_synapse.h:150
double Aplus_
Definition stdp_triplet_synapse.h:241
CommonSynapseProperties CommonPropertiesType
Definition stdp_triplet_synapse.h:127
double Aminus_triplet_
Definition stdp_triplet_synapse.h:244
stdp_triplet_synapse()
Default Constructor.
Definition stdp_triplet_synapse.h:315
stdp_triplet_synapse(const stdp_triplet_synapse &)=default
Copy constructor.
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 Aplus_triplet("Aplus_triplet")
const std::string Kplus_triplet("Kplus_triplet")
const std::string Aminus("Aminus")
const std::string Aplus("Aplus")
const std::string Kplus("Kplus")
const std::string tau_plus("tau_plus")
const std::string tau_plus_triplet("tau_plus_triplet")
const std::string weight("weight")
const std::string Wmax("Wmax")
const std::string Aminus_triplet("Aminus_triplet")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
KernelManager & kernel()
Definition kernel_manager.h:311
void register_stdp_triplet_synapse(const std::string &name)
Definition stdp_triplet_synapse.cpp:32
ConnectionModelProperties
Definition connector_model.h:49
constexpr size_t invalid_port
Value for invalid connection port number.
Definition nest_types.h:141