NEST main@f146f75
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, TotalDelay >
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.
123
125 void
126 set_weight( double w )
127 {
128 weight_ = w;
129 }
130
134 void get_status( Dictionary& d ) const;
135
139 void set_status( const Dictionary& d, ConnectorModel& cm );
140
144 void check_synapse_params( const Dictionary& d ) const;
145
151 bool send( Event& e, size_t t, const CommonSynapseProperties& cp );
152
154 {
155 public:
156 // Ensure proper overriding of overloaded virtual functions.
157 // Return values from functions are ignored.
159 size_t
160 handles_test_event( SpikeEvent&, size_t ) override
161 {
162 return invalid_port;
163 }
164 size_t
165 handles_test_event( RateEvent&, size_t ) override
166 {
167 return invalid_port;
168 }
169 size_t
171 {
172 return invalid_port;
173 }
174 size_t
175 handles_test_event( CurrentEvent&, size_t ) override
176 {
177 return invalid_port;
178 }
179 size_t
181 {
182 return invalid_port;
183 }
184 size_t
186 {
187 return invalid_port;
188 }
189 size_t
190 handles_test_event( DSSpikeEvent&, size_t ) override
191 {
192 return invalid_port;
193 }
194 size_t
196 {
197 return invalid_port;
198 }
199 };
200
201 void
202 check_connection( Node& s, Node& t, const size_t receptor_type, const synindex syn_id, const CommonPropertiesType& )
203 {
204 ConnTestDummyNode dummy_target;
205 ConnectionBase::check_connection_( dummy_target, s, t, syn_id, receptor_type );
206 }
207
208private:
209 double weight_;
212};
213
219template < typename targetidentifierT >
220inline bool
222{
223 e.set_receiver( *get_target( t ) );
224 e.set_weight( weight_ );
225 e.set_rport( get_rport() );
226 double orig_event_offset = e.get_offset();
227 double total_offset = orig_event_offset + delay_offset_;
228 // As far as i have seen, offsets are outside of tics regime provided
229 // by the Time-class to allow more precise spike-times, hence comparing
230 // on the tics level here is not reasonable. Still, the double comparison
231 // seems save.
232 if ( total_offset < Time::get_resolution().get_ms() )
233 {
234 e.set_delay_steps( get_delay_steps() );
235 e.set_offset( total_offset );
236 }
237 else
238 {
239 e.set_delay_steps( get_delay_steps() - 1 );
240 e.set_offset( total_offset - Time::get_resolution().get_ms() );
241 }
242 e();
243 // reset offset to original value
244 e.set_offset( orig_event_offset );
245
246 return true;
247}
248
249template < typename targetidentifierT >
251
252} // of namespace nest
253
254#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:848
Base class for dummy nodes used in connection testing.
Definition connection.h:70
double get_delay_ms() const
Definition connection.h:262
size_t get_rport() const
Definition connection.h:316
void set_delay_steps(const long d)
Definition connection.h:289
long get_delay_steps() const
Definition connection.h:271
Node * get_target(const size_t tid) const
Definition connection.h:311
void check_connection_(Node &dummy_target, Node &source, Node &target, const synindex syn_id, const size_t receptor_type)
Definition connector_model.h:69
Event for electrical currents.
Definition event.h:608
"Callback request event" for use in Device.
Definition event.h:654
"Callback request event" for use in Device.
Definition event.h:560
Request data to be logged/logged data to be sent.
Definition event.h:675
Definition event.h:919
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:574
Event for spike information.
Definition event.h:420
static Time get_resolution()
Definition nest_time.h:325
Definition cont_delay_synapse.h:154
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:160
size_t handles_test_event(DoubleDataEvent &, size_t) override
Definition cont_delay_synapse.h:185
size_t handles_test_event(ConductanceEvent &, size_t) override
Definition cont_delay_synapse.h:180
size_t handles_test_event(CurrentEvent &, size_t) override
Definition cont_delay_synapse.h:175
size_t handles_test_event(DSCurrentEvent &, size_t) override
Definition cont_delay_synapse.h:195
size_t handles_test_event(DataLoggingRequest &, size_t) override
Definition cont_delay_synapse.h:170
size_t handles_test_event(DSSpikeEvent &, size_t) override
Definition cont_delay_synapse.h:190
size_t handles_test_event(RateEvent &, size_t) override
Definition cont_delay_synapse.h:165
size_t get_rport() const
Definition connection.h:316
~cont_delay_synapse()
Default Destructor.
Definition cont_delay_synapse.h:110
double weight_
synaptic weight
Definition cont_delay_synapse.h:209
bool send(Event &e, size_t t, const CommonSynapseProperties &cp)
Send an event to the receiver of this connection.
Definition cont_delay_synapse.h:221
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
long get_delay_steps() const
Return the delay of the connection in steps.
Definition connection.h:271
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:126
Connection< targetidentifierT, TotalDelay > ConnectionBase
Definition cont_delay_synapse.h:89
Node * get_target(const size_t tid) const
Definition connection.h:311
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_
Definition cont_delay_synapse.h:210
static constexpr ConnectionModelProperties properties
Definition cont_delay_synapse.h:91
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
void check_connection(Node &s, Node &t, const size_t receptor_type, const synindex syn_id, const CommonPropertiesType &)
Definition cont_delay_synapse.h:202
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:282
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
@ HAS_DELAY
Definition connector_model.h:54
@ SUPPORTS_LBL
Definition connector_model.h:52
@ SUPPORTS_HPC
Definition connector_model.h:51
@ IS_PRIMARY
Definition connector_model.h:53
@ SUPPORTS_WFR
Definition connector_model.h:55
constexpr size_t invalid_port
Value for invalid connection port number.
Definition nest_types.h:147
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:121