23#ifndef CONNECTOR_BASE_H
24#define CONNECTOR_BASE_H
81 virtual size_t size()
const = 0;
101 const size_t target_node_id,
104 const long synapse_label,
105 std::deque< ConnectionID >& conns )
const = 0;
118 const long synapse_label,
119 std::deque< ConnectionID >& conns )
const = 0;
127 const size_t target_node_id,
129 const long synapse_label,
130 std::deque< ConnectionID >& conns )
const = 0;
137 get_source_lcids(
const size_t tid,
const size_t target_node_id, std::vector< size_t >& source_lcids )
const = 0;
144 const size_t start_lcid,
145 const std::string& post_synaptic_element,
146 std::vector< size_t >& target_node_ids )
const = 0;
156 virtual void send_to_all(
const size_t tid,
const std::vector< ConnectorModel* >& cm,
Event& e ) = 0;
163 virtual size_t send(
const size_t tid,
const size_t lcid,
const std::vector< ConnectorModel* >& cm,
Event& e ) = 0;
173 const std::vector< spikecounter >& dopa_spikes,
175 const std::vector< ConnectorModel* >& cm ) = 0;
193 virtual size_t find_first_target(
const size_t tid,
const size_t start_lcid,
const size_t target_node_id )
const = 0;
203 const size_t source_node_id,
204 const size_t target_node_id,
222template <
typename ConnectionT >
255 assert( lcid <
C_.
size() );
257 C_[ lcid ].get_status( dict );
261 dict[
names::target ] =
static_cast< long >(
C_[ lcid ].get_target( tid )->get_node_id() );
267 assert( lcid <
C_.
size() );
286 const size_t target_node_id,
289 const long synapse_label,
290 std::deque< ConnectionID >& conns )
const override
292 if ( not
C_[ lcid ].is_disabled() )
296 const size_t current_target_node_id =
C_[ lcid ].get_target( tid )->get_node_id();
297 if ( target_node_id == 0 or target_node_id == current_target_node_id )
310 const long synapse_label,
311 std::deque< ConnectionID >& conns )
const override
313 if ( not
C_[ lcid ].is_disabled() )
317 const size_t current_target_node_id =
C_[ lcid ].get_target( tid )->get_node_id();
318 if ( target->contains( current_target_node_id ) )
328 const size_t target_node_id,
330 const long synapse_label,
331 std::deque< ConnectionID >& conns )
const override
333 for (
size_t lcid = 0; lcid <
C_.
size(); ++lcid )
335 get_connection( source_node_id, target_node_id, tid, lcid, synapse_label, conns );
340 get_source_lcids(
const size_t tid,
const size_t target_node_id, std::vector< size_t >& source_lcids )
const override
342 for (
size_t lcid = 0; lcid <
C_.
size(); ++lcid )
344 const size_t current_target_node_id =
C_[ lcid ].get_target( tid )->get_node_id();
345 if ( current_target_node_id == target_node_id and not
C_[ lcid ].is_disabled() )
354 const size_t start_lcid,
355 const std::string& post_synaptic_element,
356 std::vector< size_t >& target_node_ids )
const override
358 size_t lcid = start_lcid;
361 if (
C_[ lcid ].get_target( tid )->get_synaptic_elements( post_synaptic_element ) != 0.0
362 and not
C_[ lcid ].is_disabled() )
364 target_node_ids.push_back(
C_[ lcid ].get_target( tid )->get_node_id() );
367 if ( not
C_[ lcid ].source_has_more_targets() )
379 return C_[ lcid ].get_target( tid )->get_node_id();
383 send_to_all(
const size_t tid,
const std::vector< ConnectorModel* >& cm,
Event& e )
override
385 if ( not ConnectionT::supports_flush_event and e.is_flush_event() )
392 for (
size_t lcid = 0; lcid <
C_.
size(); ++lcid )
395 assert( not
C_[ lcid ].is_disabled() );
396 C_[ lcid ].send( e, tid, cp );
401 send(
const size_t tid,
const size_t lcid,
const std::vector< ConnectorModel* >& cm,
Event& e )
override
403 if ( not ConnectionT::supports_flush_event and e.is_flush_event() )
408 typename ConnectionT::CommonPropertiesType
const& cp =
411 size_t lcid_offset = 0;
415 assert( lcid + lcid_offset <
C_.
size() );
416 ConnectionT& conn =
C_[ lcid + lcid_offset ];
418 e.set_port( lcid + lcid_offset );
419 if ( not conn.is_disabled() )
422 const bool event_sent = conn.send( e, tid, cp );
428 if ( not conn.source_has_more_targets() )
435 return 1 + lcid_offset;
445 const std::vector< spikecounter >& dopa_spikes,
447 const std::vector< ConnectorModel* >& cm )
override
449 for (
size_t i = 0; i <
C_.
size(); ++i )
452 ->get_common_properties()
456 C_[ i ].trigger_update_weight( tid,
473 C_[ lcid ].set_source_has_more_targets( has_more_targets );
477 find_first_target(
const size_t tid,
const size_t start_lcid,
const size_t target_node_id )
const override
483 size_t lcid = start_lcid;
486 if (
C_[ lcid ].get_target( tid )->get_node_id() == target_node_id and not
C_[ lcid ].is_disabled() )
491 if ( not
C_[ lcid ].source_has_more_targets() )
493 return invalid_index;
503 const size_t source_node_id,
504 const size_t target_node_id,
507 for (
size_t lcid = 0; lcid <
C_.
size(); ++lcid )
509 if ( source_table.
get_node_id( tid, syn_id, lcid ) == source_node_id
510 and
C_[ lcid ].get_target( tid )->get_node_id() == target_node_id and not
C_[ lcid ].is_disabled() )
516 return invalid_index;
522 assert( not
C_[ lcid ].is_disabled() );
523 C_[ lcid ].disable();
529 assert(
C_[ first_disabled_index ].is_disabled() );
Container with a vector-of-vectors structure.
Definition block_vector.h:156
iterator begin()
Returns a read/write iterator that points to the first element in the BlockVector.
Definition block_vector.h:380
void clear()
Erases all the elements.
Definition block_vector.h:442
iterator end()
Returns a read/write iterator that points one past the last element in the BlockVector.
Definition block_vector.h:394
iterator erase(const_iterator, const_iterator)
Remove a range of elements.
Definition block_vector.h:473
size_t size() const
Returns the number of elements in the BlockVector.
Definition block_vector.h:456
void push_back(const value_type_ &value)
Add data to the end of the BlockVector.
Definition block_vector.h:408
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:64
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:70
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 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
Homogeneous connector, contains synapses of one particular type (syn_id_).
Definition connector_base.h:224
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:383
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:265
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:501
void push_back(const ConnectionT &c)
Definition connector_base.h:273
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:306
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:241
void disable_connection(const size_t lcid) override
Disable the transfer of events through the connection at position lcid.
Definition connector_base.h:520
void remove_disabled_connections(const size_t first_disabled_index) override
Remove disabled connections from the connector.
Definition connector_base.h:527
const synindex syn_id_
Definition connector_base.h:227
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:443
size_t size() const override
Return the number of connections in this Connector.
Definition connector_base.h:247
Connector(const synindex syn_id)
Definition connector_base.h:230
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:401
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:353
void push_back(ConnectionT &&c)
Definition connector_base.h:279
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:327
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:477
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:285
void send_weight_event(const size_t tid, const unsigned int lcid, Event &e, const CommonSynapseProperties &cp) override
Definition connector_base_impl.h:39
BlockVector< ConnectionT > C_
Definition connector_base.h:226
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:377
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:253
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:471
~Connector() override
Definition connector_base.h:235
void sort_connections(BlockVector< Source > &sources) override
Sort connections according to source node IDs.
Definition connector_base.h:465
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:340
Encapsulate information sent between nodes.
Definition event.h:103
Definition connector_model.h:152
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
static const long UNLABELED_CONNECTION
Connections are unlabeled by default.
Definition connection_label.h:38
std::shared_ptr< NodeCollection > NodeCollectionPTR
Definition node_collection.h:50
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Declarations for base class Node.