pub struct AdaptiveCodeDistance { /* private fields */ }Expand description
Dynamically adjusts code distance based on observed logical error rates.
Monitors a sliding window of recent logical error rates and recommends increasing the code distance when errors are too high, or decreasing when resources can be reclaimed.
Thresholds:
- Increase when average error rate > 10^(-distance/3)
- Decrease when average error rate < 10^(-(distance+2)/3) for sustained periods
Implementations§
Source§impl AdaptiveCodeDistance
impl AdaptiveCodeDistance
Sourcepub fn new(initial: u32, min: u32, max: u32) -> Self
pub fn new(initial: u32, min: u32, max: u32) -> Self
Create a new adaptive code distance tracker.
§Panics
Panics if min > max, initial < min, or initial > max.
Sourcepub fn record_error_rate(&mut self, rate: f64)
pub fn record_error_rate(&mut self, rate: f64)
Record a new observed logical error rate sample.
Sourcepub fn recommended_distance(&self) -> u32
pub fn recommended_distance(&self) -> u32
Return the recommended code distance based on recent error rates.
Sourcepub fn should_increase(&self) -> bool
pub fn should_increase(&self) -> bool
Returns true if the code distance should be increased.
Triggered when the average error rate over the window exceeds the threshold for the current distance.
Sourcepub fn should_decrease(&self) -> bool
pub fn should_decrease(&self) -> bool
Returns true if the code distance can be safely decreased.
Triggered when the average error rate is well below the threshold for the next smaller distance.
Trait Implementations§
Source§impl Clone for AdaptiveCodeDistance
impl Clone for AdaptiveCodeDistance
Source§fn clone(&self) -> AdaptiveCodeDistance
fn clone(&self) -> AdaptiveCodeDistance
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more