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§
- Complexity
Class - 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
constso callers canmatchon it at compile time. - Complexity
Introspect - Object-safe runtime introspection. Defaulting
impl<T: Complexity>so any type with a staticComplexityimpl getsComplexityIntrospectfor free, and adyn ComplexityIntrospectquery works on solver trait objects.