The OpenD Programming Language

solveBoxQP

Solves: argmin_x(xPx + qx) : l <= x <= u

  1. BoxQPStatus solveBoxQP(Slice!(T*, 2, Canonical) P, Slice!(const(T)*) q, Slice!(const(T)*) l, Slice!(const(T)*) u, Slice!(T*) x, BoxQPSettings!T settings)
  2. BoxQPStatus solveBoxQP(BoxQPSettings!T settings, Slice!(T*, 2, Canonical) P, Slice!(const(T)*) q, Slice!(const(T)*) l, Slice!(const(T)*) u, Slice!(T*) x, bool unconstrainedSolution, Slice!(T*) work, Slice!(lapackint*) iwork, bool restoreUpperP)
    @safe pure nothrow @nogc
    solveBoxQP
    (
    T
    )
    (,
    Slice!(T*, 2, Canonical) P
    ,
    Slice!(const(T)*) q
    ,
    Slice!(const(T)*) l
    ,
    Slice!(const(T)*) u
    ,
    Slice!(T*) x
    ,,
    Slice!(T*) work
    ,,
    bool restoreUpperP = true
    )
    if (
    is(T == float) ||
    is(T == double)
    )

Parameters

settings BoxQPSettings!T

Iteration settings

P Slice!(T*, 2, Canonical)

Positive-definite Matrix (in lower triangular part is store), NxN. The upper triangular part (and diagonal) of the matrix is used for temporary data and then can be resotored. Matrix diagonal is always restored.

q Slice!(const(T)*)

Linear component, N

l Slice!(const(T)*)

Lower bounds in [-inf, +inf$(RPAREN), N

u Slice!(const(T)*)

Upper bounds in $(LPAREN)-inf, +inf], N

x Slice!(T*)

solutoin, N

unconstrainedSolution bool
work Slice!(T*)
iwork Slice!(lapackint*)

integer workspace, mir_box_qp_iwork_length(N)

restoreUpperP bool

(optional) restore upper triangular part of P

Examples

import mir.ndslice;
import mir.algorithm.iteration;
import mir.math.common;

auto P = [
    [ 2.0, -1, 0],
    [-1.0, 2, -1],
    [ 0.0, -1, 2],
].fuse.canonical;

auto q = [3.0, -7, 5].sliced;
auto l = [-100.0, -2, 1].sliced;
auto u = [100.0, 2, 1].sliced;
auto x = slice!double(q.length);

solveBoxQP(P, q, l, u, x);
assert(x.equal!approxEqual([-0.5, 2, 1]));

Meta