NEST main@caf0ae8
 
Loading...
Searching...
No Matches
bernoulli_synapse.h
Go to the documentation of this file.
1/*
2 * bernoulli_synapse.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
24#ifndef BERNOULLI_SYNAPSE_H
25#define BERNOULLI_SYNAPSE_H
26
27// Includes from nestkernel:
28#include "connection.h"
29#include "kernel_manager.h"
30
31namespace nest
32{
33
34/* BeginUserDocs: synapse, chemical, static, stochastic
35
36Short description
37+++++++++++++++++
38
39Static synapse with stochastic transmission
40
41Description
42+++++++++++
43
44Spikes are transmitted by ``bernoulli_synapse`` following a Bernoulli
45trial with success probability ``p_transmit``. This synaptic mechanism was
46inspired by the results described in :footcite:p:`Lefort2009` of greater transmission
47probability for stronger excitatory connections and it was previously
48applied in :footcite:p:`Teramae2012` and :footcite:p:`Omura2015`.
49
50``bernoulli_synapse`` does not support any kind of plasticity. It simply
51stores the parameters target, weight, transmission probability, delay
52and receiver port for each connection.
53
54Parameters
55++++++++++
56
57=========== ====== ===================================================
58 p_transmit real Transmission probability, must be between 0 and 1
59=========== ====== ===================================================
60
61Transmits
62+++++++++
63
64SpikeEvent, RateEvent, CurrentEvent, ConductanceEvent,
65DoubleDataEvent, DataLoggingRequest
66
67References
68++++++++++
69
70.. footbibliography::
71
72See also
73++++++++
74
75static_synapse, static_synapse_hom_w
76
77Examples using this model
78+++++++++++++++++++++++++
79
80.. listexamples:: bernoulli_synapse
81
82EndUserDocs */
83
84void register_bernoulli_synapse( const std::string& name );
85
86template < typename targetidentifierT >
87class bernoulli_synapse : public Connection< targetidentifierT >
88{
89public:
90 // this line determines which common properties to use
93
97
104 , weight_( 1.0 )
105 , p_transmit_( 1.0 )
106 {
107 }
108
113 bernoulli_synapse( const bernoulli_synapse& rhs ) = default;
115
116 // Explicitly declare all methods inherited from the dependent base
117 // ConnectionBase. This avoids explicit name prefixes in all places these
118 // functions are used. Since ConnectionBase depends on the template parameter,
119 // they are not automatically found in the base class.
123
124
126 {
127 public:
128 // Ensure proper overriding of overloaded virtual functions.
129 // Return values from functions are ignored.
131 size_t
132 handles_test_event( SpikeEvent&, size_t ) override
133 {
134 return invalid_port;
135 }
136 };
137
138 void
139 check_connection( Node& s, Node& t, size_t receptor_type, const CommonPropertiesType& )
140 {
141 ConnTestDummyNode dummy_target;
142 ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
143 }
144
145 bool
146 send( Event& e, size_t t, const CommonSynapseProperties& )
147 {
148 SpikeEvent e_spike = static_cast< SpikeEvent& >( e );
149
150 assert( e_spike.get_multiplicity() == 1 );
151
152 const bool send_spike = get_vp_specific_rng( t )->drand() < p_transmit_;
153
154 if ( send_spike )
155 {
156 e.set_weight( weight_ );
157 e.set_delay_steps( get_delay_steps() );
158 e.set_receiver( *get_target( t ) );
159 e.set_rport( get_rport() );
160 e();
161 }
162
163 return send_spike;
164 }
165
166 void get_status( Dictionary& d ) const;
167
168 void set_status( const Dictionary& d, ConnectorModel& cm );
169
170 void
171 set_weight( double w )
172 {
173 weight_ = w;
174 }
175
176private:
177 double weight_;
179};
180
181template < typename targetidentifierT >
183
184template < typename targetidentifierT >
185void
187{
188 ConnectionBase::get_status( d );
189 d[ names::weight ] = weight_;
190 d[ names::p_transmit ] = p_transmit_;
191 d[ names::size_of ] = static_cast< long >( sizeof( *this ) );
192}
193
194template < typename targetidentifierT >
195void
197{
198 ConnectionBase::set_status( d, cm );
199 d.update_value( names::weight, weight_ );
200 d.update_value( names::p_transmit, p_transmit_ );
201
202 if ( p_transmit_ < 0 or p_transmit_ > 1 )
203 {
204 throw BadProperty( "Spike transmission probability must be in [0, 1]." );
205 }
206}
207
208} // namespace
209
210#endif /* #ifndef BERNOULLI_SYNAPSE_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Exception to be thrown if a status parameter is incomplete or inconsistent.
Definition exceptions.h:680
virtual double drand()=0
Uses the wrapped RNG engine to draw a double from a uniform distribution in the range [0,...
Class containing the common properties for all connections of a certain type.
Definition common_synapse_properties.h:50
Base class for dummy nodes used in connection testing.
Definition connection.h:67
Base class for representing connections.
Definition connection.h:110
void check_connection_(Node &dummy_target, Node &source, Node &target, const size_t receptor_type)
This function calls check_connection() on the sender to check if the receiver accepts the event type ...
Definition connection.h:319
long get_delay_steps() const
Return the delay of the connection in steps.
Definition connection.h:181
Node * get_target(const size_t tid) const
Definition connection.h:239
size_t get_rport() const
Definition connection.h:244
Definition connector_model.h:69
Encapsulate information sent between nodes.
Definition event.h:103
Base class for all NEST network objects.
Definition node.h:99
Event for spike information.
Definition event.h:418
size_t get_multiplicity() const
Definition event.h:449
Definition bernoulli_synapse.h:126
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition bernoulli_synapse.h:132
Definition bernoulli_synapse.h:88
long get_delay_steps() const
Return the delay of the connection in steps.
Definition connection.h:181
bernoulli_synapse & operator=(const bernoulli_synapse &rhs)=default
Node * get_target(const size_t tid) const
Definition connection.h:239
void get_status(Dictionary &d) const
Definition bernoulli_synapse.h:186
void check_connection(Node &s, Node &t, size_t receptor_type, const CommonPropertiesType &)
Definition bernoulli_synapse.h:139
void set_weight(double w)
Definition bernoulli_synapse.h:171
Connection< targetidentifierT > ConnectionBase
Definition bernoulli_synapse.h:92
double p_transmit_
Definition bernoulli_synapse.h:178
void set_status(const Dictionary &d, ConnectorModel &cm)
Definition bernoulli_synapse.h:196
size_t get_rport() const
Definition connection.h:244
CommonSynapseProperties CommonPropertiesType
Definition bernoulli_synapse.h:91
bool send(Event &e, size_t t, const CommonSynapseProperties &)
Definition bernoulli_synapse.h:146
double weight_
Definition bernoulli_synapse.h:177
static constexpr ConnectionModelProperties properties
Definition bernoulli_synapse.h:94
bernoulli_synapse()
Default Constructor.
Definition bernoulli_synapse.h:102
bernoulli_synapse(const bernoulli_synapse &rhs)=default
Copy constructor from a property object.
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
const std::string p_transmit("p_transmit")
const std::string weight("weight")
const std::string size_of("sizeof")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
RngPtr get_vp_specific_rng(size_t tid)
Definition kernel_manager.h:298
void register_bernoulli_synapse(const std::string &name)
Definition bernoulli_synapse.cpp:32
ConnectionModelProperties
Definition connector_model.h:49
constexpr size_t invalid_port
Value for invalid connection port number.
Definition nest_types.h:141