pdmlabs.energy.payoff#

Payoff models: turning detection quality into avoided energy or cost.

E-LQO’s EROI and EPT both need a payoff per deployment cycle. In learned query optimization that payoff is energy itself – a better plan executes more cheaply – so the metric is self-contained. In predictive maintenance it is not: a better-tuned detector does not make inference cheaper, it avoids unplanned failures and unnecessary call-outs. The payoff therefore has to come from a model of what those outcomes cost, and that model is an assumption.

This module makes the assumption explicit, configurable and testable rather than burying it. Two providers, because some datasets ship a cost matrix (SCANIA Component X) and some do not:

  • EnergyPayoffModel – coefficients in joules. Use when there is no cost information but the physical cost of a failure can be reasoned about (lost production, corrective repair).

  • CostPayoffModel – coefficients in currency, with an electricity price converting the compute side into the same units.

Both expose the same two methods, so pdmlabs.energy.metrics computes EROI and EPT identically for either:

payoff_per_cycle(tuned, baseline)

Benefit of the tuned pipeline over the baseline, per cycle, in model units.

compute_cost(energy_j)

A compute energy expressed in those same model units.

Counting at the right granularity#

Costs are charged per event, not per sample. A cost matrix says “a missed failure costs X” and “an unnecessary inspection costs Y” – one sustained alarm is one call-out, not one per timestamp. Charging point-level counts would overstate inspection cost by orders of magnitude. The defaults therefore use fn_episodes and n_false_alarm_groups from pdmlabs.evaluation.evaluation.outcome_counts().

Because the coefficients are assumptions, never report a single EROI or EPT from them without sensitivity() or breakeven_ratio() alongside.

Module Attributes

SCANIA_APS_COSTS

10 per unnecessary check, 500 per missed failure.

Functions

breakeven_ratio(model_factory, counts_tuned, ...)

Smallest failure-to-inspection ratio at which tuning pays back.

evaluate(model, counts_tuned, ...[, ...])

EROI, EPT and regime for one payoff model.

scania_aps_model([electricity_price_per_kwh])

CostPayoffModel preset for the SCANIA APS cost matrix.

sensitivity(model_factory, counts_tuned, ...)

Sweep the failure-to-inspection cost ratio.

Classes

BasePayoffModel()

Converts outcome counts into a per-cycle benefit, in model units.

CostPayoffModel(c_fail, c_inspect[, ...])

Payoff denominated in currency, for datasets that ship a cost matrix.

EnergyPayoffModel(e_fail, e_inspect[, ...])

Payoff denominated in joules.

class pdmlabs.energy.payoff.BasePayoffModel#

Bases: ABC

Converts outcome counts into a per-cycle benefit, in model units.

abstractmethod compute_cost(energy_j) → float#

A compute energy in joules, expressed in model units.

abstractmethod maintenance_cost(counts) → float#

Cost of one cycle’s maintenance outcomes, in model units.

payoff_per_cycle(counts_tuned, counts_baseline)#

Benefit of tuned over baseline for one cycle.

Positive means the tuned pipeline avoided cost. Negative is returned as such, not clamped: EROI is defined as negative in that regime and E-LQO reports those cases separately rather than hiding them.

units = 'unknown'#
class pdmlabs.energy.payoff.CostPayoffModel(c_fail, c_inspect, c_planned=0.0, electricity_price_per_kwh=0.0, episode_level=True)#

Bases: BasePayoffModel

Payoff denominated in currency, for datasets that ship a cost matrix.

electricity_price_per_kwh converts compute energy into the same units, so EROI stays a pure ratio rather than mixing joules with currency.

compute_cost(energy_j)#

A compute energy in joules, expressed in model units.

maintenance_cost(counts)#

Cost of one cycle’s maintenance outcomes, in model units.

units = 'currency'#
class pdmlabs.energy.payoff.EnergyPayoffModel(e_fail, e_inspect, e_planned=0.0, episode_level=True)#

Bases: BasePayoffModel

Payoff denominated in joules.

Parameters are the energy consequences of each outcome:

e_fail

An unplanned failure: lost production plus corrective repair. Dominates everything else, usually by orders of magnitude.

e_inspect

One unnecessary inspection triggered by a false alarm.

e_planned

One planned repair following a correct, timely detection – the cost that is incurred in order to avoid e_fail.

compute_cost(energy_j)#

A compute energy in joules, expressed in model units.

maintenance_cost(counts)#

Cost of one cycle’s maintenance outcomes, in model units.

units = 'J'#
pdmlabs.energy.payoff.SCANIA_APS_COSTS = {'c_fail': 500.0, 'c_inspect': 10.0}#

10 per unnecessary check, 500 per missed failure. A useful sanity reference and a reasonable default when a dataset ships no matrix of its own – but SCANIA Component X publishes its own, which should be preferred when working with that dataset.

Type:

The classic SCANIA APS cost matrix (UCI)

pdmlabs.energy.payoff.breakeven_ratio(model_factory, counts_tuned, counts_baseline, debt_j, infer_j, max_cycles=None, lo=1.0, hi=1000000.0, tol=0.001)#

Smallest failure-to-inspection ratio at which tuning pays back.

With max_cycles given, the smallest ratio whose EPT falls below it; otherwise the smallest ratio at which EPT is defined at all.

This is the most assumption-light result available from Layer 2. Rather than asserting a payback time from coefficients nobody can pin down, it inverts the question into one a maintenance engineer can actually answer: “tuning pays for itself provided a missed failure costs at least N inspections.”

Bisection is valid because EPT is monotone non-increasing in the ratio: a costlier failure can only increase the benefit of catching it.

pdmlabs.energy.payoff.evaluate(model, counts_tuned, counts_baseline, debt_j, infer_j, expected_cycles=None)#

EROI, EPT and regime for one payoff model.

pdmlabs.energy.payoff.scania_aps_model(electricity_price_per_kwh=0.0)#

CostPayoffModel preset for the SCANIA APS cost matrix.

pdmlabs.energy.payoff.sensitivity(model_factory, counts_tuned, counts_baseline, debt_j, infer_j, ratios)#

Sweep the failure-to-inspection cost ratio.

model_factory takes a ratio and returns a payoff model. Reporting a single EPT from one guessed coefficient pair would be false precision; the shape of EPT across plausible ratios is the honest result.