pub struct NewtonTrustRegion<ObjFn> { /* private fields */ }Implementations§
Source§impl<ObjFn> NewtonTrustRegion<ObjFn>where
ObjFn: SecondOrderObjective,
impl<ObjFn> NewtonTrustRegion<ObjFn>where
ObjFn: SecondOrderObjective,
Sourcepub fn new(x0: Array1<f64>, obj_fn: ObjFn) -> Self
pub fn new(x0: Array1<f64>, obj_fn: ObjFn) -> Self
Creates a new Newton trust-region solver.
§Arguments
x0- The initial guess for the minimum.obj_fn- Second-order objective.
Sourcepub fn with_tolerance(self, tolerance: Tolerance) -> Self
pub fn with_tolerance(self, tolerance: Tolerance) -> Self
Sets the convergence tolerance on projected gradient norm (default: 1e-5).
Sourcepub fn with_max_iterations(self, max_iterations: MaxIterations) -> Self
pub fn with_max_iterations(self, max_iterations: MaxIterations) -> Self
Sets the maximum number of iterations (default: 100).
pub fn with_fd_hessian_step(self, fd_hessian_step: f64) -> Self
Sourcepub fn with_bounds(self, bounds: Bounds) -> Self
pub fn with_bounds(self, bounds: Bounds) -> Self
Provides simple box bounds for each coordinate (lower <= x <= upper).
pub fn with_profile(self, profile: Profile) -> Self
Sourcepub fn with_hessian_fallback_policy(self, policy: HessianFallbackPolicy) -> Self
pub fn with_hessian_fallback_policy(self, policy: HessianFallbackPolicy) -> Self
Choose what to do when the objective returns
SecondOrderSample { hessian: None }: estimate the Hessian by
finite-differencing the gradient (default; legacy behavior) or
surface a fatal evaluation error. Set to Error when the
caller guarantees an analytic Hessian on every call — a single
None then signals a routing/contract mismatch instead of
silently triggering O(n) extra gradient probes per iteration.
Sourcepub fn with_fallback_policy(self, policy: FallbackPolicy) -> Self
pub fn with_fallback_policy(self, policy: FallbackPolicy) -> Self
Choose whether the trust-region solver may demote to BFGS on
step failure. FallbackPolicy::Never keeps the solver inside
its analytic-Hessian geometry on rejection; AutoBfgs (the
default for Profile::Robust / Aggressive) restarts BFGS
from the current best point when no second-order step makes
progress.
Sourcepub fn with_initial_sample(
self,
x0: Array1<f64>,
sample: SecondOrderSample,
) -> Self
pub fn with_initial_sample( self, x0: Array1<f64>, sample: SecondOrderSample, ) -> Self
Hand the solver a precomputed (x0, sample) pair so its first
evaluation (cost + gradient + Hessian) is served from cache
instead of re-running the objective. The sample’s
hessian: Option<Array2<f64>> is honored: if None the
Hessian is recomputed (or finite-differenced, depending on
with_hessian_fallback_policy).
Validation of shape and finiteness is deferred to run();
calling with_initial_sample itself never fails.
Sourcepub fn with_initial_trust_radius(self, radius: f64) -> Self
pub fn with_initial_trust_radius(self, radius: f64) -> Self
Set the initial trust radius (default: 1.0). Useful when the
caller has scale information — e.g. warm-starting from a
previous run’s OptimizationDiagnostics.final_trust_radius.
Sourcepub fn with_max_trust_radius(self, radius: f64) -> Self
pub fn with_max_trust_radius(self, radius: f64) -> Self
Set the maximum trust radius (default: 1e6).
Sourcepub fn with_gradient_tolerance(self, tol: GradientTolerance) -> Self
pub fn with_gradient_tolerance(self, tol: GradientTolerance) -> Self
See Bfgs::with_gradient_tolerance.
Sourcepub fn with_observer<O>(self, observer: O) -> Selfwhere
O: OptimizerObserver + 'static,
pub fn with_observer<O>(self, observer: O) -> Selfwhere
O: OptimizerObserver + 'static,
See Bfgs::with_observer.
Sourcepub fn run(&mut self) -> Result<Solution, NewtonTrustRegionError>
pub fn run(&mut self) -> Result<Solution, NewtonTrustRegionError>
Executes the Newton trust-region optimization.
Sourcepub fn run_report(&mut self) -> OptimizationReport
pub fn run_report(&mut self) -> OptimizationReport
Structured report variant of run(). See Bfgs::run_report.
Populates OptimizationDiagnostics.final_trust_radius from the
solver’s last observed trust radius so the caller can warm-start
a follow-up NewtonTrustRegion::with_initial_trust_radius.
Auto Trait Implementations§
impl<ObjFn> !RefUnwindSafe for NewtonTrustRegion<ObjFn>
impl<ObjFn> !Sync for NewtonTrustRegion<ObjFn>
impl<ObjFn> !UnwindSafe for NewtonTrustRegion<ObjFn>
impl<ObjFn> Freeze for NewtonTrustRegion<ObjFn>where
ObjFn: Freeze,
impl<ObjFn> Send for NewtonTrustRegion<ObjFn>where
ObjFn: Send,
impl<ObjFn> Unpin for NewtonTrustRegion<ObjFn>where
ObjFn: Unpin,
impl<ObjFn> UnsafeUnpin for NewtonTrustRegion<ObjFn>where
ObjFn: 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 more