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, Fseed> ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>
impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed> ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>
pub fn with_exact_polish<Fpolish>(self, transition: Fpolish) -> Self
Sourcepub fn with_terminal_eval_order(self, order: OuterEvalOrder) -> Self
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.
Sourcepub fn with_rail_face_limit<Fface>(self, limit: Fface) -> Selfwhere
Fface: FnMut(&mut S, &Array1<f64>, &[usize]) -> Result<RailFaceLimitOutcome, EstimationError> + 'static,
pub fn with_rail_face_limit<Fface>(self, limit: Fface) -> Selfwhere
Fface: FnMut(&mut S, &Array1<f64>, &[usize]) -> Result<RailFaceLimitOutcome, EstimationError> + 'static,
Install the analytic λ→∞ rail-face limit hook (#2348 Inc 5).
Sourcepub fn with_soft_rho_guard_gradient<Fguard>(self, guard: Fguard) -> Self
pub fn with_soft_rho_guard_gradient<Fguard>(self, guard: Fguard) -> Self
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.
Sourcepub fn with_criterion_invariance<Finv>(self, invariance: Finv) -> Self
pub fn with_criterion_invariance<Finv>(self, invariance: Finv) -> Self
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>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
Source§fn eval_cost(&mut self, rho: &Array1<f64>) -> Result<f64, EstimationError>
fn eval_cost(&mut self, rho: &Array1<f64>) -> Result<f64, EstimationError>
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>
rho. Read moreSource§fn eval(&mut self, rho: &Array1<f64>) -> Result<OuterEval, EstimationError>
fn eval(&mut self, rho: &Array1<f64>) -> Result<OuterEval, EstimationError>
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>
Source§fn eval_efs(&mut self, rho: &Array1<f64>) -> Result<EfsEval, EstimationError>
fn eval_efs(&mut self, rho: &Array1<f64>) -> Result<EfsEval, EstimationError>
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>
fn eval_fixed_point_certificate( &mut self, rho: &Array1<f64>, ) -> Result<FixedPointCertificateEval, EstimationError>
Source§fn rail_face_limit(
&mut self,
rho: &Array1<f64>,
face: &[usize],
) -> Result<RailFaceLimitOutcome, EstimationError>
fn rail_face_limit( &mut self, rho: &Array1<f64>, face: &[usize], ) -> Result<RailFaceLimitOutcome, EstimationError>
Source§fn soft_rho_guard_gradient(
&mut self,
theta: &Array1<f64>,
) -> Option<Array1<f64>>
fn soft_rho_guard_gradient( &mut self, theta: &Array1<f64>, ) -> Option<Array1<f64>>
Source§fn criterion_invariant_directions(
&mut self,
theta: &Array1<f64>,
) -> Option<Array2<f64>>
fn criterion_invariant_directions( &mut self, theta: &Array1<f64>, ) -> Option<Array2<f64>>
theta (#2676). Read moreSource§fn seed_inner_state(
&mut self,
beta: &Array1<f64>,
) -> Result<SeedOutcome, EstimationError>
fn seed_inner_state( &mut self, beta: &Array1<f64>, ) -> Result<SeedOutcome, EstimationError>
(ρ, β) pair from a prior run, or
when a typed reactive continuation path forwards
OuterEval::inner_beta_hint
from the previous step. Read moreSource§fn terminal_eval_order(&self) -> Option<OuterEvalOrder>
fn terminal_eval_order(&self) -> Option<OuterEvalOrder>
rho. Read moreSource§fn owns_terminal_coefficient_mode(&self) -> bool
fn owns_terminal_coefficient_mode(&self) -> bool
Source§fn begin_exact_polish(&mut self) -> bool
fn begin_exact_polish(&mut self) -> bool
Source§fn outer_domain_upper_bound(
&self,
) -> Result<Option<Array1<f64>>, EstimationError>
fn outer_domain_upper_bound( &self, ) -> Result<Option<Array1<f64>>, EstimationError>
Source§fn outer_domain_lower_bound(
&self,
) -> Result<Option<Array1<f64>>, EstimationError>
fn outer_domain_lower_bound( &self, ) -> Result<Option<Array1<f64>>, EstimationError>
Source§fn outer_device_admission(&self) -> Option<RemlOuterAdmission>
fn outer_device_admission(&self) -> Option<RemlOuterAdmission>
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 reactive_domain_scalar_contract(
&self,
) -> Result<Option<ContinuationScalarContract>, EstimationError>
fn reactive_domain_scalar_contract( &self, ) -> Result<Option<ContinuationScalarContract>, EstimationError>
crate::continuation_path::ContinuationPath. Read moreSource§fn install_reactive_domain_scalar_state(
&mut self,
state: &ContinuationScalarState,
) -> Result<(), EstimationError>
fn install_reactive_domain_scalar_state( &mut self, state: &ContinuationScalarState, ) -> Result<(), EstimationError>
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>
fn begin_reactive_domain_waypoint(&mut self) -> Result<(), EstimationError>
Self::rollback_reactive_domain_waypoint.Source§fn commit_reactive_domain_waypoint(
&mut self,
rho: &Array1<f64>,
) -> Result<(), EstimationError>
fn commit_reactive_domain_waypoint( &mut self, rho: &Array1<f64>, ) -> Result<(), EstimationError>
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>
fn rollback_reactive_domain_waypoint(&mut self) -> Result<(), EstimationError>
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>>
fn curvature_homotopy_entry( &mut self, rho: &Array1<f64>, ) -> Option<Result<bool, EstimationError>>
η = 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>
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>
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>where
S: Freeze,
Fc: Freeze,
Fe: Freeze,
Option<Feo>: Freeze,
Option<Fr>: Freeze,
Option<Fefs>: Freeze,
Option<Box<dyn FnMut(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<FixedPointCertificateEval, EstimationError>>>: Freeze,
Option<Box<dyn FnMut(&mut S) -> bool>>: Freeze,
Option<Box<dyn FnMut(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, &[usize]) -> Result<RailFaceLimitOutcome, EstimationError>>>: Freeze,
Option<Box<dyn FnMut(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>>: Freeze,
Option<Box<dyn FnMut(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Option<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>>>: Freeze,
Option<Fsp>: Freeze,
Option<Fseed>: Freeze,
impl<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed> Unpin for ClosureObjective<S, Fc, Fe, Fr, Fefs, Feo, Fsp, Fseed>where
S: Unpin,
Fc: Unpin,
Fe: Unpin,
Option<Feo>: Unpin,
Option<Fr>: Unpin,
Option<Fefs>: Unpin,
Option<Box<dyn FnMut(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<FixedPointCertificateEval, EstimationError>>>: Unpin,
Option<Box<dyn FnMut(&mut S) -> bool>>: Unpin,
Option<Box<dyn FnMut(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, &[usize]) -> Result<RailFaceLimitOutcome, EstimationError>>>: Unpin,
Option<Box<dyn FnMut(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>>: Unpin,
Option<Box<dyn FnMut(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Option<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>>>: Unpin,
Option<Fsp>: Unpin,
Option<Fseed>: Unpin,
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,
Option<Feo>: UnsafeUnpin,
Option<Fr>: UnsafeUnpin,
Option<Fefs>: UnsafeUnpin,
Option<Box<dyn FnMut(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Result<FixedPointCertificateEval, EstimationError>>>: UnsafeUnpin,
Option<Box<dyn FnMut(&mut S) -> bool>>: UnsafeUnpin,
Option<Box<dyn FnMut(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, &[usize]) -> Result<RailFaceLimitOutcome, EstimationError>>>: UnsafeUnpin,
Option<Box<dyn FnMut(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>>: UnsafeUnpin,
Option<Box<dyn FnMut(&mut S, &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>) -> Option<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>>>: UnsafeUnpin,
Option<Fsp>: UnsafeUnpin,
Option<Fseed>: UnsafeUnpin,
Blanket Implementations§
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
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> ⓘ
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> ⓘ
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.