NEST main@caf0ae8
 
Loading...
Searching...
No Matches
spike_dilutor.h
Go to the documentation of this file.
1/*
2 * spike_dilutor.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 SPIKE_DILUTOR_H
24#define SPIKE_DILUTOR_H
25
26// Includes from nestkernel:
27#include "connection.h"
28#include "device_node.h"
29#include "event.h"
30#include "nest_types.h"
31#include "ring_buffer.h"
32#include "stimulation_device.h"
33
34namespace nest
35{
36
37/* BeginUserDocs: device, generator
38
39Short description
40+++++++++++++++++
41
42Repeat incoming spikes with a certain probability
43
44Description
45+++++++++++
46
47The device repeats incoming spikes with a certain probability.
48Targets will receive different spike trains.
49
50In parallel simulations, a copy of the device is present on each process
51and spikes are collected only from local sources.
52
53.. admonition:: Deprecated model
54
55 ``spike_dilutor`` is deprecated because it does not work with multiple threads.
56 To create connections that transmit spikes with a given probability, use :doc:`bernoulli_synapse <bernoulli_synapse>`
57 instead.
58
59.. admonition:: Does not work with threads
60
61 ``spike_dilutor`` only works in single-threaded simulations. It can be used with MPI-parallel simulations.
62
63Parameters
64++++++++++
65
66p_copy
67 Copy probability
68
69Sends
70+++++
71
72SpikeEvent
73
74See also
75++++++++
76
77mip_generator
78
79
80Examples using this model
81+++++++++++++++++++++++++
82
83.. listexamples:: spike_dilutor
84
85EndUserDocs */
86
87void register_spike_dilutor( const std::string& name );
88
90{
91
92public:
94 spike_dilutor( const spike_dilutor& rhs );
95
96 bool
97 has_proxies() const override
98 {
99 return false;
100 }
101
102 bool
103 local_receiver() const override
104 {
105 return true;
106 }
107
108 std::string
109 get_element_type() const override
110 {
111 return names::stimulator;
112 }
113
114 using Node::event_hook;
115 using Node::handle;
116 using Node::handles_test_event; // new
117
118 size_t send_test_event( Node&, size_t, synindex, bool ) override;
119 size_t handles_test_event( SpikeEvent&, size_t ) override;
120 void handle( SpikeEvent& ) override;
121
122 void get_status( Dictionary& ) const override;
123 void set_status( const Dictionary& ) override;
124
125private:
126 void init_state_() override;
127 void init_buffers_() override;
128 void pre_run_hook() override;
129
130 void update( Time const&, const long, const long ) override;
131
132 void event_hook( DSSpikeEvent& ) override;
133
134 // ------------------------------------------------------------
135
140 {
141 double p_copy_;
142
143 Parameters_();
144 Parameters_( const Parameters_& ) = default;
145 Parameters_& operator=( const Parameters_& ) = default;
146
147 void get( Dictionary& ) const;
148 void set( const Dictionary&, Node* node );
149 };
150
151 struct Buffers_
152 {
154 };
155
156 // ------------------------------------------------------------
157
166
169};
170
171inline size_t
172spike_dilutor::send_test_event( Node& target, size_t receptor_type, synindex syn_id, bool )
173{
175
176 SpikeEvent e;
177 e.set_sender( *this );
178 return target.handles_test_event( e, receptor_type );
179}
180
181inline size_t
183{
184 if ( receptor_type != 0 )
185 {
186 throw UnknownReceptorType( receptor_type, get_name() );
187 }
188 return 0;
189}
190
191inline void
193{
194 P_.get( d );
195 device_.get_status( d );
196}
197
198inline void
200{
201 Parameters_ ptmp = P_; // temporary copy in case of errors
202 ptmp.set( d, this ); // throws if BadProperty
203
204 // We now know that ptmp is consistent. We do not write it back
205 // to P_ before we are also sure that the properties to be set
206 // in the parent class are internally consistent.
207 device_.set_status( d );
208
209 // if we get here, temporaries contain consistent set of properties
210 P_ = ptmp;
211}
212
213} // namespace nest
214
215#endif
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
"Callback request event" for use in Device.
Definition event.h:521
Base class for device objects.
Definition device_node.h:36
Base class for all NEST network objects.
Definition node.h:99
virtual void event_hook(DSSpikeEvent &)
Modify Event object parameters during event delivery.
Definition node.cpp:586
std::string get_name() const
Return class name.
Definition node.cpp:105
Buffer Layout.
Definition ring_buffer.h:83
Event for spike information.
Definition event.h:418
Base class for common properties of StimulationDevices.
Definition stimulation_device.h:154
void enforce_single_syn_type(synindex)
Throws IllegalConnection if synapse id differs from initial synapse id.
Definition stimulation_device.cpp:62
Type
Device type.
Definition stimulation_device.h:187
@ SPIKE_GENERATOR
Definition stimulation_device.h:189
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition stimulation_device.cpp:125
void get_status(Dictionary &d) const override
Export properties of the node by setting entries in the status dictionary.
Definition stimulation_device.cpp:168
Definition nest_time.h:135
Exception to be thrown if the specified receptor type does not exist in the node.
Definition exceptions.h:417
Definition spike_dilutor.h:159
StimulationDevice::Type get_type() const override
Definition spike_dilutor.h:161
Definition spike_dilutor.h:90
void update(Time const &, const long, const long) override
Advance the state of the node in time through the given interval.
Definition spike_dilutor.cpp:128
size_t send_test_event(Node &, size_t, synindex, bool) override
Send an event to the receiving_node passed as an argument.
Definition spike_dilutor.h:172
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition spike_dilutor.h:192
void init_state_() override
Configure state variables depending on runtime information.
Definition spike_dilutor.cpp:97
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition spike_dilutor.h:182
nest::spike_dilutor::DilutorStimulationDevice device_
spike_dilutor()
Definition spike_dilutor.cpp:78
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition spike_dilutor.cpp:118
Parameters_ P_
Definition spike_dilutor.h:167
void init_buffers_() override
Configure persistent internal data structures.
Definition spike_dilutor.cpp:111
std::string get_element_type() const override
Return the element type of the node.
Definition spike_dilutor.h:109
Buffers_ B_
Definition spike_dilutor.h:168
bool has_proxies() const override
Returns true if the node has proxies on remote threads.
Definition spike_dilutor.h:97
void handle(SpikeEvent &) override
Handle incoming spike events.
Definition spike_dilutor.cpp:184
void event_hook(DSSpikeEvent &) override
Modify Event object parameters during event delivery.
Definition spike_dilutor.cpp:151
bool local_receiver() const override
Returns true if the node only receives events from nodes/devices on the same thread.
Definition spike_dilutor.h:103
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition spike_dilutor.h:199
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 handle(SpikeEvent &e)
Handle incoming spike events.
Definition node.cpp:265
const std::string stimulator("stimulator")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_spike_dilutor(const std::string &name)
Definition spike_dilutor.cpp:39
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Definition spike_dilutor.h:152
RingBuffer n_spikes_
Definition spike_dilutor.h:153
Store independent parameters of the model.
Definition spike_dilutor.h:140
Parameters_(const Parameters_ &)=default
double p_copy_
copy probability for each incoming spike
Definition spike_dilutor.h:141
Parameters_ & operator=(const Parameters_ &)=default
Parameters_()
Sets default parameter values.
Definition spike_dilutor.cpp:49
void get(Dictionary &) const
Store current values in dictionary.
Definition spike_dilutor.cpp:59
void set(const Dictionary &, Node *node)
Set values from dictionary.
Definition spike_dilutor.cpp:65