CVXGEN: Code Generation for Convex Optimization

Indexed parameters and variables

Many optimization problems contain a sequence of variables or parameters, indexed by time or some other offset. For example, in a model predictive control (MPC) problem, the state variables are typically x^{(0)}, ldots, x^{(T)} in mathbf{R}^n. Rather than declare all T+1 variables individually, CVXGEN provides special syntax to work with indexed variables. Here are some examples:

parameters
  A[i] (m,n) nonnegative, i=1..3
end

variables
  x[t] (n), t=0..T
  z[tau], tau=-L..L
end

In CVXGEN's mbox{LaTeX} output, these will be indexed with a superscript, bracketed index, such as z^{(-2)}.

Indexed symbols can be used in sum functions like sum[t=0..T](x[t]), or in indexed constraints.

Notes

  • If you're looking to instead index into a single vector, see this page.

  • You can use any variable name for the index, but be sure the two instances match.

  • You can use symbolic dimensions and simple arithmetic in the limits.

  • Indices can be zero or positive. Negative indices are not supported.