Skip to main content

FdHessianUpdater

Struct FdHessianUpdater 

Source
pub struct FdHessianUpdater {
    pub pattern_source: FdPatternSource,
    pub coloring: FdColoring,
    pub reuse_tol: Number,
    pub objective_vars: Option<Vec<Index>>,
    pub nonlinear_vars: Option<Vec<Index>>,
    pub reused: u64,
    pub rebuilt: u64,
    /* private fields */
}

Fields§

§pattern_source: FdPatternSource§coloring: FdColoring§reuse_tol: Number

Reuse the previous Hessian when neither the primal iterate nor the multipliers have moved by more than this, relative to their own magnitude (fd_hessian_reuse_tol). 0 rebuilds every iteration.

Both are tested, not just x: ∇²L = ∇²f + Σ yⱼ ∇²cⱼ depends on the multipliers too, so a cached Hessian is stale the moment y moves even if x has not.

§objective_vars: Option<Vec<Index>>

Variables the objective is nonlinear in, in the compressed x_var space. The Jacobian-derived pattern must include objective_vars ⊗ objective_vars: ⋃ⱼ supp(∇gⱼ) ⊗ supp(∇gⱼ) describes the constraints only, so without this a ∇²f entry whose two variables never co-occur in a constraint row falls outside the pattern and is silently dropped — the pattern would be a subset of the truth, not the superset this mode’s safety argument rests on. None falls back to the first ∇f’s nonzeros.

§nonlinear_vars: Option<Vec<Index>>

Variables that enter f or g nonlinearly, in the compressed x_var space. A variable outside this set is linear everywhere, so every off-diagonal Hessian entry touching it is structurally zero and it can be dropped from the Jacobian-derived cliques:

    ⋃_j supp(∇g_j) ⊗ supp(∇g_j)
 →  ⋃_j (supp(∇g_j) ∩ N) ⊗ (supp(∇g_j) ∩ N)

Still a superset of the truth, just a tighter one. The full primal diagonal stays in the pattern regardless — the barrier and the inertia correction need those rows present even where the model has no curvature. Suggested in review by @srikanth-gm.

§reused: u64§rebuilt: u64

Implementations§

Source§

impl FdHessianUpdater

Source

pub fn new(pattern_source: FdPatternSource) -> Self

Source

pub fn stats(&self) -> FdStats

Trait Implementations§

Source§

impl HessianUpdater for FdHessianUpdater

Source§

fn hessian_at_current( &mut self, data: &IpoptDataHandle, cq: &IpoptCqHandle, ) -> Option<Rc<dyn SymMatrix>>

The finite-difference Hessian is a pure function of (x, y) — it reads data.curr and the already-evaluated curr_grad_f / curr_jac_* and carries no step history — so it can simply be rebuilt here. That is what makes it different from the quasi-Newton updaters, and what provides_exact_hessian could not express (gh#823 review, finding 1).

data.w is saved and restored around the rebuild: at this point it holds W for the previous iterate, and the post-optimal sensitivity hook reads it. The rebuild does refresh the reuse cache to the current (x, y), which is correct — the cache is keyed on exactly that, so the update_hessian call in step 3 of this same iterate then hits it instead of paying for a second pass.

Source§

fn fd_hessian_stats(&self) -> Option<FdStats>

The finite-difference Hessian’s pattern and probe census, for the updater that has one. None for every other updater. Read more
Source§

fn update_hessian(&mut self, data: &IpoptDataHandle, cq: &IpoptCqHandle) -> bool

Refresh data.w for the current iterate. Returns true on success. Mirrors IpHessianUpdater::UpdateHessian (which is pure-virtual; implementations write into IpData().Set_W(...)).
Source§

fn provides_exact_hessian(&self) -> bool

Whether data.w is the exact Lagrangian Hessian at the iterate it was built from, rather than a quasi-Newton approximation (gh #797). Read more
Source§

fn reanchor(&mut self) -> bool

Discard the accumulated quasi-Newton curvature and re-anchor the approximation at the current iterate, returning true if there was anything to discard (gh#818). Read more

Auto Trait Implementations§

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<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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more