mod regime

module regime

GJQ-style auto-selection of optimization regimes for the portfolio.

Policy (documented, safe, not oracle-optimal). Maps measurable problem features onto preferred portfolio arm order and Beta prior boosts. The restart arm (explore) always stays first so the almost-sure convergence floor remains valid. Unknown / incomplete features fall to Default.

Pattern mirrors GaussJacobiQuad select_method_auto: several specialized kernels/arms, feature-based routing, and explicit refusal where a path is invalid (exact Metropolis under declared objective noise).

Functions

fn arm_prior_boost(regime: OptimizationRegime, arm: &str) -> (f64, f64)

Beta prior (alpha0, beta0) boost for an arm under a regime.

Larger alpha relative to beta biases Thompson sampling toward the arm early on; (1,1) is the uninformative default. Boosts are intentionally strong so Auto and Legacy policies differ in finite-budget allocation (not just list order).

fn arm_slice_multiplier(regime: OptimizationRegime, arm: &str) -> f64

Slice-size multiplier for preferred arms (1.0 = baseline).

fn check_accept_path(regime: OptimizationRegime, noise_aware: bool) -> Result<(), RegimeError>

Check whether an accept path is legal under regime.

Exact Metropolis under OptimizationRegime::StochasticNoise is refused.

fn exact_accept_allowed(regime: OptimizationRegime) -> bool

Whether exact Metropolis (non-OSA) is allowed under this regime.

fn order_arms(available: &[&str], regime: OptimizationRegime, k_active: usize) -> Vec<String>

Build the ordered arm list: explore first, then regime preference, then remaining library arms, truncated by horizon capacity.

fn preferred_arm_tail(regime: OptimizationRegime) -> &'static [&'static str]

Preferred arm name order after the mandatory restart arm explore.

Returned names match portfolio arm identifiers. Unknown names are ignored by the portfolio when mapping to internal arm kinds.

fn regime_exploit_prob(regime: OptimizationRegime) -> f64

Probability of picking a regime-preferred arm instead of pure Thompson after warmup (Auto policy only). Safe default: not 1.0 so exploration remains.

fn regime_exploit_width(regime: OptimizationRegime) -> usize

How many leading preferred arms (after explore) participate in the regime-exploit lottery.

fn require_accept_compatible(noise_sigma: Option<f64>, use_noise_aware: bool) -> Result<(), RegimeError>

Shipped gate for accept-path choice (GJQ-style regime refusal).

When noise_sigma is a positive finite scale, exact Metropolis is out of regime: callers must use a noise-aware rule (OSA). This is the public check custom drivers and the portfolio entry path share.

fn select_regime(f: &ProblemFeatures) -> OptimizationRegime

Select regime from features. Safe / documented, not oracle-optimal.

Enums

enum OptimizationRegime

Named optimization regimes.

LowDimSmooth

dim ≤ 5 with gradient: polish-heavy local refinement.

HighDimIllConditioned

dim ≥ 20 with gradient: colored-noise / reduced-space first.

StochasticNoise

Caller declared objective noise: OSA accept required.

MultimodalNoGrad

No gradient; multimodal / elongated box: DE / GSA / surrogate.

MultimodalGlobal

Large design box (Schwefel-class): global GSA/DE first even with grads. dual_annealing wins the synthetic protocol when LowDimSmooth starves GSA.

Default

Safe fallback when no specialized regime matches.

enum RegimeError

Error when a requested numerical path is invalid for the regime.

ExactAcceptUnderNoise

Exact Metropolis acceptance under declared stochastic costs.

Traits implemented

impl std::fmt::Display for RegimeError
impl std::error::Error for RegimeError

Structs and Unions

struct ProblemFeatures

Measurable inputs for regime selection.

dim: usize

State dimension.

has_grad: bool

Whether a native gradient is available.

noise_sigma: Option<f64>

Known observation-noise scale on the objective, if any.

aspect_ratio: f64

Box aspect ratio (max/min side length).

mean_width: f64

Mean finite side length of the design box (Schwefel-class signal).

budget: usize

Shared work-unit budget.

Implementations

impl ProblemFeatures

Functions

fn from_bounds(bounds: &Bounds<f64>, has_grad: bool, noise_sigma: Option<f64>, budget: usize) -> Self

Build features from box bounds and caller-supplied flags.

fn from_geometry(geom: &BoxGeometry, has_grad: bool, noise_sigma: Option<f64>, budget: usize) -> Self

Build from precomputed geometry.