23#ifndef CONNECTOR_BASE_H
24#define CONNECTOR_BASE_H
82 virtual size_t size()
const = 0;
99 const size_t target_node_id,
102 const long synapse_label,
103 std::deque< ConnectionID >& conns )
const = 0;
116 const long synapse_label,
117 std::deque< ConnectionID >& conns )
const = 0;
124 const size_t target_node_id,
126 const long synapse_label,
127 std::deque< ConnectionID >& conns )
const = 0;
133 get_source_lcids(
const size_t tid,
const size_t target_node_id, std::vector< size_t >& source_lcids )
const = 0;
139 const size_t start_lcid,
140 const std::string& post_synaptic_element,
141 std::vector< size_t >& target_node_ids )
const = 0;
151 virtual void send_to_all(
const size_t tid,
const std::vector< ConnectorModel* >& cm,
Event& e ) = 0;
157 virtual size_t send(
const size_t tid,
const size_t lcid,
const std::vector< ConnectorModel* >& cm,
Event& e ) = 0;
173 const double t_spike_critical_interval_end,
174 const double t_post_spike ) = 0;
184 const std::vector< spikecounter >& dopa_spikes,
186 const std::vector< ConnectorModel* >& cm ) = 0;
202 virtual size_t find_first_target(
const size_t tid,
const size_t start_lcid,
const size_t target_node_id )
const = 0;
212 const size_t source_node_id,
213 const size_t target_node_id,
230template <
typename ConnectionT >
279 assert( lcid <
C_.size() );
281 C_[ lcid ].get_status( dict );
285 dict[
names::target ] =
static_cast< long >(
C_[ lcid ].get_target( tid )->get_node_id() );
291 assert( lcid <
C_.size() );
310 C_.push_back( std::move( c ) );
315 const size_t target_node_id,
318 const long synapse_label,
319 std::deque< ConnectionID >& conns )
const override
321 if ( not
C_[ lcid ].is_disabled() )
325 const size_t current_target_node_id =
C_[ lcid ].get_target( tid )->get_node_id();
326 if ( target_node_id == 0 or target_node_id == current_target_node_id )
328 conns.push_back(
ConnectionID( source_node_id, current_target_node_id, tid,
syn_id_, lcid ) );
339 const long synapse_label,
340 std::deque< ConnectionID >& conns )
const override
342 if ( not
C_[ lcid ].is_disabled() )
346 const size_t current_target_node_id =
C_[ lcid ].get_target( tid )->get_node_id();
347 if ( target->contains( current_target_node_id ) )
349 conns.push_back(
ConnectionID( source_node_id, current_target_node_id, tid,
syn_id_, lcid ) );
357 const size_t target_node_id,
359 const long synapse_label,
360 std::deque< ConnectionID >& conns )
const override
362 for (
size_t lcid = 0; lcid <
C_.size(); ++lcid )
364 get_connection( source_node_id, target_node_id, tid, lcid, synapse_label, conns );
369 get_source_lcids(
const size_t tid,
const size_t target_node_id, std::vector< size_t >& source_lcids )
const override
371 for (
size_t lcid = 0; lcid <
C_.size(); ++lcid )
373 const size_t current_target_node_id =
C_[ lcid ].get_target( tid )->get_node_id();
374 if ( current_target_node_id == target_node_id and not
C_[ lcid ].is_disabled() )
376 source_lcids.push_back( lcid );
383 const size_t start_lcid,
384 const std::string& post_synaptic_element,
385 std::vector< size_t >& target_node_ids )
const override
387 size_t lcid = start_lcid;
390 if (
C_[ lcid ].get_target( tid )->get_synaptic_elements( post_synaptic_element ) != 0.0
391 and not
C_[ lcid ].is_disabled() )
393 target_node_ids.push_back(
C_[ lcid ].get_target( tid )->get_node_id() );
396 if ( not
C_[ lcid ].source_has_more_targets() )
408 return C_[ lcid ].get_target( tid )->get_node_id();
412 send_to_all(
const size_t tid,
const std::vector< ConnectorModel* >& cm,
Event& e )
override
414 if ( not ConnectionT::supports_flush_event and e.is_flush_event() )
421 for (
size_t lcid = 0; lcid <
C_.size(); ++lcid )
424 assert( not
C_[ lcid ].is_disabled() );
425 C_[ lcid ].send( e, tid, cp );
430 send(
const size_t tid,
const size_t lcid,
const std::vector< ConnectorModel* >& cm,
Event& e )
override
432 if ( not ConnectionT::supports_flush_event and e.is_flush_event() )
437 typename ConnectionT::CommonPropertiesType
const& cp =
440 size_t lcid_offset = 0;
444 assert( lcid + lcid_offset <
C_.size() );
445 ConnectionT& conn =
C_[ lcid + lcid_offset ];
447 e.set_port( lcid + lcid_offset );
448 if ( not conn.is_disabled() )
450 if constexpr ( ConnectionT::requires_axonal_delay_correction )
456 e.set_sender_node_id_info( tid,
syn_id_, lcid + lcid_offset );
460 const bool event_sent = conn.send( e, tid, cp );
466 if ( not conn.source_has_more_targets() )
473 return 1 + lcid_offset;
478 const double t_spike_critical_interval_end,
479 const double t_post_spike )
override;
488 const std::vector< spikecounter >& dopa_spikes,
490 const std::vector< ConnectorModel* >& cm )
override
492 for (
size_t i = 0; i <
C_.size(); ++i )
495 ->get_common_properties()
499 C_[ i ].trigger_update_weight( tid,
516 C_[ lcid ].set_source_has_more_targets( has_more_targets );
520 find_first_target(
const size_t tid,
const size_t start_lcid,
const size_t target_node_id )
const override
526 size_t lcid = start_lcid;
529 if (
C_[ lcid ].get_target( tid )->get_node_id() == target_node_id and not
C_[ lcid ].is_disabled() )
534 if ( not
C_[ lcid ].source_has_more_targets() )
536 return invalid_index;
546 const size_t source_node_id,
547 const size_t target_node_id,
550 for (
size_t lcid = 0; lcid <
C_.size(); ++lcid )
552 if ( source_table.
get_node_id( tid, syn_id, lcid ) == source_node_id
553 and
C_[ lcid ].get_target( tid )->get_node_id() == target_node_id and not
C_[ lcid ].is_disabled() )
559 return invalid_index;
565 assert( not
C_[ lcid ].is_disabled() );
566 C_[ lcid ].disable();
572 assert(
C_[ first_disabled_index ].is_disabled() );
573 C_.erase(
C_.begin() + first_disabled_index,
C_.end() );
Container with a vector-of-vectors structure.
Definition block_vector.h:156
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
Definition connection_id.h:33
Base class to allow storing Connectors for different synapse types in vectors.
Definition connector_base.h:66
virtual void trigger_update_weight(const long vt_node_id, const size_t tid, const std::vector< spikecounter > &dopa_spikes, const double t_trig, const std::vector< ConnectorModel * > &cm)=0
Update weights of dopamine modulated STDP connections.
virtual void get_source_lcids(const size_t tid, const size_t target_node_id, std::vector< size_t > &source_lcids) const =0
For a given target_node_id add lcids of all connections with matching node ID of target to source_lci...
virtual void remove_disabled_connections(const size_t first_disabled_index)=0
Remove disabled connections from the connector.
virtual ~ConnectorBase()
Definition connector_base.h:72
virtual synindex get_syn_id() const =0
Return syn_id_ of the synapse type of this Connector (size_t in list of synapse prototypes).
virtual size_t find_enabled_connection(const size_t tid, const size_t syn_id, const size_t source_node_id, const size_t target_node_id, const SourceTable &source_table) const =0
Return lcid of first connection matching source and target node id and that is not disabled.
virtual void sort_connections(BlockVector< Source > &)=0
Sort connections according to source node IDs.
virtual void get_all_connections(const size_t source_node_id, const size_t target_node_id, const size_t tid, const long synapse_label, std::deque< ConnectionID > &conns) const =0
Add ConnectionIDs with given source_node_id to conns, looping over all lcids.
virtual void disable_connection(const size_t lcid)=0
Disable the transfer of events through the connection at position lcid.
virtual size_t send(const size_t tid, const size_t lcid, const std::vector< ConnectorModel * > &cm, Event &e)=0
Send the event e to the connection at position lcid.
virtual void get_connection(const size_t source_node_id, const size_t target_node_id, const size_t tid, const size_t lcid, const long synapse_label, std::deque< ConnectionID > &conns) const =0
Add ConnectionID with given source_node_id and lcid to conns.
virtual void send_weight_event(const size_t tid, const unsigned int lcid, Event &e, const CommonSynapseProperties &cp)=0
virtual void set_synapse_status(const size_t tid, const Dictionary &dict, ConnectorModel &cm)=0
Set status of the connection at position lcid according to the dictionary dict.
virtual size_t size() const =0
Return the number of connections in this Connector.
virtual void get_connection_with_specified_targets(const size_t source_node_id, const NodeCollectionPTR &target, const size_t tid, const size_t lcid, const long synapse_label, std::deque< ConnectionID > &conns) const =0
Add Connections with given source_node_id and lcid to conns.
virtual void get_synapse_status(const size_t tid, const size_t lcid, Dictionary &dict) const =0
Write status of the connection at position lcid to the dictionary dict.
virtual void send_to_all(const size_t tid, const std::vector< ConnectorModel * > &cm, Event &e)=0
Send the event e to all connections of this Connector.
virtual void get_target_node_ids(const size_t tid, const size_t start_lcid, const std::string &post_synaptic_element, std::vector< size_t > &target_node_ids) const =0
For a given start_lcid add node IDs of all targets that belong to the same source to target_node_ids.
virtual void correct_weight_stdp_ax_delay(const size_t tid, CorrectionEntrySTDPAxDelay &entry, const double t_spike_critical_interval_end, const double t_post_spike)=0
On occurrence of a post-synaptic spike, correct the weight update of a previous pre-synaptic spike wh...
virtual void set_source_has_more_targets(const size_t lcid, const bool has_more_targets)=0
Set a flag in the connection indicating whether the following connection belongs to the same source.
virtual size_t get_target_node_id(const size_t tid, const unsigned int lcid) const =0
For a given lcid return the node ID of the target of the connection.
virtual size_t find_first_target(const size_t tid, const size_t start_lcid, const size_t target_node_id) const =0
Return lcid of the first connection after start_lcid (inclusive) where the node_id of the target matc...
Definition connector_model.h:69
void correct_weight_stdp_ax_delay(const size_t tid, CorrectionEntrySTDPAxDelay &entry, const double t_spike_critical_interval_end, const double t_post_spike) override
On occurrence of a post-synaptic spike, correct the weight update of a previous pre-synaptic spike wh...
Definition connector_base_impl.h:82
void send_to_all(const size_t tid, const std::vector< ConnectorModel * > &cm, Event &e) override
Send the event e to all connections of this Connector.
Definition connector_base.h:412
void set_synapse_status(const size_t lcid, const Dictionary &dict, ConnectorModel &cm) override
Set status of the connection at position lcid according to the dictionary dict.
Definition connector_base.h:289
size_t find_enabled_connection(const size_t tid, const size_t syn_id, const size_t source_node_id, const size_t target_node_id, const SourceTable &source_table) const override
Return lcid of first connection matching source and target node id and that is not disabled.
Definition connector_base.h:544
void push_back(const ConnectionT &c)
Definition connector_base.h:300
bool axonal_delay_correction_required_
Whether any connection held here can ever require a retrospective correction.
Definition connector_base.h:244
void get_connection_with_specified_targets(const size_t source_node_id, const NodeCollectionPTR &target, const size_t tid, const size_t lcid, const long synapse_label, std::deque< ConnectionID > &conns) const override
Add Connections with given source_node_id and lcid to conns.
Definition connector_base.h:335
synindex get_syn_id() const override
Return syn_id_ of the synapse type of this Connector (size_t in list of synapse prototypes).
Definition connector_base.h:265
void disable_connection(const size_t lcid) override
Disable the transfer of events through the connection at position lcid.
Definition connector_base.h:563
void remove_disabled_connections(const size_t first_disabled_index) override
Remove disabled connections from the connector.
Definition connector_base.h:570
const synindex syn_id_
Definition connector_base.h:235
void trigger_update_weight(const long vt_node_id, const size_t tid, const std::vector< spikecounter > &dopa_spikes, const double t_trig, const std::vector< ConnectorModel * > &cm) override
Update weights of dopamine modulated STDP connections.
Definition connector_base.h:486
size_t size() const override
Return the number of connections in this Connector.
Definition connector_base.h:271
Connector(const synindex syn_id)
Definition connector_base.h:253
size_t send(const size_t tid, const size_t lcid, const std::vector< ConnectorModel * > &cm, Event &e) override
Send the event e to the connection at position lcid.
Definition connector_base.h:430
void get_target_node_ids(const size_t tid, const size_t start_lcid, const std::string &post_synaptic_element, std::vector< size_t > &target_node_ids) const override
For a given start_lcid add node IDs of all targets that belong to the same source to target_node_ids.
Definition connector_base.h:382
void push_back(ConnectionT &&c)
Definition connector_base.h:307
void get_all_connections(const size_t source_node_id, const size_t target_node_id, const size_t tid, const long synapse_label, std::deque< ConnectionID > &conns) const override
Add ConnectionIDs with given source_node_id to conns, looping over all lcids.
Definition connector_base.h:356
size_t find_first_target(const size_t tid, const size_t start_lcid, const size_t target_node_id) const override
Return lcid of the first connection after start_lcid (inclusive) where the node_id of the target matc...
Definition connector_base.h:520
void get_connection(const size_t source_node_id, const size_t target_node_id, const size_t tid, const size_t lcid, const long synapse_label, std::deque< ConnectionID > &conns) const override
Add ConnectionID with given source_node_id and lcid to conns.
Definition connector_base.h:314
void send_weight_event(const size_t tid, const unsigned int lcid, Event &e, const CommonSynapseProperties &cp) override
Definition connector_base_impl.h:54
BlockVector< ConnectionT > C_
Definition connector_base.h:234
size_t get_target_node_id(const size_t tid, const unsigned int lcid) const override
For a given lcid return the node ID of the target of the connection.
Definition connector_base.h:406
void get_synapse_status(const size_t tid, const size_t lcid, Dictionary &dict) const override
Write status of the connection at position lcid to the dictionary dict.
Definition connector_base.h:277
void set_source_has_more_targets(const size_t lcid, const bool has_more_targets) override
Set a flag in the connection indicating whether the following connection belongs to the same source.
Definition connector_base.h:514
~Connector() override
Definition connector_base.h:259
void sort_connections(BlockVector< Source > &sources) override
Sort connections according to source node IDs.
Definition connector_base.h:508
void register_axonal_delay_correction_required_(const ConnectionT &c)
Fold a newly added or modified connection into axonal_delay_correction_required_ and the kernel-wide ...
Definition connector_base_impl.h:40
void get_source_lcids(const size_t tid, const size_t target_node_id, std::vector< size_t > &source_lcids) const override
For a given target_node_id add lcids of all connections with matching node ID of target to source_lci...
Definition connector_base.h:369
Information on a received pre-synaptic spike which is buffered by an AxonalDelayArchivingNode,...
Definition axonal_delay_archiving_node.h:46
Encapsulate information sent between nodes.
Definition event.h:103
Definition connector_model.h:156
This data structure stores the node IDs of presynaptic neurons during postsynaptic connection creatio...
Definition source_table.h:104
size_t get_node_id(const size_t tid, const synindex syn_id, const size_t lcid) const
Returns the node ID of the source at tid|syn_id|lcid.
Definition source_table.cpp:159
const std::string target("target")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void sort(BlockVector< T1 > &vec_sort, BlockVector< T2 > &vec_perm)
Sorts two vectors according to elements in first vector.
Definition sort.h:177
std::shared_ptr< NodeCollection > NodeCollectionPTR
Definition node_collection.h:50
static const long UNLABELED_CONNECTION
Connections are unlabeled by default.
Definition connection_label.h:38
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:121
Declarations for base class Node.