# CVXGEN: Code Generation for Convex Optimization

## Parameter specification

Parameters are placeholders for problem data, and may be used in the objective and constraints. Parameter values are not given until the generated solver is called. Parameters are specified by a name, dimension and optional attributes. Dimensions can use symbolic values from dimensions blocks. CVXGEN supports scalar, vector and matrix parameters, as well as indexed parameters.

Some examples (assuming m and n were specified in a dimensions block):

parameters
A (m,n)
b (m)
c (2*m)
Q (n,n) symmetric psd
a nonnegative
end

### Notes

• Each dimension will be assumed 1 if omitted.

• Valid attributes are nonnegative, nonpositive, psd, nsd and symmetric and diagonal.

• You may prefer using the abbreviated attributes nonneg or nonpos, or, informally, positive or negative.

• If a parameter is diagonal, it is worth using that attribute, as it will improve performance.

• Columns will be set to rows if a parameter is symmetric.

• Parameter dimensions can be integers, or simple arithmetic expressions involving dimensions.

• The parameter name must consist only of numbers, letters and underscores, and must start with a letter or an underscore.

## Sparse parameters

CVXGEN supports sparse parameters; that is, parameters with only certain specific entries non-zero. To specify a sparse matrix , for example, use the syntax

parameters
A (3,5) {1,1 2,2 3,3 3,4 3,5 2,5 1,5}
end

Here, is a matrix, with nonzero entries . With the C interface, these will be stored in the order declared, so params.A[0] will be the entry, and params.A[6] will be the entry. If you are using the Matlab interface, pass in a dense matrix. Only the indicated entries will be used, and all other entries will be ignored, even if nonzero. Treat symmetric matrices in an identical way: declare diagonals once, and declare and set non-zero off-diagonals for both the and entries.