NEST main@f146f75
Loading...
Searching...
No Matches
node.h
Go to the documentation of this file.
1/*
2 * node.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 NODE_H
24#define NODE_H
25
26// C++ includes:
27#include <bitset>
28#include <deque>
29#include <sstream>
30#include <string>
31#include <utility>
32#include <vector>
33
34// Includes from nestkernel:
36#include "deprecation_warning.h"
37#include "event.h"
38#include "histentry.h"
39#include "nest_names.h"
40#include "nest_time.h"
41#include "nest_types.h"
42#include "secondary_event.h"
43
44
48
49namespace nest
50{
51class Model;
52class ArchivingNode;
53class TimeConverter;
54class WeightOptimizer;
55
62
82
97
98class Node
99{
100 friend class NodeManager;
101 friend class ModelManager;
102 friend class proxynode;
103 friend class Model;
104 friend class SimulationManager;
105
106 Node& operator=( const Node& );
107
108public:
109 Node();
110 Node( Node const& );
111 virtual ~Node();
112
117 virtual Node*
118 clone() const
119 {
120 return nullptr;
121 }
122
129 virtual bool has_proxies() const;
130
134 virtual bool supports_urbanczik_archiving() const;
135
140 virtual bool local_receiver() const;
141
149 virtual bool one_node_per_process() const;
150
157 virtual bool is_off_grid() const;
158
164 virtual bool is_proxy() const;
165
173 std::string get_name() const;
174
184 virtual std::string get_element_type() const;
185
195 size_t get_node_id() const;
196
197
206 int get_model_id() const;
207
211 bool is_frozen() const;
212
216 bool node_uses_wfr() const;
217
222 void set_node_uses_wfr( const bool );
223
232 void init();
233
242 virtual void pre_run_hook() = 0;
243
248 virtual void
250 {
251 }
252
261 virtual void
263 {
264 }
265
273 virtual void
275 {
276 }
277
297 virtual void update( Time const&, const long, const long ) = 0;
298
312 virtual bool wfr_update( Time const&, const long, const long );
313
329
337 virtual void set_status( const Dictionary& ) = 0;
338
346 virtual void get_status( Dictionary& ) const = 0;
347
348public:
361
376 virtual size_t send_test_event( Node& receiving_node, size_t receptor_type, synindex syn_id, bool dummy_target );
377
397 virtual size_t handles_test_event( SpikeEvent&, size_t receptor_type );
398 virtual size_t handles_test_event( WeightCorrectionEvent&, size_t receptor_type );
399 virtual size_t handles_test_event( WeightRecorderEvent&, size_t receptor_type );
400 virtual size_t handles_test_event( RateEvent&, size_t receptor_type );
401 virtual size_t handles_test_event( DataLoggingRequest&, size_t receptor_type );
402 virtual size_t handles_test_event( CurrentEvent&, size_t receptor_type );
403 virtual size_t handles_test_event( ConductanceEvent&, size_t receptor_type );
404 virtual size_t handles_test_event( DoubleDataEvent&, size_t receptor_type );
405 virtual size_t handles_test_event( DSSpikeEvent&, size_t receptor_type );
406 virtual size_t handles_test_event( DSCurrentEvent&, size_t receptor_type );
407 virtual size_t handles_test_event( GapJunctionEvent&, size_t receptor_type );
408 virtual size_t handles_test_event( InstantaneousRateConnectionEvent&, size_t receptor_type );
409 virtual size_t handles_test_event( DiffusionConnectionEvent&, size_t receptor_type );
410 virtual size_t handles_test_event( DelayedRateConnectionEvent&, size_t receptor_type );
411 virtual size_t handles_test_event( LearningSignalConnectionEvent&, size_t receptor_type );
412 virtual size_t handles_test_event( SICEvent&, size_t receptor_type );
413
422 virtual void sends_secondary_event( GapJunctionEvent& ge );
423
433
443
453
463
472 virtual void sends_secondary_event( SICEvent& sic );
473
484 virtual void register_stdp_connection( double, double, double );
485
492 virtual bool supports_axonal_delay_corrections() const;
493
499 virtual void register_eprop_connection();
500
509 virtual void initialize_update_history();
510
526 virtual long get_shift() const;
527
537 virtual void write_update_to_history( const long t_previous_update,
538 const long t_current_update,
539 const bool is_flush_event,
540 const bool previous_was_flush_event );
541
549 virtual void erase_used_eprop_history();
550
559 virtual void erase_used_eprop_history( const long t_spike, const long t_spike_previous );
560
572 virtual bool is_eprop_recurrent_node() const;
573
585 virtual void handle( SpikeEvent& e );
586 virtual void handle( WeightCorrectionEvent& );
587
599 virtual void handle( WeightRecorderEvent& e );
600
608 virtual void handle( RateEvent& e );
609
617 virtual void handle( DataLoggingRequest& e );
618
628 virtual void handle( DataLoggingReply& e );
629
637 virtual void handle( CurrentEvent& e );
638
646 virtual void handle( ConductanceEvent& e );
647
655 virtual void handle( DoubleDataEvent& e );
656
664 virtual void handle( GapJunctionEvent& e );
665
673 virtual void handle( InstantaneousRateConnectionEvent& e );
674
682 virtual void handle( DiffusionConnectionEvent& e );
683
691 virtual void handle( DelayedRateConnectionEvent& e );
692
700 virtual void handle( LearningSignalConnectionEvent& e );
701
709 virtual void handle( SICEvent& e );
710
718
727 virtual double
729 {
730 return 0.0;
731 }
732
740 virtual double
741 get_synaptic_elements( std::string ) const
742 {
743 return 0.0;
744 }
745
751 virtual int
752 get_synaptic_elements_vacant( std::string ) const
753 {
754 return 0;
755 }
756
763 virtual int
765 {
766 return 0;
767 }
768
775 virtual std::map< std::string, double >
777 {
778 return std::map< std::string, double >();
779 }
780
790 virtual void update_synaptic_elements( double ) {};
791
800
809 virtual void connect_synaptic_element( std::string, int ) {};
810
815 virtual double get_K_value( double t );
816
817 virtual double get_LTD_value( double t );
818
825 virtual void get_K_values( double t, double& Kminus, double& nearest_neighbor_Kminus, double& Kminus_triplet );
826
831 virtual void get_history( double t1,
832 double t2,
833 std::deque< histentry >::iterator* start,
834 std::deque< histentry >::iterator* finish );
835
836 // for Clopath synapse
837 virtual void get_LTP_history( double t1,
838 double t2,
839 std::deque< histentry_extended >::iterator* start,
840 std::deque< histentry_extended >::iterator* finish );
841 // for Urbanczik synapse
842 virtual void get_urbanczik_history( double t1,
843 double t2,
844 std::deque< histentry_extended >::iterator* start,
845 std::deque< histentry_extended >::iterator* finish,
846 int );
847 // make neuron parameters accessible in Urbanczik synapse
848 virtual double get_C_m( int comp );
849 virtual double get_g_L( int comp );
850 virtual double get_tau_L( int comp );
851 virtual double get_tau_s( int comp );
852 virtual double get_tau_syn_ex( int comp );
853 virtual double get_tau_syn_in( int comp );
854
874 virtual void compute_gradient( const long t_spike,
875 const long t_spike_previous,
876 double& z_previous_buffer,
877 double& z_bar,
878 double& e_bar,
879 double& e_bar_reg,
880 double& epsilon,
881 double& weight,
882 const CommonSynapseProperties& cp,
883 WeightOptimizer* optimizer,
884 bool is_flush_event,
885 bool previous_was_flush_event,
886 double& sum_grad,
887 long& remaining_steps_until_cutoff,
888 long& decay_steps );
889
905 virtual double compute_gradient( std::vector< long >& presyn_isis,
906 const long t_previous_update,
907 const long t_previous_trigger_spike,
908 const double kappa,
909 const bool average_gradient );
910
925 virtual void event_hook( DSSpikeEvent& );
926
927 virtual void event_hook( DSCurrentEvent& );
928
935 void set_thread( size_t );
936
940 size_t get_thread() const;
941
947 void set_vp( size_t );
948
952 size_t get_vp() const;
953
960 void set_model_id( int );
961
969 void set_initialized();
970
976 virtual SignalType
978 {
979 return SPIKE;
980 }
981
987 virtual SignalType
989 {
990 return SPIKE;
991 }
992
993
1003
1010 void set_status_base( const Dictionary& );
1011
1015 bool is_model_prototype() const;
1016
1021 void set_thread_lid( const size_t );
1022
1026 size_t get_thread_lid() const;
1027
1034 virtual void set_local_device_id( const size_t lsdid );
1035
1042 virtual size_t get_local_device_id() const;
1043
1049
1053 void set_tmp_nc_index( size_t index );
1054
1060 size_t get_tmp_nc_index();
1061
1062
1063private:
1064 void set_node_id_( size_t );
1065
1073 virtual Dictionary get_status_dict_();
1074
1075protected:
1083 virtual void init_state_();
1084
1091 virtual void init_buffers_();
1092
1093 virtual void set_initialized_();
1094
1095 Model& get_model_() const;
1096
1098 void
1099 set_frozen_( bool frozen )
1100 {
1101 frozen_ = frozen;
1102 }
1103
1110 template < typename ConcreteNode >
1111 const ConcreteNode& downcast( const Node& );
1112
1113private:
1119 size_t node_id_;
1120
1125
1134
1135 size_t thread_;
1136 size_t vp_;
1137 bool frozen_;
1140
1151};
1152
1153inline bool
1155{
1156 return frozen_;
1157}
1158
1159inline bool
1161{
1162 return node_uses_wfr_;
1163}
1164
1165inline bool
1167{
1168 return false;
1169}
1170
1171inline void
1172Node::set_node_uses_wfr( const bool uwfr )
1173{
1174 node_uses_wfr_ = uwfr;
1175}
1176
1177inline bool
1179{
1180 return true;
1181}
1182
1183inline bool
1185{
1186 return false;
1187}
1188
1189inline bool
1191{
1192 return false;
1193}
1194
1195inline bool
1197{
1198 return false;
1199}
1200
1201inline bool
1203{
1204 return false;
1205}
1206
1207inline std::string
1209{
1210 return names::neuron;
1211}
1212
1213inline size_t
1215{
1216 return node_id_;
1217}
1218
1219
1220inline void
1222{
1223 node_id_ = i;
1224}
1225
1226
1227inline int
1229{
1230 return model_id_;
1231}
1232
1233inline void
1235{
1236 model_id_ = i;
1237}
1238
1239inline bool
1241{
1242 return vp_ == invalid_thread;
1243}
1244
1245inline void
1247{
1248 thread_ = t;
1249}
1250
1251inline size_t
1253{
1254 return thread_;
1255}
1256
1257inline void
1258Node::set_vp( size_t vp )
1259{
1260 vp_ = vp;
1261}
1262
1263inline size_t
1265{
1266 return vp_;
1267}
1268
1269template < typename ConcreteNode >
1270const ConcreteNode&
1272{
1273 ConcreteNode const* tp = dynamic_cast< ConcreteNode const* >( &n );
1274 assert( tp != 0 );
1275 return *tp;
1276}
1277
1278inline void
1279Node::set_thread_lid( const size_t tlid )
1280{
1281 thread_lid_ = tlid;
1282}
1283
1284inline size_t
1286{
1287 return thread_lid_;
1288}
1289
1290inline void
1292{
1293 tmp_nc_index_ = index;
1294}
1295
1296inline size_t
1298{
1299 assert( tmp_nc_index_ != invalid_index );
1300
1301 const auto index = tmp_nc_index_;
1302 tmp_nc_index_ = invalid_index;
1303
1304 return index;
1305}
1306
1307
1308} // namespace
1309
1310#endif
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
A node which archives spike history for the purposes of spike-timing dependent plasticity (STDP).
Definition archiving_node.h:49
Class containing the common properties for all connections of a certain type.
Definition common_synapse_properties.h:50
Event for electrical conductances.
Definition event.h:848
Event for electrical currents.
Definition event.h:608
"Callback request event" for use in Device.
Definition event.h:654
"Callback request event" for use in Device.
Definition event.h:560
Provide logged data through request transmitting reference.
Definition event.h:779
Request data to be logged/logged data to be sent.
Definition event.h:675
Event for rate model connections with delay.
Definition secondary_event.h:331
Definition deprecation_warning.h:52
Event for diffusion connections (rate model connections for the siegert_neuron).
Definition secondary_event.h:348
Definition event.h:919
Event for gap-junction information.
Definition secondary_event.h:299
Event for rate model connections without delay.
Definition secondary_event.h:315
Event for learning signal connections.
Definition secondary_event.h:384
Base class for all Models.
Definition model.h:53
Base class for all NEST network objects.
Definition node.h:99
virtual void init_state_()
Configure state variables depending on runtime information.
Definition node.cpp:70
virtual Node * clone() const
This function creates a new object by calling the derived class' copy constructor and returning its p...
Definition node.h:118
size_t get_vp() const
Retrieve the number of the virtual process to which the node is assigned.
Definition node.h:1264
virtual size_t send_test_event(Node &receiving_node, size_t receptor_type, synindex syn_id, bool dummy_target)
Send an event to the receiving_node passed as an argument.
Definition node.cpp:199
virtual double get_K_value(double t)
return the Kminus value at t (in ms).
Definition node.cpp:505
virtual bool one_node_per_process() const
Returns true if the node exists only once per process, but does not have proxies on remote threads.
Definition node.h:1190
friend class proxynode
Definition node.h:102
void init()
Initialize node prior to first simulation after node has been created.
Definition node.cpp:75
Node()
Definition node.cpp:36
virtual std::string get_element_type() const
Return the element type of the node.
Definition node.h:1208
const ConcreteNode & downcast(const Node &)
Auxiliary function to downcast a Node to a concrete class derived from Node.
Definition node.h:1271
size_t thread_
thread node is assigned to
Definition node.h:1135
virtual bool supports_urbanczik_archiving() const
Returns true if the node supports the Urbanczik-Senn plasticity rule.
Definition node.h:1166
virtual void get_LTP_history(double t1, double t2, std::deque< histentry_extended >::iterator *start, std::deque< histentry_extended >::iterator *finish)
Definition node.cpp:524
void set_node_uses_wfr(const bool)
Sets node_uses_wfr_ member variable (to be able to set it to "true" for any class derived from Node).
Definition node.h:1172
virtual ~Node()
Definition node.cpp:65
virtual void register_eprop_connection()
Registers an eprop connection.
Definition node.cpp:223
friend class Model
Definition node.h:103
virtual void event_hook(DSSpikeEvent &)
Modify Event object parameters during event delivery.
Definition node.cpp:605
void set_tmp_nc_index(size_t index)
Set index in node collection; required by ThirdOutBuilder.
Definition node.h:1291
virtual void get_K_values(double t, double &Kminus, double &nearest_neighbor_Kminus, double &Kminus_triplet)
write the Kminus, nearest_neighbor_Kminus, and Kminus_triplet values at t (in ms) to the provided loc...
Definition node.cpp:512
virtual bool has_proxies() const
Returns true if the node has proxies on remote threads.
Definition node.h:1178
virtual bool supports_axonal_delay_corrections() const
Whether this model can be the target of a synapse with predominantly axonal delay.
Definition node.cpp:217
Node & operator=(const Node &)
not implemented
virtual void compute_gradient(const long t_spike, const long t_spike_previous, double &z_previous_buffer, double &z_bar, double &e_bar, double &e_bar_reg, double &epsilon, double &weight, const CommonSynapseProperties &cp, WeightOptimizer *optimizer, bool is_flush_event, bool previous_was_flush_event, double &sum_grad, long &remaining_steps_until_cutoff, long &decay_steps)
Compute gradient change for eprop synapses.
Definition node.cpp:579
bool node_uses_wfr() const
Returns true if the node uses the waveform relaxation method.
Definition node.h:1160
virtual double get_g_L(int comp)
Definition node.cpp:549
size_t thread_lid_
Local id of this node in the thread-local vector of nodes.
Definition node.h:1124
virtual void init_buffers_()
Configure persistent internal data structures.
Definition node.cpp:89
virtual void register_stdp_connection(double, double, double)
Register a STDP connection.
Definition node.cpp:211
virtual void get_history(double t1, double t2, std::deque< histentry >::iterator *start, std::deque< histentry >::iterator *finish)
return the spike history for (t1,t2].
Definition node.cpp:518
virtual void get_urbanczik_history(double t1, double t2, std::deque< histentry_extended >::iterator *start, std::deque< histentry_extended >::iterator *finish, int)
Definition node.cpp:533
friend class SimulationManager
Definition node.h:104
virtual double get_C_m(int comp)
Definition node.cpp:543
size_t get_thread_lid() const
get thread local index
Definition node.h:1285
virtual void update(Time const &, const long, const long)=0
Advance the state of the node in time through the given interval.
DeprecationWarning deprecation_warning
Member of DeprecationWarning class to be used by models if parameters are deprecated.
Definition node.h:1048
virtual SignalType receives_signal() const
Definition node.h:988
virtual void initialize_update_history()
Initializes the update history.
Definition node.cpp:229
void set_thread_lid(const size_t)
set thread local index
Definition node.h:1279
void set_frozen_(bool frozen)
Mark node as frozen.
Definition node.h:1099
virtual double get_tau_s(int comp)
Definition node.cpp:561
bool frozen_
node shall not be updated if true
Definition node.h:1137
Dictionary get_status_base()
Return a dictionary with the node's properties.
Definition node.cpp:142
virtual double get_LTD_value(double t)
Definition node.cpp:499
size_t get_thread() const
Retrieve the number of the thread to which the node is assigned.
Definition node.h:1252
virtual SignalType sends_signal() const
Definition node.h:977
std::string get_name() const
Return class name.
Definition node.cpp:105
virtual bool wfr_update(Time const &, const long, const long)
Advance the state of the node in time through the given interval (see Node::update() for more details...
Definition node.cpp:190
virtual bool is_proxy() const
Returns true if the node is a proxy node.
Definition node.h:1202
void set_model_id(int)
Set the model id.
Definition node.h:1234
virtual void calibrate_time(const TimeConverter &)
Re-calculate time-based properties of the node.
Definition node.h:249
void set_initialized()
Execute post-initialization actions in node models.
Definition node.cpp:94
virtual Dictionary get_status_dict_()
Return a new dictionary datum .
Definition node.cpp:123
bool initialized_
state and buffers have been initialized
Definition node.h:1138
int get_model_id() const
Return model ID of the node.
Definition node.h:1228
virtual bool is_eprop_recurrent_node() const
Checks if the node is part of the recurrent network and thus not a readout neuron.
Definition node.cpp:259
bool node_uses_wfr_
node uses waveform relaxation method
Definition node.h:1139
virtual void finalize()
Finalize node.
Definition node.h:274
friend class NodeManager
Definition node.h:100
friend class ModelManager
Definition node.h:101
virtual size_t get_local_device_id() const
Gets the local device id.
Definition node.cpp:135
size_t get_node_id() const
Return global Network ID.
Definition node.h:1214
virtual void set_local_device_id(const size_t lsdid)
Sets the local device id.
Definition node.cpp:129
bool is_model_prototype() const
Returns true if node is model prototype.
Definition node.h:1240
virtual long get_shift() const
Retrieves the temporal shift of the signal.
Definition node.cpp:235
bool is_frozen() const
Returns true if node is frozen, i.e., shall not be updated.
Definition node.h:1154
virtual void erase_used_eprop_history()
Erases used e-prop history for bsshslm_2020 models.
Definition node.cpp:247
virtual void write_update_to_history(const long t_previous_update, const long t_current_update, const bool is_flush_event, const bool previous_was_flush_event)
Registers the current update in the update history and deregisters the previous update.
Definition node.cpp:241
virtual bool local_receiver() const
Returns true if the node only receives events from nodes/devices on the same thread.
Definition node.h:1184
size_t node_id_
Global Element ID (node ID).
Definition node.h:1119
virtual bool is_off_grid() const
Returns true if the node sends/receives off-grid events.
Definition node.h:1196
void set_thread(size_t)
Store the number of the thread to which the node is assigned.
Definition node.h:1246
void set_vp(size_t)
Store the number of the virtual process to which the node is assigned.
Definition node.h:1258
virtual double get_tau_syn_in(int comp)
Definition node.cpp:573
virtual void pre_run_hook()=0
Re-calculate dependent parameters of the node.
size_t get_tmp_nc_index()
Return and invalidate index in node collection; required by ThirdOutBuilder.
Definition node.h:1297
virtual double get_tau_syn_ex(int comp)
Definition node.cpp:567
void set_node_id_(size_t)
Set global node id.
Definition node.h:1221
virtual void post_run_cleanup()
Cleanup node after Run.
Definition node.h:262
int model_id_
Model ID.
Definition node.h:1133
size_t vp_
virtual process node is assigned to
Definition node.h:1136
void set_status_base(const Dictionary &)
Set status dictionary of a node.
Definition node.cpp:170
size_t tmp_nc_index_
Store index in NodeCollection.
Definition node.h:1150
virtual void set_initialized_()
Definition node.cpp:100
Model & get_model_() const
Definition node.cpp:116
virtual double get_tau_L(int comp)
Definition node.cpp:555
Event for firing rate information.
Definition event.h:574
Event for slow inward current (SIC) connections between astrocytes and neurons.
Definition secondary_event.h:458
Event for spike information.
Definition event.h:420
Class to convert times from one representation to another.
Definition nest_timeconverter.h:42
Definition nest_time.h:135
Definition event.h:457
Base class implementing a weight optimizer model.
Definition weight_optimizer.h:238
Event for recording the weight of a spike.
Definition event.h:498
virtual int get_synaptic_elements_connected(std::string) const
Get the number of connected synaptic element for the current Node.
Definition node.h:764
virtual void decay_synaptic_elements_vacant()
Is used to reduce the number of synaptic elements in the node through time.
Definition node.h:799
virtual std::map< std::string, double > get_synaptic_elements() const
Get the number of all synaptic elements for the current Node at time t.
Definition node.h:776
virtual double get_synaptic_elements(std::string) const
Get the number of synaptic element for the current Node at Ca_t which corresponds to the time of the ...
Definition node.h:741
virtual void connect_synaptic_element(std::string, int)
Is used to update the number of connected synaptic elements (SynapticElement::z_connected_) when a sy...
Definition node.h:809
virtual int get_synaptic_elements_vacant(std::string) const
Get the number of vacant synaptic element for the current Node Return 0 if not overridden.
Definition node.h:752
virtual double get_Ca_minus() const
Return the Ca_minus value at time Ca_t which corresponds to the time of the last update in Calcium co...
Definition node.h:728
virtual void update_synaptic_elements(double)
Triggers the update of all SynapticElements stored in the synaptic_element_map_.
Definition node.h:790
virtual size_t handles_test_event(SpikeEvent &, size_t receptor_type)
Check if the node can handle a particular event and receptor type.
Definition node.cpp:282
virtual void sends_secondary_event(GapJunctionEvent &ge)
Required to check, if source neuron may send a SecondaryEvent.
Definition node.cpp:400
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition node.cpp:271
virtual void set_status(const Dictionary &)=0
Change properties of the node according to the entries in the dictionary.
virtual void get_status(Dictionary &) const =0
Export properties of the node by setting entries in the status dictionary.
const std::string neuron("neuron")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
constexpr size_t invalid_thread
Value for invalid connection thread id.
Definition nest_types.h:142
SignalType
enum type of signal conveyed by spike events of a node.
Definition nest_types.h:171
@ SPIKE
Definition nest_types.h:173
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:121