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: SImplementations§
Source§impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp> ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp>where
Fc: FnMut(&mut S, &Array1<f64>) -> Result<f64, EstimationError>,
Fe: FnMut(&mut S, &Array1<f64>) -> Result<OuterEval, EstimationError>,
Fr: FnMut(&mut S),
Fefs: FnMut(&mut S, &Array1<f64>) -> Result<EfsEval, EstimationError>,
Feo: FnMut(&mut S, &Array1<f64>, OuterEvalOrder) -> Result<OuterEval, EstimationError>,
Fsp: FnMut(&mut S, &Array1<f64>) -> Result<f64, EstimationError>,
impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp> ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp>where
Fc: FnMut(&mut S, &Array1<f64>) -> Result<f64, EstimationError>,
Fe: FnMut(&mut S, &Array1<f64>) -> Result<OuterEval, EstimationError>,
Fr: FnMut(&mut S),
Fefs: FnMut(&mut S, &Array1<f64>) -> Result<EfsEval, EstimationError>,
Feo: FnMut(&mut S, &Array1<f64>, OuterEvalOrder) -> Result<OuterEval, EstimationError>,
Fsp: FnMut(&mut S, &Array1<f64>) -> Result<f64, EstimationError>,
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>where
Fc: FnMut(&mut S, &Array1<f64>) -> Result<f64, EstimationError>,
Fe: FnMut(&mut S, &Array1<f64>) -> Result<OuterEval, EstimationError>,
Fr: FnMut(&mut S),
Fefs: FnMut(&mut S, &Array1<f64>) -> Result<EfsEval, EstimationError>,
Feo: FnMut(&mut S, &Array1<f64>, OuterEvalOrder) -> Result<OuterEval, EstimationError>,
Fsp: FnMut(&mut S, &Array1<f64>) -> Result<f64, EstimationError>,
Fseed: FnMut(&mut S, &Array1<f64>) -> Result<SeedOutcome, EstimationError>,
impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed> OuterObjective for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>where
Fc: FnMut(&mut S, &Array1<f64>) -> Result<f64, EstimationError>,
Fe: FnMut(&mut S, &Array1<f64>) -> Result<OuterEval, EstimationError>,
Fr: FnMut(&mut S),
Fefs: FnMut(&mut S, &Array1<f64>) -> Result<EfsEval, EstimationError>,
Feo: FnMut(&mut S, &Array1<f64>, OuterEvalOrder) -> Result<OuterEval, EstimationError>,
Fsp: FnMut(&mut S, &Array1<f64>) -> Result<f64, EstimationError>,
Fseed: FnMut(&mut S, &Array1<f64>) -> Result<SeedOutcome, EstimationError>,
Source§fn capability(&self) -> OuterCapability
fn capability(&self) -> OuterCapability
Declare what this objective can compute analytically.
Source§fn eval_cost(&mut self, rho: &Array1<f64>) -> Result<f64, EstimationError>
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>
fn eval_screening_proxy( &mut self, rho: &Array1<f64>, ) -> Result<f64, EstimationError>
Evaluate the seed-screening ranking proxy at this
rho. Read moreSource§fn eval(&mut self, rho: &Array1<f64>) -> Result<OuterEval, EstimationError>
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>
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>
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 seed_inner_state(
&mut self,
beta: &Array1<f64>,
) -> Result<SeedOutcome, EstimationError>
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 the continuation walk forwards OuterEval::inner_beta_hint
from the previous step. Read moreSource§fn allow_continuation_prewarm(&self) -> bool
fn allow_continuation_prewarm(&self) -> bool
Whether the objective can benefit from continuation pre-warm before
the first solver eval at a candidate seed. Read more
Source§fn outer_device_admission(&self) -> Option<RemlOuterAdmission>
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 moreSource§fn requires_continuation_path_entry(&self) -> bool
fn requires_continuation_path_entry(&self) -> bool
Whether every joint fit of this objective must ENTER through the
crate::continuation_path::ContinuationPath (heavy-smoothing
entry) rather than being solved cold at the seed ρ*. Read moreSource§fn curvature_homotopy_entry(
&mut self,
rho: &Array1<f64>,
) -> Option<Result<bool, EstimationError>>
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 moreSource§fn accept_seed_without_outer_iterations(
&mut self,
rho: &Array1<f64>,
) -> Result<Option<f64>, EstimationError>
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>
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, Fefs, Feo, Fsp, Fseed> Freeze for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>
impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed> RefUnwindSafe for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>where
S: RefUnwindSafe,
Fc: RefUnwindSafe,
Fe: RefUnwindSafe,
Feo: RefUnwindSafe,
Fr: RefUnwindSafe,
Fefs: RefUnwindSafe,
Fsp: RefUnwindSafe,
Fseed: RefUnwindSafe,
impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed> Send for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>
impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed> Sync 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>where
S: UnsafeUnpin,
Fc: UnsafeUnpin,
Fe: UnsafeUnpin,
Feo: UnsafeUnpin,
Fr: UnsafeUnpin,
Fefs: UnsafeUnpin,
Fsp: UnsafeUnpin,
Fseed: UnsafeUnpin,
impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed> UnwindSafe for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>where
S: UnwindSafe,
Fc: UnwindSafe,
Fe: UnwindSafe,
Feo: UnwindSafe,
Fr: UnwindSafe,
Fefs: UnwindSafe,
Fsp: UnwindSafe,
Fseed: UnwindSafe,
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.