qps_master

qps_master(H, c, A, l, u, xmin, xmax, x0, opt)

qps_master() - Quadratic Program Solver wrapper function.

[X, F, EXITFLAG, OUTPUT, LAMBDA] = ...
    QPS_MASTER(H, C, A, L, U, XMIN, XMAX, X0, OPT)
[X, F, EXITFLAG, OUTPUT, LAMBDA] = QPS_MASTER(PROBLEM)
A common wrapper function for various QP solvers.
Solves the following QP (quadratic programming) problem:

    min 1/2 X'*H*X + C'*X
     X

subject to

    L <= A*X <= U       (linear constraints)
    XMIN <= X <= XMAX   (variable bounds)

Inputs (all optional except H, C, A and L):
    H : matrix (possibly sparse) of quadratic cost coefficients
    C : vector of linear cost coefficients
    A, L, U : define the optional linear constraints. Default
        values for the elements of L and U are -Inf and Inf,
        respectively.
    XMIN, XMAX : optional lower and upper bounds on the
        X variables, defaults are -Inf and Inf, respectively.
    X0 : optional starting value of optimization vector X
    OPT : optional options structure with the following fields,
        all of which are also optional (default values shown in
        parentheses)
        alg ('DEFAULT') : determines which solver to use, can be either
                a string (new-style) or a numerical alg code (old-style)
            'DEFAULT' : (or 0) automatic, first available of Gurobi,
                    CPLEX, MOSEK, Opt Tbx (if MATLAB), GLPK (LPs only),
                    BPMPD, MIPS
            'MIPS'    : (or 200) MIPS, MATPOWER Interior Point Solver
                     pure MATLAB implementation of a primal-dual
                     interior point method, if mips_opt.step_control = 1
                     (or alg=250) it uses MIPS-sc, a step controlled
                     variant of MIPS
            'BPMPD'   : (or 100) BPMPD_MEX
            'CLP'     : CLP
            'CPLEX'   : (or 500) CPLEX
            'GLPK'    : GLPK, (LP problems only, i.e. empty H matrix)
            'GUROBI'  : (or 700) Gurobi
            'IPOPT'   : (or 400) IPOPT, requires MEX interface to IPOPT
                        solver, https://github.com/coin-or/Ipopt
            'MOSEK'   : (or 600) MOSEK
            'OSQP'    : OSQP, https://osqp.org
            'OT'      : (or 300) Optimization Toolbox, QUADPROG or LINPROG
        verbose (0) - controls level of progress output displayed
            0 = no progress output
            1 = some progress output
            2 = verbose progress output
        bp_opt      - options vector for BP
        clp_opt     - options vector for CLP
        cplex_opt   - options struct for CPLEX
        glpk_opt    - options struct for GLPK
        grb_opt     - options struct for GUROBI
        ipopt_opt   - options struct for IPOPT
        linprog_opt - options struct for LINPROG
        mips_opt    - options struct for QPS_MIPS
        mosek_opt   - options struct for MOSEK
        osqp_opt    - options struct for OSQP
        quadprog_opt - options struct for QUADPROG
    PROBLEM : The inputs can alternatively be supplied in a single
        PROBLEM struct with fields corresponding to the input arguments
        described above: H, c, A, l, u, xmin, xmax, x0, opt

Outputs:
    X : solution vector
    F : final objective function value
    EXITFLAG : exit flag
        1 = converged
        0 or negative values = solver specific failure codes
    OUTPUT : output struct with the following fields:
        alg - algorithm code of solver used
        (others) - algorithm specific fields
    LAMBDA : struct containing the Langrange and Kuhn-Tucker
        multipliers on the constraints, with fields:
        mu_l - lower (left-hand) limit on linear constraints
        mu_u - upper (right-hand) limit on linear constraints
        lower - lower bound on optimization variables
        upper - upper bound on optimization variables

Note the calling syntax is almost identical to that of QUADPROG
from MathWorks' Optimization Toolbox. The main difference is that
the linear constraints are specified with A, L, U instead of
A, B, Aeq, Beq.

Calling syntax options:
    [x, f, exitflag, output, lambda] = ...
        qps_master(H, c, A, l, u, xmin, xmax, x0, opt)

    x = qps_master(H, c, A, l, u)
    x = qps_master(H, c, A, l, u, xmin, xmax)
    x = qps_master(H, c, A, l, u, xmin, xmax, x0)
    x = qps_master(H, c, A, l, u, xmin, xmax, x0, opt)
    x = qps_master(problem), where problem is a struct with fields:
                    H, c, A, l, u, xmin, xmax, x0, opt
                    all fields except 'c', 'A' and 'l' or 'u' are optional
    x = qps_master(...)
    [x, f] = qps_master(...)
    [x, f, exitflag] = qps_master(...)
    [x, f, exitflag, output] = qps_master(...)
    [x, f, exitflag, output, lambda] = qps_master(...)

Example: (problem from from https://v8doc.sas.com/sashtml/iml/chap8/sect12.htm)
    H = [   1003.1  4.3     6.3     5.9;
            4.3     2.2     2.1     3.9;
            6.3     2.1     3.5     4.8;
            5.9     3.9     4.8     10  ];
    c = zeros(4,1);
    A = [   1       1       1       1;
            0.17    0.11    0.10    0.18    ];
    l = [1; 0.10];
    u = [1; Inf];
    xmin = zeros(4,1);
    x0 = [1; 0; 0; 1];
    opt = struct('verbose', 2);
    [x, f, s, out, lambda] = qps_master(H, c, A, l, u, xmin, [], x0, opt);