Pergunta

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.

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top