Skip to main content

event_stream_iter

Function event_stream_iter 

Source
pub fn event_stream_iter<'a, I>(
    matrix: &'a dyn Matrix,
    prev_solution: &'a [Precision],
    events: I,
    config: &'a EventStreamConfig,
    budget: Option<&'a mut PlanBudget>,
) -> EventStreamIter<'a, I> 
where I: Iterator<Item = (SparseDelta, Vec<Precision>)>,
Expand description

Process an iterator of (SparseDelta, b_new) events through the SubLinear orchestrator, yielding ProcessedEvents. The optional budget argument tracks cumulative consumption across the stream; when it refuses, the iterator yields one final BudgetRefused event and ends.

matrix and prev_solution are borrowed for the lifetime of the iterator — the same baseline state applies to every event in the stream (matching the “stable baseline + sparse events” idiom RuView agents use).

§Examples

let mut budget = PlanBudget::new(ComplexityClass::SubLinear, 100);
let cfg = EventStreamConfig { tolerance: 1e-8, k: 3, ..Default::default() };

for e in event_stream_iter(matrix, prev, events.into_iter(), &cfg, Some(&mut budget)) {
    println!("event {}: {} anomalies in {:?}", e.event_idx, e.anomalies.len(), e.latency);
}