pub struct LpSensitivity {
pub basis: Vec<usize>,
pub x_basic: Vec<f64>,
pub dual: Vec<f64>,
pub b_inv: Vec<Vec<f64>>,
}Expand description
Exact sensitivity analysis for LP in standard form.
For the LP:
min cᵀx s.t. Ax = b, x ≥ 0
at an optimal basic feasible solution with basis B (indices of basic variables), the optimal basic variable values are x_B = B⁻¹ b, and the sensitivity is:
dx_B*/dc_B = -B⁻¹ (from KKT optimality conditions) dx_B*/db = B⁻¹ (from primal feasibility) dx_N*/dc = 0 (nonbasic variables at zero)
Fields§
§basis: Vec<usize>Optimal basis indices (into the original variable vector).
x_basic: Vec<f64>Optimal basic variable values x_B = B⁻¹ b.
dual: Vec<f64>Optimal dual variables (shadow prices): y = (B⁻¹)ᵀ c_B.
b_inv: Vec<Vec<f64>>Inverse of the basis matrix B⁻¹.
Implementations§
Source§impl LpSensitivity
impl LpSensitivity
Sourcepub fn new(
a: &[Vec<f64>],
b_rhs: &[f64],
c: &[f64],
basis: Vec<usize>,
) -> OptimizeResult<Self>
pub fn new( a: &[Vec<f64>], b_rhs: &[f64], c: &[f64], basis: Vec<usize>, ) -> OptimizeResult<Self>
Compute LP sensitivity at a given basic feasible solution.
§Arguments
a– equality constraint matrix (p×n).b_rhs– equality rhs (p).c– cost vector (n).basis– indices of basic variables (length p).
Sourcepub fn dl_dc(&self, n: usize, dl_dx: &[f64]) -> Vec<f64>
pub fn dl_dc(&self, n: usize, dl_dx: &[f64]) -> Vec<f64>
Compute dL/dc_B given upstream gradient dL/dx_B.
From the KKT conditions, dx_B*/dc_B = -B⁻¹, so: dL/dc_B_j = -Σ_i (B⁻¹)_{ij} * dL/dx_B_i
§Arguments
n– total number of variables.dl_dx– upstream gradient (length n).
Trait Implementations§
Source§impl Clone for LpSensitivity
impl Clone for LpSensitivity
Source§fn clone(&self) -> LpSensitivity
fn clone(&self) -> LpSensitivity
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for LpSensitivity
impl RefUnwindSafe for LpSensitivity
impl Send for LpSensitivity
impl Sync for LpSensitivity
impl Unpin for LpSensitivity
impl UnsafeUnpin for LpSensitivity
impl UnwindSafe for LpSensitivity
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.