pub enum MarginRule {
BudgetRatio {
dimension_index: usize,
budget: f64,
},
RangeBound {
dimension_index: usize,
min: f64,
max: f64,
},
PatternMatch {
dimension_index: usize,
approved_values: Vec<f64>,
tolerance: f64,
fallback_margin: f64,
},
WeightedSum {
weights: Vec<(usize, f64)>,
offset: f64,
},
Constant {
margin: f64,
},
}Expand description
How to compute the margin from a state vector.
Variants§
BudgetRatio
Margin = value / budget. Produces 1.0 when value == 0, 0.0 when value >= budget.
dimension_index selects which state dimension to read.
RangeBound
Margin = how far value is from the [min, max] boundary, normalized to [0, 1]. Inside range → margin based on distance to nearest edge.
PatternMatch
Margin = 1.0 if value matches pattern, else fallback. Useful for categorical checks (e.g., “is this in an approved list?”).
Fields
WeightedSum
Margin computed from a simple arithmetic expression over state dimensions. Supports: weighted sum clamped to [0, 1].
Fields
Constant
Constant margin — useful for testing or placeholder channels.
Trait Implementations§
Source§impl Clone for MarginRule
impl Clone for MarginRule
Source§fn clone(&self) -> MarginRule
fn clone(&self) -> MarginRule
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MarginRule
impl Debug for MarginRule
Source§impl<'de> Deserialize<'de> for MarginRule
impl<'de> Deserialize<'de> for MarginRule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for MarginRule
impl RefUnwindSafe for MarginRule
impl Send for MarginRule
impl Sync for MarginRule
impl Unpin for MarginRule
impl UnsafeUnpin for MarginRule
impl UnwindSafe for MarginRule
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
Mutably borrows from an owned value. Read more