pub enum Rate {
Fixed(f32),
Linear(f32, f32, usize),
Exponential(f32, f32, usize),
Cyclical(f32, f32, usize, CycleShape),
Stepwise(Vec<(usize, f32)>),
Expr(Expr),
}Expand description
Rate enum representing different types of rate schedules where each variant defines a method to compute the rate value at a given step. These are designed to produce values within the range [0.0, 1.0] - ie: a rate.
Variants§
Fixed(f32)
Linear(f32, f32, usize)
A linear rate that changes from start to end over a number of steps.
§Parameters
start: The starting rate value.end: The ending rate value.steps: The number of steps over which to change the rate.
Exponential(f32, f32, usize)
An exponential rate that changes from start to end over a half-life period.
§Parameters
start: The starting rate value.end: The ending rate value.half_life: The half-life period over which to change the rate.
Cyclical(f32, f32, usize, CycleShape)
A cyclical rate that oscillates between min and max over a period.
§Parameters
min: The minimum rate value.max: The maximum rate value.period: The period over which to cycle the rate.shape: The shape of the cycle (Triangle or Sine).
Stepwise(Vec<(usize, f32)>)
Piecewise-constant schedule: at each listed step, rate jumps to the given value. The value remains constant until the next listed step. The first step must be 0. If the current step is beyond the last listed step, the rate remains at the last value.
§Parameters
Vec<(usize, f32)>: A vector of (step, rate) pairs.
Expr(Expr)
A rate defined by an expression that can query metrics. The expression should evaluate to a float value representing the rate. The expression can use the provided metrics to compute a dynamic rate based on the current state of the ecosystem. The expression is expected to return a value in the range [0.0, 1.0], but this is not enforced at compile time.