NEST  2.6.0,not_revisioned_source_dir@0
poisson_generator_ps.h
Go to the documentation of this file.
1 /*
2  * poisson_generator_ps.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 POISSON_GENERATOR_PS_H
24 #define POISSON_GENERATOR_PS_H
25 
26 #include <vector>
27 #include "nest.h"
28 #include "event.h"
29 #include "node.h"
30 #include "stimulating_device.h"
31 #include "scheduler.h"
32 #include "exp_randomdev.h"
33 #include "connection.h"
34 
35 /*BeginDocumentation
36 Name: poisson_generator_ps - simulate neuron firing with Poisson processes
37 (with arbitrary dead time) statistics and exact timing
38 Description:
39 
40  The poisson_generator_ps generator simulates a neuron firing with Poisson
41  statistics (with dead time), ie, exponentially distributed interspike
42  intervals plus constant dead time, spike events have exact timing
43  (i.e. not binned).
44 
45 Parameters:
46  The following parameters appear in the element's status dictionary:
47 
48  rate - mean firing rate. (double, var)
49  dead_time - minimal time between two spikes. (double, var)
50 
51 Note:
52  - This generator must be connected to all its targets using the
53  same synapse model. Failure to do so will only be detected at
54  runtime.
55  - This generator has only been validated in a very basic manner.
56 
57  Sends: SpikeEvent
58 
59 SeeAlso: poisson_generator, spike_generator, Device, StimulatingDevice
60 */
61 
62 namespace nest{
63 
74  class poisson_generator_ps: public Node
75  {
76 
77  public:
78 
81 
82  bool has_proxies() const {return false;}
83  bool is_off_grid() const {return true;} // uses off_grid events
84 
85  using Node::event_hook;
86 
88 
89  void get_status(DictionaryDatum &) const;
90  void set_status(const DictionaryDatum &);
91 
92  private:
93  void init_state_(const Node&);
94  void init_buffers_();
95  void calibrate();
96 
106  void update(Time const &, const long_t, const long_t);
107 
113  void event_hook(DSSpikeEvent&);
114 
115  // ------------------------------------------------------------
116 
120  struct Parameters_ {
123 
130  size_t num_targets_;
131 
132  Parameters_();
133 
134  void get(DictionaryDatum&) const;
135  void set(const DictionaryDatum&);
136  };
137 
138  // ------------------------------------------------------------
139 
140  struct Buffers_ {
141  typedef std::pair<Time, double_t> SpikeTime;
142 
150  std::vector<SpikeTime> next_spike_;
151  };
152 
153  // ------------------------------------------------------------
154 
155  struct Variables_ {
158 
171 
172  };
173 
174  // ------------------------------------------------------------
175 
180  };
181 
182 inline
184  {
185  device_.enforce_single_syn_type(syn_id);
186 
187  if ( dummy_target )
188  {
189  DSSpikeEvent e;
190  e.set_sender(*this);
191  return target.handles_test_event(e, receptor_type);
192  }
193  else
194  {
195  SpikeEvent e;
196  e.set_sender(*this);
197  const port p = target.handles_test_event(e, receptor_type);
198  if ( p != invalid_port_ and not is_model_prototype() )
199  ++P_.num_targets_; // count number of targets
200  return p;
201  }
202  }
203 
204 inline
206 {
207  P_.get(d);
208  device_.get_status(d);
209 }
210 
211 inline
213 {
214  Parameters_ ptmp = P_; // temporary copy in case of errors
215  ptmp.set(d); // throws if BadProperty
216 
217  // We now know that ptmp is consistent. We do not write it back
218  // to P_ before we are also sure that the properties to be set
219  // in the parent class are internally consistent.
220  device_.set_status(d);
221 
222  // if we get here, temporaries contain consistent set of properties
223  P_ = ptmp;
224 }
225 
226 } // namespace
227 
228 #endif //POISSON_GENERATOR_PS_H
poisson_generator_ps()
Definition: poisson_generator_ps.cpp:77
Time t_max_active_
end of generator activity in slice
Definition: poisson_generator_ps.h:170
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
Store independent parameters of the model.
Definition: poisson_generator_ps.h:120
bool is_model_prototype() const
Returns true if node is model prototype.
Definition: node.h:795
Definition: lockptrdatum.h:40
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Declarations for base class Node.
"Callback request event" for use in Device.
Definition: event.h:374
Base class for common properties of Stimulating Devices.
Definition: stimulating_device.h:117
bool is_off_grid() const
Returns true if the node if it sends/receives -grid events This is used to discriminate between diffe...
Definition: poisson_generator_ps.h:83
const rport invalid_port_
Value for invalid connection port number.
Definition: nest.h:160
void set_sender(Node &)
Change pointer to sending Node.
Definition: event.h:714
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: poisson_generator_ps.cpp:48
Definition: poisson_generator_ps.h:140
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
double_t inv_rate_ms_
1000.0 / Parameters_.rate_
Definition: poisson_generator_ps.h:156
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: poisson_generator_ps.cpp:101
size_t num_targets_
Number of targets.
Definition: poisson_generator_ps.h:130
Parameters_()
Sets default parameter values.
Definition: poisson_generator_ps.cpp:38
void calibrate()
Re-calculate dependent parameters of the node.
Definition: poisson_generator_ps.cpp:110
void set_status(const DictionaryDatum &)
Definition: poisson_generator_ps.h:212
Poisson generator (with dead time) with precisely timed spikes.
Definition: poisson_generator_ps.h:74
Definition: nest_time.h:130
Parameters_ P_
Definition: poisson_generator_ps.h:177
port send_test_event(Node &, rport, synindex, bool)
Send an event to the receiving_node passed as an argument.
Definition: poisson_generator_ps.h:183
void set(const DictionaryDatum &)
Set values from dicitonary.
Definition: poisson_generator_ps.cpp:54
Time t_min_active_
start of generator activity in slice
Definition: poisson_generator_ps.h:169
std::pair< Time, double_t > SpikeTime
Definition: poisson_generator_ps.h:141
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
librandom::ExpRandomDev exp_dev_
random deviate generator
Definition: poisson_generator_ps.h:157
void get_status(DictionaryDatum &) const
Definition: poisson_generator_ps.h:205
double_t rate_
process rate [Hz]
Definition: poisson_generator_ps.h:121
Definition: poisson_generator_ps.h:155
Buffers_ B_
Definition: poisson_generator_ps.h:179
void update(Time const &, const long_t, const long_t)
Update state.
Definition: poisson_generator_ps.cpp:151
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
double double_t
Double precision floating point numbers.
Definition: nest.h:93
Variables_ V_
Definition: poisson_generator_ps.h:178
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
double_t dead_time_
dead time [ms]
Definition: poisson_generator_ps.h:122
std::vector< SpikeTime > next_spike_
Time of next spike represented as time stamp and offset, for each target.
Definition: poisson_generator_ps.h:150
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
Default types used by the NEST kernel.
Event for spike information.
Definition: event.h:320
Base class for all NEST network objects.
Definition: node.h:96
void init_state_(const Node &)
Private function to initialize the state of a node to model defaults.
Definition: poisson_generator_ps.cpp:94
bool has_proxies() const
Returns true if the node has proxies on remote threads.
Definition: poisson_generator_ps.h:82
virtual void event_hook(DSSpikeEvent &)
Modify Event object parameters during event delivery.
Definition: node.cpp:301
const Name p("p")
current release probability (Tsodyks2_connection)
Definition: nest_names.h:218
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
const double e
Definition: numerics.cpp:62
StimulatingDevice< CurrentEvent > device_
Definition: poisson_generator_ps.h:176
void event_hook(DSSpikeEvent &)
Send out spikes.
Definition: poisson_generator_ps.cpp:180