Skip to main content

Module complexity

Module complexity 

Source
Expand description

Complexity-class declarations for every public solver / sampler / analyser.

See ADR-001: Complexity as Architecture for the strategic context. The short version: every public algorithm in this crate carries an explicit worst-case complexity class as a compile-time associated constant, so callers can refuse anything that exceeds their per-subsystem budget without reading the source.

use sublinear_solver::complexity::{Complexity, ComplexityClass};
use sublinear_solver::OptimizedConjugateGradientSolver;

// Compile-time check: the optimised CG solver is linear-in-nonzeros per iter.
const _: () = assert!(
    matches!(<OptimizedConjugateGradientSolver as Complexity>::CLASS,
             ComplexityClass::Linear)
);

Runtime introspection works the same way via the ComplexityIntrospect trait, which is object-safe so a dyn ComplexityIntrospect query works on any solver:

fn budget_check(solver: &dyn ComplexityIntrospect, max: ComplexityClass) -> bool {
    solver.complexity_class() <= max
}

Enums§

ComplexityClass
The twelve-tier complexity taxonomy from the directive in ADR-001.

Traits§

Complexity
Compile-time complexity-class declaration. Every public solver / sampler / analyser in this crate implements this trait, exposing its worst-case class as a const so callers can match on it at compile time.
ComplexityIntrospect
Object-safe runtime introspection. Defaulting impl<T: Complexity> so any type with a static Complexity impl gets ComplexityIntrospect for free, and a dyn ComplexityIntrospect query works on solver trait objects.