CVXGEN: Code Generation for Convex Optimization

Example: Lasso

This example, from statistics, demonstrates the lasso procedure (ell_1-regularized least squares). For some more details, see Boyd and Vandenberghe, S6.3.2.

Optimization problem

We wish to solve the optimization problem

 begin{array}{ll} mbox{minimize} & (1/2)|Ax - b|_2^2 + lambda |x|_1  end{array}

with parameters

  • A in mathbf{R}^{m times n}

  • b in mathbf{R}^m

  • lambda in mathbf{R}_+

and optimization variable

  • x in mathbf{R}^n

The problem is interesting both when m < n, and when m > n.

CVXGEN code

dimensions
  m = 100
  n = 10
end

parameters
  A (m,n)
  b (m)
  lambda nonnegative  # regularization weight.
end

variables
  x (n)
end

minimize
  (1/2)*quad(A*x - b) + lambda*norm_1(x)
end