NEST main@caf0ae8
 
Loading...
Searching...
No Matches
cont_delay_synapse.h
Go to the documentation of this file.
1/*
2 * cont_delay_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 CONT_DELAY_SYNAPSE_H
24#define CONT_DELAY_SYNAPSE_H
25
26
27// C++ includes:
28#include <cmath>
29
30// Includes from nestkernel:
31#include "connection.h"
32
33namespace nest
34{
35
36/* BeginUserDocs: synapse, chemical, static
37
38Short description
39+++++++++++++++++
40
41Synapse type for continuous delays
42
43Description
44+++++++++++
45
46``cont_delay_synapse`` relaxes the condition that NEST only implements delays
47which are an integer multiple of the time step `h`. A continuous delay is
48decomposed into an integer part (``delay_``) and a double (``delay_offset_``) so
49that the actual delay is given by ``delay_*h - delay_offset_``. This can be
50combined with off-grid spike times.
51
52All delays set by the normal NEST Connect function will be rounded, even
53when using cont_delay_synapse. To set non-grid delays, you must either
54
551. set the delay as model default using :py:func:`.SetDefaults`, which
56 is very efficient, but results in a situation where all synapses then
57 will have the same delay.
58
592. set the delay for each synapse after the connections have been
60 created, which is slower, but allows individual delay values.
61
62Continuous delays cannot be shorter than the simulation resolution.
63
64Transmits
65+++++++++
66
67SpikeEvent, RateEvent, CurrentEvent, ConductanceEvent, DoubleDataEvent
68
69See also
70++++++++
71
72static_synapse, iaf_psc_alpha_ps
73
74Examples using this model
75+++++++++++++++++++++++++
76
77.. listexamples:: cont_delay_synapse
78
79EndUserDocs */
80
81void register_cont_delay_synapse( const std::string& name );
82
83template < typename targetidentifierT >
84class cont_delay_synapse : public Connection< targetidentifierT >
85{
86
87public:
90
94
100
106
111 {
112 }
113
114 // Explicitly declare all methods inherited from the dependent base
115 // ConnectionBase. This avoids explicit name prefixes in all places these
116 // functions are used. Since ConnectionBase depends on the template parameter,
117 // they are not automatically found in the base class.
122
124 void
125 set_weight( double w )
126 {
127 weight_ = w;
128 }
129
133 void get_status( Dictionary& d ) const;
134
138 void set_status( const Dictionary& d, ConnectorModel& cm );
139
143 void check_synapse_params( const Dictionary& d ) const;
144
150 bool send( Event& e, size_t t, const CommonSynapseProperties& cp );
151
153 {
154 public:
155 // Ensure proper overriding of overloaded virtual functions.
156 // Return values from functions are ignored.
158 size_t
159 handles_test_event( SpikeEvent&, size_t ) override
160 {
161 return invalid_port;
162 }
163 size_t
164 handles_test_event( RateEvent&, size_t ) override
165 {
166 return invalid_port;
167 }
168 size_t
170 {
171 return invalid_port;
172 }
173 size_t
174 handles_test_event( CurrentEvent&, size_t ) override
175 {
176 return invalid_port;
177 }
178 size_t
180 {
181 return invalid_port;
182 }
183 size_t
185 {
186 return invalid_port;
187 }
188 size_t
189 handles_test_event( DSSpikeEvent&, size_t ) override
190 {
191 return invalid_port;
192 }
193 size_t
195 {
196 return invalid_port;
197 }
198 };
199
200 void
201 check_connection( Node& s, Node& t, size_t receptor_type, const CommonPropertiesType& )
202 {
203 ConnTestDummyNode dummy_target;
204 ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
205 }
206
207private:
208 double weight_;
211};
212
218template < typename targetidentifierT >
219inline bool
221{
222 e.set_receiver( *get_target( t ) );
223 e.set_weight( weight_ );
224 e.set_rport( get_rport() );
225 double orig_event_offset = e.get_offset();
226 double total_offset = orig_event_offset + delay_offset_;
227 // As far as i have seen, offsets are outside of tics regime provided
228 // by the Time-class to allow more precise spike-times, hence comparing
229 // on the tics level here is not reasonable. Still, the double comparison
230 // seems save.
231 if ( total_offset < Time::get_resolution().get_ms() )
232 {
233 e.set_delay_steps( get_delay_steps() );
234 e.set_offset( total_offset );
235 }
236 else
237 {
238 e.set_delay_steps( get_delay_steps() - 1 );
239 e.set_offset( total_offset - Time::get_resolution().get_ms() );
240 }
241 e();
242 // reset offset to original value
243 e.set_offset( orig_event_offset );
244
245 return true;
246}
247
248template < typename targetidentifierT >
250
251} // of namespace nest
252
253#endif // of #ifndef CONT_DELAY_SYNAPSE_H
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Class containing the common properties for all connections of a certain type.
Definition common_synapse_properties.h:50
Event for electrical conductances.
Definition event.h:809
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
void set_delay_steps(const long delay)
Set the delay of the connection in steps.
Definition connection.h:199
Definition connector_model.h:69
Event for electrical currents.
Definition event.h:569
"Callback request event" for use in Device.
Definition event.h:615
"Callback request event" for use in Device.
Definition event.h:521
Request data to be logged/logged data to be sent.
Definition event.h:636
Definition event.h:880
Encapsulate information sent between nodes.
Definition event.h:103
Base class for all NEST network objects.
Definition node.h:99
Event for firing rate information.
Definition event.h:535
Event for spike information.
Definition event.h:418
static Time get_resolution()
Definition nest_time.h:325
Definition cont_delay_synapse.h:153
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition cont_delay_synapse.h:159
size_t handles_test_event(DoubleDataEvent &, size_t) override
Definition cont_delay_synapse.h:184
size_t handles_test_event(ConductanceEvent &, size_t) override
Definition cont_delay_synapse.h:179
size_t handles_test_event(CurrentEvent &, size_t) override
Definition cont_delay_synapse.h:174
size_t handles_test_event(DSCurrentEvent &, size_t) override
Definition cont_delay_synapse.h:194
size_t handles_test_event(DataLoggingRequest &, size_t) override
Definition cont_delay_synapse.h:169
size_t handles_test_event(DSSpikeEvent &, size_t) override
Definition cont_delay_synapse.h:189
size_t handles_test_event(RateEvent &, size_t) override
Definition cont_delay_synapse.h:164
Definition cont_delay_synapse.h:85
~cont_delay_synapse()
Default Destructor.
Definition cont_delay_synapse.h:110
double weight_
synaptic weight
Definition cont_delay_synapse.h:208
bool send(Event &e, size_t t, const CommonSynapseProperties &cp)
Send an event to the receiver of this connection.
Definition cont_delay_synapse.h:220
void check_synapse_params(const Dictionary &d) const
Issue warning if delay is given in syn_spec.
Definition cont_delay_synapse_impl.h:93
cont_delay_synapse()
Default Constructor.
Definition cont_delay_synapse_impl.h:38
CommonSynapseProperties CommonPropertiesType
Definition cont_delay_synapse.h:88
void set_weight(double w)
Used by ConnectorModel::add_connection() for fast initialization.
Definition cont_delay_synapse.h:125
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition cont_delay_synapse_impl.h:58
double delay_offset_
fractional delay < h, total delay = delay_ - delay_offset_
Definition cont_delay_synapse.h:209
static constexpr ConnectionModelProperties properties
Definition cont_delay_synapse.h:91
Connection< targetidentifierT > ConnectionBase
Definition cont_delay_synapse.h:89
void check_connection(Node &s, Node &t, size_t receptor_type, const CommonPropertiesType &)
Definition cont_delay_synapse.h:201
cont_delay_synapse(const cont_delay_synapse &)=default
Copy constructor.
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition cont_delay_synapse_impl.h:47
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
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_cont_delay_synapse(const std::string &name)
Definition cont_delay_synapse.cpp:33
ConnectionModelProperties
Definition connector_model.h:49
constexpr size_t invalid_port
Value for invalid connection port number.
Definition nest_types.h:141