Skip to content

solvi.costs

Run-time costs: CostBook (system.cost_book) and MeasuredCosts (System(cost_policy="measured")). Part of solvi.learned up to 0.7; the learned order and producer policy are in solvi.strategist.

Run-time costs: CostBook, the moving average of each part's run time (ms) that every System keeps (system.cost_book) and updates after every ask; MeasuredCosts, the settings under which the cost-optimal planner plans with those measurements (System(cost_policy="measured")). Moved out of solvi.learned in 0.8 (nothing here is learned).

CostBook

CostBook(alpha=0.3)

Moving average of each part's run time in ms (exponential, alpha).

MeasuredCosts

MeasuredCosts(min_samples=3, recheck=50, alpha=None)

Costs from measurements for the cost-optimal planner (System(..., cost_policy="measured") or costs=MeasuredCosts(...)).

The planner (solvi.strategy.ModelStrategist with producers="equivalent") picks the cheapest plan by the cost of each producer: its measured run time (system.cost_book, a moving average in ms) once it has run min_samples times; before that its declared cost=, or — undeclared — 0 ms, so that it is tried and measured (warm-up). A producer not run for recheck asks counts 0 ms again for one plan (it may have got faster; None: never). alpha sets the smoothing of system.cost_book (the weight of the newest run; None: keep CostBook's). System.freeze_costs() fixes the costs the planner uses; the plan record of each trace says which cost decided each choice and where it came from.

observe

observe(names)

An ask ran these parts (their timings went to the CostBook).

costs

costs(book, producers)

→ ({producer: cost}, {producer: (source, runs)}) for the planner; sources: measured, declared, warm-up, recheck, or frozen (see freeze).

freeze

freeze(book, producers, unit=1.0)

Fix the planner's costs: measured where a producer has run at all, else declared, else unit (no warm-up, no recheck) → {producer: cost}.