Skip to content

Commit

Permalink
Merge pull request #3044 from heplesser/fix-wr-call
Browse files Browse the repository at this point in the history
Register only spikes actually sent with weight_recorder
  • Loading branch information
heplesser authored Dec 11, 2023
2 parents 508a1d7 + 7c980d0 commit 1ab8c5d
Show file tree
Hide file tree
Showing 29 changed files with 180 additions and 69 deletions.
19 changes: 5 additions & 14 deletions models/bernoulli_synapse.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,34 +154,25 @@ class bernoulli_synapse : public Connection< targetidentifierT >
ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
}

void
bool
send( Event& e, size_t t, const CommonSynapseProperties& )
{
SpikeEvent e_spike = static_cast< SpikeEvent& >( e );

const unsigned long n_spikes_in = e_spike.get_multiplicity();
unsigned long n_spikes_out = 0;
assert( e_spike.get_multiplicity() == 1 );

for ( unsigned long n = 0; n < n_spikes_in; ++n )
{
if ( get_vp_specific_rng( t )->drand() < p_transmit_ )
{
++n_spikes_out;
}
}
const bool send_spike = get_vp_specific_rng( t )->drand() < p_transmit_;

if ( n_spikes_out > 0 )
if ( send_spike )
{
e_spike.set_multiplicity( n_spikes_out );
e.set_weight( weight_ );
e.set_delay_steps( get_delay_steps() );
e.set_receiver( *get_target( t ) );
e.set_rport( get_rport() );
e();
}

// Resets multiplicity for consistency
e_spike.set_multiplicity( n_spikes_in );
return send_spike;
}

void get_status( DictionaryDatum& d ) const;
Expand Down
6 changes: 4 additions & 2 deletions models/clopath_synapse.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class clopath_synapse : public Connection< targetidentifierT >
* \param e The event to send
* \param cp common properties of all synapses (empty).
*/
void send( Event& e, size_t t, const CommonSynapseProperties& cp );
bool send( Event& e, size_t t, const CommonSynapseProperties& cp );


class ConnTestDummyNode : public ConnTestDummyNodeBase
Expand Down Expand Up @@ -234,7 +234,7 @@ constexpr ConnectionModelProperties clopath_synapse< targetidentifierT >::proper
* \param cp Common properties object, containing the stdp parameters.
*/
template < typename targetidentifierT >
inline void
inline bool
clopath_synapse< targetidentifierT >::send( Event& e, size_t t, const CommonSynapseProperties& )
{
double t_spike = e.get_stamp().get_ms();
Expand Down Expand Up @@ -279,6 +279,8 @@ clopath_synapse< targetidentifierT >::send( Event& e, size_t t, const CommonSyna
x_bar_ = x_bar_ * std::exp( ( t_lastspike_ - t_spike ) / tau_x_ ) + 1.0 / tau_x_;

t_lastspike_ = t_spike;

return true;
}


Expand Down
6 changes: 4 additions & 2 deletions models/cont_delay_synapse.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class cont_delay_synapse : public Connection< targetidentifierT >
* \param e The event to send
* \param cp common properties of all synapses (empty).
*/
void send( Event& e, size_t t, const CommonSynapseProperties& cp );
bool send( Event& e, size_t t, const CommonSynapseProperties& cp );

class ConnTestDummyNode : public ConnTestDummyNodeBase
{
Expand Down Expand Up @@ -216,7 +216,7 @@ class cont_delay_synapse : public Connection< targetidentifierT >
* \param p The port under which this connection is stored in the Connector.
*/
template < typename targetidentifierT >
inline void
inline bool
cont_delay_synapse< targetidentifierT >::send( Event& e, size_t t, const CommonSynapseProperties& )
{
e.set_receiver( *get_target( t ) );
Expand All @@ -241,6 +241,8 @@ cont_delay_synapse< targetidentifierT >::send( Event& e, size_t t, const CommonS
e();
// reset offset to original value
e.set_offset( orig_event_offset );

return true;
}

template < typename targetidentifierT >
Expand Down
4 changes: 3 additions & 1 deletion models/diffusion_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,16 @@ class diffusion_connection : public Connection< targetidentifierT >
* \param e The event to send
* \param p The port under which this connection is stored in the Connector.
*/
void
bool
send( Event& e, size_t t, const CommonSynapseProperties& )
{
e.set_drift_factor( drift_factor_ );
e.set_diffusion_factor( diffusion_factor_ );
e.set_receiver( *get_target( t ) );
e.set_rport( get_rport() );
e();

return true;
}

void get_status( DictionaryDatum& d ) const;
Expand Down
3 changes: 2 additions & 1 deletion models/gap_junction.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,14 @@ class gap_junction : public Connection< targetidentifierT >
* \param e The event to send
* \param p The port under which this connection is stored in the Connector.
*/
void
bool
send( Event& e, size_t t, const CommonSynapseProperties& )
{
e.set_weight( weight_ );
e.set_receiver( *get_target( t ) );
e.set_rport( get_rport() );
e();
return true;
}

void get_status( DictionaryDatum& d ) const;
Expand Down
6 changes: 4 additions & 2 deletions models/ht_synapse.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class ht_synapse : public Connection< targetidentifierT >
* \param e The event to send
* \param cp Common properties to all synapses (empty).
*/
void send( Event& e, size_t t, const CommonSynapseProperties& cp );
bool send( Event& e, size_t t, const CommonSynapseProperties& cp );

class ConnTestDummyNode : public ConnTestDummyNodeBase
{
Expand Down Expand Up @@ -202,7 +202,7 @@ constexpr ConnectionModelProperties ht_synapse< targetidentifierT >::properties;
* \param p The port under which this connection is stored in the Connector.
*/
template < typename targetidentifierT >
inline void
inline bool
ht_synapse< targetidentifierT >::send( Event& e, size_t t, const CommonSynapseProperties& )
{
// propagation t_lastspike -> t_spike, t_lastspike_ = 0 initially, p_ = 1
Expand All @@ -221,6 +221,8 @@ ht_synapse< targetidentifierT >::send( Event& e, size_t t, const CommonSynapsePr
p_ *= ( 1 - delta_P_ );

t_lastspike_ = t_spike;

return true;
}

template < typename targetidentifierT >
Expand Down
6 changes: 4 additions & 2 deletions models/jonke_synapse.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class jonke_synapse : public Connection< targetidentifierT >
* \param e The event to send
* \param cp common properties of all synapses (empty).
*/
void send( Event& e, size_t t, const JonkeCommonProperties& cp );
bool send( Event& e, size_t t, const JonkeCommonProperties& cp );


class ConnTestDummyNode : public ConnTestDummyNodeBase
Expand Down Expand Up @@ -297,7 +297,7 @@ constexpr ConnectionModelProperties jonke_synapse< targetidentifierT >::properti
* \param cp Common properties object, containing the stdp parameters.
*/
template < typename targetidentifierT >
inline void
inline bool
jonke_synapse< targetidentifierT >::send( Event& e, size_t t, const JonkeCommonProperties& cp )
{
// synapse STDP depressing/facilitation dynamics
Expand Down Expand Up @@ -347,6 +347,8 @@ jonke_synapse< targetidentifierT >::send( Event& e, size_t t, const JonkeCommonP
Kplus_ = Kplus_ * std::exp( ( t_lastspike_ - t_spike ) / cp.tau_plus_ ) + 1.0;

t_lastspike_ = t_spike;

return true;
}


Expand Down
10 changes: 7 additions & 3 deletions models/quantal_stp_synapse.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class quantal_stp_synapse : public Connection< targetidentifierT >
* \param e The event to send
* \param cp Common properties to all synapses (empty).
*/
void send( Event& e, size_t t, const CommonSynapseProperties& cp );
bool send( Event& e, size_t t, const CommonSynapseProperties& cp );

class ConnTestDummyNode : public ConnTestDummyNodeBase
{
Expand Down Expand Up @@ -205,7 +205,7 @@ constexpr ConnectionModelProperties quantal_stp_synapse< targetidentifierT >::pr
* \param cp Common properties object, containing the quantal_stp parameters.
*/
template < typename targetidentifierT >
inline void
inline bool
quantal_stp_synapse< targetidentifierT >::send( Event& e, size_t t, const CommonSynapseProperties& )
{
const double t_spike = e.get_stamp().get_ms();
Expand All @@ -225,7 +225,9 @@ quantal_stp_synapse< targetidentifierT >::send( Event& e, size_t t, const Common
}
}

if ( n_release > 0 )
const bool send_spike = n_release > 0;

if ( send_spike )
{
e.set_receiver( *get_target( t ) );
e.set_weight( n_release * weight_ );
Expand All @@ -248,6 +250,8 @@ quantal_stp_synapse< targetidentifierT >::send( Event& e, size_t t, const Common
}

t_lastspike_ = t_spike;

return send_spike;
}

} // namespace
Expand Down
4 changes: 3 additions & 1 deletion models/rate_connection_delayed.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,16 @@ class rate_connection_delayed : public Connection< targetidentifierT >
* \param e The event to send
* \param p The port under which this connection is stored in the Connector.
*/
void
bool
send( Event& e, size_t t, const CommonSynapseProperties& )
{
e.set_weight( weight_ );
e.set_delay_steps( get_delay_steps() );
e.set_receiver( *get_target( t ) );
e.set_rport( get_rport() );
e();

return true;
}

void get_status( DictionaryDatum& d ) const;
Expand Down
3 changes: 2 additions & 1 deletion models/rate_connection_instantaneous.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,14 @@ class rate_connection_instantaneous : public Connection< targetidentifierT >
* \param e The event to send
* \param p The port under which this connection is stored in the Connector.
*/
void
bool
send( Event& e, size_t t, const CommonSynapseProperties& )
{
e.set_weight( weight_ );
e.set_receiver( *get_target( t ) );
e.set_rport( get_rport() );
e();
return true;
}

void get_status( DictionaryDatum& d ) const;
Expand Down
4 changes: 3 additions & 1 deletion models/sic_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,16 @@ class sic_connection : public Connection< targetidentifierT >
* \param e The event to send
* \param p The port under which this connection is stored in the Connector.
*/
void
bool
send( Event& e, size_t t, const CommonSynapseProperties& )
{
e.set_weight( weight_ );
e.set_delay_steps( get_delay_steps() );
e.set_receiver( *get_target( t ) );
e.set_rport( get_rport() );
e();

return true;
}

void get_status( DictionaryDatum& d ) const;
Expand Down
3 changes: 2 additions & 1 deletion models/static_synapse.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,15 @@ class static_synapse : public Connection< targetidentifierT >
ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
}

void
bool
send( Event& e, const size_t tid, const CommonSynapseProperties& )
{
e.set_weight( weight_ );
e.set_delay_steps( get_delay_steps() );
e.set_receiver( *get_target( tid ) );
e.set_rport( get_rport() );
e();
return true;
}

void get_status( DictionaryDatum& d ) const;
Expand Down
4 changes: 3 additions & 1 deletion models/static_synapse_hom_w.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,16 @@ class static_synapse_hom_w : public Connection< targetidentifierT >
* \param tid Thread ID of the target
* \param cp Common properties-object of the synapse
*/
void
bool
send( Event& e, const size_t tid, const CommonPropertiesHomW& cp )
{
e.set_weight( cp.get_weight() );
e.set_delay_steps( get_delay_steps() );
e.set_receiver( *get_target( tid ) );
e.set_rport( get_rport() );
e();

return true;
}

void
Expand Down
6 changes: 4 additions & 2 deletions models/stdp_dopamine_synapse.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class stdp_dopamine_synapse : public Connection< targetidentifierT >
* Send an event to the receiver of this connection.
* \param e The event to send
*/
void send( Event& e, size_t t, const STDPDopaCommonProperties& cp );
bool send( Event& e, size_t t, const STDPDopaCommonProperties& cp );

void trigger_update_weight( size_t t,
const std::vector< spikecounter >& dopa_spikes,
Expand Down Expand Up @@ -523,7 +523,7 @@ stdp_dopamine_synapse< targetidentifierT >::depress_( double kminus, const STDPD
* \param p The port under which this connection is stored in the Connector.
*/
template < typename targetidentifierT >
inline void
inline bool
stdp_dopamine_synapse< targetidentifierT >::send( Event& e, size_t t, const STDPDopaCommonProperties& cp )
{
Node* target = get_target( t );
Expand Down Expand Up @@ -572,6 +572,8 @@ stdp_dopamine_synapse< targetidentifierT >::send( Event& e, size_t t, const STDP
Kplus_ = Kplus_ * std::exp( ( t_last_update_ - t_spike ) / cp.tau_plus_ ) + 1.0;
t_last_update_ = t_spike;
t_lastspike_ = t_spike;

return true;
}

template < typename targetidentifierT >
Expand Down
7 changes: 4 additions & 3 deletions models/stdp_facetshw_synapse_hom.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,7 @@ class stdp_facetshw_synapse_hom : public Connection< targetidentifierT >
* Send an event to the receiver of this connection.
* \param e The event to send
*/
void send( Event& e, size_t t, const STDPFACETSHWHomCommonProperties< targetidentifierT >& );

bool send( Event& e, size_t t, const STDPFACETSHWHomCommonProperties< targetidentifierT >& );

class ConnTestDummyNode : public ConnTestDummyNodeBase
{
Expand Down Expand Up @@ -407,7 +406,7 @@ stdp_facetshw_synapse_hom< targetidentifierT >::lookup_( unsigned int discrete_w
* \param p The port under which this connection is stored in the Connector.
*/
template < typename targetidentifierT >
inline void
inline bool
stdp_facetshw_synapse_hom< targetidentifierT >::send( Event& e,
size_t t,
const STDPFACETSHWHomCommonProperties< targetidentifierT >& cp )
Expand Down Expand Up @@ -534,6 +533,8 @@ stdp_facetshw_synapse_hom< targetidentifierT >::send( Event& e,
e();

t_lastspike_ = t_spike;

return true;
}
} // of namespace nest

Expand Down
7 changes: 4 additions & 3 deletions models/stdp_nn_pre_centered_synapse.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ class stdp_nn_pre_centered_synapse : public Connection< targetidentifierT >
* \param e The event to send
* \param cp common properties of all synapses (empty).
*/
void send( Event& e, size_t t, const CommonSynapseProperties& cp );

bool send( Event& e, size_t t, const CommonSynapseProperties& cp );

class ConnTestDummyNode : public ConnTestDummyNodeBase
{
Expand Down Expand Up @@ -249,7 +248,7 @@ constexpr ConnectionModelProperties stdp_nn_pre_centered_synapse< targetidentifi
* \param cp Common properties object, containing the stdp parameters.
*/
template < typename targetidentifierT >
inline void
inline bool
stdp_nn_pre_centered_synapse< targetidentifierT >::send( Event& e, size_t t, const CommonSynapseProperties& )
{
// synapse STDP depressing/facilitation dynamics
Expand Down Expand Up @@ -316,6 +315,8 @@ stdp_nn_pre_centered_synapse< targetidentifierT >::send( Event& e, size_t t, con
e();

t_lastspike_ = t_spike;

return true;
}


Expand Down
Loading

0 comments on commit 1ab8c5d

Please sign in to comment.