NEST  2.6.0,not_revisioned_source_dir@0
network.h
Go to the documentation of this file.
1 /*
2  * network.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 NETWORK_H
24 #define NETWORK_H
25 #include "config.h"
26 #include <vector>
27 #include <string>
28 #include <typeinfo>
29 #include "nest.h"
30 #include "model.h"
31 #include "scheduler.h"
32 #include "exceptions.h"
33 #include "proxynode.h"
34 #include "connection_manager.h"
35 #include "event.h"
36 #include "modelrangemanager.h"
37 #include "compose.hpp"
38 #include "dictdatum.h"
39 #include <ostream>
40 #include <cmath>
41 
42 #include "dirent.h"
43 #include "errno.h"
44 
45 #include "sparse_node_array.h"
46 
47 #ifdef M_ERROR
48 #undef M_ERROR
49 #endif
50 
51 #ifdef _OPENMP
52 #include <omp.h>
53 #endif
54 
55 #ifdef HAVE_MUSIC
56 #include "music_event_handler.h"
57 #endif
58 
63 class TokenArray;
64 class SLIInterpreter;
65 
66 namespace nest
67 {
68  class Subnet;
69  class SiblingContainer;
70  class Event;
71  class Node;
72  class GenericConnBuilderFactory;
73  class GIDCollection;
74 
98 /* BeginDocumentation
99 Name: kernel - Global properties of the simulation kernel.
100 
101 Description:
102 (start here.)
103 
104 Parameters:
105  The following parameters can be set in the status dictionary.
106 
107  communicate_allgather booltype - Whether to use MPI_Allgather for communication (otherwise use CPEX)
108  data_path stringtype - A path, where all data is written to (default is the current directory)
109  data_prefix stringtype - A common prefix for all data files
110  dict_miss_is_error booltype - Whether missed dictionary entries are treated as errors
111  local_num_threads integertype - The local number of threads (cf. global_num_virt_procs)
112  max_delay doubletype - The maximum delay in the network
113  min_delay doubletype - The minimum delay in the network
114  ms_per_tic doubletype - The number of miliseconds per tic (cf. tics_per_ms, tics_per_step)
115  network_size integertype - The number of nodes in the network
116  num_connections integertype - The number of connections in the network
117  num_processes integertype - The number of MPI processes
118  num_rec_processes integertype - The number of MPI processes reserved for recording spikes
119  num_sim_processes integertype - The number of MPI processes reserved for simulating neurons
120  off_grid_spiking booltype - Whether to transmit precise spike times in MPI communicatio
121  overwrite_files booltype - Whether to overwrite existing data files
122  print_time booltype - Whether to print progress information during the simulation
123  resolution doubletype - The resolution of the simulation (in ms)
124  rng_buffsize integertype - The buffer size of the random number generators
125  tics_per_ms doubletype - The number of tics per milisecond (cf. ms_per_tic, tics_per_step)
126  tics_per_step integertype - The number of tics per simulation time step (cf. ms_per_tic, tics_per_ms)
127  time doubletype - The current simulation time
128  total_num_virtual_procs integertype - The total number of virtual processes (cf. local_num_threads)
129  to_do integertype - The number of steps yet to be simulated
130  T_max doubletype - The largest representable time value
131  T_min doubletype - The smallest representable time value
132 SeeAlso: Simulate, Node
133 */
134 
135  class Network
136  {
137  friend class Scheduler;
138 
139  public:
140 
142  ~Network();
143 
148  void reset();
149 
154  void reset_kernel();
155 
159  void reset_network();
160 
169  void register_basis_model(Model& m, bool private_model = false);
170 
180  index register_model(Model& m, bool private_model = false);
181 
185  void unregister_model(index m_id);
186 
191  void try_unregister_model(index m_id);
192 
203  index copy_model(index old_id, std::string new_name);
204 
209 
214  int copy_synapse_prototype(index sc, std::string);
215 
219  template <typename ConnBuilder>
220  void register_conn_builder(const std::string& name);
221 
225  int get_model_id(const char []) const;
226 
230  Model * get_model(index) const;
231 
236 
241 
246  const modelrange& get_contiguous_gid_range(index gid) const;
247 
257  index add_node(index m, long_t n = 1);
258 
271  void restore_nodes(ArrayDatum &);
272 
277  void init_state(index);
278 
283  index size() const;
284 
303  index syn, double_t d=NAN, double_t w=NAN);
304 
324  index syn, DictionaryDatum& params, double_t d=NAN, double_t w=NAN);
325 
337  bool connect(index s, index r, DictionaryDatum& params, index syn);
338 
339  void subnet_connect(Subnet &, Subnet &, int, index syn);
340 
344  void connect(ArrayDatum& connectome);
345 
346  void divergent_connect(index s, const TokenArray r, const TokenArray weights, const TokenArray delays, index syn);
353 
354  void random_divergent_connect(index s, const TokenArray r, index n, const TokenArray w, const TokenArray d, bool, bool, index syn);
355 
356  void convergent_connect(const TokenArray s, index r, const TokenArray weights, const TokenArray delays, index syn);
357 
362  void convergent_connect(const std::vector<index> &s_id, index r, const TokenArray &weight, const TokenArray &delays, index syn);
363 
364  void random_convergent_connect(const TokenArray s, index t, index n, const TokenArray w, const TokenArray d, bool, bool, index syn);
365 
371 
375  void connect(const GIDCollection&, const GIDCollection&,
376  const DictionaryDatum&, const DictionaryDatum&);
377 
380 
382  void set_synapse_status(index gid, index syn, port p, thread tid, DictionaryDatum& d);
383 
385 
386  Subnet * get_root() const;
387  Subnet * get_cwn() const;
388 
394  void go_to(index);
395 
396  void simulate(Time const &);
400  void resume();
401 
405  void terminate();
406 
410  bool quit_by_error() const;
411 
416  int get_exitcode() const;
417 
418  void memory_info();
419 
420  void print(index, int);
421 
427  void trigger_update_weight(const long_t vt_gid, const vector<spikecounter>& dopa_spikes, const double_t t_trig);
428 
439  template <class EventT>
440  void send(Node& source, EventT& e, const long_t lag = 0);
441 
445  void send_local(thread t, Node& source, Event& e);
446 
452  void send_to_node(Event& e);
453 
457  delay get_min_delay() const;
458 
462  delay get_max_delay() const;
463 
467  Time const& get_slice_origin() const;
468 
473 
478  Time const get_time() const;
479 
486  librandom::RngPtr get_rng(thread thrd = 0) const;
487 
492  librandom::RngPtr get_grng() const;
493 
498  thread get_num_threads() const;
499 
503  thread suggest_vp(index) const;
504 
508  thread suggest_rec_vp(index) const;
509 
513  thread vp_to_thread(thread vp) const;
514 
518  thread thread_to_vp(thread t) const;
519 
523  thread get_num_processes() const;
524 
529 
534 
538  void set_num_rec_processes(int nrp);
539 
543  bool is_local_node(Node*) const;
544 
548  bool is_local_gid(index gid) const;
549 
553  bool is_local_vp(thread) const;
554 
558  bool get_simulated() const;
559 
574  Node* get_node(index, thread thr = 0);
575 
585 
591  bool model_in_use(index i);
592 
598  const std::string& get_data_prefix() const;
599 
605  const std::string& get_data_path() const;
606 
611  bool overwrite_files() const;
612 
617  bool get_off_grid_communication() const;
618 
625  void set_status(index, const DictionaryDatum&);
626 
632 
637 
641  const Dictionary &get_modeldict();
642 
646  const Dictionary &get_synapsedict() const;
647 
651  void calibrate_clock();
652 
660  size_t write_toggle() const;
661 
669  size_t read_toggle() const;
670 
674  bool has_user_models() const;
675 
680 
692  void message(int level, const char from[], const char text[]);
693  void message(int level, const std::string& loc, const std::string& msg);
694 
698  bool dict_miss_is_error() const;
699 
700 #ifdef HAVE_MUSIC
701  public:
707  void register_music_in_port(std::string portname);
708 
715  void unregister_music_in_port(std::string portname);
716 
723  void register_music_event_in_proxy(std::string portname, int channel, nest::Node *mp);
724 
728  void set_music_in_port_acceptable_latency(std::string portname, double_t latency);
729  void set_music_in_port_max_buffered(std::string portname, int_t maxbuffered);
733  struct MusicPortData {
734  MusicPortData (size_t n, double_t latency, int_t m)
735  : n_input_proxies (n), acceptable_latency (latency), max_buffered (m)
736  { }
738  size_t n_input_proxies; // Counter for number of music_input proxies
739  // connected to this port
742  };
743 
750  std::map< std::string, MusicPortData > music_in_portlist_;
751 
756  std::map< std::string, MusicEventHandler > music_in_portmap_;
757 
763 
768  void update_music_event_handlers_(Time const &, const long_t, const long_t);
769 #endif
770 
776  int get_thread_id() const;
777 
780 
782 
783  private:
789  void init_();
790  void destruct_nodes_();
791  void clear_models_(bool called_from_destructor=false);
792 
801  void set_status_single_node_(Node&, const DictionaryDatum&, bool clear_flags = true);
802 
805 
810 
813 
814  /* BeginDocumentation
815  Name: synapsedict - Dictionary containing all synapse models.
816  Description:
817  'synapsedict info' shows the contents of the dictionary
818  FirstVersion: October 2005
819  Author: Jochen Martin Eppler
820  SeeAlso: info
821  */
823 
824  /* BeginDocumentation
825  Name: modeldict - dictionary containing all devices and models of NEST
826  Description:
827  'modeldict info' shows the contents of the dictionary
828  SeeAlso: info, Device, RecordingDevice, iaf_neuron, subnet
829  */
831 
832  /* BeginDocumentation
833  Name: connruledict - dictionary containing all connectivity rules
834  Description:
835  This dictionary provides the connection rules that can be used
836  in Connect.
837  'connruledict info' shows the contents of the dictionary.
838  SeeAlso: Connect
839  */
841 
843 
844  std::string data_path_;
845  std::string data_prefix_;
847 
854  std::vector< std::pair<Model *, bool> > pristine_models_;
855 
856  std::vector<Model *> models_;
857  std::vector< std::vector<Node*> > proxy_nodes_;
858  std::vector<Node*> dummy_spike_sources_;
859 
860  std::vector<GenericConnBuilderFactory*> connbuilder_factories_;
861 
863 
865 
867  };
868 
869  inline
871  {
873  }
874 
875  inline
877  {
878  Token t = interpreter_.baselookup(Name("systemdict"));
879  DictionaryDatum systemdict = getValue<DictionaryDatum>(t);
880  t = systemdict->lookup(Name("errordict"));
881  DictionaryDatum errordict = getValue<DictionaryDatum>(t);
882  return getValue<bool>(errordict, "quitbyerror");
883  }
884 
885  inline
887  {
888  Token t = interpreter_.baselookup(Name("statusdict"));
889  DictionaryDatum statusdict = getValue<DictionaryDatum>(t);
890  return getValue<long>(statusdict, "exitcode");
891  }
892 
893  inline
895  {
896  return local_nodes_.get_max_gid() + 1;
897  }
898 
899  inline
901  {
902  return scheduler_.thread_lid_to_node(t, thread_local_id);
903  }
904 
905  inline
906  void Network::connect(ArrayDatum &connectome)
907  {
908  connection_manager_.connect(connectome);
909  }
910 
911  inline
913  {
914  return connection_manager_.get_synapse_status(gid, syn, p, tid);
915  }
916 
917  inline
919  {
920  connection_manager_.set_synapse_status(gid, syn, p, tid, d);
921  }
922 
923  inline
925  {
926  return connection_manager_.get_connections(params);
927  }
928 
929  inline
931  {
933  }
934 
935  inline
937  {
939  }
940 
941  inline
943  {
945  }
946 
947  inline
948  int Network::copy_synapse_prototype(index sc, std::string name)
949  {
951  }
952 
953  inline
955  {
956  return scheduler_.get_slice_origin();
957  }
958 
959  inline
961  {
963  }
964 
965  inline
966  Time const Network::get_time() const
967  {
968  return scheduler_.get_time();
969  }
970 
971  inline
973  {
974  return root_;
975  }
976 
977  inline
979  {
980  return current_;
981  }
982 
983  inline
985  {
986  return scheduler_.get_num_threads();
987  }
988 
989  inline
991  {
992  return scheduler_.get_num_processes();
993  }
994 
995  inline
997  {
999  }
1000 
1001  inline
1003  {
1005  }
1006 
1007  inline
1009  {
1011  }
1012 
1013  inline
1015  {
1016  return !(n->is_proxy());
1017  }
1018 
1019  inline
1021  {
1022  return local_nodes_.get_node_by_gid(gid) != 0;
1023  }
1024 
1025  inline
1027  {
1028  return scheduler_.is_local_vp(t);
1029  }
1030 
1031  inline
1033  {
1034  return scheduler_.suggest_vp(gid);
1035  }
1036 
1037  inline
1039  {
1040  return scheduler_.suggest_rec_vp(gid);
1041  }
1042 
1043  inline
1045  {
1046  return scheduler_.vp_to_thread(vp);
1047  }
1048 
1049  inline
1051  {
1052  return scheduler_.thread_to_vp(t);
1053  }
1054 
1055  inline
1057  {
1058  return scheduler_.get_simulated();
1059  }
1060 
1061  inline
1063  {
1064  return scheduler_.get_min_delay();
1065  }
1066 
1067  inline
1069  {
1070  return scheduler_.get_max_delay();
1071  }
1072 
1073  inline
1074  void Network::trigger_update_weight(const long_t vt_gid, const vector<spikecounter>& dopa_spikes, const double_t t_trig)
1075  {
1076  connection_manager_.trigger_update_weight(vt_gid, dopa_spikes, t_trig);
1077  }
1078 
1079  template <class EventT>
1080  inline
1081  void Network::send(Node& source, EventT& e, const long_t lag)
1082  {
1083  e.set_stamp(get_slice_origin() + Time::step(lag + 1));
1084  e.set_sender(source);
1085  thread t = source.get_thread();
1086  index gid = source.get_gid();
1087 
1088  assert(!source.has_proxies());
1089  connection_manager_.send(t, gid, e);
1090  }
1091 
1092  template <>
1093  inline
1094  void Network::send<SpikeEvent>(Node& source, SpikeEvent& e, const long_t lag)
1095  {
1096  e.set_stamp(get_slice_origin() + Time::step(lag + 1));
1097  e.set_sender(source);
1098  thread t = source.get_thread();
1099 
1100  if (source.has_proxies())
1101  {
1102  if ( source.is_off_grid() )
1103  scheduler_.send_offgrid_remote(t, e, lag);
1104  else
1105  scheduler_.send_remote(t, e, lag);
1106  }
1107  else
1108  send_local(t, source, e);
1109  }
1110 
1111  template <>
1112  inline
1113  void Network::send<DSSpikeEvent>(Node& source, DSSpikeEvent& e, const long_t lag)
1114  {
1115  e.set_stamp(get_slice_origin() + Time::step(lag + 1));
1116  e.set_sender(source);
1117  thread t = source.get_thread();
1118 
1119  assert(!source.has_proxies());
1120  send_local(t, source, e);
1121  }
1122 
1123  inline
1125  {
1126  index sgid = source.get_gid();
1127  e.set_sender_gid(sgid);
1128  connection_manager_.send(t, sgid, e);
1129  }
1130 
1131  inline
1133  {
1134  e();
1135  }
1136 
1137  inline
1139  {
1141  }
1142 
1143  inline
1144  size_t Network::write_toggle() const
1145  {
1146  return scheduler_.get_slice() % 2;
1147  }
1148 
1149  inline
1150  size_t Network::read_toggle() const
1151  {
1152  // define in terms of write_toggle() to ensure consistency
1153  return 1 - write_toggle();
1154  }
1155 
1156  inline
1158  {
1159  return scheduler_.get_rng(t);
1160  }
1161 
1162  inline
1164  {
1165  return scheduler_.get_grng();
1166  }
1167 
1168  inline
1170  {
1171  if (m >= models_.size() || models_[m] == 0)
1172  throw UnknownModelID(m);
1173 
1174  return models_[m];
1175  }
1176 
1177  inline
1179  {
1180  return models_[get_model_id_of_gid(gid)];
1181  }
1182 
1183  inline
1185  {
1186  if (not node_model_ids_.is_in_range(gid))
1187  throw UnknownNode(gid);
1188 
1189  return node_model_ids_.get_model_id(gid);
1190  }
1191 
1192  inline
1194  {
1195  return node_model_ids_.get_range(gid);
1196  }
1197 
1198  inline
1199  const std::string& Network::get_data_path() const
1200  {
1201  return data_path_;
1202  }
1203 
1204  inline
1205  const std::string& Network::get_data_prefix() const
1206  {
1207  return data_prefix_;
1208  }
1209 
1210  inline
1212  {
1213  return overwrite_files_;
1214  }
1215 
1216  inline
1218  {
1220  }
1221 
1222  inline
1224  {
1225  assert(modeldict_ != 0);
1226  return *modeldict_;
1227  }
1228 
1229  inline
1231  {
1232  assert(synapsedict_ != 0);
1233  return *synapsedict_;
1234  }
1235 
1236  inline
1238  {
1239  return models_.size() > pristine_models_.size();
1240  }
1241 
1242  inline
1244  {
1245  return dict_miss_is_error_;
1246  }
1247 
1249 
1251  class ModelComp : public std::binary_function<int, int, bool>
1252  {
1253  const std::vector<Model*> &models;
1254 
1255  public:
1256  ModelComp(const vector<Model*> &nmodels) : models(nmodels) {}
1257  bool operator()(int a, int b)
1258  {
1259  return models[a]->get_name() < models[b]->get_name();
1260  }
1261  };
1262 
1263  inline
1265  {
1266 #ifdef _OPENMP
1267  return omp_get_thread_num();
1268 #else
1269  return 0;
1270 #endif
1271  }
1272 
1273 } // namespace
1274 
1275 #endif
size_t index
Unsigned long type for enumerations.
Definition: nest.h:109
Subnet * current_
Current working node (for insertion).
Definition: network.h:812
SLIInterpreter & interpreter_
Definition: network.h:806
Definition: modelrangemanager.h:32
std::vector< std::pair< Model *, bool > > pristine_models_
The list of clean models.
Definition: network.h:854
const Dictionary & get_synapsedict() const
Return the synapse dictionary.
Definition: network.h:1230
bool dict_miss_is_error_
whether to throw exception on missed dictionary entries
Definition: network.h:864
SiblingContainer class.
Definition: sibling_container.h:46
double_t weight
Weight of a connection.
Definition: nest.h:170
void send(thread t, index sgid, Event &e)
int int_t
Integer number with at least 16 bit.
Definition: nest.h:95
ConnectionManager connection_manager_
Definition: network.h:809
std::map< std::string, MusicPortData > music_in_portlist_
The mapping between MUSIC input ports identified by portname and the corresponding port variables and...
Definition: network.h:750
Base class for all subnet nodes.
Definition: subnet.h:67
MusicPortData(size_t n, double_t latency, int_t m)
Definition: network.h:734
std::vector< Node * > dummy_spike_sources_
Placeholders for spiking remote nodes, one per thread.
Definition: network.h:858
void random_divergent_connect(index s, const TokenArray r, index n, const TokenArray w, const TokenArray d, bool, bool, index syn)
Definition: network.cpp:1243
void set_status(index, const DictionaryDatum &)
Set properties of a Node.
Definition: network.cpp:704
bool has_user_models() const
Does the network contain copies of models created using CopyModel?
Definition: network.h:1237
index get_gid() const
Return global Network ID.
Definition: node.h:753
Data structure to hold variables and parameters associated with a port.
Definition: network.h:733
synindex register_synapse_prototype(ConnectorModel *cf)
Register a synapse type.
bool is_local_vp(thread) const
Return true, if the given VP is on the local machine.
Definition: network.h:1026
thread get_num_processes() const
Return the number of processes used during simulation.
Definition: scheduler.h:623
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
bool get_simulated() const
See Scheduler::get_simulated()
Definition: network.h:1056
void set_num_rec_processes(int nrp, bool called_by_reset=false)
Set number of recording processes, switches NEST to global spike detection mode.
thread vp_to_thread(thread vp) const
Definition: scheduler.h:690
void go_to(index)
Change current working node.
Definition: network.cpp:611
synindex register_synapse_prototype(ConnectorModel *cf)
Register a synapse prototype at the connection manager.
Definition: network.h:942
"Callback request event" for use in Device.
Definition: event.h:374
index get_model_id_of_gid(index)
Return the Model ID for a given GID.
Definition: network.h:1184
Time const get_time() const
Precise time of simulation.
Definition: scheduler.h:610
thread get_num_threads() const
Return the number of threads used during simulation.
Definition: scheduler.h:617
void print(index, int)
Definition: network.cpp:695
void unregister_music_in_port(std::string portname)
Unregister a MUSIC input port (portname) from the port list.
Definition: network.cpp:1856
thread get_num_rec_processes() const
Get number of recording processes.
Definition: network.h:996
const modelrange & get_contiguous_gid_range(index gid) const
Return the contiguous range of ids of nodes with the same model than the node with the given GID...
Definition: network.h:1193
int execute_sli_protected(DictionaryDatum, Name)
Execute a SLI command in the neuron's namespace.
Definition: network.cpp:1819
void send(Node &source, EventT &e, const long_t lag=0)
Standard routine for sending events.
Definition: network.h:1081
size_t get_slice() const
Get slice number.
Definition: scheduler.h:817
size_t write_toggle() const
Return 0 for even, 1 for odd time slices.
Definition: network.h:1144
thread suggest_rec_vp(index) const
Suggest a VP for a given global recording node ID.
Definition: network.h:1038
Encapsulates information which is sent between Nodes.
Definition: event.h:73
void send_to_node(Event &e)
Send event e directly to its target node.
Definition: network.h:1132
const std::string & get_data_path() const
The path for files written by devices.
Definition: network.h:1199
void terminate()
Definition: scheduler.h:823
Subnet * get_cwn() const
current working node.
Definition: network.h:978
Definition: nest_time.h:230
void init_state(index)
Set the state (observable dynamic variables) of a node to model defaults.
Definition: network.cpp:602
void set_music_in_port_max_buffered(std::string portname, int_t maxbuffered)
Definition: network.cpp:1896
const modelrange & get_range(index gid) const
Definition: modelrangemanager.cpp:99
const Name weights("weights")
Connection parameters.
Definition: nest_names.h:348
void set_sender_gid(index)
Change GID of sending Node.
Definition: event.h:720
DictionaryDatum get_synapse_status(index gid, synindex syn_id, port p, thread tid)
void message(int level, const char from[], const char text[])
Display a message.
Definition: network.cpp:1698
void divergent_connect(index s, const TokenArray r, const TokenArray weights, const TokenArray delays, index syn)
Definition: network.cpp:988
Provide sparse representation of local nodes.
Definition: sparse_node_array.h:52
Represent strings by ints to facilitate fast comparison.
Definition: name.h:53
const Dictionary & get_modeldict()
Return a reference to the model dictionary.
Definition: network.h:1223
SparseNodeArray local_nodes_
The network as sparse array of local nodes.
Definition: network.h:807
virtual bool has_proxies() const
Returns true if the node has proxies on remote threads.
Definition: node.h:711
static delay get_min_delay()
Return minimal connection delay.
Definition: scheduler.h:805
Model * siblingcontainer_model
The model for the SiblingContainer class.
Definition: network.h:842
librandom::RngPtr get_grng() const
Get global random number client.
Definition: network.h:1163
bool overwrite_files_
If true, overwrite existing data files.
Definition: network.h:846
void send_local(thread t, Node &source, Event &e)
Send event e to all targets of node source on thread t.
Definition: network.h:1124
void update_music_event_handlers_(Time const &, const long_t, const long_t)
Call update() for each of the registered MUSIC event handlers to deliver all queued events to the tar...
Definition: network.cpp:1913
Definition: network.h:1251
size_t read_toggle() const
Return 1 - write_toggle().
Definition: network.h:1150
synindex copy_synapse_prototype(synindex old_id, std::string new_name)
thread get_num_processes() const
Get number of processes.
Definition: network.h:990
delay get_max_delay() const
Return maximal connection delay.
Definition: network.h:1068
Definition: tokenarray.h:62
thread suggest_vp(index) const
Suggest a VP for a given global node ID.
Definition: network.h:1032
const Name a("a")
Specific to Brette & Gerstner 2005 (aeif_cond-*)
Definition: nest_names.h:41
thread vp_to_thread(thread vp) const
Convert a given VP ID to the corresponding thread ID.
Definition: network.h:1044
bool quit_by_error() const
Return true if NEST will be quit because of an error, false otherwise.
Definition: network.h:876
std::map< std::string, MusicEventHandler > music_in_portmap_
The mapping between MUSIC input ports identified by portname and the corresponding MUSIC event handle...
Definition: network.h:756
void trigger_update_weight(const long_t vt_gid, const vector< spikecounter > &dopa_spikes, const double_t t_trig)
Triggered by volume transmitter in update.
Definition: network.h:1074
assert(pNet!=0)
void connect(index s, Node *target, thread target_thread, index syn, double_t d=NAN, double_t w=NAN)
Connect two nodes.
Definition: network.cpp:867
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.
Time const & get_slice_origin() const
Time at beginning of current slice.
Definition: scheduler.h:598
index get_max_gid() const
Return largest GID in global network.
Definition: sparse_node_array.h:168
Subnet * root_
Root node.
Definition: network.h:811
Dictionary * connruledict_
Dictionary for connection rules.
Definition: network.h:840
void subnet_connect(Subnet &, Subnet &, int, index syn)
void register_conn_builder(const std::string &name)
Add a connectivity rule, i.e.
Definition: network_impl.h:31
const Name delays("delays")
Connection parameters.
Definition: nest_names.h:93
int get_exitcode() const
Return the exitcode that would be returned to the calling shell if NEST would quit now...
Definition: network.h:886
~Network()
Definition: network.cpp:95
ArrayDatum get_connections(DictionaryDatum dict)
Definition: network.h:924
A class that associates names and tokens.
Definition: dict.h:45
size_t n_input_proxies
Definition: network.h:738
const Name w("w")
Specific to Brette & Gerstner 2005 (aeif_cond-*)
Definition: nest_names.h:343
thread get_num_rec_processes() const
Definition: scheduler.h:629
void set_model_defaults_modified()
Definition: network.h:778
Time get_previous_slice_origin() const
Get the time at the beginning of the previous time slice.
Definition: network.h:960
void terminate()
Terminate the simulation after the time-slice is finished.
Definition: network.h:870
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
std::vector< GenericConnBuilderFactory * > connbuilder_factories_
Definition: network.h:860
int_t max_buffered
Definition: network.h:741
Definition: nest_time.h:130
void set_synapse_status(index gid, synindex syn_id, port p, thread tid, const DictionaryDatum &d)
bool get_off_grid_communication() const
return current communication style.
Definition: scheduler.h:728
int get_thread_id() const
Gets ID of local thread.
Definition: network.h:1264
unsigned short targetindex
Unsigned short type for compact target representation.
Definition: nest.h:123
ModelComp(const vector< Model * > &nmodels)
Definition: network.h:1256
Exception to be thrown if a model with the the specified ID does not exist.
Definition: exceptions.h:109
Subnet * get_root() const
return root subnet.
Definition: network.h:972
Time const get_time() const
Get the current simulation time.
Definition: network.h:966
void set_num_rec_processes(int nrp)
Set number of recording processes.
Definition: network.h:1008
bool getValue< bool >(const Token &t)
Definition: tokenutils.cc:124
std::string data_prefix_
Prefix for all files written by devices.
Definition: network.h:845
void ensure_valid_thread_local_ids()
Ensure that all nodes in the network have valid thread-local IDs.
Definition: network.h:679
void set_synapse_status(index gid, index syn, port p, thread tid, DictionaryDatum &d)
Definition: network.h:918
Definition: gid_collection.h:37
void set_connector_defaults(index sc, DictionaryDatum &d)
Definition: network.h:930
const std::string & get_data_prefix() const
The prefix for files written by devices.
Definition: network.h:1205
std::vector< std::vector< Node * > > proxy_nodes_
Placeholders for remote nodes, one per thread.
Definition: network.h:857
bool is_in_range(index gid) const
Definition: modelrangemanager.h:37
const Name source("source")
Connection parameters.
Definition: nest_names.h:260
void random_convergent_connect(const TokenArray s, index t, index n, const TokenArray w, const TokenArray d, bool, bool, index syn)
Definition: network.cpp:1479
thread get_num_sim_processes() const
Get number of simulating processes.
Definition: network.h:1002
const std::vector< Model * > & models
Definition: network.h:1253
thread suggest_vp(index gid) const
Return a thread number for a given global node id.
Definition: scheduler.h:678
void init_()
Initialize the network data structures.
Definition: network.cpp:107
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
Dictionary * synapsedict_
Dictionary for synapse models.
Definition: network.h:822
Base class for all Models.
Definition: model.h:48
void resume()
Resume the simulation after it was terminated.
Definition: network.cpp:657
librandom::RngPtr get_rng(thread thrd=0) const
Get random number client of a thread.
Definition: network.h:1157
void ensure_valid_thread_local_ids()
Ensure that all nodes in the network have valid thread-local IDs.
Definition: scheduler.h:342
thread get_num_threads() const
Get number of threads.
Definition: network.h:984
index copy_model(index old_id, std::string new_name)
Copy an existing model and register it as a new model.
Definition: network.cpp:1708
Dictionary * modeldict_
Dictionary for models.
Definition: network.h:830
Definition: interpret.h:69
virtual bool is_proxy() const
Returns true if the node is a proxy node.
Definition: node.h:741
Model * get_model_of_gid(index)
Return the Model for a given GID.
Definition: network.h:1178
Node * get_node(index, thread thr=0)
Return pointer of the specified Node.
Definition: network.cpp:619
librandom::RngPtr get_grng() const
Return pointer to global random number generator.
Definition: scheduler.h:741
void convergent_connect(const TokenArray s, index r, const TokenArray weights, const TokenArray delays, index syn)
Definition: network.cpp:1300
const Name vp("vp")
Node parameter.
Definition: nest_names.h:341
Main administrative interface to the network.
Definition: network.h:135
long_t get_model_id(index gid)
Definition: modelrangemanager.cpp:53
thread thread_to_vp(thread t) const
Definition: scheduler.h:703
bool is_local_vp(thread) const
Return true if the thread is on the local machine, false if not.
Definition: scheduler.h:672
const Name thread_local_id("thread_local_id")
Thead-local ID of node, see Kunkel et al 2014, Sec 3.3.2.
Definition: nest_names.h:310
Scheduler scheduler_
Definition: network.h:808
void set_prototype_status(synindex syn_id, const DictionaryDatum &d)
lockPTR< Network > NetPtr
Functor to compare Models by their name.
Definition: network.h:1248
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
void set_music_in_port_acceptable_latency(std::string portname, double_t latency)
Set the acceptable latency (latency) for a music input port (portname).
Definition: network.cpp:1886
const SiblingContainer * get_thread_siblings(index n) const
Return the Subnet that contains the thread siblings.
Definition: network.cpp:636
std::string data_path_
Path for all files written by devices.
Definition: network.h:844
void unregister_model(index m_id)
Unregister a previously registered model.
Definition: network.cpp:1779
ArrayDatum get_connections(DictionaryDatum params) const
Return connections between pairs of neurons.
DictionaryDatum get_synapse_status(index gid, index syn, port p, thread tid)
Definition: network.h:912
bool operator()(int a, int b)
Definition: network.h:1257
Network(SLIInterpreter &)
Definition: network.cpp:55
librandom::RngPtr get_rng(const thread) const
Return pointer to random number generator of the specified thread.
Definition: scheduler.h:734
double double_t
Double precision floating point numbers.
Definition: nest.h:93
Time get_previous_slice_origin() const
Time at beginning of previous slice.
Definition: scheduler.h:604
bool model_defaults_modified_
whether any model defaults have been modified
Definition: network.h:866
int copy_synapse_prototype(index sc, std::string)
Copy an existing synapse type.
Definition: network.h:948
const Name b("b")
Specific to Brette & Gerstner 2005 (aeif_cond-*)
Definition: nest_names.h:58
const Token & baselookup(const Name &n) const
Lookup a name searching only the bottom level dictionary.
Definition: interpret.cc:333
void destruct_nodes_()
Definition: network.cpp:192
void clear_models_(bool called_from_destructor=false)
Definition: network.cpp:214
Definition: modelrange.h:30
bool get_off_grid_communication() const
return current communication style.
Definition: network.h:1217
index add_node(index m, long_t n=1)
Add a number of nodes to the network.
Definition: network.cpp:333
const Name target_thread("target_thread")
Connection parameters.
Definition: nest_names.h:283
thread thread_to_vp(thread t) const
Convert a given thread ID to the corresponding VP ID.
Definition: network.h:1050
static delay get_max_delay()
Return maximal connection delay.
Definition: scheduler.h:811
void reset()
Reset deletes all nodes and reallocates all memory pools for nodes.
Definition: network.cpp:233
DictionaryDatum get_connector_defaults(index sc)
Definition: network.h:936
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
DictionaryDatum get_prototype_status(synindex syn_id) const
thread get_thread() const
Retrieve the number of the thread to which the node is assigned.
Definition: node.h:825
void calibrate_clock()
Calibrate clock after resolution change.
Definition: scheduler.h:747
const Name n("n")
Number of synaptic release sites (int >=0) (Tsodyks2_connection)
Definition: nest_names.h:202
long_t delay
Delay of a connection.
Definition: nest.h:178
void calibrate_clock()
Recalibrate scheduler clock.
Definition: network.h:1138
Default types used by the NEST kernel.
std::vector< Model * > models_
The list of available models.
Definition: network.h:856
void register_music_in_port(std::string portname)
Register a MUSIC input port (portname) with the port list.
Definition: network.cpp:1846
Event for spike information.
Definition: event.h:320
Base class for all NEST network objects.
Definition: node.h:96
Node * thread_lid_to_node(thread t, targetindex thread_local_id) const
Definition: network.h:900
void simulate(Time const &)
Definition: network.cpp:652
void reset_kernel()
Reset number of threads to one, reset device prefix to the empty string and call reset().
Definition: network.cpp:252
long getValue< long >(const Token &t)
Definition: tokenutils.cc:36
bool model_in_use(index i)
Check, if there are instances of a given model.
Definition: network.cpp:647
bool overwrite_files() const
Indicate if existing data files should be overwritten.
Definition: network.h:1211
Model * get_model(index) const
Return the Model for a given model ID.
Definition: network.h:1169
bool get_simulated() const
Return true, if the network has already been simulated for some time.
Definition: scheduler.h:716
A type-independent container for C++-types.
Definition: token.h:68
int get_model_id(const char[]) const
Return the model id for a given model name.
Definition: network.cpp:320
void try_unregister_model(index m_id)
Try unregistering model prototype.
Definition: network.cpp:1806
void register_music_event_in_proxy(std::string portname, int channel, nest::Node *mp)
Register a node (of type music_input_proxy) with a given MUSIC port (portname) and a specific channel...
Definition: network.cpp:1869
void memory_info()
Definition: network.cpp:662
Schedule update of Nodes and Events during simulation.
Definition: scheduler.h:66
bool is_local_gid(index gid) const
Return true, if the given gid is on the local machine.
Definition: network.h:1020
bool is_local_node(Node *) const
Return true, if the given Node is on the local machine.
Definition: network.h:1014
void publish_music_in_ports_()
Publish all MUSIC input ports that were registered using Network::register_music_event_in_proxy().
Definition: network.cpp:1906
delay get_min_delay() const
Return minimal connection delay.
Definition: network.h:1062
void reset_network()
Reset the network to the state at T = 0.
Definition: network.cpp:272
void set_status_single_node_(Node &, const DictionaryDatum &, bool clear_flags=true)
Helper function to set properties on single node.
Definition: network.cpp:776
bool model_defaults_modified() const
Definition: network.h:779
const Name p("p")
current release probability (Tsodyks2_connection)
Definition: nest_names.h:218
Definition: connector_model.h:38
Node * get_node_by_gid(index) const
Lookup node based on GID.
Definition: sparse_node_array.cpp:88
Modelrangemanager node_model_ids_
ConnBuilder factories, indexed by connruledict_ elements.
Definition: network.h:862
Exception to be thrown if the specified Node does not exist.
Definition: exceptions.h:175
int_t thread
Thread index type.
Definition: nest.h:133
MusicPortData()
Definition: network.h:737
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
index size() const
Return total number of network nodes.
Definition: network.h:894
const double e
Definition: numerics.cpp:62
bool dict_miss_is_error() const
Returns true if unread dictionary items should be treated as error.
Definition: network.h:1243
double_t acceptable_latency
Definition: network.h:740
void register_basis_model(Model &m, bool private_model=false)
Registers a fundamental model for use with the network.
Definition: network.cpp:1730
DictionaryDatum get_status(index)
Get properties of a node.
Definition: network.cpp:837
thread get_num_sim_processes() const
Definition: scheduler.h:635
Node * thread_lid_to_node(thread t, targetindex thread_local_id) const
Definition: scheduler.h:762
Time const & get_slice_origin() const
Get the time at the beginning of the current time slice.
Definition: network.h:954
void set_data_path_prefix_(const DictionaryDatum &d)
Helper function to set device data path and prefix.
Definition: network.cpp:796
void restore_nodes(ArrayDatum &)
Restore nodes from an array of status dictionaries.
Definition: network.cpp:567
index register_model(Model &m, bool private_model=false)
Register a built-in model for use with the network.
Definition: network.cpp:1744
thread suggest_rec_vp(index gid) const
Return a thread number for a given global recording node id.
Definition: scheduler.h:684