pub struct QpProblem {
pub q: CscMatrix,
pub c: Vec<f64>,
pub a: CscMatrix,
pub b: Vec<f64>,
pub bounds: Vec<(f64, f64)>,
pub num_vars: usize,
pub num_constraints: usize,
pub constraint_types: Vec<ConstraintType>,
pub quadratic_constraints: Vec<QcqpMatrix>,
pub obj_offset: f64,
}Expand description
min 1/2 x^T Q x + c^T x s.t. Ax {<=,=,>=} b, lb <= x <= ub
When quadratic_constraints is non-empty the problem is a QCQP.
Entry k holds the symmetric n×n matrix Q_k for the quadratic part
of constraint k: 1/2 x^T Q_k x + a_k^T x {<=,=,>=} b_k.
An empty QcqpMatrix at index k means constraint k has no quadratic part.
Fields§
§q: CscMatrix§c: Vec<f64>§a: CscMatrix§b: Vec<f64>§bounds: Vec<(f64, f64)>§num_vars: usize§num_constraints: usize§constraint_types: Vec<ConstraintType>§quadratic_constraints: Vec<QcqpMatrix>Per-constraint quadratic matrices for QCQP, stored in COO format.
Length is either 0 (pure QP/LP) or num_constraints (QCQP).
Entry k holds symmetrized triplets for Q_k; empty means no quadratic part.
obj_offset: f64目的関数値 = 1/2 x^T Q x + c^T x + obj_offset
Implementations§
Source§impl QpProblem
impl QpProblem
pub fn new( q: CscMatrix, c: Vec<f64>, a: CscMatrix, b: Vec<f64>, bounds: Vec<(f64, f64)>, constraint_types: Vec<ConstraintType>, ) -> Result<Self, QpProblemError>
Sourcepub fn is_zero_q(&self) -> bool
pub fn is_zero_q(&self) -> bool
Q が構造的にゼロ(LP)かを判定する。
LP/QP の dispatch 判定に使う。数値閾値ではなく構造的ゼロで判定する:
stored 値が一つでも非ゼロなら QP (IPM 経路)。CscMatrix::from_triplets は
|v| ≤ DROP_TOL を構築時に落とすため、ここに残る値は構造的非ゼロである。
閾値判定 (例 |v| < 1e-12) は微小 Q QP を LP 化して status を変える
(例 bounded QP → false-Unbounded)。dispatch は status を変えてはならない。
Sourcepub fn has_qcqp_constraints(&self) -> bool
pub fn has_qcqp_constraints(&self) -> bool
Returns true if the problem has at least one constraint with a non-zero quadratic term.
Used as a guard: the QP/LP solver cannot handle QCQP and must reject such problems.
Sourcepub fn set_quadratic_constraints(
&mut self,
qcs: Vec<QcqpMatrix>,
) -> Result<(), QpProblemError>
pub fn set_quadratic_constraints( &mut self, qcs: Vec<QcqpMatrix>, ) -> Result<(), QpProblemError>
Set per-constraint quadratic matrices for QCQP, with validation.
qcs must be either empty (pure QP) or have length equal to num_constraints.
Each QcqpMatrix must have n == num_vars, finite values, and triplet indices
within [0, n).
Sourcepub fn is_diagonal_q(&self) -> bool
pub fn is_diagonal_q(&self) -> bool
Q が対角行列かどうかを検査する
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QpProblem
impl RefUnwindSafe for QpProblem
impl Send for QpProblem
impl Sync for QpProblem
impl Unpin for QpProblem
impl UnsafeUnpin for QpProblem
impl UnwindSafe for QpProblem
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> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
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