Struct totsu_core::solver::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>
impl<L: LinAlg> Solver<L>
sourcepub fn query_worklen(op_a_size: (usize, usize)) -> usize
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§impl<L: LinAlg> Solver<L>where
L::F: Float + Debug + LowerExp,
impl<L: LinAlg> Solver<L>where
L::F: Float + Debug + LowerExp,
sourcepub 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>,
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 linearOperator
.op_a
is \(A\) as a linearOperator
.op_b
is \(b\) as a linearOperator
.cone
is \(\mathcal{K}\) expressed byCone
.work
slice is used for temporal variables.Solver::solve
does not rely on dynamic heap allocation.