NEST main@caf0ae8
 
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
49namespace nest
50{
51class Model;
52class ArchivingNode;
53class TimeConverter;
54class WeightOptimizer;
55
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
337 virtual void set_status( const Dictionary& ) = 0;
338
346 virtual void get_status( Dictionary& ) const = 0;
347
348public:
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( WeightRecorderEvent&, size_t receptor_type );
399 virtual size_t handles_test_event( RateEvent&, size_t receptor_type );
400 virtual size_t handles_test_event( DataLoggingRequest&, size_t receptor_type );
401 virtual size_t handles_test_event( CurrentEvent&, size_t receptor_type );
402 virtual size_t handles_test_event( ConductanceEvent&, size_t receptor_type );
403 virtual size_t handles_test_event( DoubleDataEvent&, size_t receptor_type );
404 virtual size_t handles_test_event( DSSpikeEvent&, size_t receptor_type );
405 virtual size_t handles_test_event( DSCurrentEvent&, size_t receptor_type );
406 virtual size_t handles_test_event( GapJunctionEvent&, size_t receptor_type );
407 virtual size_t handles_test_event( InstantaneousRateConnectionEvent&, size_t receptor_type );
408 virtual size_t handles_test_event( DiffusionConnectionEvent&, size_t receptor_type );
409 virtual size_t handles_test_event( DelayedRateConnectionEvent&, size_t receptor_type );
410 virtual size_t handles_test_event( LearningSignalConnectionEvent&, size_t receptor_type );
411 virtual size_t handles_test_event( SICEvent&, size_t receptor_type );
412
421 virtual void sends_secondary_event( GapJunctionEvent& ge );
422
432
442
452
462
471 virtual void sends_secondary_event( SICEvent& sic );
472
479 virtual void register_stdp_connection( double, double );
480
486 virtual void register_eprop_connection();
487
496 virtual void initialize_update_history();
497
513 virtual long get_shift() const;
514
524 virtual void write_update_to_history( const long t_previous_update,
525 const long t_current_update,
526 const bool is_flush_event,
527 const bool previous_was_flush_event );
528
536 virtual void erase_used_eprop_history();
537
546 virtual void erase_used_eprop_history( const long t_spike, const long t_spike_previous );
547
559 virtual bool is_eprop_recurrent_node() const;
560
572 virtual void handle( SpikeEvent& e );
573
585 virtual void handle( WeightRecorderEvent& e );
586
594 virtual void handle( RateEvent& e );
595
603 virtual void handle( DataLoggingRequest& e );
604
614 virtual void handle( DataLoggingReply& e );
615
623 virtual void handle( CurrentEvent& e );
624
632 virtual void handle( ConductanceEvent& e );
633
641 virtual void handle( DoubleDataEvent& e );
642
650 virtual void handle( GapJunctionEvent& e );
651
659 virtual void handle( InstantaneousRateConnectionEvent& e );
660
668 virtual void handle( DiffusionConnectionEvent& e );
669
677 virtual void handle( DelayedRateConnectionEvent& e );
678
686 virtual void handle( LearningSignalConnectionEvent& e );
687
695 virtual void handle( SICEvent& e );
696
713 virtual double
715 {
716 return 0.0;
717 }
718
726 virtual double
727 get_synaptic_elements( std::string ) const
728 {
729 return 0.0;
730 }
731
737 virtual int
738 get_synaptic_elements_vacant( std::string ) const
739 {
740 return 0;
741 }
742
749 virtual int
751 {
752 return 0;
753 }
754
761 virtual std::map< std::string, double >
763 {
764 return std::map< std::string, double >();
765 }
766
776 virtual void update_synaptic_elements( double ) {};
777
786
795 virtual void connect_synaptic_element( std::string, int ) {};
796
801 virtual double get_K_value( double t );
802
803 virtual double get_LTD_value( double t );
804
811 virtual void get_K_values( double t, double& Kminus, double& nearest_neighbor_Kminus, double& Kminus_triplet );
812
817 virtual void get_history( double t1,
818 double t2,
819 std::deque< histentry >::iterator* start,
820 std::deque< histentry >::iterator* finish );
821
822 // for Clopath synapse
823 virtual void get_LTP_history( double t1,
824 double t2,
825 std::deque< histentry_extended >::iterator* start,
826 std::deque< histentry_extended >::iterator* finish );
827 // for Urbanczik synapse
828 virtual void get_urbanczik_history( double t1,
829 double t2,
830 std::deque< histentry_extended >::iterator* start,
831 std::deque< histentry_extended >::iterator* finish,
832 int );
833 // make neuron parameters accessible in Urbanczik synapse
834 virtual double get_C_m( int comp );
835 virtual double get_g_L( int comp );
836 virtual double get_tau_L( int comp );
837 virtual double get_tau_s( int comp );
838 virtual double get_tau_syn_ex( int comp );
839 virtual double get_tau_syn_in( int comp );
840
860 virtual void compute_gradient( const long t_spike,
861 const long t_spike_previous,
862 double& z_previous_buffer,
863 double& z_bar,
864 double& e_bar,
865 double& e_bar_reg,
866 double& epsilon,
867 double& weight,
868 const CommonSynapseProperties& cp,
869 WeightOptimizer* optimizer,
870 bool is_flush_event,
871 bool previous_was_flush_event,
872 double& sum_grad,
873 long& remaining_steps_until_cutoff,
874 long& decay_steps );
875
891 virtual double compute_gradient( std::vector< long >& presyn_isis,
892 const long t_previous_update,
893 const long t_previous_trigger_spike,
894 const double kappa,
895 const bool average_gradient );
896
911 virtual void event_hook( DSSpikeEvent& );
912
913 virtual void event_hook( DSCurrentEvent& );
914
921 void set_thread( size_t );
922
926 size_t get_thread() const;
927
933 void set_vp( size_t );
934
938 size_t get_vp() const;
939
946 void set_model_id( int );
947
955 void set_initialized();
956
962 virtual SignalType
964 {
965 return SPIKE;
966 }
967
973 virtual SignalType
975 {
976 return SPIKE;
977 }
978
979
989
996 void set_status_base( const Dictionary& );
997
1001 bool is_model_prototype() const;
1002
1007 void set_thread_lid( const size_t );
1008
1012 size_t get_thread_lid() const;
1013
1020 virtual void set_local_device_id( const size_t lsdid );
1021
1028 virtual size_t get_local_device_id() const;
1029
1035
1039 void set_tmp_nc_index( size_t index );
1040
1046 size_t get_tmp_nc_index();
1047
1048
1049private:
1050 void set_node_id_( size_t );
1051
1059 virtual Dictionary get_status_dict_();
1060
1061protected:
1069 virtual void init_state_();
1070
1077 virtual void init_buffers_();
1078
1079 virtual void set_initialized_();
1080
1081 Model& get_model_() const;
1082
1084 void
1085 set_frozen_( bool frozen )
1086 {
1087 frozen_ = frozen;
1088 }
1089
1096 template < typename ConcreteNode >
1097 const ConcreteNode& downcast( const Node& );
1098
1099private:
1105 size_t node_id_;
1106
1111
1120
1121 size_t thread_;
1122 size_t vp_;
1123 bool frozen_;
1126
1137};
1138
1139inline bool
1141{
1142 return frozen_;
1143}
1144
1145inline bool
1147{
1148 return node_uses_wfr_;
1149}
1150
1151inline bool
1153{
1154 return false;
1155}
1156
1157inline void
1158Node::set_node_uses_wfr( const bool uwfr )
1159{
1160 node_uses_wfr_ = uwfr;
1161}
1162
1163inline bool
1165{
1166 return true;
1167}
1168
1169inline bool
1171{
1172 return false;
1173}
1174
1175inline bool
1177{
1178 return false;
1179}
1180
1181inline bool
1183{
1184 return false;
1185}
1186
1187inline bool
1189{
1190 return false;
1191}
1192
1193inline std::string
1195{
1196 return names::neuron;
1197}
1198
1199inline size_t
1201{
1202 return node_id_;
1203}
1204
1205
1206inline void
1208{
1209 node_id_ = i;
1210}
1211
1212
1213inline int
1215{
1216 return model_id_;
1217}
1218
1219inline void
1221{
1222 model_id_ = i;
1223}
1224
1225inline bool
1227{
1228 return vp_ == invalid_thread;
1229}
1230
1231inline void
1233{
1234 thread_ = t;
1235}
1236
1237inline size_t
1239{
1240 return thread_;
1241}
1242
1243inline void
1244Node::set_vp( size_t vp )
1245{
1246 vp_ = vp;
1247}
1248
1249inline size_t
1251{
1252 return vp_;
1253}
1254
1255template < typename ConcreteNode >
1256const ConcreteNode&
1258{
1259 ConcreteNode const* tp = dynamic_cast< ConcreteNode const* >( &n );
1260 assert( tp != 0 );
1261 return *tp;
1262}
1263
1264inline void
1265Node::set_thread_lid( const size_t tlid )
1266{
1267 thread_lid_ = tlid;
1268}
1269
1270inline size_t
1272{
1273 return thread_lid_;
1274}
1275
1276inline void
1278{
1279 tmp_nc_index_ = index;
1280}
1281
1282inline size_t
1284{
1285 assert( tmp_nc_index_ != invalid_index );
1286
1287 const auto index = tmp_nc_index_;
1288 tmp_nc_index_ = invalid_index;
1289
1290 return index;
1291}
1292
1293
1294} // namespace
1295
1296#endif
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
Event for electrical conductances.
Definition event.h:809
Event for electrical currents.
Definition event.h:569
"Callback request event" for use in Device.
Definition event.h:615
"Callback request event" for use in Device.
Definition event.h:521
Provide logged data through request transmitting reference.
Definition event.h:740
Request data to be logged/logged data to be sent.
Definition event.h:636
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:880
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
Definition model_manager.h:45
Base class for all Models.
Definition model.h:53
Definition node_manager.h:47
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:1250
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:486
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:1176
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:1194
const ConcreteNode & downcast(const Node &)
Auxiliary function to downcast a Node to a concrete class derived from Node.
Definition node.h:1257
size_t thread_
thread node is assigned to
Definition node.h:1121
virtual bool supports_urbanczik_archiving() const
Returns true if the node supports the Urbanczik-Senn plasticity rule.
Definition node.h:1152
virtual void get_LTP_history(double t1, double t2, std::deque< histentry_extended >::iterator *start, std::deque< histentry_extended >::iterator *finish)
Definition node.cpp:505
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:1158
virtual ~Node()
Definition node.cpp:65
virtual void register_stdp_connection(double, double)
Register a STDP connection.
Definition node.cpp:211
virtual void register_eprop_connection()
Registers an eprop connection.
Definition node.cpp:217
virtual void event_hook(DSSpikeEvent &)
Modify Event object parameters during event delivery.
Definition node.cpp:586
void set_tmp_nc_index(size_t index)
Set index in node collection; required by ThirdOutBuilder.
Definition node.h:1277
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:493
virtual bool has_proxies() const
Returns true if the node has proxies on remote threads.
Definition node.h:1164
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:560
bool node_uses_wfr() const
Returns true if the node uses the waveform relaxation method.
Definition node.h:1146
virtual double get_g_L(int comp)
Definition node.cpp:530
size_t thread_lid_
Local id of this node in the thread-local vector of nodes.
Definition node.h:1110
virtual void init_buffers_()
Configure persistent internal data structures.
Definition node.cpp:89
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:499
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:514
virtual double get_C_m(int comp)
Definition node.cpp:524
size_t get_thread_lid() const
get thread local index
Definition node.h:1271
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:1034
virtual SignalType receives_signal() const
Definition node.h:974
virtual void initialize_update_history()
Initializes the update history.
Definition node.cpp:223
void set_thread_lid(const size_t)
set thread local index
Definition node.h:1265
void set_frozen_(bool frozen)
Mark node as frozen.
Definition node.h:1085
virtual double get_tau_s(int comp)
Definition node.cpp:542
bool frozen_
node shall not be updated if true
Definition node.h:1123
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:480
size_t get_thread() const
Retrieve the number of the thread to which the node is assigned.
Definition node.h:1238
virtual SignalType sends_signal() const
Definition node.h:963
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:1188
void set_model_id(int)
Set the model id.
Definition node.h:1220
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:1124
int get_model_id() const
Return model ID of the node.
Definition node.h:1214
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:253
bool node_uses_wfr_
node uses waveform relaxation method
Definition node.h:1125
virtual void finalize()
Finalize node.
Definition node.h:274
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:1200
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:1226
virtual long get_shift() const
Retrieves the temporal shift of the signal.
Definition node.cpp:229
bool is_frozen() const
Returns true if node is frozen, i.e., shall not be updated.
Definition node.h:1140
virtual void erase_used_eprop_history()
Erases used e-prop history for bsshslm_2020 models.
Definition node.cpp:241
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:235
virtual bool local_receiver() const
Returns true if the node only receives events from nodes/devices on the same thread.
Definition node.h:1170
size_t node_id_
Global Element ID (node ID).
Definition node.h:1105
virtual bool is_off_grid() const
Returns true if the node sends/receives off-grid events.
Definition node.h:1182
void set_thread(size_t)
Store the number of the thread to which the node is assigned.
Definition node.h:1232
void set_vp(size_t)
Store the number of the virtual process to which the node is assigned.
Definition node.h:1244
virtual double get_tau_syn_in(int comp)
Definition node.cpp:554
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:1283
virtual double get_tau_syn_ex(int comp)
Definition node.cpp:548
void set_node_id_(size_t)
Set global node id.
Definition node.h:1207
virtual void post_run_cleanup()
Cleanup node after Run.
Definition node.h:262
int model_id_
Model ID.
Definition node.h:1119
size_t vp_
virtual process node is assigned to
Definition node.h:1122
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:1136
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:536
Event for firing rate information.
Definition event.h:535
Event for slow inward current (SIC) connections between astrocytes and neurons.
Definition secondary_event.h:458
Definition simulation_manager.h:47
Event for spike information.
Definition event.h:418
Class to convert times from one representation to another.
Definition nest_timeconverter.h:42
Definition nest_time.h:135
Base class implementing a weight optimizer model.
Definition weight_optimizer.h:238
Event for recording the weight of a spike.
Definition event.h:459
Proxy to provide Nodes on remote machines.
Definition proxynode.h:42
virtual int get_synaptic_elements_connected(std::string) const
Get the number of connected synaptic element for the current Node.
Definition node.h:750
virtual void decay_synaptic_elements_vacant()
Is used to reduce the number of synaptic elements in the node through time.
Definition node.h:785
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:762
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:727
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:795
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:738
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:714
virtual void update_synaptic_elements(double)
Triggers the update of all SynapticElements stored in the synaptic_element_map_.
Definition node.h:776
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:271
virtual void sends_secondary_event(GapJunctionEvent &ge)
Required to check, if source neuron may send a SecondaryEvent.
Definition node.cpp:381
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition node.cpp:265
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:136
SignalType
enum type of signal conveyed by spike events of a node.
Definition nest_types.h:165
@ SPIKE
Definition nest_types.h:167
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115