Skip to main content

Module cost_model

Module cost_model 

Source
Expand description

Empirical cost model — fits a subsystem’s measured runtime to a complexity class so the DCC can anticipate a budget breach instead of only reacting to it.

Big-O cannot be derived from arbitrary code, so the engine measures it: given (n, time) samples (workload size vs observed milliseconds), it fits a constant factor c to each candidate class f(n) by least squares and keeps the best-fitting one. The prediction is then cost(n) ≈ c · f(n) — the same shape a database query optimiser uses (cardinality × per-row cost). This learns the cost on the hardware it actually runs on, instead of trusting a compile-time guess, and lets the cold path forecast “at this growth rate the frame budget breaks at ~N entities”.

This module is the pure, dependency-free algorithm. Feeding it live samples from telemetry and consuming its forecast in arbitration is the integration step performed by the DCC.

Structs§

CostModel
A rolling empirical cost model for a single subsystem (agent / strategy).
CostSample
One observation: a workload size and the time it took (milliseconds).

Enums§

ComplexityClass
A candidate complexity class the cost model can fit a measured workload to.