Skip to main content

ClosureObjective

Struct ClosureObjective 

Source
pub struct ClosureObjective<S, Fc, Fe, Fr = fn(&mut S), Fefs = fn(&mut S, &Array1<f64>) -> Result<EfsEval, EstimationError>, Feo = fn(&mut S, &Array1<f64>, OuterEvalOrder) -> Result<OuterEval, EstimationError>, Fsp = fn(&mut S, &Array1<f64>) -> Result<f64, EstimationError>, Fseed = fn(&mut S, &Array1<f64>) -> Result<SeedOutcome, EstimationError>> {
    pub state: S,
    /* private fields */
}
Expand description

Closure-based adapter for OuterObjective.

This allows any call site to construct an OuterObjective from closures without needing to define a wrapper struct or modify the state type. Each call site wraps its existing methods into closures and passes them here.

Fields§

§state: S

Implementations§

Source§

impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed> ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>

Source

pub fn with_exact_polish<Fpolish>(self, transition: Fpolish) -> Self
where Fpolish: FnMut(&mut S) -> bool + 'static,

Source

pub fn with_terminal_eval_order(self, order: OuterEvalOrder) -> Self

Force final state installation through one analytic evaluator order. Search-time solver selection remains unchanged.

Source

pub fn with_rail_face_limit<Fface>(self, limit: Fface) -> Self
where Fface: FnMut(&mut S, &Array1<f64>, &[usize]) -> Result<RailFaceLimitOutcome, EstimationError> + 'static,

Install the analytic λ→∞ rail-face limit hook (#2348 Inc 5).

Source

pub fn with_soft_rho_guard_gradient<Fguard>(self, guard: Fguard) -> Self
where Fguard: FnMut(&mut S, &Array1<f64>) -> Array1<f64> + 'static,

Install the soft rho-guard barrier gradient hook (#2545).

The closure must PROJECT the barrier gradient the criterion already added (for REML: RemlState::soft_rho_guard_gradient, which reads the same SoftRhoGuardPriorAtom build_prior reads), never recompute it from the policy constants — the barrier is evaluated at the weight-anchored coordinate, so a raw-ρ closed form is a different function on any weighted fit.

The closure speaks ρ, not θ: it receives the leading rho_dim entries of the outer point and returns one entry per ρ-coordinate. OuterObjective::soft_rho_guard_gradient embeds that into the full θ with exact zeros in the ψ/link block, so an objective with auxiliary outer coordinates installs the SAME closure as one without — the layout arithmetic that the mixture/SAS arm would otherwise have had to hand-write (and that #2629 records as invisible when wrong) lives in one place, driven by the declared OuterThetaLayout.

A closure whose criterion is NOT built on RemlState must not install this hook at all: None is the correct answer for an objective that carries no barrier, and publishing a zero array would be indistinguishable from publishing a real one at the consumers.

Source

pub fn with_criterion_invariance<Finv>(self, invariance: Finv) -> Self
where Finv: FnMut(&mut S, &Array1<f64>) -> Option<Array2<f64>> + 'static,

Publish the criterion’s exact invariance directions (#2676).

The closure receives the FULL outer point and returns orthonormal columns in the same coordinates, so an objective with auxiliary psi or link coordinates supplies the embedding itself (the rho block is what carries the invariance; every other coordinate is exactly zero).

An objective whose criterion is not built on a penalty map must not install this hook: None is the correct answer, and publishing an empty matrix would be indistinguishable from publishing a real one.

Source§

impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp> ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp>

Source

pub fn with_seed_inner_state<Fseed>( self, seed_fn: Fseed, ) -> ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>

Trait Implementations§

Source§

impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed> OuterObjective for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>

Source§

fn capability(&self) -> OuterCapability

Declare what this objective can compute analytically.
Source§

fn eval_cost(&mut self, rho: &Array1<f64>) -> Result<f64, EstimationError>

Evaluate cost only for cost-based optimization paths.
Source§

fn eval_screening_proxy( &mut self, rho: &Array1<f64>, ) -> Result<f64, EstimationError>

Evaluate the seed-screening ranking proxy at this rho. Read more
Source§

fn eval(&mut self, rho: &Array1<f64>) -> Result<OuterEval, EstimationError>

Evaluate cost + gradient + (if capable) Hessian.
Source§

fn eval_with_order( &mut self, rho: &Array1<f64>, order: OuterEvalOrder, ) -> Result<OuterEval, EstimationError>

Evaluate the outer objective at the order requested by the active plan. Read more
Source§

fn eval_efs(&mut self, rho: &Array1<f64>) -> Result<EfsEval, EstimationError>

Evaluate cost + EFS step vector. Only needed when the plan selects Solver::Efs. The default returns an error indicating EFS is not supported by this objective.
Source§

fn eval_fixed_point_certificate( &mut self, rho: &Array1<f64>, ) -> Result<FixedPointCertificateEval, EstimationError>

Re-evaluate the terminal fixed point and provide an explicit analytic residual for every optimized coordinate. Read more
Source§

fn rail_face_limit( &mut self, rho: &Array1<f64>, face: &[usize], ) -> Result<RailFaceLimitOutcome, EstimationError>

Analytic λ→∞ limit data for a rail face (#2348 Inc 5). Read more
Source§

fn soft_rho_guard_gradient( &mut self, theta: &Array1<f64>, ) -> Option<Array1<f64>>

The ρ-gradient of the soft numerical-guard BARRIER this objective adds to its criterion, if it adds one (#2545). Read more
Source§

fn criterion_invariant_directions( &mut self, theta: &Array1<f64>, ) -> Option<Array2<f64>>

Directions of the outer coordinate along which this criterion is EXACTLY constant by construction, at theta (#2676). Read more
Source§

fn seed_inner_state( &mut self, beta: &Array1<f64>, ) -> Result<SeedOutcome, EstimationError>

Seed the inner-solver iterate before the first eval, e.g. when the outer-iterate cache restored a (ρ, β) pair from a prior run, or when a typed reactive continuation path forwards OuterEval::inner_beta_hint from the previous step. Read more
Source§

fn terminal_eval_order(&self) -> Option<OuterEvalOrder>

Optional analytic evaluation order that must own the final installed objective state, independently of the solver plan that found rho. Read more
Source§

fn reset(&mut self)

Restore to a clean baseline for the next multi-start candidate.
Source§

fn owns_terminal_coefficient_mode(&self) -> bool

Whether this objective owns a terminal coefficient mode whose bitwise identity fit assembly will later bind against the certified outer value. Read more
Source§

fn begin_exact_polish(&mut self) -> bool

Transition an objective that actually used an approximate derivative pilot to its exact full-data measure. Read more
Source§

fn outer_domain_upper_bound( &self, ) -> Result<Option<Array1<f64>>, EstimationError>

Optional objective-owned hard upper domain for the outer coordinates. Read more
Source§

fn outer_domain_lower_bound( &self, ) -> Result<Option<Array1<f64>>, EstimationError>

Optional objective-owned hard lower domain for the outer coordinates. Read more
Source§

fn outer_device_admission(&self) -> Option<RemlOuterAdmission>

Optional opt-in to the device-resident outer REML BFGS-over-ρ driver (crate::gpu::reml_outer::run_reml_outer_on_device). Returns Some(adm) when the objective is a REML evaluator whose (spec, n, p, num_rho) admission predicate accepts the device path, and None otherwise. Read more
Source§

fn reactive_domain_scalar_contract( &self, ) -> Result<Option<ContinuationScalarContract>, EstimationError>

Typed scalar continuation contract for repairing a non-finite literal outer seed through crate::continuation_path::ContinuationPath. Read more
Source§

fn install_reactive_domain_scalar_state( &mut self, state: &ContinuationScalarState, ) -> Result<(), EstimationError>

Install one scalar waypoint before the continuation rho spine evaluates the objective. Objectives that return Some from Self::reactive_domain_scalar_contract must override this method; the default is a typed contract refusal, never a silent no-op.
Source§

fn begin_reactive_domain_waypoint(&mut self) -> Result<(), EstimationError>

Snapshot the objective’s complete accepted inner state before a reactive coupled waypoint is installed. Contract-advertising objectives must make this transactional: a failed trial is restored by Self::rollback_reactive_domain_waypoint.
Source§

fn commit_reactive_domain_waypoint( &mut self, rho: &Array1<f64>, ) -> Result<(), EstimationError>

Commit the converged full inner state produced by the value evaluation at rho. A coefficient-only handoff is insufficient: latent coordinates, routing logits, decoder frames, loss, and scalar state must advance as one accepted waypoint.
Source§

fn rollback_reactive_domain_waypoint(&mut self) -> Result<(), EstimationError>

Restore the full accepted state saved by Self::begin_reactive_domain_waypoint after an errored or non-finite trial.
Source§

fn curvature_homotopy_entry( &mut self, rho: &Array1<f64>, ) -> Option<Result<bool, EstimationError>>

Run the objective’s certified curvature-homotopy entry leg, if it has one, leaving the inner state warm at the real (η = 1) objective. Read more
Source§

fn accept_seed_without_outer_iterations( &mut self, rho: &Array1<f64>, ) -> Result<Option<f64>, EstimationError>

Let an objective declare that a seed is already a terminal outer result. Used for objectives with a certified high-quality construction seed where the generic rho optimizer can only degrade the fitted state.
Source§

fn finalize_outer_result( &mut self, rho: &Array1<f64>, plan: &OuterPlan, ) -> Result<(), EstimationError>

Re-install the selected outer result into the mutable objective before callers consume objective-owned fitted state. Optimizers may evaluate rejected trial points after the best point was found; without this final synchronization, stateful objectives can report the last trial fit rather than the returned OuterResult::rho.

Auto Trait Implementations§

§

impl<S, Fc, Fe, Fr = fn(&mut S), Fefs = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<EfsEval, EstimationError>, Feo = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, OuterEvalOrder) -> Result<OuterEval, EstimationError>, Fsp = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<f64, EstimationError>, Fseed = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<SeedOutcome, EstimationError>> !RefUnwindSafe for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>

§

impl<S, Fc, Fe, Fr = fn(&mut S), Fefs = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<EfsEval, EstimationError>, Feo = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, OuterEvalOrder) -> Result<OuterEval, EstimationError>, Fsp = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<f64, EstimationError>, Fseed = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<SeedOutcome, EstimationError>> !Send for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>

§

impl<S, Fc, Fe, Fr = fn(&mut S), Fefs = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<EfsEval, EstimationError>, Feo = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, OuterEvalOrder) -> Result<OuterEval, EstimationError>, Fsp = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<f64, EstimationError>, Fseed = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<SeedOutcome, EstimationError>> !Sync for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>

§

impl<S, Fc, Fe, Fr = fn(&mut S), Fefs = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<EfsEval, EstimationError>, Feo = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, OuterEvalOrder) -> Result<OuterEval, EstimationError>, Fsp = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<f64, EstimationError>, Fseed = fn(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<SeedOutcome, EstimationError>> !UnwindSafe for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>

§

impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed> Freeze for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>

§

impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed> Unpin for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>

§

impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed> UnsafeUnpin for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>

Blanket Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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