# QPgen

### What it does

QPgen is a MATLAB toolbox that generates C code that solve convex parametric problems of the form:

 minimize $$\tfrac{1}{2}x^THx+g^Tx+h(Cx)$$ subject to $$Ax=b$$,

where:

• $$x\in\mathbf{R}^n$$ is the variable to be decided

• $$H\in\mathbf{R}^{n\times n}$$ is a positive semi definite real data matrix

• $$C\in\mathbf{R}^{p\times n}$$ and $$A\in\mathbf{R}^{m\times n}$$ are fixed data matrices

• $$h : \mathbf{R}^p\to\mathbf{R}\cup\{\infty\}$$ is a sum of piecewise linear functions which models, e.g.,

• Upper and lower bounds on $$Cx$$

• Soft upper and lower bounds on $$Cx$$

• The 1-norm

The generated C code takes $$g\in\mathbf{R}^n$$ and/or $$b\in\mathbf{R}^m$$ as inputs and solves the corresponding problem instance.

### How it does it

The generated C code uses one of the following three algorithms to solve the optimization problem instances:

• The alternating direction method of multipliers (ADMM)

• Fast dual proximal gradient method (FGMdual)

• Fast primal proximal gradient method (FGMprimal)

Features of the generated C code:

• It usually has very good performance (up to 10 000 times faster than standard software, see examples)

• It can be made library free

• It can be made division free for fixed-point implementations

Keys points that enable good performance:

• Optimal preconditioning and parameter selection

• Efficient handling of soft constraints (without introducing additional variables)

• Solver tailoring to specific parametric program by code generation

• Offline matrix factorization

• Limited online data checks