mixle.doe._contracts module¶
Structural (duck-typed) contracts for the DOE layer, as runtime-checkable Protocols (WS-E).
The DOE layer follows a “register, don’t branch” pattern: acquisition functions go through
mixle.doe.bayesopt.register_acquisition(), optimality criteria through
mixle.doe.optimal.register_criterion(), and the GP surrogate is passed in as a duck-typed
gp= argument. This module formalizes those three contracts as @runtime_checkable Protocols
so the registry value types and the gp= parameters can be annotated precisely (instead of bare
Callable[..., ...] / Any), and so a surrogate can be validated with isinstance.
These are typing-level only: they add no behavior and the registries / call sites are unchanged.
- class Acquisition(*args, **kwargs)[source]
Bases:
ProtocolThe acquisition-function contract registered via
register_acquisition(EI/PI/UCB).An acquisition scores candidate points from their surrogate posterior moments and returns a merit array that the proposal loop maximizes over the candidate set. It is called as
fn(mean, std, best, *, maximize, **params)wheremean/stdare the predictive mean and standard deviation at the candidates,bestis the incumbent objective value,maximizeselects the optimization sense, and**paramscarries per-acquisition knobs (e.g.xifor EI/PI,kappafor UCB). Built-insmixle.doe.bayesopt.expected_improvement(),probability_of_improvement(), andupper_confidence_bound()satisfy this contract.
- class Surrogate(*args, **kwargs)[source]
Bases:
ProtocolThe GP-surrogate contract passed as
gp=to the Bayesian-optimization loops.A surrogate is fit to the observed
(x, y)and queried for the posterior predictive moments at new candidate points. The call convention is the one used bymixle.models.gaussian_process.GaussianProcessRegressor:fittrains in place (it may return diagnostics, which the loops ignore), andpredicttakes the training data alongside the query points, returning the posterior mean (return_cov=False) or(mean, cov)pair (return_cov=True).- fit(x, y, **kwargs)[source]
Fit or update the surrogate from observed design points
xand responsesy.
- class Criterion(*args, **kwargs)[source]
Bases:
ProtocolThe optimality-criterion contract registered via
register_criterion(D/A/I-optimality).A criterion maps the information matrix
M = F.T @ Fto a scalar merit thatmixle.doe.optimal.optimal_design()maximizes over candidate designs. It is called asfn(info, *, ref)whererefis an optional reference model matrix (used by I-optimality). Built-insmixle.doe.optimal.d_criterion(),a_criterion(), andi_criterion()satisfy this contract.