NEST  2.6.0,not_revisioned_source_dir@0
stdp_pl_connection_hom.h
Go to the documentation of this file.
1 /*
2  * stdp_pl_connection_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_CONNECTION_HOM_H
24 #define STDP_PL_CONNECTION_HOM_H
25 
26 /* BeginDocumentation
27  Name: stdp_pl_synapse_hom - Synapse type for spike-timing dependent
28  plasticity with power law implementation using homogeneous parameters, i.e.
29  all synapses have the same parameters.
30 
31  Description:
32  stdp_pl_synapse is a connector to create synapses with spike time
33  dependent plasticity (as defined in [1]).
34 
35 
36  Parameters:
37  tau_plus double - Time constant of STDP window, potentiation in ms
38  (tau_minus defined in post-synaptic neuron)
39  lambda double - Learning rate
40  alpha double - Asymmetry parameter (scales depressing increments as alpha*lambda)
41  mu double - Weight dependence exponent, potentiation
42 
43  References:
44  [1] Morrison et al. (2007) Spike-timing dependent plasticity in balanced
45  random networks. Neural Computation.
46 
47  Transmits: SpikeEvent
48 
49  FirstVersion: May 2007
50  Author: Abigail Morrison
51  SeeAlso: synapsedict, stdp_synapse, tsodyks_synapse, static_synapse
52 */
53 
54 #include "connection.h"
55 
56 #include <cmath>
57 
58 namespace nest
59 {
60 
65  {
66 
67  public:
68 
74 
78  void get_status(DictionaryDatum & d) const;
79 
83  void set_status(const DictionaryDatum & d, ConnectorModel& cm);
84 
85  // data members common to all connections
90  };
91 
92 
93 
97  template<typename targetidentifierT>
98  class STDPPLConnectionHom : public Connection<targetidentifierT>
99  {
100 
101  public:
102 
105 
106 
112 
118 
119  // Explicitly declare all methods inherited from the dependent base ConnectionBase.
120  // This avoids explicit name prefixes in all places these functions are used.
121  // Since ConnectionBase depends on the template parameter, they are not automatically
122  // found in the base class.
127 
131  void get_status(DictionaryDatum & d) const;
132 
136  void set_status(const DictionaryDatum & d, ConnectorModel &cm);
137 
143  void send(Event& e, thread t, double_t t_lastspike, const STDPPLHomCommonProperties &);
144 
146  {
147  public:
148  // Ensure proper overriding of overloaded virtual functions.
149  // Return values from functions are ignored.
152  };
153 
154  /*
155  * This function calls check_connection on the sender and checks if the receiver
156  * accepts the event type and receptor type requested by the sender.
157  * Node::check_connection() will either confirm the receiver port by returning
158  * true or false if the connection should be ignored.
159  * We have to override the base class' implementation, since for STDP
160  * connections we have to call register_stdp_pl_connection on the target neuron
161  * to inform the Archiver to collect spikes for this connection.
162  *
163  * \param s The source node
164  * \param r The target node
165  * \param receptor_type The ID of the requested receptor type
166  * \param t_lastspike last spike produced by presynaptic neuron (in ms)
167  */
169  {
170  ConnTestDummyNode dummy_target;
171 
172  ConnectionBase::check_connection_(dummy_target, s, t, receptor_type);
173 
174  t.register_stdp_connection(t_lastspike - get_delay());
175  }
176 
178 
179  private:
180 
182  {
183  return w + (cp.lambda_ * std::pow(w,cp.mu_) * kplus);
184  }
185 
187  {
188  double_t new_w = w - (cp.lambda_ * cp.alpha_ * w * kminus);
189  return new_w > 0.0 ? new_w : 0.0;
190  }
191 
192  // data members of each connection
195 
196  };
197 
198  //
199  // Implementation of class STDPPLConnectionHom.
200  //
201 
208  template<typename targetidentifierT>
209  inline
211  {
212  // synapse STDP depressing/facilitation dynamics
213 
215 
216  // t_lastspike_ = 0 initially
217 
218  Node *target = get_target(t);
219 
220  double_t dendritic_delay = get_delay();
221 
222  //get spike history in relevant range (t1, t2] from post-synaptic neuron
223  std::deque<histentry>::iterator start;
224  std::deque<histentry>::iterator finish;
225  target->get_history(t_lastspike - dendritic_delay, t_spike - dendritic_delay,
226  &start, &finish);
227 
228  //facilitation due to post-synaptic spikes since last pre-synaptic spike
229  double_t minus_dt;
230  while (start != finish)
231  {
232  minus_dt = t_lastspike - (start->t_ + dendritic_delay);
233  start++;
234  if (minus_dt == 0)
235  continue;
236  weight_ = facilitate_(weight_, Kplus_ * std::exp(minus_dt / cp.tau_plus_), cp);
237  }
238 
239  //depression due to new pre-synaptic spike
240  weight_ = depress_(weight_, target->get_K_value(t_spike - dendritic_delay), cp);
241 
242  e.set_receiver(*target);
243  e.set_weight(weight_);
244  e.set_delay(get_delay_steps());
245  e.set_rport(get_rport());
246  e();
247 
248  Kplus_ = Kplus_ * std::exp((t_lastspike - t_spike) / cp.tau_plus_) + 1.0;
249  }
250 
251  template<typename targetidentifierT>
253  ConnectionBase(),
254  weight_(1.0),
255  Kplus_(0.0)
256  { }
257 
258  template<typename targetidentifierT>
260  ConnectionBase(rhs),
261  weight_(rhs.weight_),
262  Kplus_(rhs.Kplus_)
263  { }
264 
265  template<typename targetidentifierT>
267  {
268 
269  // base class properties, different for individual synapse
270  ConnectionBase::get_status(d);
271  def<double_t>(d, names::weight, weight_);
272 
273  // own properties, different for individual synapse
274  def<double_t>(d, "Kplus", Kplus_);
275  def<long_t>(d, names::size_of, sizeof(*this));
276  }
277 
278  template<typename targetidentifierT>
280  {
281  // base class properties
282  ConnectionBase::set_status(d, cm);
283  updateValue<double_t>(d, names::weight, weight_);
284 
285  updateValue<double_t>(d, "Kplus", Kplus_);
286  }
287 
288 } // of namespace nest
289 
290 #endif // of #ifndef STDP_PL_CONNECTION_HOM_H
Class containing the common properties for all synapses of type STDPConnectionHom.
Definition: stdp_pl_connection_hom.h:64
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
STDPPLHomCommonProperties CommonPropertiesType
Definition: stdp_pl_connection_hom.h:103
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
void set_weight(double_t w)
Definition: stdp_pl_connection_hom.h:177
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
port handles_test_event(SpikeEvent &, rport)
Check if the node can handle a particular event and receptor type.
Definition: stdp_pl_connection_hom.h:151
double_t lambda_
Definition: stdp_pl_connection_hom.h:87
const Name weight("weight")
Connection parameters.
Definition: nest_names.h:344
Class representing an STDP connection with homogeneous parameters, i.e.
Definition: stdp_pl_connection_hom.h:98
Encapsulates information which is sent between Nodes.
Definition: event.h:73
STDPPLHomCommonProperties()
Default constructor.
Definition: stdp_pl_connection_hom.cpp:37
void set_status(const DictionaryDatum &d, ConnectorModel &cm)
Set properties from the values given in dictionary.
Definition: stdp_pl_connection_hom.cpp:55
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
Node * get_target(thread t) const
Definition: connection.h:155
void check_connection(Node &s, Node &t, rport receptor_type, double_t t_lastspike, const CommonPropertiesType &)
Definition: stdp_pl_connection_hom.h:168
double_t get_delay() const
Return the delay of the connection in ms.
Definition: connection.h:121
const Name w("w")
Specific to Brette & Gerstner 2005 (aeif_cond-*)
Definition: nest_names.h:343
Definition: stdp_pl_connection_hom.h:145
double_t facilitate_(double_t w, double_t kplus, const STDPPLHomCommonProperties &cp)
Definition: stdp_pl_connection_hom.h:181
void set_delay(delay)
Set the transmission delay of the event.
Definition: event.h:781
double_t alpha_
Definition: stdp_pl_connection_hom.h:88
double_t weight_
Definition: stdp_pl_connection_hom.h:193
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
double_t tau_plus_
Definition: stdp_pl_connection_hom.h:86
virtual void register_stdp_connection(double_t)
Register a STDP connection.
Definition: node.cpp:178
Connection< targetidentifierT > ConnectionBase
Definition: stdp_pl_connection_hom.h:104
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
void get_status(DictionaryDatum &d) const
Get all properties and put them into a dictionary.
Definition: stdp_pl_connection_hom.cpp:45
double double_t
Double precision floating point numbers.
Definition: nest.h:93
STDPPLConnectionHom()
Default Constructor.
Definition: stdp_pl_connection_hom.h:252
double_t mu_
Definition: stdp_pl_connection_hom.h:89
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
void get_status(DictionaryDatum &d) const
Get all properties of this connection and put them into a dictionary.
Definition: stdp_pl_connection_hom.h:266
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
double_t Kplus_
Definition: stdp_pl_connection_hom.h:194
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
Definition: connector_model.h:38
int_t thread
Thread index type.
Definition: nest.h:133
void send(Event &e, thread t, double_t t_lastspike, const STDPPLHomCommonProperties &)
Send an event to the receiver of this connection.
Definition: stdp_pl_connection_hom.h:210
const double e
Definition: numerics.cpp:62
double_t depress_(double_t w, double_t kminus, const STDPPLHomCommonProperties &cp)
Definition: stdp_pl_connection_hom.h:186
const Name t_spike("t_spike")
Time of last spike.
Definition: nest_names.h:281
void set_status(const DictionaryDatum &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition: stdp_pl_connection_hom.h:279