NEST  2.6.0,not_revisioned_source_dir@0
sli_neuron.h
Go to the documentation of this file.
1 /*
2  * sli_neuron.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 SLI_NEURON_H
24 #define SLI_NEURON_H
25 
26 #include "nest.h"
27 #include "event.h"
28 #include "archiving_node.h"
29 #include "ring_buffer.h"
30 #include "connection.h"
31 #include "universal_data_logger.h"
32 
33 namespace nest{
34 
35  class Network;
36 
37  /* BeginDocumentation
38 Name: sli_neuron - neuron with SLI callback
39 
40 Description:
41 The sli_neuron is a model whose state, update and calibration can be
42 defined in SLI.
43 
44 The state of the neuron is a SLI dictionary which can be retrieved
45 with GetStatus. The state should contain two procedures:
46  1. /update
47  2. /calibrate
48 
49 /calibrate is called before the simulation starts. It is used to
50  pre-compute constants of the dynamics and to scale
51  parameters to the temporal resolution. A minimal
52  implementation of calibrate is:
53 
54  /calibrate { GetResolution /h Set } def
55 
56 /update is called during simulation and must propagate the node's
57  state by one integration step h. If /update decides that
58  the node should spike, it must set the variable /spike to
59  true.
60 
61 Both /calibrate and /update are called with the node's status
62 dictionary on top of the dictionary stack. This means that node
63 variables override names in the systemdict or in the userdict.
64 Moreover, all definitions are done in the node's statusdict and
65 persist throughout the simulation.
66 
67 Errors.
68 If an error occurs during the evaluation of /calibrate or /update, the
69 errorneous neuron is skipped and update proceeds to the next node
70 until the time-slice is finished. After the time-slice is finished,
71 simulation terminates with an additional error message that issues the
72 global id of the errorneous node.
73 
74 Errors are handled by the SLI standard errorhandler. In addition, the
75 contents of the error dictionary is copied into the node's status
76 dictionary, to allow debugging of the node.
77 
78 Parameters:
79 
80 
81 Sends: SpikeEvent
82 
83 Receives: SpikeEvent, CurrentEvent, DataLoggingRequest
84 
85 Author: Diesmann, Plesser, Gewaltig
86 FirstVersion: January 2009
87 SeeAlso: iaf_psc_delta, iaf_psc_exp, iaf_cond_exp, testsuite::test_sli_neuron
88 */
89 
93  class sli_neuron : public Archiving_Node
94  {
95 
96  public:
97 
98  sli_neuron();
99  sli_neuron(const sli_neuron&);
100 
105  using Node::handle;
107 
109 
110  void handle(SpikeEvent &);
111  void handle(CurrentEvent &);
112  void handle(DataLoggingRequest &);
113 
114 
118 
119 
120  void get_status(DictionaryDatum &) const;
121  void set_status(const DictionaryDatum &);
122 
123  private:
124 
126 
127  void init_state_(const Node& proto);
128  void init_buffers_();
129  void calibrate();
130 
131  void update(Time const &, const long_t, const long_t);
132 
133  void get(DictionaryDatum&) const;
134  void set(const DictionaryDatum&);
135 
136  // The next two classes need to be friends to access the State_ class/member
137  friend class RecordablesMap<sli_neuron>;
138  friend class UniversalDataLogger<sli_neuron>;
139 
140  // ----------------------------------------------------------------
141 
145  struct Buffers_ {
146  Buffers_(sli_neuron &);
147  Buffers_(const Buffers_ &, sli_neuron &);
148 
153 
154 
157  };
158 
159  // Access functions for UniversalDataLogger -------------------------------
160 
163  {
164  double vm = 0.0;
165  if (state_->known(names::V_m))
167 
168  return vm;
169  }
170 
171  // ----------------------------------------------------------------
172 
193  Token *spike_t;//< Boolean for fast spike initiation
195 
198 
201  };
202 
203 inline
205 {
206  SpikeEvent e;
207  e.set_sender(*this);
208 
209  return target.handles_test_event(e, receptor_type);
210 }
211 
212 
213 inline
215 {
216  if (receptor_type != 0)
217  throw UnknownReceptorType(receptor_type, get_name());
218  return 0;
219 }
220 
221 inline
223 {
224  if (receptor_type != 0)
225  throw UnknownReceptorType(receptor_type, get_name());
226  return 0;
227 }
228 
229 inline
232 {
233  if (receptor_type != 0)
234  throw UnknownReceptorType(receptor_type, get_name());
235  return B_.logger_.connect_logging_device(dlr, recordablesMap_);
236 }
237 
238 
239 inline
241 {
242  return state_;
243 }
244 
245 inline
247 {
248  // We needn't do anything else here, since d already points to
249  // sli_neuron::state_, because of Node::get_status_dict_().
250  //
252  (*d)[names::recordables] = recordablesMap_.get_list();
253 }
254 
255 inline
257 {
259 
260  // To initialize the state dictionary, we copy all entries from d into s.
261  // Later, the state dictionary will be in the interpreter and values are changed
262  // automatically. SetStatus is then only needed to change properties of Archiving_Node.
263  for ( TokenMap::const_iterator it = d->begin();it != d->end(); ++it)
264  {
265  state_->insert(it->first, it->second);
266  it->second.set_access_flag();
267  }
268 }
269 
270 } // namespace
271 
272 #endif /* #ifndef SLI_NEURON_H */
port send_test_event(Node &, rport, synindex, bool)
Send an event to the receiving_node passed as an argument.
Definition: sli_neuron.h:204
const Name recordables("recordables")
List of recordable state data (Device parameters)
Definition: nest_names.h:244
const Name V_m("V_m")
Membrane potential.
Definition: nest_names.h:331
DictionaryDatum get_status_dict_()
Return a new dictionary datum .
Definition: sli_neuron.h:240
Definition of Archiving_Node which is capable of recording and managing a spike history.
void get_status(DictionaryDatum &) const
Definition: sli_neuron.h:246
void init_state_(const Node &proto)
Private function to initialize the state of a node to model defaults.
Definition: sli_neuron.cpp:89
Token * in_spikes_t
number of excitatory spikes during the time slice
Definition: sli_neuron.h:188
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Token * update_t
points to update
Definition: sli_neuron.h:186
void set_status(const DictionaryDatum &)
Definition: sli_neuron.h:256
double_t get_V_m_() const
Read out the real membrane potential.
Definition: sli_neuron.h:162
void set_sender(Node &)
Change pointer to sending Node.
Definition: event.h:714
void handle(SpikeEvent &)
Handle incoming spike events.
Definition: sli_neuron.cpp:187
Token * spike_t
Definition: sli_neuron.h:193
Buffers of the model.
Definition: sli_neuron.h:145
Event for electrical currents.
Definition: event.h:420
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
static RecordablesMap< sli_neuron > recordablesMap_
Mapping of recordables names to access functions.
Definition: sli_neuron.h:197
Buffers_(sli_neuron &)
Definition: sli_neuron.cpp:54
friend class UniversalDataLogger< sli_neuron >
Definition: sli_neuron.h:138
Map names of recordables to data access functions.
Definition: recordables_map.h:58
Token * last_spike_t
time of last spike
Definition: sli_neuron.h:191
Definition: nest_time.h:130
std::string get_name() const
Return class name.
Definition: node.cpp:83
RingBuffer currents_
Definition: sli_neuron.h:152
void set_status(const DictionaryDatum &d)
Definition: archiving_node.cpp:185
sli_neuron()
Definition: sli_neuron.cpp:66
DictionaryDatum state_
Definition: sli_neuron.h:180
Exception to be thrown if the specified receptor type does not exist in the node. ...
Definition: exceptions.h:254
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
neuron with state and dynamics defined as SLI code
Definition: sli_neuron.h:93
double getValue< double >(const Token &t)
Definition: tokenutils.cc:68
void calibrate()
Re-calculate dependent parameters of the node.
Definition: sli_neuron.cpp:106
a node which archives spike history for the purposes of timing dependent plasticity ...
Definition: archiving_node.h:50
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition: node.cpp:198
double double_t
Double precision floating point numbers.
Definition: nest.h:93
virtual port handles_test_event(SpikeEvent &, rport receptor_type)
Check if the node can handle a particular event and receptor type.
Definition: node.cpp:203
RingBuffer ex_spikes_
buffers and summs up incoming spikes/currents
Definition: sli_neuron.h:150
Request data to be logged/logged data to be sent.
Definition: event.h:486
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
port handles_test_event(SpikeEvent &, rport)
Check if the node can handle a particular event and receptor type.
Definition: sli_neuron.h:214
Token * currents_t
external current
Definition: sli_neuron.h:190
Default types used by the NEST kernel.
void get_status(DictionaryDatum &d) const
Definition: archiving_node.cpp:175
Event for spike information.
Definition: event.h:320
Buffers_ B_
Definition: sli_neuron.h:194
Base class for all NEST network objects.
Definition: node.h:96
Token * vm_t
These are pointers into the status dictionary and must be updated in calibrate.
Definition: sli_neuron.h:185
Token * calibrate_t
points to calibrate
Definition: sli_neuron.h:187
RingBuffer in_spikes_
Definition: sli_neuron.h:151
A type-independent container for C++-types.
Definition: token.h:68
Token * ex_spikes_t
number of inhibitory spikes during the sime slice
Definition: sli_neuron.h:189
void update(Time const &, const long_t, const long_t)
Bring the node from state $t$ to $t+n*dt$.
Definition: sli_neuron.cpp:143
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
const double e
Definition: numerics.cpp:62
void set(const DictionaryDatum &)
Set values from dicitonary.
UniversalDataLogger< sli_neuron > logger_
Logger for all analog data.
Definition: sli_neuron.h:156
Buffer Layout.
Definition: ring_buffer.h:77
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: sli_neuron.cpp:95
Token * out_events_t
Events produced by the neuron.
Definition: sli_neuron.h:192