2

I want to solve the following optimization problem:

Non-Latex: Given x and mu, find

argmin_p ||x-p||_2 s.t. ||p||_2 < mu.

Latex:

Given $\mathbf{x}$ and $\mu$, find

$\mathrm{argmin}_p \|\mathbf{x}-\mathbf{p}\|_2 \;\; \mathrm{s.t.}\;\;\|\mathbf{p}\|_2 \leq \mu$,

which is a convex function over a convex set. I have been using Matlab's fmincon but it is just too slow. Search engine results have so far brought me material that is much more theoretical than what I am looking for. I can't be the first person to want to solve this problem and was hoping to find an existing and efficient Matlab implementation.

AnonSubmitter85
  • 933
  • 7
  • 14
  • Previous comment revoked; dunno why I tried to read the LaTeX code instead of the plaintext... – bnaul Jun 25 '12 at 05:54

1 Answers1

4

cvx can handle this problem quite simply. Even if you're not familiar with it, the syntax is quite intuitive:

% test data
n = 1e4;
x = randn(n,1);
mu = 1;

cvx_begin
variable p(n)
minimize norm(x-p)
subject to
norm(p) <= mu
cvx_end

On my system this takes under a second for 10^4 variables.

bnaul
  • 17,288
  • 4
  • 32
  • 30
  • Hey can you tell me why cvx doesn't allow vector multiplication? I keep getting this error: mtimes : only quadratic forms allowed. Is there a way to circumvent this problem. Because I really need to use cvx, which seems to solve problems quite quickly. – sprajagopal Jun 12 '13 at 15:46
  • What kind of vector multiplication? The user's manual lists several options: http://cvxr.com/cvx/cvx_usrguide.pdf. If you're trying to do `x' * y` you can use `dot(x,y)`, for example. – bnaul Jun 12 '13 at 21:56
  • Yeah, I went through the entire thing and I understand that this is very different from the nonlcon in fmincon. It doesn't compute for a specific optimization variable. It performs the check by keeping the variables as such. I was having a vector A(x) and B(x). A(x)*B(x)' is where I get an error, like I would expect after reading the manual. – sprajagopal Jun 12 '13 at 23:02