Expand description
Synapse model — clean port from v0.1 libneuralos/src/core/spiking_neural_network/synapse.rs.
§Audit context
The audit flagged this as Gem #3 — “the better-engineered STDP rule impl”
(vs stdp_plasticity.rs which had the LTP timing filter bug). Port this version.
§Invariants (testable)
Synapse::new(id, id, _)always refuses, withError::SelfConnection(no self-connections).
With the unstable-stdp feature (update_weight, STDPRule, a
synapse’s bounds and its two counters exist in no other build, and may
change or go in a minor release):
Synapse::newsets the bounds from the weight’s sign:[0, 2000]for a weight of 0 or more,[-2000, 0]below 0. The fields are the crate’s, so no caller writes the bounds.- Weight stays within
[min_weight, max_weight]after everyupdate_weightcall. STDPRule::calculate_weight_change(dt)returns 0 for|dt| ≥ tau, where the linear factor reaches 0.- LTP (pre before post, dt < 0) returns a non-negative delta.
- LTD (post before pre, dt > 0) returns a non-positive delta.
§Fixed-point conventions
- Weight:
i16, fixed-point 1000 = 1.0 (range ~[-2000, 2000] typically). - Time:
u32microseconds.
§no_std
Uses crate::Error (no String, no alloc) for self-connection rejection.
Fully no_std-compatible — pairs with lif_neuron.
Structs§
- STDP
Rule unstable-stdp - Unstable: behind
unstable-stdp. Spike-Timing-Dependent Plasticity rule. - Synapse
- A synapse: its two ends and its fixed-point weight, and with
unstable-stdpthe bounds STDP clamps the weight to and two instrumentation counters.
Constants§
- SCALE
- Fixed-point scale: 1000 = 1.0.