NEST main@f146f75
Loading...
Searching...
No Matches
connection.h
Go to the documentation of this file.
1/*
2 * 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 CONNECTION_H
24#define CONNECTION_H
25
26#include <type_traits>
27
28// Includes from nestkernel:
30#include "connection_label.h"
31#include "connector_base_impl.h"
32#include "delay_checker.h"
33#include "delay_types.h"
34#include "event.h"
35#include "kernel_manager.h"
36#include "nest.h"
37#include "nest_names.h"
38#include "nest_time.h"
39#include "nest_timeconverter.h"
40#include "nest_types.h"
41#include "node.h"
42#include "spikecounter.h"
43#include "target_identifier.h"
44
45namespace nest
46{
47
48class ConnectorModel;
49
70{
71 void
72 pre_run_hook() override
73 {
74 }
75 void
76 update( const Time&, long, long ) override
77 {
78 }
79 void
80 set_status( const Dictionary& ) override
81 {
82 }
83 void
84 get_status( Dictionary& ) const override
85 {
86 }
87 void
88 init_state_() override
89 {
90 }
91 void
92 init_buffers_() override
93 {
94 }
95};
96
111template < typename targetidentifierT, typename DelayTypeT >
113{
114
115public:
116 static constexpr bool requires_axonal_delay_correction = std::is_same< DelayTypeT, AxonalDendriticDelay >::value;
117
118 // properties used when registering a connection with the ModelManager
120
121 // Whether this connection type supports flush events.
122 static constexpr bool supports_flush_event = false;
123
125 : target_()
126 , more_targets_( false )
127 , disabled_( false )
128 , delay_( 1.0 )
129 {
130 }
131
134
141 std::unique_ptr< SecondaryEvent > get_secondary_event();
142
146 void get_status( Dictionary& d ) const;
147
154 void set_status( const Dictionary& d, ConnectorModel& cm );
155
168 void check_synapse_params( const Dictionary& d ) const;
169
173 void calibrate( const TimeConverter& );
174
180 void correct_weight_stdp_ax_delay( const size_t tid,
182 const double t_spike_critical_interval_end,
183 const double t_post_spike,
185
189 double
191 {
192 return delay_.get_dendritic_delay_ms();
193 }
194
198 long
200 {
201 return delay_.get_dendritic_delay_steps();
202 }
203
207 void
208 set_dendritic_delay_ms( const double d )
209 {
210 delay_.set_dendritic_delay_ms( d );
211 }
212
216 void
218 {
219 delay_.set_dendritic_delay_steps( d );
220 }
221
225 void
226 set_axonal_delay_ms( const double d )
227 {
228 delay_.set_axonal_delay_ms( d );
229 }
230
234 double
236 {
237 return delay_.get_axonal_delay_ms();
238 }
239
243 void
245 {
246 delay_.set_axonal_delay_steps( d );
247 }
248
252 double
254 {
255 return delay_.get_axonal_delay_steps();
256 }
257
261 double
263 {
264 return delay_.get_delay_ms();
265 }
266
270 long
272 {
273 return delay_.get_delay_steps();
274 }
275
279 void
280 set_delay_ms( const double d )
281 {
282 delay_.set_delay_ms( d );
283 }
284
288 void
289 set_delay_steps( const long d )
290 {
291 delay_.set_delay_steps( d );
292 }
293
294 long
295 get_label() const
296 {
298 }
299
305 void trigger_update_weight( const size_t,
306 const std::vector< spikecounter >&,
307 const double,
309
310 Node*
311 get_target( const size_t tid ) const
312 {
313 return target_.get_target_ptr( tid );
314 }
315 size_t
316 get_rport() const
317 {
318 return target_.get_rport();
319 }
320
327 void
328 set_source_has_more_targets( const bool more_targets )
329 {
330 more_targets_ = more_targets;
331 }
332
339 bool
341 {
342 return more_targets_;
343 }
344
350 void
352 {
353 disabled_ = true;
354 }
355
361 bool
363 {
364 return disabled_;
365 }
366
367protected:
377 void check_connection_( Node& dummy_target,
378 Node& source,
379 Node& target,
380 const synindex syn_id,
381 const size_t receptor_type );
382
383 targetidentifierT target_;
385 bool disabled_ : 1;
386 DelayTypeT delay_;
387 // There are still 14 bits to spare here. If more bits are required, the sizes of the delays in the delay struct could
388 // be reduced even more as well.
389};
390
391// Make sure the Connection template instances are as compact as possible
400
401template < typename targetidentifierT, typename DelayTypeT >
403
404template < typename targetidentifierT, typename DelayTypeT >
405inline void
407 Node& source,
408 Node& target,
409 const synindex syn_id,
410 const size_t receptor_type )
411{
412 // 1. does this connection support the event type sent by source try to send event from source to dummy_target this
413 // line might throw an exception
414 source.send_test_event( dummy_target, receptor_type, syn_id, true );
415
416 // 2. does the target accept the event type sent by source try to send event from source to target
417 // this returns the port of the incoming connection p must be stored in the base class connection
418 // this line might throw an exception
419 target_.set_rport( source.send_test_event( target, receptor_type, syn_id, false ) );
420
421 // 3. do the events sent by source mean the same thing as they are interpreted in target?
422 // note that we here use a bitwise and operation (&), because we interpret
423 // each bit in the signal type as a collection of individual flags
424 if ( not( source.sends_signal() & target.receives_signal() ) )
425 {
426 throw IllegalConnection( "Source and target neuron are not compatible (e.g., spiking vs binary neuron)." );
427 }
428
429 target_.set_target( &target );
430}
431
432template < typename targetidentifierT, typename DelayTypeT >
433inline void
435{
436 delay_.get_status( d );
437 target_.get_status( d );
438}
439
440template < typename targetidentifierT, typename DelayTypeT >
441inline void
443{
444 delay_.set_status( d, cm );
445 // no call to target_.set_status() because target and rport cannot be changed
446}
447
448template < typename targetidentifierT, typename DelayTypeT >
449inline void
453
454template < typename targetidentifierT, typename DelayTypeT >
455inline void
460
461template < typename targetidentifierT, typename DelayTypeT >
462inline void
465 const double,
466 const double,
468{
469 throw IllegalConnection( "Connection does not support correction in case of STDP with predominantly axonal delays." );
470}
471
472template < typename targetidentifierT, typename DelayTypeT >
473inline void
475 const std::vector< spikecounter >&,
476 const double,
478{
479 throw IllegalConnection( "Connection does not support updates that are triggered by a volume transmitter." );
480}
481
482template < typename targetidentifierT, typename DelayTypeT >
483std::unique_ptr< SecondaryEvent >
485{
486 assert( false and "Non-primary connections have to provide get_secondary_event()" );
487 return nullptr;
488}
489
490} // namespace nest
491
492#endif /* CONNECTION_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
Base class for dummy nodes used in connection testing.
Definition connection.h:70
void update(const Time &, long, long) override
Advance the state of the node in time through the given interval.
Definition connection.h:76
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition connection.h:72
void init_buffers_() override
Configure persistent internal data structures.
Definition connection.h:92
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition connection.h:84
void init_state_() override
Configure state variables depending on runtime information.
Definition connection.h:88
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition connection.h:80
Base class for representing connections.
Definition connection.h:113
double get_delay_ms() const
Return the delay of the connection in ms.
Definition connection.h:262
bool source_has_more_targets() const
Returns a flag denoting whether the connection has source subsequent targets.
Definition connection.h:340
void set_delay_ms(const double d)
Set the delay of the connection.
Definition connection.h:280
void set_axonal_delay_ms(const double d)
Set the proportion of the transmission delay attributed to the axon.
Definition connection.h:226
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition connection.h:434
void set_dendritic_delay_ms(const double d)
Set the proportion of the transmission delay attributed to the dendrite.
Definition connection.h:208
static constexpr bool supports_flush_event
Definition connection.h:122
void correct_weight_stdp_ax_delay(const size_t tid, CorrectionEntrySTDPAxDelay &entry, const double t_spike_critical_interval_end, const double t_post_spike, const CommonSynapseProperties &)
Framework for STDP with predominantly axonal delays: Correct this synapse and the corresponding previ...
Definition connection.h:463
size_t get_rport() const
Definition connection.h:316
void set_delay_steps(const long d)
Set the delay of the connection in steps.
Definition connection.h:289
long get_delay_steps() const
Return the delay of the connection in steps.
Definition connection.h:271
void trigger_update_weight(const size_t, const std::vector< spikecounter > &, const double, const CommonSynapseProperties &)
Triggers an update of a synaptic weight.
Definition connection.h:474
void set_source_has_more_targets(const bool more_targets)
Sets a flag in the connection to signal that the following connection has the same source.
Definition connection.h:328
TotalDelay delay_
Definition connection.h:386
Connection(const Connection< targetidentifierT, DelayTypeT > &rhs)=default
void disable()
Disables the synapse.
Definition connection.h:351
Connection & operator=(const Connection< targetidentifierT, DelayTypeT > &rhs)=default
double get_axonal_delay_ms() const
Get the proportion of the transmission delay attributed to the axon.
Definition connection.h:235
long get_label() const
Definition connection.h:295
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition connection.h:442
void calibrate(const TimeConverter &)
Calibrate the delay of this connection to the desired resolution.
Definition connection.h:456
void set_dendritic_delay_steps(const long d)
Set the proportion of the transmission delay attributed to the dendrite.
Definition connection.h:217
void check_synapse_params(const Dictionary &d) const
Check syn_spec dictionary for parameters that are not allowed with the given connection.
Definition connection.h:450
static constexpr ConnectionModelProperties properties
Definition connection.h:119
long get_dendritic_delay_steps() const
Return the proportion of the transmission delay attributed to the dendrite.
Definition connection.h:199
static constexpr bool requires_axonal_delay_correction
Definition connection.h:116
Connection()
Definition connection.h:124
Node * get_target(const size_t tid) const
Definition connection.h:311
void set_axonal_delay_steps(const long d)
Set the proportion of the transmission delay attributed to the axon.
Definition connection.h:244
double get_axonal_delay_steps() const
Get the proportion of the transmission delay attributed to the axon.
Definition connection.h:253
double get_dendritic_delay_ms() const
Return the proportion of the transmission delay attributed to the dendrite.
Definition connection.h:190
bool disabled_
Definition connection.h:385
bool more_targets_
Definition connection.h:384
bool is_disabled() const
Returns a flag denoting if the synapse is disabled.
Definition connection.h:362
targetidentifierT target_
Definition connection.h:383
std::unique_ptr< SecondaryEvent > get_secondary_event()
Get a pointer to an instance of a SecondaryEvent if this connection supports secondary events.
Definition connection.h:484
void check_connection_(Node &dummy_target, Node &source, Node &target, const synindex syn_id, 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:406
Definition connector_model.h:69
Information on a received pre-synaptic spike which is buffered by an AxonalDelayArchivingNode,...
Definition axonal_delay_archiving_node.h:46
To be thrown if a connection is not possible.
Definition exceptions.h:490
Base class for all NEST network objects.
Definition node.h:99
Node()
Definition node.cpp:36
Class to convert times from one representation to another.
Definition nest_timeconverter.h:42
Definition nest_time.h:135
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
StaticAssert< sizeof(Connection< TargetIdentifierPtrRport, TotalDelay >)==24 >::success success_connection_target_ptr_size
Definition connection.h:392
StaticAssert< sizeof(Connection< TargetIdentifierIndex, TotalDelay >)==8 >::success success_connection_target_idx_size
Definition connection.h:394
static const long UNLABELED_CONNECTION
Connections are unlabeled by default.
Definition connection_label.h:38
ConnectionModelProperties
Definition connector_model.h:49
@ NONE
Definition connector_model.h:50
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:121
Declarations for base class Node.
Compile time assertions.
Definition static_assert.h:47