23#ifndef CONNECTOR_BASE_H
24#define CONNECTOR_BASE_H
80 virtual size_t size()
const = 0;
100 const size_t target_node_id,
103 const long synapse_label,
104 std::deque< ConnectionID >& conns )
const = 0;
112 const std::vector< size_t >& target_neuron_node_ids,
115 const long synapse_label,
116 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;
134 get_source_lcids(
const size_t tid,
const size_t target_node_id, std::vector< size_t >& source_lcids )
const = 0;
141 const size_t start_lcid,
142 const std::string& post_synaptic_element,
143 std::vector< size_t >& target_node_ids )
const = 0;
153 virtual void send_to_all(
const size_t tid,
const std::vector< ConnectorModel* >& cm,
Event& e ) = 0;
160 virtual size_t send(
const size_t tid,
const size_t lcid,
const std::vector< ConnectorModel* >& cm,
Event& e ) = 0;
170 const std::vector< spikecounter >& dopa_spikes,
172 const std::vector< ConnectorModel* >& cm ) = 0;
190 virtual size_t find_first_target(
const size_t tid,
const size_t start_lcid,
const size_t target_node_id )
const = 0;
200 const size_t source_node_id,
201 const size_t target_node_id,
219template <
typename ConnectionT >
252 assert( lcid <
C_.
size() );
254 C_[ lcid ].get_status( dict );
258 dict[
names::target ] =
static_cast< long >(
C_[ lcid ].get_target( tid )->get_node_id() );
264 assert( lcid <
C_.
size() );
283 const size_t target_node_id,
286 const long synapse_label,
287 std::deque< ConnectionID >& conns )
const override
289 if ( not
C_[ lcid ].is_disabled() )
293 const size_t current_target_node_id =
C_[ lcid ].get_target( tid )->get_node_id();
294 if ( current_target_node_id == target_node_id or target_node_id == 0 )
304 const std::vector< size_t >& target_neuron_node_ids,
307 const long synapse_label,
308 std::deque< ConnectionID >& conns )
const override
310 if ( not
C_[ lcid ].is_disabled() )
314 const size_t current_target_node_id =
C_[ lcid ].get_target( tid )->get_node_id();
315 if ( std::find( target_neuron_node_ids.begin(), target_neuron_node_ids.end(), current_target_node_id )
316 != target_neuron_node_ids.end() )
326 const size_t target_node_id,
328 const long synapse_label,
329 std::deque< ConnectionID >& conns )
const override
331 for (
size_t lcid = 0; lcid <
C_.
size(); ++lcid )
333 get_connection( source_node_id, target_node_id, tid, lcid, synapse_label, conns );
338 get_source_lcids(
const size_t tid,
const size_t target_node_id, std::vector< size_t >& source_lcids )
const override
340 for (
size_t lcid = 0; lcid <
C_.
size(); ++lcid )
342 const size_t current_target_node_id =
C_[ lcid ].get_target( tid )->get_node_id();
343 if ( current_target_node_id == target_node_id and not
C_[ lcid ].is_disabled() )
352 const size_t start_lcid,
353 const std::string& post_synaptic_element,
354 std::vector< size_t >& target_node_ids )
const override
356 size_t lcid = start_lcid;
359 if (
C_[ lcid ].get_target( tid )->get_synaptic_elements( post_synaptic_element ) != 0.0
360 and not
C_[ lcid ].is_disabled() )
362 target_node_ids.push_back(
C_[ lcid ].get_target( tid )->get_node_id() );
365 if ( not
C_[ lcid ].source_has_more_targets() )
377 return C_[ lcid ].get_target( tid )->get_node_id();
381 send_to_all(
const size_t tid,
const std::vector< ConnectorModel* >& cm,
Event& e )
override
383 if ( not ConnectionT::supports_flush_event and e.is_flush_event() )
390 for (
size_t lcid = 0; lcid <
C_.
size(); ++lcid )
393 assert( not
C_[ lcid ].is_disabled() );
394 C_[ lcid ].send( e, tid, cp );
399 send(
const size_t tid,
const size_t lcid,
const std::vector< ConnectorModel* >& cm,
Event& e )
override
401 if ( not ConnectionT::supports_flush_event and e.is_flush_event() )
406 typename ConnectionT::CommonPropertiesType
const& cp =
409 size_t lcid_offset = 0;
413 assert( lcid + lcid_offset <
C_.
size() );
414 ConnectionT& conn =
C_[ lcid + lcid_offset ];
416 e.set_port( lcid + lcid_offset );
417 if ( not conn.is_disabled() )
420 const bool event_sent = conn.send( e, tid, cp );
426 if ( not conn.source_has_more_targets() )
433 return 1 + lcid_offset;
443 const std::vector< spikecounter >& dopa_spikes,
445 const std::vector< ConnectorModel* >& cm )
override
447 for (
size_t i = 0; i <
C_.
size(); ++i )
450 ->get_common_properties()
454 C_[ i ].trigger_update_weight( tid,
471 C_[ lcid ].set_source_has_more_targets( has_more_targets );
475 find_first_target(
const size_t tid,
const size_t start_lcid,
const size_t target_node_id )
const override
481 size_t lcid = start_lcid;
484 if (
C_[ lcid ].get_target( tid )->get_node_id() == target_node_id and not
C_[ lcid ].is_disabled() )
489 if ( not
C_[ lcid ].source_has_more_targets() )
491 return invalid_index;
501 const size_t source_node_id,
502 const size_t target_node_id,
505 for (
size_t lcid = 0; lcid <
C_.
size(); ++lcid )
507 if ( source_table.
get_node_id( tid, syn_id, lcid ) == source_node_id
508 and
C_[ lcid ].get_target( tid )->get_node_id() == target_node_id and not
C_[ lcid ].is_disabled() )
514 return invalid_index;
520 assert( not
C_[ lcid ].is_disabled() );
521 C_[ lcid ].disable();
527 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:63
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 void get_connection_with_specified_targets(const size_t source_node_id, const std::vector< size_t > &target_neuron_node_ids, 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 ~ConnectorBase()
Definition connector_base.h:69
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_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:221
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:381
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:262
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:499
void push_back(const ConnectionT &c)
Definition connector_base.h:270
void get_connection_with_specified_targets(const size_t source_node_id, const std::vector< size_t > &target_neuron_node_ids, 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:303
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:238
void disable_connection(const size_t lcid) override
Disable the transfer of events through the connection at position lcid.
Definition connector_base.h:518
void remove_disabled_connections(const size_t first_disabled_index) override
Remove disabled connections from the connector.
Definition connector_base.h:525
const synindex syn_id_
Definition connector_base.h:224
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:441
size_t size() const override
Return the number of connections in this Connector.
Definition connector_base.h:244
Connector(const synindex syn_id)
Definition connector_base.h:227
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:399
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:351
void push_back(ConnectionT &&c)
Definition connector_base.h:276
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:325
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:475
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:282
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:223
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:375
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:250
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:469
~Connector() override
Definition connector_base.h:232
void sort_connections(BlockVector< Source > &sources) override
Sort connections according to source node IDs.
Definition connector_base.h:463
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:338
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
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Declarations for base class Node.