## QPC - Quadratic Programming in C

## Usage

Using the quadratic programming routines (taken from README file):

!!! IMPORTANT !!!: ALL ROUTINES ASSUME THAT THE INPUT DATA IS IN DENSE FORMAT qpas: This dual active-set algorithm attempts to solve quadratic programming problems in the following form: x* = arg min 0.5x'Hx + f'x x s.t. Ax = b, linear equality constraints, Lx <= k, general linear inequality constraints, l <= x <= u, bound constraints. In Matlab a call to this function would look like: [x,err,lm] = qpas(H,f,L,k,A,b,l,u,display); where the inputs are: H: An (n x n) positive semi-definite symmetric matrix f: A n element column vector (L,k): General linear inequality constraints (A,b): General linear equality constraints l: Element-wise lower bound constraints u: Element-wise upper bound constraints display: If display>0 then iteration information is displayed and the outputs are: x: the optimal solution (if obtained) err: error number, if err=0, then x is optimal lm: structure of Lagrange multipliers lm.equality: Lagrange multipliers for equality constraints lm.inequality: Lagrange multipliers for general inequality constraints lm.lowerbound: Lagrange multipliers for lower bound constraints lm.upperbound: Lagrange multipliers for upper bound constraints If (A,b) and/or (L,k) and/or l and/or u, are not being used, then set the respective entry to [] (i.e. the empty matrix). E.g.1 suppose that only L and k are being used then a call would look like x = qpas(H,f,L,k); E.g.2 suppose that (A,b) and l are required, then a call would look like x = qpas(H,f,[],[],A,b,l); qpip: This primal-dual predictor-corrector algorithm attempts to solve quadratic programming problems in the following form: x* = arg min 0.5x'Hx + f'x x s.t. Ax = b, linear equality constraints, Lx <= k, general linear inequality constraints, l <= x <= u, bound constraints. In Matlab a call to this function would look like: [x,err,lm] = qpip(H,f,L,k,A,b,l,u,display,mu,method); where the inputs are: H: An (n x n) positive semi-definite symmetric matrix f: A n element column vector (L,k): General linear inequality constraints (A,b): General linear equality constraints l: Element-wise lower bound constraints u: Element-wise upper bound constraints display: If display>0 then iteration information is displayed mu: Desired complementarity gap target (point on central-path) [Default is mu=0.0] method: If method=1 (default), then a faster but less accurate linear solve step is used. Conversely, if method=0 then a slower but more accurate linear solve step is used. and the outputs are: x: the optimal solution (if obtained) err: error number, if err=0, then x is optimal lm: structure of Lagrange multipliers lm.equality: Lagrange multipliers for equality constraints lm.inequality: Lagrange multipliers for general inequality constraints lm.lowerbound: Lagrange multipliers for lower bound constraints lm.upperbound: Lagrange multipliers for upper bound constraints If (A,b) and/or (L,k) and/or l and/or u, are not being used, then set the respective entry to [] (i.e. the empty matrix). E.g.1 suppose that only L and k are being used then a call would look like x = qpip(H,f,L,k); E.g.2 suppose that (A,b) and l are required, then a call would look like x = qpip(H,f,[],[],A,b,l); qps_as: This dual active-set algorithm attempts to solve quadratic programming problems in the following form: x* = arg min 0.5x'Hx + f'x x s.t. l <= x <= u, bound constraints. In Matlab a call to this function would look like: [x,err,lm] = qps_as(H,f,l,u,display); where the inputs are: H: An (n x n) positive semi-definite symmetric matrix f: A n element column vector l: Element-wise lower bound constraints u: Element-wise upper bound constraints display: If display>0 then iteration information is displayed and the outputs are: x: the optimal solution (if obtained) err: error number, if err=0, then x is optimal lm: structure of Lagrange multipliers lm.lowerbound: Lagrange multipliers for lower bound constraints lm.upperbound: Lagrange multipliers for upper bound constraints NOTE: Both l and u must be provided, however, +/-inf entries are acceptable so that "free" variables are catered for. qps_ip: This primal-dual predictor-corrector algorithm attempts to solve quadratic programming problems in the following form: x* = arg min 0.5x'Hx + f'x x s.t. l <= x <= u, bound constraints. In Matlab a call to this function would look like: [x,err,lm] = qps_ip(H,f,l,u,display); where the inputs are: H: An (n x n) positive semi-definite symmetric matrix f: A n element column vector l: Element-wise lower bound constraints u: Element-wise upper bound constraints display: If display>0 then iteration information is displayed and the outputs are: x: the optimal solution (if obtained) err: error number, if err=0, then x is optimal lm: structure of Lagrange multipliers lm.lowerbound: Lagrange multipliers for lower bound constraints lm.upperbound: Lagrange multipliers for upper bound constraints NOTE: Both l and u must be provided, however, +/-inf entries are acceptable so that "free" variables are catered for. qps_mq: This branch-and-bound type algorithm attempts to solve quadratic programming problems in the following form: x* = arg min 0.5x'Hx + f'x x s.t. l <= x <= u, bound constraints. In Matlab a call to this function would look like: [x,err,lm] = qps_mq(H,f,l,u); where the inputs are: H: An (n x n) positive semi-definite symmetric matrix f: A n element column vector l: Element-wise lower bound constraints u: Element-wise upper bound constraints and the outputs are: x: the optimal solution (if obtained) err: error number, if err=0, then x is optimal lm: structure of Lagrange multipliers lm.lowerbound: Lagrange multipliers for lower bound constraints lm.upperbound: Lagrange multipliers for upper bound constraints NOTE: Both l and u must be provided, however, +/-inf entries are acceptable so that "free" variables are catered for.