Solver

Struct Solver 

Source
pub struct Solver<L: LinAlg> {
    pub par: SolverParam<L::F>,
}
Expand description

First-order conic linear program solver struct.

This struct abstracts a solver of a conic linear program: \[ \begin{array}{ll} {\rm minimize} & c^T x \\ {\rm subject \ to} & A x + s = b \\ & s \in \mathcal{K}, \end{array} \] where

  • variables \( x \in \mathbb{R}^n,\ s \in \mathbb{R}^m \)
  • \( c \in \mathbb{R}^n \) as an objective linear operator
  • \( A \in \mathbb{R}^{m \times n} \) and \( b \in \mathbb{R}^m \) as constraint linear operators
  • a nonempty, closed, convex cone \( \mathcal{K} \).

The solution gives optimal values of primal variables \(x\) as well as dual variables \(y\) of the dual problem: \[ \begin{array}{ll} {\rm maximize} & -b^T y \\ {\rm subject \ to} & -A^T y = c \\ & y \in \mathcal{K}^*, \end{array} \] where

  • variables \( y \in \mathbb{R}^m \)
  • \( \mathcal{K}^* \) is the dual cone of \( \mathcal{K} \).

Fields§

§par: SolverParam<L::F>

solver parameters.

Implementations§

Source§

impl<L: LinAlg> Solver<L>

Source

pub fn query_worklen(op_a_size: (usize, usize)) -> usize

Query of a length of work slice.

Returns a length of work slice that Solver::solve requires.

  • op_a_size is a number of rows and columns of \(A\).
Source

pub fn new() -> Self

Creates an instance.

Returns Solver instance.

Source

pub fn par<P>(self, f: P) -> Self
where P: FnOnce(&mut SolverParam<L::F>),

Changes solver parameters.

Returns Solver with its parameters changed.

  • f is a function to change parameters given by its argument.
Source§

impl<L: LinAlg> Solver<L>
where L::F: Float + Debug + LowerExp,

Source

pub fn solve<OC, OA, OB, C>( self, (op_c, op_a, op_b, cone, work): (OC, OA, OB, C, &mut [L::F]), ) -> Result<(&[L::F], &[L::F]), SolverError>
where OC: Operator<L>, OA: Operator<L>, OB: Operator<L>, C: Cone<L>,

Starts to solve a conic linear program.

Returns Ok with a tuple of optimal \(x, y\) or Err with SolverError type.

  • op_c is \(c\) as a linear Operator.
  • op_a is \(A\) as a linear Operator.
  • op_b is \(b\) as a linear Operator.
  • cone is \(\mathcal{K}\) expressed by Cone.
  • work slice is used for temporal variables. Solver::solve does not rely on dynamic heap allocation.

Auto Trait Implementations§

§

impl<L> Freeze for Solver<L>
where <L as LinAlg>::F: Freeze,

§

impl<L> RefUnwindSafe for Solver<L>
where <L as LinAlg>::F: RefUnwindSafe,

§

impl<L> Send for Solver<L>
where <L as LinAlg>::F: Send,

§

impl<L> Sync for Solver<L>
where <L as LinAlg>::F: Sync,

§

impl<L> Unpin for Solver<L>
where <L as LinAlg>::F: Unpin,

§

impl<L> UnwindSafe for Solver<L>
where <L as LinAlg>::F: UnwindSafe,

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> 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, 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.