Skip to main content

PdSensBacksolver

Struct PdSensBacksolver 

Source
pub struct PdSensBacksolver { /* private fields */ }
Expand description

Adapter from PdFullSpaceSolver to SensBacksolver. Holds owning clones of the four pieces of the algorithm’s converged state, plus the 8-block iterate template used to allocate fresh RHS / LHS vectors.

The PD solver lives behind an Rc<RefCell<…>> because SensBacksolver::solve is &self but the upstream signature for PdFullSpaceSolver::solve is &mut self (it caches the last-solve dependency tags and the augsys-improved flag). The RefCell is single-thread-only, single-borrow, exactly matching the call pattern from pounce-sensitivity’s pipeline.

Owning (rather than borrowing) the four handles is what lets a PdSensBacksolver outlive the on_converged callback frame — required by the public Solver session API in pounce-algorithm, which retains the backsolver for repeated parametric_step / kkt_solve / compute_reduced_hessian calls after the IPM has returned. The data, cq, and nlp handles are already Rc<RefCell<…>> cheap-clone handles upstream, so this carries no allocation overhead.

Implementations§

Source§

impl PdSensBacksolver

Source

pub fn new( data: &IpoptDataHandle, cq: &IpoptCqHandle, nlp: &Rc<RefCell<dyn IpoptNlp>>, pd: Rc<RefCell<PdFullSpaceSolver>>, ) -> Result<Self, ()>

Construct from the four handles handed in by the on_converged callback. Returns Err(()) if data has no curr (i.e. the algorithm never reached an iterate — should not happen on SolveSucceeded).

Source

pub fn block_dims(&self) -> [usize; 8]

Block dimensions of the compound KKT vector at convergence, in (x, s, y_c, y_d, z_l, z_u, v_l, v_u) order. Sum equals SensBacksolver::dim. Useful when a caller needs to compute the flat offset of a non-x block (e.g. n_x + n_s for the start of the equality-multiplier y_c block).

Source§

impl PdSensBacksolver

Source

pub fn solve_many( &self, rhs_flat: &[Number], lhs_flat: &mut [Number], n_rhs: usize, ) -> bool

Batched-RHS back-solve over the held factor. rhs_flat and lhs_flat are row-major (n_rhs, dim) buffers. Equivalent to looping SensBacksolver::solve over each row but reuses one frozen IteratesVector for the RHS and one IteratesVectorMut for the result across all n_rhs calls into PdFullSpaceSolver::solve. The pack step writes into the existing DenseVector storage via Rc::get_mut + set_values, and the unpack step reads it back via values() /scalar() — skipping the per-call 8-block make_new_zeroed (Box alloc) in pack and the per-block expanded_values() Vec alloc in unpack that otherwise dominate the held-factor back-solve cost under jax.jacrev over a JaxProblem solve (pounce#77 follow-up).

The matrix and perturbation state inside PdFullSpaceSolver are unchanged across calls, so each iteration hits the cached fast path in solve_once (uptodate && !pretend_singular).

Trait Implementations§

Source§

impl Clone for PdSensBacksolver

Source§

fn clone(&self) -> PdSensBacksolver

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl SensBacksolver for PdSensBacksolver

Source§

fn dim(&self) -> usize

Size of the linear system in entries (length of lhs and rhs). The backsolver’s notion of “full state” — pounce’s IPM uses the compound (x, s, λ_c, λ_d, z_l, z_u, v_l, v_u) concatenation here.
Source§

fn solve(&self, rhs: &[Number], lhs: &mut [Number]) -> bool

Solve K · lhs = rhs. The implementation may use rhs as scratch; callers should treat it as moved-from on return. lhs must have length self.dim().

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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