NEST  2.6.0,not_revisioned_source_dir@0
stdp_connection.h
Go to the documentation of this file.
1 /*
2  * stdp_connection.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_CONNECTION_H
24 #define STDP_CONNECTION_H
25 
26 /* BeginDocumentation
27  Name: stdp_synapse - Synapse type for spike-timing dependent
28  plasticity.
29 
30  Description:
31  stdp_synapse is a connector to create synapses with spike time
32  dependent plasticity (as defined in [1]). Here the weight dependence
33  exponent can be set separately for potentiation and depression.
34 
35  Examples:
36  multiplicative STDP [2] mu_plus = mu_minus = 1.0
37  additive STDP [3] mu_plus = mu_minus = 0.0
38  Guetig STDP [1] mu_plus = mu_minus = [0.0,1.0]
39  van Rossum STDP [4] mu_plus = 0.0 mu_minus = 1.0
40 
41  Parameters:
42  tau_plus double - Time constant of STDP window, potentiation in ms
43  (tau_minus defined in post-synaptic neuron)
44  lambda double - Step size
45  alpha double - Asymmetry parameter (scales depressing increments as alpha*lambda)
46  mu_plus double - Weight dependence exponent, potentiation
47  mu_minus double - Weight dependence exponent, depression
48  Wmax double - Maximum allowed weight
49 
50  Transmits: SpikeEvent
51 
52  References:
53  [1] Guetig et al. (2003) Learning Input Correlations through Nonlinear
54  Temporally Asymmetric Hebbian Plasticity. Journal of Neuroscience
55 
56  [2] Rubin, J., Lee, D. and Sompolinsky, H. (2001). Equilibrium
57  properties of temporally asymmetric Hebbian plasticity, PRL
58  86,364-367
59 
60  [3] Song, S., Miller, K. D. and Abbott, L. F. (2000). Competitive
61  Hebbian learning through spike-timing-dependent synaptic
62  plasticity,Nature Neuroscience 3:9,919--926
63 
64  [4] van Rossum, M. C. W., Bi, G-Q and Turrigiano, G. G. (2000).
65  Stable Hebbian learning from spike timing-dependent
66  plasticity, Journal of Neuroscience, 20:23,8812--8821
67 
68  FirstVersion: March 2006
69  Author: Moritz Helias, Abigail Morrison
70  SeeAlso: synapsedict, tsodyks_synapse, static_synapse
71 */
72 
73 #include <cmath>
74 
75 #include "connection.h"
76 
77 //#include "network.h"
78 //#include "dictdatum.h"
79 //#include "connector_model.h"
80 //#include "common_synapse_properties.h"
81 //#include "event.h"
82 
83 
84 namespace nest
85 {
86 
87  // connections are templates of target identifier type (used for pointer / target index addressing)
88  // derived from generic connection template
89  template<typename targetidentifierT>
90  class STDPConnection : public Connection<targetidentifierT>
91  {
92 
93  public:
94 
97 
102  STDPConnection();
103 
104 
110 
111  // Explicitly declare all methods inherited from the dependent base ConnectionBase.
112  // This avoids explicit name prefixes in all places these functions are used.
113  // Since ConnectionBase depends on the template parameter, they are not automatically
114  // found in the base class.
119 
123  void get_status(DictionaryDatum & d) const;
124 
128  void set_status(const DictionaryDatum & d, ConnectorModel &cm);
129 
136  void send(Event& e, thread t, double_t t_lastspike, const CommonSynapseProperties &cp);
137 
138 
140  {
141  public:
142  // Ensure proper overriding of overloaded virtual functions.
143  // Return values from functions are ignored.
146  };
147 
149  {
150  ConnTestDummyNode dummy_target;
151 
152  ConnectionBase::check_connection_(dummy_target, s, t, receptor_type);
153 
154  t.register_stdp_connection(t_lastspike - get_delay());
155  }
156 
158 
159  private:
160 
162  {
163  double_t norm_w = (w / Wmax_) + (lambda_ * std::pow(1.0 - (w/Wmax_), mu_plus_) * kplus);
164  return norm_w < 1.0 ? norm_w * Wmax_ : Wmax_;
165  }
166 
168  {
169  double_t norm_w = (w / Wmax_) - (alpha_ * lambda_ * std::pow(w/Wmax_, mu_minus_) * kminus);
170  return norm_w > 0.0 ? norm_w * Wmax_ : 0.0;
171  }
172 
173  // data members of each connection
182 
183 };
184 
185 
193 template<typename targetidentifierT>
194 inline
196 {
197  // synapse STDP depressing/facilitation dynamics
198  // if(t_lastspike >0) {std::cout << "last spike " << t_lastspike << std::endl ;}
200  // t_lastspike_ = 0 initially
201 
202  // use accessor functions (inherited from Connection< >) to obtain delay and target
203  Node *target = get_target(t);
204  double_t dendritic_delay = get_delay();
205 
206  //get spike history in relevant range (t1, t2] from post-synaptic neuron
207  std::deque<histentry>::iterator start;
208  std::deque<histentry>::iterator finish;
209 
210  // For a new synapse, t_lastspike contains the point in time of the last spike.
211  // So we initially read the history(t_last_spike - dendritic_delay, ..., T_spike-dendritic_delay]
212  // which increases the access counter for these entries.
213  // At registration, all entries' access counters of history[0, ..., t_last_spike - dendritic_delay] have been
214  // incremented by Archiving_Node::register_stdp_connection(). See bug #218 for details.
215  target->get_history(t_lastspike - dendritic_delay, t_spike - dendritic_delay,
216  &start, &finish);
217  //facilitation due to post-synaptic spikes since last pre-synaptic spike
218  double_t minus_dt;
219  while (start != finish)
220  {
221  minus_dt = t_lastspike - (start->t_ + dendritic_delay);
222  ++start;
223  if (minus_dt == 0)
224  continue;
225  weight_ = facilitate_(weight_, Kplus_ * std::exp(minus_dt / tau_plus_));
226  }
227 
228  //depression due to new pre-synaptic spike
229  weight_ = depress_(weight_, target->get_K_value(t_spike - dendritic_delay));
230 
231  e.set_receiver(*target);
232  e.set_weight(weight_);
233  // use accessor functions (inherited from Connection< >) to obtain delay in steps and rport
234  e.set_delay(get_delay_steps());
235  e.set_rport(get_rport());
236  e();
237 
238  Kplus_ = Kplus_ * std::exp((t_lastspike - t_spike) / tau_plus_) + 1.0;
239 }
240 
241 
242  template<typename targetidentifierT>
244  ConnectionBase(),
245  weight_(1.0),
246  tau_plus_(20.0),
247  lambda_(0.01),
248  alpha_(1.0),
249  mu_plus_(1.0),
250  mu_minus_(1.0),
251  Wmax_(100.0),
252  Kplus_(0.0)
253  { }
254 
255  template<typename targetidentifierT>
257  ConnectionBase(rhs),
258  weight_(rhs.weight_),
259  tau_plus_(rhs.tau_plus_),
260  lambda_(rhs.lambda_),
261  alpha_(rhs.alpha_),
262  mu_plus_(rhs.mu_plus_),
263  mu_minus_(rhs.mu_minus_),
264  Wmax_(rhs.Wmax_),
265  Kplus_(rhs.Kplus_)
266  { }
267 
268  template<typename targetidentifierT>
270  {
271  ConnectionBase::get_status(d);
272  def<double_t>(d, names::weight, weight_);
273  def<double_t>(d, "tau_plus", tau_plus_);
274  def<double_t>(d, "lambda", lambda_);
275  def<double_t>(d, "alpha", alpha_);
276  def<double_t>(d, "mu_plus", mu_plus_);
277  def<double_t>(d, "mu_minus", mu_minus_);
278  def<double_t>(d, "Wmax", Wmax_);
279  def<long_t>(d, names::size_of, sizeof(*this));
280  }
281 
282  template<typename targetidentifierT>
284  {
285  ConnectionBase::set_status(d, cm);
286  updateValue<double_t>(d, names::weight, weight_);
287  updateValue<double_t>(d, "tau_plus", tau_plus_);
288  updateValue<double_t>(d, "lambda", lambda_);
289  updateValue<double_t>(d, "alpha", alpha_);
290  updateValue<double_t>(d, "mu_plus", mu_plus_);
291  updateValue<double_t>(d, "mu_minus", mu_minus_);
292  updateValue<double_t>(d, "Wmax", Wmax_);
293  }
294 
295 } // of namespace nest
296 
297 #endif // of #ifndef STDP_CONNECTION_H
void set_rport(rport p)
Set the receiver port number (r-port).
Definition: event.h:817
void set_receiver(Node &)
Change pointer to receiving Node.
Definition: event.h:708
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
void get_status(DictionaryDatum &d) const
Get all properties of this connection and put them into a dictionary.
Definition: stdp_connection.h:269
Connection< targetidentifierT > ConnectionBase
Definition: stdp_connection.h:96
port handles_test_event(SpikeEvent &, rport)
Check if the node can handle a particular event and receptor type.
Definition: stdp_connection.h:145
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
virtual double_t get_K_value(double_t t)
return the Kminus value at t (in ms).
Definition: node.cpp:273
double_t mu_plus_
Definition: stdp_connection.h:178
void set_weight(double_t w)
Definition: stdp_connection.h:157
long_t get_delay_steps() const
Return the delay of the connection in steps.
Definition: connection.h:126
void check_connection_(Node &dummy_target, Node &source, Node &target, rport receptor_type)
This function calls check_connection() on the sender to check if the receiver accepts the event type ...
Definition: connection.h:183
const rport invalid_port_
Value for invalid connection port number.
Definition: nest.h:160
const Name weight("weight")
Connection parameters.
Definition: nest_names.h:344
Encapsulates information which is sent between Nodes.
Definition: event.h:73
void set_status(const DictionaryDatum &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition: stdp_connection.h:283
void set_weight(weight t)
Set weight of the event.
Definition: event.h:751
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
double_t depress_(double_t w, double_t kminus)
Definition: stdp_connection.h:167
Node * get_target(thread t) const
Definition: connection.h:155
double_t get_delay() const
Return the delay of the connection in ms.
Definition: connection.h:121
void send(Event &e, thread t, double_t t_lastspike, const CommonSynapseProperties &cp)
Send an event to the receiver of this connection.
Definition: stdp_connection.h:195
const Name w("w")
Specific to Brette & Gerstner 2005 (aeif_cond-*)
Definition: nest_names.h:343
void set_delay(delay)
Set the transmission delay of the event.
Definition: event.h:781
double_t lambda_
Definition: stdp_connection.h:176
virtual void get_history(double_t t1, double_t t2, std::deque< histentry >::iterator *start, std::deque< histentry >::iterator *finish)
return the spike history for (t1,t2].
Definition: node.cpp:284
Time const & get_stamp() const
Return time stamp of the event.
Definition: event.h:757
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
const Name start("start")
Device parameters.
Definition: nest_names.h:263
Base class for dummy nodes used in connection testing.
Definition: connection.h:64
void check_connection(Node &s, Node &t, rport receptor_type, double_t t_lastspike, const CommonPropertiesType &)
Definition: stdp_connection.h:148
double_t mu_minus_
Definition: stdp_connection.h:179
double_t alpha_
Definition: stdp_connection.h:177
STDPConnection()
Default Constructor.
Definition: stdp_connection.h:243
Definition: stdp_connection.h:139
virtual void register_stdp_connection(double_t)
Register a STDP connection.
Definition: node.cpp:178
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
double_t Wmax_
Definition: stdp_connection.h:180
double double_t
Double precision floating point numbers.
Definition: nest.h:93
rport get_rport() const
Definition: connection.h:156
virtual port handles_test_event(SpikeEvent &, rport receptor_type)
Check if the node can handle a particular event and receptor type.
Definition: node.cpp:203
double_t get_ms() const
Definition: nest_time.h:389
const Name size_of("sizeof")
Connection parameters.
Definition: nest_names.h:259
Class containing the common properties for all connections of a certain type.
Definition: common_synapse_properties.h:44
Base class for representing connections.
Definition: connection.h:85
Event for spike information.
Definition: event.h:320
Base class for all NEST network objects.
Definition: node.h:96
double_t weight_
Definition: stdp_connection.h:174
Definition: connector_model.h:38
int_t thread
Thread index type.
Definition: nest.h:133
CommonSynapseProperties CommonPropertiesType
Definition: stdp_connection.h:95
double_t Kplus_
Definition: stdp_connection.h:181
const double e
Definition: numerics.cpp:62
double_t facilitate_(double_t w, double_t kplus)
Definition: stdp_connection.h:161
Definition: stdp_connection.h:90
const Name t_spike("t_spike")
Time of last spike.
Definition: nest_names.h:281
double_t tau_plus_
Definition: stdp_connection.h:175