NEST main@caf0ae8
 
Loading...
Searching...
No Matches
urbanczik_synapse.h
Go to the documentation of this file.
1/*
2 * urbanczik_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 URBANCZIK_SYNAPSE_H
24#define URBANCZIK_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#include "ring_buffer.h"
35
36
37namespace nest
38{
39
40/* BeginUserDocs: synapse, chemical, functional, stdp, 3-factor, Urbanczik
41
42Short description
43+++++++++++++++++
44
45Synapse type for a plastic synapse after Urbanczik and Senn
46
47Description
48+++++++++++
49
50``urbanczik_synapse`` is a connector to create Urbanczik synapses as defined in
51:footcite:p:`Urbanczik2014` that can connect suitable :ref:`multicompartment models
52<multicompartment-models>`. In contrast to most STDP models, the synaptic weight
53depends on the postsynaptic dendritic potential, in addition to the pre- and
54postsynaptic spike timing.
55
56Urbanczik synapses require the archiving of the dendritic membrane potential
57which is continuous in time. Therefore they can only be connected to neuron
58models that are capable of doing this archiving. So far, the only compatible
59model is :doc:`pp_cond_exp_mc_urbanczik <pp_cond_exp_mc_urbanczik>`.
60
61.. warning::
62
63 This synaptic plasticity rule does not take
64 :ref:`precise spike timing <sim_precise_spike_times>` into
65 account. When calculating the weight update, the precise spike time part
66 of the timestamp is ignored.
67
68Parameters
69++++++++++
70
71========= ==== =========================================================
72eta real Learning rate
73tau_Delta real Time constant of low pass filtering of the weight change
74Wmax real Maximum allowed weight
75Wmin real Minimum allowed weight
76========= ==== =========================================================
77
78All other parameters are stored in the neuron models that are compatible
79with the Urbanczik synapse.
80
81Transmits
82+++++++++
83
84SpikeEvent
85
86References
87++++++++++
88
89.. footbibliography::
90
91See also
92++++++++
93
94stdp_synapse, clopath_synapse, pp_cond_exp_mc_urbanczik
95
96Examples using this model
97+++++++++++++++++++++++++
98
99.. listexamples:: urbanczik_synapse
100
101EndUserDocs */
102
103// connections are templates of target identifier type (used for pointer /
104// target index addressing) derived from generic connection template
105
106void register_urbanczik_synapse( const std::string& name );
107
108template < typename targetidentifierT >
109class urbanczik_synapse : public Connection< targetidentifierT >
110{
111
112public:
115
120
126
127
134
135 // Explicitly declare all methods inherited from the dependent base
136 // ConnectionBase. This avoids explicit name prefixes in all places these
137 // functions are used. Since ConnectionBase depends on the template parameter,
138 // they are not automatically found in the base class.
143
147 void get_status( Dictionary& d ) const;
148
152 void set_status( const Dictionary& d, ConnectorModel& cm );
153
159 bool send( Event& e, size_t t, const CommonSynapseProperties& cp );
160
161
163 {
164 public:
165 // Ensure proper overriding of overloaded virtual functions.
166 // Return values from functions are ignored.
168 size_t
169 handles_test_event( SpikeEvent&, size_t ) override
170 {
171 return invalid_port;
172 }
173 };
174
175 void
176 check_connection( Node& s, Node& t, size_t receptor_type, const CommonPropertiesType& )
177 {
178 ConnTestDummyNode dummy_target;
179
180 ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
181
183 }
184
185 void
186 set_weight( double w )
187 {
188 weight_ = w;
189 }
190
191private:
192 // data members of each connection
193 double weight_;
196 double eta_;
197 double Wmin_;
198 double Wmax_;
203
205};
206
207template < typename targetidentifierT >
209
216template < typename targetidentifierT >
217inline bool
219{
220 double t_spike = e.get_stamp().get_ms();
221 // use accessor functions (inherited from Connection< >) to obtain delay and 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_extended >::iterator start;
227 std::deque< histentry_extended >::iterator finish;
228
229 // for now we only support two-compartment neurons
230 // in this case the dendritic compartment has index 1
231 const int comp = 1;
232
233 target->get_urbanczik_history( t_lastspike_ - dendritic_delay, t_spike - dendritic_delay, &start, &finish, comp );
234
235 double const g_L = target->get_g_L( comp );
236 double const tau_L = target->get_tau_L( comp );
237 double const C_m = target->get_C_m( comp );
238 double const tau_s = weight_ > 0.0 ? target->get_tau_syn_ex( comp ) : target->get_tau_syn_in( comp );
239 double dPI_exp_integral = 0.0;
240
241 while ( start != finish )
242 {
243 double const t_up = start->t_ + dendritic_delay; // from t_lastspike to t_spike
244 double const minus_delta_t_up = t_lastspike_ - t_up; // from 0 to -delta t
245 double const minus_t_down = t_up - t_spike; // from -t_spike to 0
246 double const PI =
247 ( tau_L_trace_ * exp( minus_delta_t_up / tau_L ) - tau_s_trace_ * exp( minus_delta_t_up / tau_s ) ) * start->dw_;
248 PI_integral_ += PI;
249 dPI_exp_integral += exp( minus_t_down / tau_Delta_ ) * PI;
250 ++start;
251 }
252
253 PI_exp_integral_ = ( exp( ( t_lastspike_ - t_spike ) / tau_Delta_ ) * PI_exp_integral_ + dPI_exp_integral );
254 weight_ = PI_integral_ - PI_exp_integral_;
255 weight_ = init_weight_ + weight_ * 15.0 * C_m * tau_s * eta_ / ( g_L * ( tau_L - tau_s ) );
256
257 if ( weight_ > Wmax_ )
258 {
259 weight_ = Wmax_;
260 }
261 else if ( weight_ < Wmin_ )
262 {
263 weight_ = Wmin_;
264 }
265
266 e.set_receiver( *target );
267 e.set_weight( weight_ );
268 // use accessor functions (inherited from Connection< >) to obtain delay in steps and rport
269 e.set_delay_steps( get_delay_steps() );
270 e.set_rport( get_rport() );
271 e();
272
273 // compute the trace of the presynaptic spike train
274 tau_L_trace_ = tau_L_trace_ * std::exp( ( t_lastspike_ - t_spike ) / tau_L ) + 1.0;
275 tau_s_trace_ = tau_s_trace_ * std::exp( ( t_lastspike_ - t_spike ) / tau_s ) + 1.0;
276
277 t_lastspike_ = t_spike;
278
279 return true;
280}
281
282
283template < typename targetidentifierT >
286 , weight_( 1.0 )
287 , init_weight_( 1.0 )
288 , tau_Delta_( 100.0 )
289 , eta_( 0.07 )
290 , Wmin_( 0.0 )
291 , Wmax_( 100.0 )
292 , PI_integral_( 0.0 )
293 , PI_exp_integral_( 0.0 )
294 , tau_L_trace_( 0.0 )
295 , tau_s_trace_( 0.0 )
296 , t_lastspike_( -1.0 )
297{
298}
299
300template < typename targetidentifierT >
301void
303{
304 ConnectionBase::get_status( d );
305 d[ names::weight ] = weight_;
306 d[ names::tau_Delta ] = tau_Delta_;
307 d[ names::eta ] = eta_;
308 d[ names::Wmin ] = Wmin_;
309 d[ names::Wmax ] = Wmax_;
310 d[ names::size_of ] = static_cast< long >( sizeof( *this ) );
311}
312
313template < typename targetidentifierT >
314void
316{
317 ConnectionBase::set_status( d, cm );
318 d.update_value( names::weight, weight_ );
319 d.update_value( names::tau_Delta, tau_Delta_ );
320 d.update_value( names::eta, eta_ );
321 d.update_value( names::Wmin, Wmin_ );
322 d.update_value( names::Wmax, Wmax_ );
323
324 init_weight_ = weight_;
325 // check if weight_ and Wmin_ has the same sign
326 if ( std::signbit( weight_ ) != std::signbit( Wmax_ ) )
327 {
328 throw BadProperty( "Weight and Wmin must have same sign." );
329 }
330
331 // check if weight_ and Wmax_ has the same sign
332 if ( not( ( ( weight_ >= 0 ) - ( weight_ < 0 ) ) == ( ( Wmax_ > 0 ) - ( Wmax_ <= 0 ) ) ) )
333 {
334 throw BadProperty( "Weight and Wmax must have same sign." );
335 }
336}
337
338} // of namespace nest
339
340#endif // of #ifndef URBANCZIK_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 urbanczik_synapse.h:163
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition urbanczik_synapse.h:169
Definition urbanczik_synapse.h:110
double tau_L_trace_
Definition urbanczik_synapse.h:201
void check_connection(Node &s, Node &t, size_t receptor_type, const CommonPropertiesType &)
Definition urbanczik_synapse.h:176
double weight_
Definition urbanczik_synapse.h:193
Connection< targetidentifierT > ConnectionBase
Definition urbanczik_synapse.h:114
double eta_
Definition urbanczik_synapse.h:196
static constexpr ConnectionModelProperties properties
Definition urbanczik_synapse.h:116
double Wmax_
Definition urbanczik_synapse.h:198
urbanczik_synapse()
Default Constructor.
Definition urbanczik_synapse.h:284
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition urbanczik_synapse.h:315
double PI_exp_integral_
Definition urbanczik_synapse.h:200
double PI_integral_
Definition urbanczik_synapse.h:199
urbanczik_synapse & operator=(const urbanczik_synapse &)=default
double t_lastspike_
Definition urbanczik_synapse.h:204
double get_delay() const
Return the delay of the connection in ms.
Definition connection.h:172
double tau_Delta_
Definition urbanczik_synapse.h:195
double tau_s_trace_
Definition urbanczik_synapse.h:202
urbanczik_synapse(const urbanczik_synapse &)=default
Copy constructor.
bool send(Event &e, size_t t, const CommonSynapseProperties &cp)
Send an event to the receiver of this connection.
Definition urbanczik_synapse.h:218
double init_weight_
Definition urbanczik_synapse.h:194
void set_weight(double w)
Definition urbanczik_synapse.h:186
CommonSynapseProperties CommonPropertiesType
Definition urbanczik_synapse.h:113
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition urbanczik_synapse.h:302
double Wmin_
Definition urbanczik_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 eta("eta")
const std::string Wmin("Wmin")
const std::string weight("weight")
const std::string size_of("sizeof")
const std::string tau_Delta("tau_Delta")
const std::string Wmax("Wmax")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_urbanczik_synapse(const std::string &name)
Definition urbanczik_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