Skip to main content

OuterProblem

Struct OuterProblem 

Source
pub struct OuterProblem { /* private fields */ }
Expand description

Declarative outer-problem builder. Produces both the OuterCapability (what the objective can provide) and the [OuterConfig] (how the runner should behave) from a small set of high-level declarations.

Implementations§

Source§

impl OuterProblem

Source

pub fn new(n_params: usize) -> Self

Source

pub fn with_rho_canonical_keys(self, keys: Option<Vec<u64>>) -> Self

Supply per-ρ-coordinate structural keys (native/formula order) so the outer search is canonicalized to be invariant to the order the smooth terms / tensor margins were written (#1538/#1539). See [OuterConfig::rho_canonical_keys].

Source

pub fn with_gradient(self, d: Derivative) -> Self

Source

pub fn with_hessian(self, form: DeclaredHessianForm) -> Self

Source

pub fn with_prefer_gradient_only(self, prefer_gradient_only: bool) -> Self

Source

pub fn with_disable_fixed_point(self, disable: bool) -> Self

Forbid the planner from selecting EFS/HybridEfs, even when the objective implements eval_efs() and the coordinate structure would otherwise make pure/hybrid EFS eligible.

Callers use this for families where the Wood-Fasiolo structural property is known not to hold (e.g. GAMLSS/location-scale with β-dependent joint Hessian), so EFS would stagnate and burn budget before the automatic cascade falls back to gradient-based BFGS.

Source

pub fn with_psi_dim(self, dim: usize) -> Self

Source

pub fn with_barrier(self, cfg: Option<BarrierConfig>) -> Self

Source

pub fn with_tolerance(self, tol: f64) -> Self

Source

pub fn with_max_iter(self, n: usize) -> Self

Source

pub fn with_bounds(self, lo: Array1<f64>, hi: Array1<f64>) -> Self

Source

pub fn with_rho_bound(self, b: f64) -> Self

Source

pub fn with_seed_config(self, sc: SeedConfig) -> Self

Source

pub fn with_heuristic_lambdas(self, h: Vec<f64>) -> Self

Source

pub fn with_initial_rho(self, rho: Array1<f64>) -> Self

Source

pub fn with_continuation_prewarm(self, enabled: bool) -> Self

Toggle the generic rho-continuation seed pre-warm. This does not affect objectives that require an explicit continuation path; it only controls the cheap-by-default pre-pass gated by allow_continuation_prewarm().

Source

pub fn with_screening_cap(self, screening_cap: Arc<AtomicUsize>) -> Self

Source

pub fn with_screen_initial_rho(self, screen_initial_rho: bool) -> Self

Allow seed screening to rank the explicit initial rho against generated candidates even when the effective seed budget is one. The default keeps a user-provided initial point authoritative and avoids a separate screening pass.

Source

pub fn with_outer_inner_cap(self, feedback: InnerProgressFeedback) -> Self

Wire the bidirectional inner-PIRLS feedback channel.

The outer bridge writes a coarsened iteration cap into feedback.cap on every accepted gradient/Hessian eval; the inner solver writes back into feedback.last_iters / feedback.last_converged after each non-screening solve so the next outer iter’s schedule can adapt to the inner solver’s actual convergence behavior. Typical caller passes InnerProgressFeedback { cap: Arc::clone(&reml_state.outer_inner_cap), last_iters: Arc::clone(&reml_state.last_inner_iters), last_converged: Arc::clone(&reml_state.last_inner_converged), } so the inner and outer observe the same atomics.

Source

pub fn with_operator_initial_trust_radius(self, radius: Option<f64>) -> Self

Source

pub fn with_arc_initial_regularization(self, sigma: Option<f64>) -> Self

Override the ARC initial cubic-regularization parameter sigma (default in opt: 1.0). Smaller sigma → less cubic penalty on the first step → larger first move on benign objectives. The matrix- free Newton-TR analog is with_operator_initial_trust_radius.

Used by Gaussian-identity REML at large-scale n: the objective is quadratic-like in log-λ near the optimum (sigma is the right scale), and log-λ moves of 2–4 units in the early iters otherwise burn 4–8 iters of trust-region expansion before the model trusts the analytic Hessian.

Source

pub fn with_objective_scale(self, scale: Option<f64>) -> Self

Set the objective’s natural magnitude scale, used to derive an n-aware absolute gradient-norm floor. When set to Some(s), the runner uses abs_floor = max(tol, s * 1e-9) for the projected-gradient convergence check.

Rationale: a fixed abs = tol (e.g. 1e-6) is appropriate when the objective and its gradient live on a unit scale, but Gaussian- identity REML carries an O(n) likelihood constant that flows into ∂/∂logλ. At large-scale n the floor becomes binding even when the relative-from-seed component (rel_initial_grad * ‖g0‖) declared convergence iters earlier — chasing sub-ULP changes in log-λ at the cost of repeated k²·n·p² analytic-Hessian assemblies.

Source

pub fn with_rel_cost_tolerance(self, rel_cost: Option<f64>) -> Self

Decouple the relative-cost-decrease convergence stop from the absolute projected-gradient floor. By default both are derived from the single with_tolerance value (abs = max(tol, scale·1e-9), rel_cost = tol). Supplying Some(r) here makes the rel-cost stop use r while the absolute floor keeps using tolerance (so a caller can keep a tight absolute floor for accuracy at large n AND a loose rel-cost stop for perf on a flat REML ridge — see #1082). None keeps the legacy coupling.

Source

pub fn with_bfgs_step_cap(self, cap: Option<f64>) -> Self

Cap the infinity-norm displacement of BFGS cost-only line-search probes on the rho axes (the first n_params - psi_dim outer parameters, = log-λ). Also scales the initial inverse metric so the first trial direction respects the same local budget coordinate-wise. Documented natural step on log-λ is ≈ 5; tighter values throttle BFGS and starve convergence on flat REML valleys.

Source

pub fn with_bfgs_step_cap_psi(self, cap: Option<f64>) -> Self

Cap the infinity-norm displacement of BFGS cost-only line-search probes on the psi axes (the trailing psi_dim outer parameters, = kappa or anisotropic log-scales). Mirrors Self::with_bfgs_step_cap but scoped to kernel-scale parameters whose natural step is much smaller than log-λ (≈ ln 2 per iter keeps kappa from oscillating). Without this split, a uniform rho-scale cap lets psi explode while a uniform psi-scale cap throttles rho — both fail the survival-marginal-slope path at large scale, where rho needs |d|≈5 while psi wants |d|≤1.

Source

pub fn with_cache_session(self, session: Arc<CacheSession>) -> Self

Source

pub fn with_cache_mirror_sessions( self, sessions: Vec<Arc<CacheSession>>, ) -> Self

Attach mirror cache sessions that receive a broadcast copy of the final-result finalize write. See [OuterConfig::cache_mirror_sessions].

Source

pub fn with_problem_size(self, n_obs: usize, p_coefficients: usize) -> Self

Source

pub fn with_fallback_policy(self, policy: FallbackPolicy) -> Self

Override the fallback policy. Default is FallbackPolicy::Automatic.

Set FallbackPolicy::Disabled when the caller requires the primary plan to stand on its own. Exact-Hessian objectives use this to ensure failures surface on the analytic geometry instead of being reinterpreted by a different optimizer class.

Source

pub fn build_objective<S, Fc, Fe, Fr, Fefs>( &self, state: S, cost_fn: Fc, eval_fn: Fe, reset_fn: Option<Fr>, efs_fn: Option<Fefs>, ) -> ClosureObjective<S, Fc, Fe, Fr, Fefs>

Construct a ClosureObjective with capability flags derived from the builder state and the closures actually provided.

fixed_point_available is set to true when efs_fn is Some, regardless of whether .with_efs() was called. This is the canonical way to create production objectives — it eliminates the drift risk of manually entering capability flags.

Source

pub fn build_objective_with_eval_order<S, Fc, Fe, Feo, Fr, Fefs>( &self, state: S, cost_fn: Fc, eval_fn: Fe, eval_order_fn: Feo, reset_fn: Option<Fr>, efs_fn: Option<Fefs>, ) -> ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo>

Construct a ClosureObjective with an order-aware evaluation hook.

This lets the runner request first-order vs second-order work based on the active outer plan while preserving the legacy eager eval_fn.

Source

pub fn build_objective_with_screening_proxy<S, Fc, Fe, Feo, Fr, Fefs, Fsp>( &self, state: S, cost_fn: Fc, eval_fn: Fe, eval_order_fn: Feo, reset_fn: Option<Fr>, efs_fn: Option<Fefs>, screening_proxy_fn: Fsp, ) -> ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp>

Construct a ClosureObjective with both an order-aware evaluation hook and a custom seed-screening ranking proxy. The proxy fires only when the cascade in rank_seeds_with_screening calls it; outside screening the regular cost path is unaffected.

Source

pub fn run( &self, obj: &mut dyn OuterObjective, context: &str, ) -> Result<OuterResult, EstimationError>

Run the outer optimization with a given objective.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V