NEST main@caf0ae8
 
Loading...
Searching...
No Matches
jonke_synapse.h
Go to the documentation of this file.
1/*
2 * jonke_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 JONKE_SYNAPSE_H
24#define JONKE_SYNAPSE_H
25
26// C++ includes:
27#include <cmath>
28
29// Includes from nestkernel:
31#include "connection.h"
32#include "connector_model.h"
33#include "event.h"
34
35
36namespace nest
37{
38
39/* BeginUserDocs: synapse, stdp
40
41Short description
42+++++++++++++++++
43
44Synapse type for spike-timing dependent plasticity with additional additive factors.
45
46Description
47+++++++++++
48
49jonke_synapse is a connector to create synapses with spike time
50dependent plasticity. Unlike ``stdp_synapse``, we use the update equations:
51
52.. math::
53
54 \Delta w &= \lambda \cdot w_{max} \cdot (K_+(w) \cdot F_+(t) - \beta) & \quad if t - t_j^(k) > 0 \\
55 \Delta w &= \lambda \cdot w_{max} \cdot (-alpha \cdot K_-(w) \cdot F_-(t) - \beta) & \quad else
56
57where
58
59.. math::
60
61 K_+(w) &= \exp(\nu_+ w) \\
62 K_-(w) &= \exp(\nu_- w)
63
64and
65
66.. math::
67
68 F_+(t) &= \exp((t - t_j^(k))/\tau_+) \\
69 F_-(t) &= \exp((t - t_j^(k))/\tau_-)
70
71This makes it possible to implement update rules which approximate the
72rule stated in :footcite:p:`Nessler2013`, and for examples, the rules given in :footcite:p:`Legenstein2016` and
73:footcite:p:`Jonke2017`.
74
75.. warning::
76
77 This synaptic plasticity rule does not take
78 :ref:`precise spike timing <sim_precise_spike_times>` into
79 account. When calculating the weight update, the precise spike time part
80 of the timestamp is ignored.
81
82Parameters
83++++++++++
84
85========== ======== ======================================================
86 lambda double Step size
87 Wmax double Maximum allowed weight, note that this scales each
88 weight update
89 alpha double Determine shape of depression term
90 mu_plus double Set weight dependency of facilitating update
91 mu_minus double Set weight dependency of depressing update
92 tau_plus double Time constant of STDP window, potentiation in ms
93 beta double Set negative offset for both updates
94========== ======== ======================================================
95
96(tau_minus is defined in the postsynaptic neuron.)
97
98Transmits
99+++++++++
100
101SpikeEvent
102
103References
104++++++++++
105
106Note that the original citation for Mueller et al. 2020 referred to the preprint v1 on ArXiv:
107`Legenstein, Papadimitriou, Vempala and Maass. 2016. Assembly pointers for variable binding in networks of
108spiking neuron. ArXiv.`
109
110
111.. footbibliography::
112
113See also
114++++++++
115
116synapsedict, stdp_synapse
117
118Examples using this model
119+++++++++++++++++++++++++
120
121.. listexamples:: jonke_synapse
122
123EndUserDocs */
124
125
131{
132public:
138
142 void get_status( Dictionary& d ) const;
143
147 void set_status( const Dictionary& d, ConnectorModel& cm );
148
149 double alpha_;
150 double beta_;
151 double lambda_;
152 double mu_plus_;
153 double mu_minus_;
154 double tau_plus_;
155 double Wmax_;
156};
157
158// connections are templates of target identifier type (used for pointer /
159// target index addressing) derived from generic connection template
160void register_jonke_synapse( const std::string& name );
161
162template < typename targetidentifierT >
163class jonke_synapse : public Connection< targetidentifierT >
164{
165
166public:
169
173
179
184 jonke_synapse( const jonke_synapse& ) = default;
185
187
188 // Explicitly declare all methods inherited from the dependent base
189 // ConnectionBase. This avoids explicit name prefixes in all places these
190 // functions are used. Since ConnectionBase depends on the template parameter,
191 // they are not automatically found in the base class.
196
200 void get_status( Dictionary& d ) const;
201
205 void set_status( const Dictionary& d, ConnectorModel& cm );
206
212 bool send( Event& e, size_t t, const JonkeCommonProperties& cp );
213
214
216 {
217 public:
218 // Ensure proper overriding of overloaded virtual functions.
219 // Return values from functions are ignored.
221 size_t
222 handles_test_event( SpikeEvent&, size_t ) override
223 {
224 return invalid_port;
225 }
226 };
227
228 void
229 check_connection( Node& s, Node& t, size_t receptor_type, const CommonPropertiesType& )
230 {
231 ConnTestDummyNode dummy_target;
232
233 ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
234
236 }
237
238 void
239 set_weight( double w )
240 {
241 weight_ = w;
242 }
243
244private:
245 double
246 facilitate_( double w, double kplus, const JonkeCommonProperties& cp )
247 {
248 if ( cp.lambda_ == 0.0 )
249 {
250 return w;
251 }
252
253 double K_w = std::exp( cp.mu_plus_ * w );
254 double F_t = kplus;
255
256 double dW = cp.lambda_ * ( K_w * F_t - cp.beta_ );
257 double new_w = w + dW;
258
259 return new_w < cp.Wmax_ ? new_w : cp.Wmax_;
260 }
261
262 double
263 depress_( double w, double kminus, const JonkeCommonProperties& cp )
264 {
265 if ( cp.lambda_ == 0.0 )
266 {
267 return w;
268 }
269
270 double K_w = std::exp( cp.mu_minus_ * w );
271 double F_t = kminus;
272
273 double dW = cp.lambda_ * ( -cp.alpha_ * K_w * F_t - cp.beta_ );
274 double new_w = w + dW;
275
276 return new_w > 0.0 ? new_w : 0.0;
277 }
278
279 // data members of each connection
280 double weight_;
281 double Kplus_;
283};
284
285template < typename targetidentifierT >
287
294template < typename targetidentifierT >
295inline bool
297{
298 // synapse STDP depressing/facilitation dynamics
299 const double t_spike = e.get_stamp().get_ms();
300
301 // use accessor functions (inherited from Connection< >) to obtain delay and
302 // target
303 Node* target = get_target( t );
304 double dendritic_delay = get_delay();
305
306 // get spike history in relevant range (t1, t2] from postsynaptic neuron
307 std::deque< histentry >::iterator start;
308 std::deque< histentry >::iterator finish;
309
310 // For a new synapse, t_lastspike_ contains the point in time of the last
311 // spike. So we initially read the
312 // history(t_last_spike - dendritic_delay, ..., T_spike-dendritic_delay]
313 // which increases the access counter for these entries.
314 // At registration, all entries' access counters of
315 // history[0, ..., t_last_spike - dendritic_delay] have been
316 // incremented by ArchivingNode::register_stdp_connection(). See bug #218 for
317 // details.
318 target->get_history( t_lastspike_ - dendritic_delay, t_spike - dendritic_delay, &start, &finish );
319 // facilitation due to postsynaptic spikes since last pre-synaptic spike
320 double minus_dt;
321 while ( start != finish )
322 {
323 minus_dt = t_lastspike_ - ( start->t_ + dendritic_delay );
324 ++start;
325 // get_history() should make sure that
326 // start->t_ > t_lastspike - dendritic_delay, i.e. minus_dt < 0
327 assert( minus_dt < -1.0 * kernel().connection_manager.get_stdp_eps() );
328 weight_ = facilitate_( weight_, Kplus_ * std::exp( minus_dt / cp.tau_plus_ ), cp );
329 }
330
331 const double _K_value = target->get_K_value( t_spike - dendritic_delay );
332 weight_ = depress_( weight_, _K_value, cp );
333
334 e.set_receiver( *target );
335 e.set_weight( weight_ );
336 // use accessor functions (inherited from Connection< >) to obtain delay in
337 // steps and rport
338 e.set_delay_steps( get_delay_steps() );
339 e.set_rport( get_rport() );
340 e();
341
342 Kplus_ = Kplus_ * std::exp( ( t_lastspike_ - t_spike ) / cp.tau_plus_ ) + 1.0;
343
344 t_lastspike_ = t_spike;
345
346 return true;
347}
348
349
350template < typename targetidentifierT >
353 , weight_( 1.0 )
354 , Kplus_( 0.0 )
355 , t_lastspike_( 0.0 )
356{
357}
358
359template < typename targetidentifierT >
360void
362{
363 ConnectionBase::get_status( d );
364 d[ names::weight ] = weight_;
365 d[ names::Kplus ] = Kplus_;
366 d[ names::size_of ] = static_cast< long >( sizeof( *this ) );
367}
368
369template < typename targetidentifierT >
370void
372{
373 ConnectionBase::set_status( d, cm );
374
375 d.update_value( names::weight, weight_ );
376
377 d.update_value( names::Kplus, Kplus_ );
378 if ( Kplus_ < 0 )
379 {
380 throw BadProperty( "Kplus must be non-negative." );
381 }
382}
383
384} // of namespace nest
385
386#endif // of #ifndef JONKE_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
Class containing the common properties for all synapses of type dopamine connection.
Definition jonke_synapse.h:131
void get_status(Dictionary &d) const
Get all properties and put them into a dictionary.
Definition jonke_synapse.cpp:51
double mu_plus_
Definition jonke_synapse.h:152
double lambda_
Definition jonke_synapse.h:151
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties from the values given in dictionary.
Definition jonke_synapse.cpp:65
double tau_plus_
Definition jonke_synapse.h:154
double Wmax_
Definition jonke_synapse.h:155
double alpha_
Definition jonke_synapse.h:149
double beta_
Definition jonke_synapse.h:150
double mu_minus_
Definition jonke_synapse.h:153
JonkeCommonProperties()
Default constructor.
Definition jonke_synapse.cpp:38
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 jonke_synapse.h:216
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition jonke_synapse.h:222
Definition jonke_synapse.h:164
jonke_synapse(const jonke_synapse &)=default
Copy constructor.
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition jonke_synapse.h:361
void set_weight(double w)
Definition jonke_synapse.h:239
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition jonke_synapse.h:371
jonke_synapse & operator=(const jonke_synapse &)=default
double Kplus_
Definition jonke_synapse.h:281
double weight_
Definition jonke_synapse.h:280
void check_connection(Node &s, Node &t, size_t receptor_type, const CommonPropertiesType &)
Definition jonke_synapse.h:229
double get_delay() const
Return the delay of the connection in ms.
Definition connection.h:172
static constexpr ConnectionModelProperties properties
Definition jonke_synapse.h:170
jonke_synapse()
Default Constructor.
Definition jonke_synapse.h:351
JonkeCommonProperties CommonPropertiesType
Definition jonke_synapse.h:167
bool send(Event &e, size_t t, const JonkeCommonProperties &cp)
Send an event to the receiver of this connection.
Definition jonke_synapse.h:296
double t_lastspike_
Definition jonke_synapse.h:282
double facilitate_(double w, double kplus, const JonkeCommonProperties &cp)
Definition jonke_synapse.h:246
double depress_(double w, double kminus, const JonkeCommonProperties &cp)
Definition jonke_synapse.h:263
Connection< targetidentifierT > ConnectionBase
Definition jonke_synapse.h:168
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_jonke_synapse(const std::string &name)
Definition jonke_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