qps_glpk
- qps_glpk(H, c, A, l, u, xmin, xmax, x0, opt)
qps_glpk()
- Linear Program Solver based on GLPK - GNU Linear Programming Kit.[X, F, EXITFLAG, OUTPUT, LAMBDA] = ... QPS_GLPK(H, C, A, L, U, XMIN, XMAX, X0, OPT) [X, F, EXITFLAG, OUTPUT, LAMBDA] = QPS_GLPK(PROBLEM) A wrapper function providing a standardized interface for using GLPK to solve the following LP (linear programming) problem: min 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 : IGNORED dummy matrix of quadratic cost coefficients for QP problems, which GLPK does not handle 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 (NOT USED) OPT : optional options structure with the following fields, all of which are also optional (default values shown in parentheses) verbose (0) - controls level of progress output displayed 0 = no progress output 1 = some progress output 2 = verbose progress output glpk_opt - options struct for GLPK, value in verbose overrides these options 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 - optimal, <= 0 - infeasible, unbounded or other OUTPUT : output struct with the following fields: errnum - GLPK errnum output arg status - GKPK status output arg runtime - solver run time in seconds 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 GLPK. 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_glpk([], c, A, l, u, xmin, xmax, x0, opt) x = qps_glpk([], c, A, l, u) x = qps_glpk([], c, A, l, u, xmin, xmax) x = qps_glpk([], c, A, l, u, xmin, xmax, x0) x = qps_glpk([], c, A, l, u, xmin, xmax, x0, opt) x = qps_glpk(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_glpk(...) [x, f] = qps_glpk(...) [x, f, exitflag] = qps_glpk(...) [x, f, exitflag, output] = qps_glpk(...) [x, f, exitflag, output, lambda] = qps_glpk(...) Example: (based on example from 'doc linprog') c = [-5; -4; -6]; A = [ 1 -1 1; -3 -2 -4; 3 2 0]; l = [-Inf; -42; -Inf]; u = [20; Inf; 30]; xmin = [0; 0; 0]; opt = struct('verbose', 2); [x, f, s, out, lambda] = qps_glpk([], c, A, l, u, xmin, [], [], opt);
See also
qps_master()
,glpk
.