pub struct Synapse {
pub pre_neuron: usize,
pub post_neuron: usize,
/* private fields */
}Expand description
Synaptic connection with STDP learning
This synapse implements spike-timing dependent plasticity (STDP), a fundamental learning rule in biological neural networks. The synaptic strength is modified based on the relative timing of pre- and post-synaptic spikes.
§STDP Rule
- If pre-synaptic spike occurs before post-synaptic spike: potentiation (strengthening)
- If post-synaptic spike occurs before pre-synaptic spike: depression (weakening)
- The magnitude of change decreases exponentially with the time difference
§Example
use scirs2_spatial::neuromorphic::core::Synapse;
let mut synapse = Synapse::new(0, 1, 0.5);
// Simulate STDP learning
synapse.update_stdp(10.0, true, false); // Pre-synaptic spike at t=10
synapse.update_stdp(15.0, false, true); // Post-synaptic spike at t=15
println!("Updated weight: {}", synapse.weight()); // Should be increasedFields§
§pre_neuron: usizePre-synaptic neuron ID
post_neuron: usizePost-synaptic neuron ID
Implementations§
Source§impl Synapse
impl Synapse
Sourcepub fn with_stdp_params(
pre_neuron: usize,
post_neuron: usize,
initial_weight: f64,
stdp_rate: f64,
stdp_tau: f64,
min_weight: f64,
max_weight: f64,
) -> Self
pub fn with_stdp_params( pre_neuron: usize, post_neuron: usize, initial_weight: f64, stdp_rate: f64, stdp_tau: f64, min_weight: f64, max_weight: f64, ) -> Self
Create synapse with custom STDP parameters
§Arguments
pre_neuron- ID of pre-synaptic neuronpost_neuron- ID of post-synaptic neuroninitial_weight- Initial synaptic weightstdp_rate- STDP learning ratestdp_tau- STDP time constantmin_weight- Minimum weight boundmax_weight- Maximum weight bound
Sourcepub fn update_stdp(
&mut self,
current_time: f64,
pre_spiked: bool,
post_spiked: bool,
)
pub fn update_stdp( &mut self, current_time: f64, pre_spiked: bool, post_spiked: bool, )
Update synaptic weight using STDP rule
Applies the spike-timing dependent plasticity learning rule based on the timing of pre- and post-synaptic spikes.
§Arguments
current_time- Current simulation timepre_spiked- Whether pre-synaptic neuron spikedpost_spiked- Whether post-synaptic neuron spiked
Sourcepub fn synaptic_current(&self, pre_spike_strength: f64) -> f64
pub fn synaptic_current(&self, pre_spike_strength: f64) -> f64
Sourcepub fn set_weight(&mut self, weight: f64)
pub fn set_weight(&mut self, weight: f64)
Set synaptic weight
Sourcepub fn pre_neuron(&self) -> usize
pub fn pre_neuron(&self) -> usize
Get pre-synaptic neuron ID
Sourcepub fn post_neuron(&self) -> usize
pub fn post_neuron(&self) -> usize
Get post-synaptic neuron ID
Sourcepub fn set_stdp_rate(&mut self, rate: f64)
pub fn set_stdp_rate(&mut self, rate: f64)
Set STDP learning rate
Sourcepub fn set_stdp_tau(&mut self, tau: f64)
pub fn set_stdp_tau(&mut self, tau: f64)
Set STDP time constant
Sourcepub fn last_pre_spike(&self) -> f64
pub fn last_pre_spike(&self) -> f64
Get last pre-synaptic spike time
Sourcepub fn last_post_spike(&self) -> f64
pub fn last_post_spike(&self) -> f64
Get last post-synaptic spike time
Sourcepub fn weight_bounds(&self) -> (f64, f64)
pub fn weight_bounds(&self) -> (f64, f64)
Get weight bounds
Sourcepub fn set_weight_bounds(&mut self, min_weight: f64, max_weight: f64)
pub fn set_weight_bounds(&mut self, min_weight: f64, max_weight: f64)
Set weight bounds
Sourcepub fn is_excitatory(&self) -> bool
pub fn is_excitatory(&self) -> bool
Check if synapse is excitatory (positive weight)
Sourcepub fn is_inhibitory(&self) -> bool
pub fn is_inhibitory(&self) -> bool
Check if synapse is inhibitory (negative weight)
Sourcepub fn reset_spike_history(&mut self)
pub fn reset_spike_history(&mut self)
Reset spike timing history
Sourcepub fn time_since_pre_spike(&self, current_time: f64) -> f64
pub fn time_since_pre_spike(&self, current_time: f64) -> f64
Calculate time since last pre-synaptic spike
Sourcepub fn time_since_post_spike(&self, current_time: f64) -> f64
pub fn time_since_post_spike(&self, current_time: f64) -> f64
Calculate time since last post-synaptic spike
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Synapse
impl RefUnwindSafe for Synapse
impl Send for Synapse
impl Sync for Synapse
impl Unpin for Synapse
impl UnwindSafe for Synapse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.