23#ifndef RATE_NEURON_IPN_IMPL_H
24#define RATE_NEURON_IPN_IMPL_H
53template <
class TNonlinearities >
60template <
class TNonlinearities >
66 , rectify_rate_( 0.0 )
67 , linear_summation_( true )
68 , rectify_output_( false )
69 , mult_coupling_( false )
74template <
class TNonlinearities >
85template <
class TNonlinearities >
103template <
class TNonlinearities >
120 "rate_neuron_ipn< TNonlinearities >::Parameters_::set",
121 "The parameter mean has been renamed to mu. Please use the new "
122 "name from now on." );
128 "rate_neuron_ipn< TNonlinearities >::Parameters_::set",
129 "The parameter std has been renamed to sigma. Please use the new "
130 "name from now on." );
140 throw BadProperty(
"Passive decay rate must be >= 0." );
144 throw BadProperty(
"Noise parameter must not be negative." );
146 if ( rectify_rate_ < 0 )
148 throw BadProperty(
"Rectifying rate must not be negative." );
152template <
class TNonlinearities >
160template <
class TNonlinearities >
167template <
class TNonlinearities >
173template <
class TNonlinearities >
183template <
class TNonlinearities >
194template <
class TNonlinearities >
197 , nonlinearities_( n.nonlinearities_ )
209template <
class TNonlinearities >
213 B_.delayed_rates_ex_.clear();
214 B_.delayed_rates_in_.clear();
218 B_.instant_rates_ex_.resize( buffer_size, 0.0 );
219 B_.instant_rates_in_.resize( buffer_size, 0.0 );
220 B_.last_y_values.resize( buffer_size, 0.0 );
224 for (
unsigned int i = 0; i < buffer_size; i++ )
233template <
class TNonlinearities >
241 if ( P_.lambda_ > 0 )
244 V_.P1_ = std::exp( -P_.lambda_ * h / P_.tau_ );
245 V_.P2_ = -1.0 / P_.lambda_ *
numerics::expm1( -P_.lambda_ * h / P_.tau_ );
246 V_.input_noise_factor_ = std::sqrt( -0.5 / P_.lambda_ *
numerics::expm1( -2. * P_.lambda_ * h / P_.tau_ ) );
252 V_.P2_ = h / P_.tau_;
253 V_.input_noise_factor_ = std::sqrt( h / P_.tau_ );
261template <
class TNonlinearities >
266 const bool called_from_wfr_update )
270 bool wfr_tol_exceeded =
false;
273 std::vector< double > new_rates( buffer_size, 0.0 );
275 for (
long lag = from; lag < to; ++lag )
278 new_rates[ lag ] = S_.rate_;
280 S_.noise_ = P_.sigma_ * B_.random_numbers[ lag ];
282 S_.rate_ = V_.P1_ * new_rates[ lag ] + V_.P2_ * P_.mu_ + V_.input_noise_factor_ * S_.noise_;
284 double delayed_rates_in = 0;
285 double delayed_rates_ex = 0;
286 if ( called_from_wfr_update )
289 delayed_rates_in = B_.delayed_rates_in_.get_value_wfr_update( lag );
290 delayed_rates_ex = B_.delayed_rates_ex_.get_value_wfr_update( lag );
295 delayed_rates_in = B_.delayed_rates_in_.get_value( lag );
296 delayed_rates_ex = B_.delayed_rates_ex_.get_value( lag );
298 double instant_rates_in = B_.instant_rates_in_[ lag ];
299 double instant_rates_ex = B_.instant_rates_ex_[ lag ];
302 if ( P_.mult_coupling_ )
304 H_ex = nonlinearities_.mult_coupling_ex( new_rates[ lag ] );
305 H_in = nonlinearities_.mult_coupling_in( new_rates[ lag ] );
308 if ( P_.linear_summation_ )
314 if ( P_.mult_coupling_ )
316 S_.rate_ += V_.P2_ * H_ex * nonlinearities_.input( delayed_rates_ex + instant_rates_ex );
317 S_.rate_ += V_.P2_ * H_in * nonlinearities_.input( delayed_rates_in + instant_rates_in );
322 V_.P2_ * nonlinearities_.input( delayed_rates_ex + instant_rates_ex + delayed_rates_in + instant_rates_in );
329 S_.rate_ += V_.P2_ * H_ex * ( delayed_rates_ex + instant_rates_ex );
330 S_.rate_ += V_.P2_ * H_in * ( delayed_rates_in + instant_rates_in );
333 if ( P_.rectify_output_ and S_.rate_ < P_.rectify_rate_ )
335 S_.rate_ = P_.rectify_rate_;
338 if ( called_from_wfr_update )
341 wfr_tol_exceeded = wfr_tol_exceeded or fabs( S_.rate_ - B_.last_y_values[ lag ] ) > wfr_tol;
343 B_.last_y_values[ lag ] = S_.rate_;
348 B_.logger_.record_data( origin.get_steps() + lag );
352 if ( not called_from_wfr_update )
361 std::vector< double >( buffer_size, 0.0 ).swap( B_.last_y_values );
364 for (
long temp = from; temp < to; ++temp )
366 new_rates[ temp ] = S_.rate_;
371 for (
unsigned int i = 0; i < buffer_size; i++ )
383 std::vector< double >( buffer_size, 0.0 ).swap( B_.instant_rates_ex_ );
384 std::vector< double >( buffer_size, 0.0 ).swap( B_.instant_rates_in_ );
386 return wfr_tol_exceeded;
390template <
class TNonlinearities >
394 const double weight = e.get_weight();
397 std::vector< unsigned int >::iterator it = e.begin();
399 while ( it != e.end() )
401 if ( P_.linear_summation_ )
405 B_.instant_rates_ex_[ i ] += weight * e.get_coeffvalue( it );
409 B_.instant_rates_in_[ i ] += weight * e.get_coeffvalue( it );
416 B_.instant_rates_ex_[ i ] += weight * nonlinearities_.input( e.get_coeffvalue( it ) );
420 B_.instant_rates_in_[ i ] += weight * nonlinearities_.input( e.get_coeffvalue( it ) );
427template <
class TNonlinearities >
431 const double weight = e.get_weight();
435 std::vector< unsigned int >::iterator it = e.begin();
437 while ( it != e.end() )
439 if ( P_.linear_summation_ )
443 B_.delayed_rates_ex_.add_value( delay + i, weight * e.get_coeffvalue( it ) );
447 B_.delayed_rates_in_.add_value( delay + i, weight * e.get_coeffvalue( it ) );
454 B_.delayed_rates_ex_.add_value( delay + i, weight * nonlinearities_.input( e.get_coeffvalue( it ) ) );
458 B_.delayed_rates_in_.add_value( delay + i, weight * nonlinearities_.input( e.get_coeffvalue( it ) ) );
465template <
class TNonlinearities >
469 B_.logger_.handle( e );
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
A node which archives spike history for the purposes of spike-timing dependent plasticity (STDP)
Definition archiving_node.h:49
void clear_history()
Clear spike history.
Definition archiving_node.cpp:269
Exception to be thrown if a status parameter is incomplete or inconsistent.
Definition exceptions.h:680
long get_min_delay() const
Return minimal connection delay, which is precomputed by update_delay_extrema_().
Definition connection_manager.h:728
Request data to be logged/logged data to be sent.
Definition event.h:636
void set_coeffarray(std::vector< DataType > &ca)
Definition secondary_event.h:224
Event for rate model connections with delay.
Definition secondary_event.h:331
void send_secondary(Node &source, SecondaryEvent &e)
Send a secondary event remote.
Definition event_delivery_manager_impl.h:138
Event for rate model connections without delay.
Definition secondary_event.h:315
Base class for all NEST network objects.
Definition node.h:99
void set_node_uses_wfr(const bool)
Sets node_uses_wfr_ member variable (to be able to set it to "true" for any class derived from Node)
Definition node.h:1158
double get_wfr_tol() const
Get the convergence tolerance of the waveform relaxation method.
Definition simulation_manager.h:331
Definition nest_time.h:135
static Time get_resolution()
Definition nest_time.h:325
double get_ms() const
Definition nest_time.h:490
Definition rate_neuron_ipn.h:109
void init_buffers_() override
Configure persistent internal data structures.
Definition rate_neuron_ipn_impl.h:211
bool update_(Time const &, const long, const long, const bool)
This is the actual update function.
Definition rate_neuron_ipn_impl.h:263
rate_neuron_ipn()
Definition rate_neuron_ipn_impl.h:184
State_ S_
Definition rate_neuron_ipn.h:291
Parameters_ P_
Definition rate_neuron_ipn.h:290
Buffers_ B_
Definition rate_neuron_ipn.h:293
static RecordablesMap< rate_neuron_ipn< TNonlinearities > > recordablesMap_
Mapping of recordables names to access functions.
Definition rate_neuron_ipn.h:296
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition rate_neuron_ipn_impl.h:235
void handle(InstantaneousRateConnectionEvent &) override
Handler for rate neuron events.
Definition rate_neuron_ipn_impl.h:392
ConnectionManager connection_manager
Definition kernel_manager.h:239
EventDeliveryManager event_delivery_manager
Definition kernel_manager.h:241
SimulationManager simulation_manager
Definition kernel_manager.h:237
#define LOG(s, fctn, msg)
Definition logging.h:29
const std::string std("std")
const std::string tau("tau")
const std::string mult_coupling("mult_coupling")
const std::string linear_summation("linear_summation")
const std::string lambda("lambda")
const std::string rate("rate")
const std::string mean("mean")
const std::string rectify_output("rectify_output")
const std::string noise("noise")
const std::string rectify_rate("rectify_rate")
const std::string sigma("sigma")
const std::string mu("mu")
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
KernelManager & kernel()
Definition kernel_manager.h:311
bool update_value_param(Dictionary const &d, const std::string &key, T &value, nest::Node *node)
Obtain value from parameter dictionary including evaluation of random or spatial parameters.
Definition dict_util.h:42
const double nan
Definition numerics.cpp:36
double expm1(double x)
Definition numerics.h:44
Buffers of the model.
Definition rate_neuron_ipn.h:237
Buffers_(rate_neuron_ipn &)
Definition rate_neuron_ipn_impl.h:168
void get(Dictionary &) const
Store current values in dictionary.
Definition rate_neuron_ipn_impl.h:87
Parameters_()
Sets default parameter values.
Definition rate_neuron_ipn_impl.h:61
void set(const Dictionary &, Node *node)
Definition rate_neuron_ipn_impl.h:105
State_()
Default initialization.
Definition rate_neuron_ipn_impl.h:75
void set(const Dictionary &, Node *node)
Set values from dictionary.
Definition rate_neuron_ipn_impl.h:162
void get(Dictionary &) const
Definition rate_neuron_ipn_impl.h:154