NEST  2.6.0,not_revisioned_source_dir@0
binary_neuron.h
Go to the documentation of this file.
1 /*
2  * binary_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 BINARY_NEURON_H
24 #define BINARY_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 #include "recordables_map.h"
33 #include "exp_randomdev.h"
34 #include <cmath>
35 
36 namespace nest{
37 
38  class Network;
39 
47  template<class TGainfunction>
49  {
50 
51  public:
52 
53  binary_neuron();
55 
60  using Node::handle;
62 
64 
65  void handle(SpikeEvent &);
66  void handle(CurrentEvent &);
67  void handle(DataLoggingRequest &);
68 
72 
73  void get_status(DictionaryDatum &) const;
74  void set_status(const DictionaryDatum &);
75 
76  private:
77 
78  void init_state_(const Node& proto);
79  void init_buffers_();
80  void calibrate();
81 
82  // gain function functor
83  // must have an double_t operator(double_t) defined
84  TGainfunction gain_;
85 
86  void update(Time const &, const long_t, const long_t);
87 
88  // The next two classes need to be friends to access the State_ class/member
89  friend class RecordablesMap<binary_neuron<TGainfunction> >;
90  friend class UniversalDataLogger<binary_neuron<TGainfunction> >;
91 
92  // ----------------------------------------------------------------
93 
97  struct Parameters_ {
100 
101  Parameters_();
102 
103  void get(DictionaryDatum&) const;
104  void set(const DictionaryDatum&);
105  };
106 
107  // ----------------------------------------------------------------
108 
112  struct State_ {
113  bool y_;
114  double h_;
115  double last_in_gid_;
118 
119  State_();
120 
121  void get(DictionaryDatum&, const Parameters_&) const;
122  void set(const DictionaryDatum&, const Parameters_&);
123  };
124 
125  // ----------------------------------------------------------------
126 
130  struct Buffers_ {
132  Buffers_(const Buffers_&, binary_neuron&);
133 
137 
138 
140  UniversalDataLogger<binary_neuron> logger_;
141  };
142 
143  // ----------------------------------------------------------------
144 
148  struct Variables_ {
149  librandom::RngPtr rng_; // random number generator of my own thread
150  librandom::ExpRandomDev exp_dev_; // random deviate generator
151  };
152 
153  // Access functions for UniversalDataLogger -------------------------------
154 
156  double_t get_output_state__() const { return S_.y_; }
157 
159  double_t get_input__() const { return S_.h_; }
160 
161  // ----------------------------------------------------------------
162 
178 
179  };
180 
181 
182 template<class TGainfunction>
183 inline
185 {
186  SpikeEvent e;
187  e.set_sender(*this);
188 
189  return target.handles_test_event(e, receptor_type);
190 }
191 
192 template<class TGainfunction>
193 inline
195 {
196  if (receptor_type != 0)
197  throw UnknownReceptorType(receptor_type, get_name());
198  return 0;
199 }
200 
201 template<class TGainfunction>
202 inline
204 {
205  if (receptor_type != 0)
206  throw UnknownReceptorType(receptor_type, get_name());
207  return 0;
208 }
209 
210 template<class TGainfunction>
211 inline
214 {
215  if (receptor_type != 0)
216  throw UnknownReceptorType(receptor_type, get_name());
217  return B_.logger_.connect_logging_device(dlr, recordablesMap_);
218 }
219 
220 template<class TGainfunction>
221 inline
223 {
224  P_.get(d);
225  S_.get(d, P_);
227  (*d)[names::recordables] = recordablesMap_.get_list();
228 
229  gain_.get(d);
230 }
231 
232 template<class TGainfunction>
233 inline
235 {
236  Parameters_ ptmp = P_; // temporary copy in case of errors
237  ptmp.set(d); // throws if BadProperty
238  State_ stmp = S_; // temporary copy in case of errors
239  stmp.set(d, ptmp); // throws if BadProperty
240 
241  // We now know that (ptmp, stmp) are consistent. We do not
242  // write them back to (P_, S_) before we are also sure that
243  // the properties to be set in the parent class are internally
244  // consistent.
246 
247  // if we get here, temporaries contain consistent set of properties
248  P_ = ptmp;
249  S_ = stmp;
250 
251  gain_.set(d);
252 }
253 
254 } // namespace
255 
256 #endif /* #ifndef BINARY_NEURON_H */
const Name recordables("recordables")
List of recordable state data (Device parameters)
Definition: nest_names.h:244
double last_in_gid_
gid of the last spike being received
Definition: binary_neuron.h:115
Binary stochastic neuron with linear or sigmoidal gain function.
Definition: binary_neuron.h:48
Definition of Archiving_Node which is capable of recording and managing a spike history.
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
double_t tau_m_
mean inter-update interval in ms (acts like a membrane time constant).
Definition: binary_neuron.h:99
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
double h_
total input current to neuron
Definition: binary_neuron.h:114
State_()
Default initialization.
Definition: binary_neuron_impl.h:57
State_ S_
Definition: binary_neuron.h:171
void set_sender(Node &)
Change pointer to sending Node.
Definition: event.h:714
librandom::ExpRandomDev exp_dev_
Definition: binary_neuron.h:150
bool y_
output of neuron in [0,1]
Definition: binary_neuron.h:113
Variables_ V_
Definition: binary_neuron.h:172
void handle(SpikeEvent &)
Handle incoming spike events.
Definition: binary_neuron_impl.h:212
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
RingBuffer spikes_
buffers and sums up incoming spikes/currents
Definition: binary_neuron.h:135
double_t get_input__() const
Read out the summed input of the neuron (= membrane potential)
Definition: binary_neuron.h:159
Parameters_ P_
Definition: binary_neuron.h:170
Map names of recordables to data access functions.
Definition: recordables_map.h:58
Definition: nest_time.h:130
State variables of the model.
Definition: binary_neuron.h:112
void set_status(const DictionaryDatum &d)
Definition: archiving_node.cpp:185
Time t_next_
time point of next update
Definition: binary_neuron.h:116
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
Independent parameters of the model.
Definition: binary_neuron.h:97
void get_status(DictionaryDatum &) const
Definition: binary_neuron.h:222
void init_state_(const Node &proto)
Private function to initialize the state of a node to model defaults.
Definition: binary_neuron_impl.h:132
port send_test_event(Node &, rport, synindex, bool)
Send an event to the receiving_node passed as an argument.
Definition: binary_neuron.h:184
void set_status(const DictionaryDatum &)
Definition: binary_neuron.h:234
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
port handles_test_event(SpikeEvent &, rport)
Check if the node can handle a particular event and receptor type.
Definition: binary_neuron.h:194
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
Request data to be logged/logged data to be sent.
Definition: event.h:486
Buffers_(binary_neuron &)
Definition: binary_neuron_impl.h:96
static RecordablesMap< binary_neuron< TGainfunction > > recordablesMap_
Mapping of recordables names to access functions.
Definition: binary_neuron.h:177
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
Buffers of the model.
Definition: binary_neuron.h:130
binary_neuron()
Definition: binary_neuron_impl.h:111
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
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: binary_neuron_impl.h:139
Base class for all NEST network objects.
Definition: node.h:96
TGainfunction gain_
Definition: binary_neuron.h:84
RingBuffer currents_
Definition: binary_neuron.h:136
void set(const DictionaryDatum &, const Parameters_ &)
Definition: binary_neuron_impl.h:92
librandom::RngPtr rng_
Definition: binary_neuron.h:149
double_t get_output_state__() const
Read out the binary_neuron state of the neuron.
Definition: binary_neuron.h:156
Class ExpRandomDev Create exponential random numbers.
Definition: exp_randomdev.h:52
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
Parameters_()
Sets default parameter values.
Definition: binary_neuron_impl.h:50
const double e
Definition: numerics.cpp:62
void set(const DictionaryDatum &)
Set values from dicitonary.
Definition: binary_neuron_impl.h:76
void update(Time const &, const long_t, const long_t)
Bring the node from state $t$ to $t+n*dt$.
Definition: binary_neuron_impl.h:165
void calibrate()
Re-calculate dependent parameters of the node.
Definition: binary_neuron_impl.h:148
Internal variables of the model.
Definition: binary_neuron.h:148
Time t_last_in_spike_
time point of last input spike seen
Definition: binary_neuron.h:117
Buffer Layout.
Definition: ring_buffer.h:77
Buffers_ B_
Definition: binary_neuron.h:173
UniversalDataLogger< binary_neuron > logger_
Logger for all analog data.
Definition: binary_neuron.h:140