NEST  2.6.0,not_revisioned_source_dir@0
connection_manager.h
Go to the documentation of this file.
1 /*
2  * connection_manager.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_MANAGER_H
24 #define CONNECTION_MANAGER_H
25 
26 #include <vector>
27 #include <limits>
28 
29 #include "nest.h"
30 #include "model.h"
31 #include "dictutils.h"
32 #include "nest_time.h"
33 #include "nest_timeconverter.h"
34 #include "arraydatum.h"
35 #include "sparsetable.h"
36 #include "../models/volume_transmitter.h"
37 #include <cmath>
38 
39 namespace nest
40 {
41  class ConnectorBase;
42  class ConnectorModel;
43  class Network;
44 
50 {
51 
52  typedef google::sparsetable< ConnectorBase* > tSConnector; // for all neurons having targets
53  typedef std::vector< tSConnector > tVSConnector; // for all threads
54 
55 public:
58 
59  void init(Dictionary*);
60  void reset();
61 
67 
72 
76  void get_status(DictionaryDatum& d) const;
77 
78  // aka SetDefaults for synapse models
79  void set_prototype_status(synindex syn_id, const DictionaryDatum& d);
80  // aka GetDefaults for synapse models
82 
83  // aka conndatum GetStatus
85  // aka conndatum SetStatus
86  void set_synapse_status(index gid, synindex syn_id, port p, thread tid, const DictionaryDatum& d);
87 
98 
99  void get_connections(ArrayDatum& connectome, TokenArray const *source, TokenArray const *target, size_t syn_id) const;
100 
101  // aka CopyModel for synapse models
102  synindex copy_synapse_prototype(synindex old_id, std::string new_name);
103 
104  bool has_user_prototypes() const;
105 
106  bool get_user_set_delay_extrema() const;
107 
108  const Time get_min_delay() const;
109  const Time get_max_delay() const;
110 
115  size_t get_num_connections() const;
116 
132  void connect(Node& s, Node& r, index s_gid, thread tid, index syn, double_t d=NAN, double_t w=NAN);
133  void connect(Node& s, Node& r, index s_gid, thread tid, index syn, DictionaryDatum& p, double_t d=NAN, double_t w=NAN);
134 
135 
139  bool connect(ArrayDatum &d);
140 
141  void trigger_update_weight(const long_t vt_gid, const vector<spikecounter>& dopa_spikes, const double_t t_trig);
142 
143  void send(thread t, index sgid, Event& e);
144 
153  void calibrate(const TimeConverter &);
154 
155 private:
156 
157  std::vector<ConnectorModel*> pristine_prototypes_;
158  std::vector < std::vector<ConnectorModel*> > prototypes_;
159 
162 
172 
173  mutable size_t num_connections_;
174 
175  void init_();
176  void delete_connections_();
177  void clear_prototypes_();
178 
180 
185  const ConnectorModel& get_synapse_prototype(synindex syn_id, thread t=0) const;
186 
191  void assert_valid_syn_id(synindex syn_id, thread t=0) const;
192 
193 };
194 
195 inline
197 {
198  assert_valid_syn_id(syn_id);
199  return *(prototypes_[t][syn_id]);
200 }
201 
202 inline
204 {
205  if (syn_id >= prototypes_[t].size() || prototypes_[t][syn_id] == 0)
206  throw UnknownSynapseType(syn_id);
207 }
208 
209 inline
211 {
212  return prototypes_[0].size() > pristine_prototypes_.size();
213 }
214 
215 
216 } // namespace
217 
218 
219 
220 
221 #endif /* #ifndef CONNECTION_MANAGER_H */
size_t index
Unsigned long type for enumerations.
Definition: nest.h:109
void send(thread t, index sgid, Event &e)
size_t num_connections_
The global counter for the number of synapses.
Definition: connection_manager.h:173
synindex register_synapse_prototype(ConnectorModel *cf)
Register a synapse type.
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Definition: connector_base.h:88
void get_status(DictionaryDatum &d) const
Add ConnectionManager specific stuff to the root status dictionary.
Encapsulates information which is sent between Nodes.
Definition: event.h:73
void calibrate(const TimeConverter &)
Resize the structures for the Connector objects if necessary.
Network & net_
The reference to the network.
Definition: connection_manager.h:160
DictionaryDatum get_synapse_status(index gid, synindex syn_id, port p, thread tid)
std::vector< tSConnector > tVSConnector
Definition: connection_manager.h:53
bool get_user_set_delay_extrema() const
Dictionary * synapsedict_
The synapsedict (owned by the network)
Definition: connection_manager.h:161
std::vector< std::vector< ConnectorModel * > > prototypes_
The list of available synapse prototypes: first dimenasion one entry per thread, second dimantion for...
Definition: connection_manager.h:158
synindex copy_synapse_prototype(synindex old_id, std::string new_name)
Definition: tokenarray.h:62
google::sparsetable< ConnectorBase * > tSConnector
Definition: connection_manager.h:52
void connect(Node &s, Node &r, index s_gid, thread tid, index syn, double_t d=NAN, double_t w=NAN)
Connect is used to establish a connection between a sender and receiving node.
A class that associates names and tokens.
Definition: dict.h:45
const Name w("w")
Specific to Brette & Gerstner 2005 (aeif_cond-*)
Definition: nest_names.h:343
ConnectorBase * validate_source_entry(thread tid, index s_gid, synindex syn_id)
void trigger_update_weight(const long_t vt_gid, const vector< spikecounter > &dopa_spikes, const double_t t_trig)
Manages the available connection prototypes and connections.
Definition: connection_manager.h:49
Definition: nest_time.h:130
void set_synapse_status(index gid, synindex syn_id, port p, thread tid, const DictionaryDatum &d)
const Name source("source")
Connection parameters.
Definition: nest_names.h:260
const ConnectorModel & get_synapse_prototype(synindex syn_id, thread t=0) const
Return pointer to protoype for given synapse id.
Definition: connection_manager.h:196
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
const Time get_max_delay() const
void assert_valid_syn_id(synindex syn_id, thread t=0) const
Asserts validity of synapse index, otherwise throws exception.
Definition: connection_manager.h:203
Main administrative interface to the network.
Definition: network.h:135
Class to convert times from one representation to another.
Definition: nest_timeconverter.h:45
ConnectionManager(Network &net)
void set_prototype_status(synindex syn_id, const DictionaryDatum &d)
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
ArrayDatum get_connections(DictionaryDatum params) const
Return connections between pairs of neurons.
bool synapse_prototype_in_use(synindex syn_id)
Checks, whether connections of the given type were created.
double double_t
Double precision floating point numbers.
Definition: nest.h:93
tVSConnector connections_
A 3-dim structure to hold the Connector objects which in turn hold the connection information...
Definition: connection_manager.h:171
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
DictionaryDatum get_prototype_status(synindex syn_id) const
Default types used by the NEST kernel.
size_t get_num_connections() const
Make sure that the connection counters are up-to-date and return the total number of connections in t...
std::vector< ConnectorModel * > pristine_prototypes_
The list of clean synapse prototypes.
Definition: connection_manager.h:157
Base class for all NEST network objects.
Definition: node.h:96
const Time get_min_delay() const
const Name p("p")
current release probability (Tsodyks2_connection)
Definition: nest_names.h:218
Definition: connector_model.h:38
bool has_user_prototypes() const
Definition: connection_manager.h:210
int_t thread
Thread index type.
Definition: nest.h:133
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
const double e
Definition: numerics.cpp:62
Exception to be thrown if the specified Synapse type does not exist.
Definition: exceptions.h:144
void init(Dictionary *)