pub struct DampedBfgs { /* private fields */ }Implementations§
Source§impl DampedBfgs
impl DampedBfgs
pub fn new(n: usize) -> Self
Sourcepub fn has_prev(&self) -> bool
pub fn has_prev(&self) -> bool
Have we recorded a previous (x, ∇L)? false until the
first call to Self::update.
Sourcepub fn seed_scale(&mut self, gamma: Number)
pub fn seed_scale(&mut self, gamma: Number)
Seed B = γI directly and mark the one-time sizing done, so the
first Self::update applies its rank-2 correction on top of
this scale instead of re-seeding from its own (s, y).
Used by the driver’s iteration-0 curvature probe: the internal
sizing in Self::update cannot fire until a first (s, y) pair
exists, i.e. not until iteration 1 — but iteration 0 already
solves a QP against B, and with the identity seed that step
overshoots by ~cond(∇²L) on an ill-conditioned problem. See the
sizing comment in Self::update for why that is fatal.
gamma must be finite and strictly positive; anything else is
ignored (leaving B = I) rather than corrupting the matrix.
Sourcepub fn reset_to_scale(&mut self)
pub fn reset_to_scale(&mut self)
Discard the accumulated rank-2 curvature and fall back to a
scaled identity γI, where γ is the current mean diagonal
(a scale the accumulated matrix has already vouched for).
prev_x / prev_grad_lag are retained, so the next
Self::update resumes accumulating from the reset base.
Used as a recovery step when the QP subproblem fails: a quasi-Newton matrix that has drifted ill-conditioned makes the step subproblem numerically unsolvable, and that is recoverable — far better than aborting an otherwise healthy solve. Off-diagonals are zeroed; the diagonal keeps the problem’s scale.
Sourcepub fn update(&mut self, x_new: &[Number], grad_lag_new: &[Number])
pub fn update(&mut self, x_new: &[Number], grad_lag_new: &[Number])
Apply the Powell-damped BFGS update from the previous
(x_old, ∇L_old) to the supplied (x_new, ∇L_new). The
first call just stores the pair; subsequent calls also
modify B.
Sourcepub fn update_sy(&mut self, s: &[Number], y: &[Number])
pub fn update_sy(&mut self, s: &[Number], y: &[Number])
Apply the Powell-damped rank-2 update from an explicit curvature
pair (s, y).
Prefer this over Self::update when the caller can form y
itself: the SQP driver must difference ∇L at a single, fixed
multiplier (see the note in sqp_alg.rs), which the (x, ∇L) form
of Self::update cannot express because it stores the previous
∇L as evaluated at the previous multiplier.
Sourcepub fn as_triplet(&self) -> Triplet
pub fn as_triplet(&self) -> Triplet
Produce the current B as a Triplet over the upper
triangle (1-based), ready to feed into SqpQpData::build.
Auto Trait Implementations§
impl Freeze for DampedBfgs
impl RefUnwindSafe for DampedBfgs
impl Send for DampedBfgs
impl Sync for DampedBfgs
impl Unpin for DampedBfgs
impl UnsafeUnpin for DampedBfgs
impl UnwindSafe for DampedBfgs
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<T, U> Imply<T> for U
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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