Skip to main content

LpProblem

Struct LpProblem 

Source
pub struct LpProblem {
    pub c: Vec<f64>,
    pub a: CscMatrix,
    pub b: Vec<f64>,
    pub num_vars: usize,
    pub num_constraints: usize,
    pub constraint_types: Vec<ConstraintType>,
    pub bounds: Vec<(f64, f64)>,
    pub name: Option<String>,
}
Expand description

線形計画問題: min c^T x s.t. Ax {op} b, x in [lb, ub]

目的関数・制約行列・右辺ベクトル・変数上下限をまとめて保持する。 制約種別(<=, >=, =)と変数ごとの上下限を個別に指定できる。

Fields§

§c: Vec<f64>

目的関数係数ベクトル(長さ: num_vars

§a: CscMatrix

制約行列(CSC形式、サイズ: num_constraints x num_vars

§b: Vec<f64>

制約右辺ベクトル(長さ: num_constraints

§num_vars: usize

決定変数の数

§num_constraints: usize

制約式の数

§constraint_types: Vec<ConstraintType>

各制約の種別(長さ: num_constraints

§bounds: Vec<(f64, f64)>

各変数の上下限 (lower, upper)(長さ: num_vars

§name: Option<String>

問題名(オプション)

Implementations§

Source§

impl LpProblem

Source

pub fn new(c: Vec<f64>, a: CscMatrix, b: Vec<f64>) -> Result<Self, SolverError>

新しいLP問題を検証付きで生成する(後方互換版)

標準形 min c^T x s.t. Ax <= b, x >= 0 を作成する。 全制約を <=、全変数の下限を 0・上限を +∞ とする。

§引数
  • c - 目的関数係数ベクトル
  • a - 制約行列(CSC形式)
  • b - 制約右辺ベクトル
§戻り値
  • Ok(LpProblem) - 次元が有効な場合
  • Err(String) - 次元不一致などの検証エラー時
Source

pub fn new_general( c: Vec<f64>, a: CscMatrix, b: Vec<f64>, constraint_types: Vec<ConstraintType>, bounds: Vec<(f64, f64)>, name: Option<String>, ) -> Result<Self, SolverError>

制約種別と変数上下限を完全指定して新しいLP問題を生成する

§引数
  • c - 目的関数係数ベクトル
  • a - 制約行列(CSC形式)
  • b - 制約右辺ベクトル
  • constraint_types - 各制約の種別(Le / Ge / Eq
  • bounds - 各変数の上下限 (lower, upper)
  • name - 問題名(オプション)
§戻り値
  • Ok(LpProblem) - 次元が有効な場合
  • Err(String) - 次元不一致などの検証エラー時

Trait Implementations§

Source§

impl Clone for LpProblem

Source§

fn clone(&self) -> LpProblem

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 Debug for LpProblem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for LpProblem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,