pub struct QpLayer { /* private fields */ }Expand description
An ADMM-based differentiable QP layer.
Stores problem data and the last forward-pass solution for use in the backward pass.
Implementations§
Source§impl QpLayer
impl QpLayer
Sourcepub fn with_config(config: QpLayerConfig) -> Self
pub fn with_config(config: QpLayerConfig) -> Self
Create a new QP layer with custom configuration.
Sourcepub fn forward(
&mut self,
q: Vec<Vec<f64>>,
c: Vec<f64>,
a_eq: Vec<Vec<f64>>,
b_eq: Vec<f64>,
g_ineq: Vec<Vec<f64>>,
h_ineq: Vec<f64>,
) -> OptimizeResult<DiffOptResult>
pub fn forward( &mut self, q: Vec<Vec<f64>>, c: Vec<f64>, a_eq: Vec<Vec<f64>>, b_eq: Vec<f64>, g_ineq: Vec<Vec<f64>>, h_ineq: Vec<f64>, ) -> OptimizeResult<DiffOptResult>
Solve the QP (forward pass).
Uses ADMM with warm-start. The constraint matrix C = [A_eq; G_ineq] is stacked, and z is projected onto the feasible set:
z_eq = b_eq (equality: exact satisfaction) z_ineq = min(z_ineq_raw, h_ineq) (inequality: clamp to ≤ h)
§Arguments
q– n×n cost matrix (symmetric PSD).c– n linear cost vector.a_eq– p×n equality constraint matrix.b_eq– p equality rhs.g_ineq– m×n inequality constraint matrix.h_ineq– m inequality rhs.
Sourcepub fn backward(&self, dl_dx: &[f64]) -> OptimizeResult<DiffOptGrad>
pub fn backward(&self, dl_dx: &[f64]) -> OptimizeResult<DiffOptGrad>
Backward pass: compute parameter gradients via KKT sensitivity.
Uses the active-set at the solution to identify binding inequality
constraints, stacks them with equality constraints, and calls
kkt_sensitivity on the resulting system.
§Arguments
dl_dx– upstream gradient dL/dx (length n).
§Errors
Returns OptimizeError::ComputationError if no forward pass has been
run, or if the KKT system is singular.
Sourcepub fn last_solution(&self) -> Option<&[f64]>
pub fn last_solution(&self) -> Option<&[f64]>
Access the cached solution from the last forward pass.
Sourcepub fn reset_warm_start(&mut self)
pub fn reset_warm_start(&mut self)
Reset warm-start cache.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QpLayer
impl RefUnwindSafe for QpLayer
impl Send for QpLayer
impl Sync for QpLayer
impl Unpin for QpLayer
impl UnsafeUnpin for QpLayer
impl UnwindSafe for QpLayer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
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.