Skip to main content

ComplexityClass

Enum ComplexityClass 

Source
pub enum ComplexityClass {
Show 13 variants Logarithmic, PolyLogarithmic, SubLinear, Linear, QuasiLinear, SubQuadratic, Polynomial(u8), SuperPolynomial, SubExponential, Exponential, Factorial, DoubleExponential, Adaptive { default: &'static ComplexityClass, worst: &'static ComplexityClass, },
}
Expand description

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

Ordering is by asymptotic growth: Logarithmic is “easiest” / “cheapest”, DoubleExponential is “hardest” / “most expensive”. PartialOrd / Ord lift this into a usable budget comparison — c <= max_budget means c is at most as expensive as the budget, so a caller with a SubLinear budget will accept Logarithmic and PolyLogarithmic and reject anything stronger.

The single-parameter Polynomial(degree) is ranked by its degree; Polynomial(2) precedes Polynomial(3) etc. Adaptive solvers that degrade on hard inputs can use Adaptive { default, worst } so the caller sees both bounds.

Variants§

§

Logarithmic

O(log n) — binary search, HNSW layer traversal, sublinear-Neumann single-entry query on a DD system.

§

PolyLogarithmic

O((log n)^k) — spectral sparsifiers, dynamic connectivity, live graph repair. The “polylog” tier.

§

SubLinear

O(n^c), c < 1 — approximate nearest neighbour, sparse attention, event-driven activation, anomaly detection.

§

Linear

O(n) — one-pass streaming, ingest, WAL replay, sensor scan.

§

QuasiLinear

O(n log n) — sorting, indexing, ANN build, graph compression. The “practical sweet spot” for offline preprocessing.

§

SubQuadratic

O(n^{2-ε}) — sparsified mincut, sub-quadratic graph algorithms.

§

Polynomial(u8)

O(n^k) — classical polynomial algorithms (matrix multiply for k=3, dense linear solves for k=2.37+, etc.). Degree of the polynomial is carried so callers can prefer lower-degree solvers.

§

SuperPolynomial

Worse than any fixed polynomial but better than exponential. Combinatorial enumeration with strong pruning lives here.

§

SubExponential

2^{O(n^c)}, c < 1 — SAT solvers, advanced cryptography, optimisation.

§

Exponential

O(2^n) — brute-force search, exhaustive planning, unrestricted combinatorics. Catastrophic at any non-trivial scale.

§

Factorial

O(n!) — permutation search, exhaustive TSP. “Heat death of the universe territory” at n ≥ 20.

§

DoubleExponential

O(2^{2^n}) — formal systems, symbolic explosion. Theoretical only.

§

Adaptive

Adaptive — a solver that runs at default on typical inputs but can degrade to worst on adversarial inputs. Callers should budget against worst to be safe.

Fields

§default: &'static ComplexityClass
§worst: &'static ComplexityClass

Implementations§

Source§

impl ComplexityClass

Source

pub const fn rank(&self) -> u16

Rank suitable for ordering. Lower = cheaper. Adaptive ranks by its worst bound so callers comparing against a budget see the safe upper bound.

Source

pub const fn short_label(&self) -> &'static str

Short human-readable label suitable for log lines and MCP tool schemas.

Source

pub const fn is_edge_safe(&self) -> bool

True if this class is acceptable for a real-time / edge / always-on hot path. Currently: anything strictly cheaper than Linear. Linear itself is conditional (acceptable for one-pass streaming, not for per-query work) — callers needing nuance should match directly.

Trait Implementations§

Source§

impl Clone for ComplexityClass

Source§

fn clone(&self) -> ComplexityClass

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ComplexityClass

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for ComplexityClass

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for ComplexityClass

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for ComplexityClass

Source§

fn eq(&self, other: &ComplexityClass) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for ComplexityClass

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for ComplexityClass

Source§

impl Eq for ComplexityClass

Source§

impl StructuralPartialEq for ComplexityClass

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V