Synapse

Struct Synapse 

Source
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 increased

Fields§

§pre_neuron: usize

Pre-synaptic neuron ID

§post_neuron: usize

Post-synaptic neuron ID

Implementations§

Source§

impl Synapse

Source

pub fn new(pre_neuron: usize, post_neuron: usize, initial_weight: f64) -> Self

Create new synapse

§Arguments
  • pre_neuron - ID of pre-synaptic neuron
  • post_neuron - ID of post-synaptic neuron
  • initial_weight - Initial synaptic weight
§Returns

A new Synapse with default STDP parameters

Source

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 neuron
  • post_neuron - ID of post-synaptic neuron
  • initial_weight - Initial synaptic weight
  • stdp_rate - STDP learning rate
  • stdp_tau - STDP time constant
  • min_weight - Minimum weight bound
  • max_weight - Maximum weight bound
Source

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 time
  • pre_spiked - Whether pre-synaptic neuron spiked
  • post_spiked - Whether post-synaptic neuron spiked
Source

pub fn synaptic_current(&self, pre_spike_strength: f64) -> f64

Calculate synaptic current

Computes the current transmitted through this synapse given the pre-synaptic spike strength.

§Arguments
  • pre_spike_strength - Strength of the pre-synaptic spike
§Returns

Synaptic current (weight * spike strength)

Source

pub fn weight(&self) -> f64

Get synaptic weight

Source

pub fn set_weight(&mut self, weight: f64)

Set synaptic weight

Source

pub fn pre_neuron(&self) -> usize

Get pre-synaptic neuron ID

Source

pub fn post_neuron(&self) -> usize

Get post-synaptic neuron ID

Source

pub fn stdp_rate(&self) -> f64

Get STDP learning rate

Source

pub fn set_stdp_rate(&mut self, rate: f64)

Set STDP learning rate

Source

pub fn stdp_tau(&self) -> f64

Get STDP time constant

Source

pub fn set_stdp_tau(&mut self, tau: f64)

Set STDP time constant

Source

pub fn last_pre_spike(&self) -> f64

Get last pre-synaptic spike time

Source

pub fn last_post_spike(&self) -> f64

Get last post-synaptic spike time

Source

pub fn weight_bounds(&self) -> (f64, f64)

Get weight bounds

Source

pub fn set_weight_bounds(&mut self, min_weight: f64, max_weight: f64)

Set weight bounds

Source

pub fn is_excitatory(&self) -> bool

Check if synapse is excitatory (positive weight)

Source

pub fn is_inhibitory(&self) -> bool

Check if synapse is inhibitory (negative weight)

Source

pub fn reset_spike_history(&mut self)

Reset spike timing history

Source

pub fn time_since_pre_spike(&self, current_time: f64) -> f64

Calculate time since last pre-synaptic spike

Source

pub fn time_since_post_spike(&self, current_time: f64) -> f64

Calculate time since last post-synaptic spike

Trait Implementations§

Source§

impl Clone for Synapse

Source§

fn clone(&self) -> Synapse

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Synapse

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V