How to give conditions on transformations of variables in cvx?

17 visualizaciones (últimos 30 días)
Hi,
I am new to CVX, here I want min-max the H where R is given to us, but the subject to conditions here are to be imposed on ifft of H ( Let ifft(H) = h). We want all coefficients of h to be greater than 0 and its submission to be one.
cvx_begin
variable H(4096)
minimize(max(abs(H- R)))
subject to
h>=0;
dot(ones,h)==1;
cvx_end
How to impose that conditions here?

Respuestas (1)

Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato el 9 de Ag. de 2020
Editada: Thiago Henrique Gomes Lobato el 9 de Ag. de 2020
As far as I know the Cvx library doesn't accepts fft/ifft. What you can do is to calculate the ifft by "brute force" in a way that cvx will accept it. Also, h can be complex, so it doesn't make sense to say that "h>0", an this indeed is not allowed at cvx. What you can do is to say, for example, "real(h)>0". Here is an example about how you would do this:
rng(42)
n = 128;
R = randn(n,1);
[mm,nn] = meshgrid(0:n-1,0:n-1);
w = exp(mm.*1i .* 2 .* pi / n .* nn); %ifft basis
H = randn(n,1);
DifferenceNorm = norm(w.'*H/n-ifft(H)) % Just to check
cvx_begin
variable H(n)
expression h(n)
h = w.'*H/n; % Ifft as matrix multiplication so cvx understand it
minimize(max(abs(H- R)))
subject to
real(h)>=0; % complex>constant makes no sense. Use real or abs. In this specific case, abs makes also no sense
ones(1,n)*h==1;
cvx_end
% Verify result
hMat = ifft(H);
Constrain = ones(1,n)*hMat
AnyRealBelowZero = any(real(hMat)<0)
% output
DifferenceNorm =
2.45421737587355e-14
Calling SDPT3 4.0: 514 variables, 257 equality constraints
For improved efficiency, SDPT3 is solving the dual problem.
------------------------------------------------------------
...
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +1.53824
Constrain =
1.00000000000709 - 1.11022302462516e-16i
AnyRealBelowZero =
logical
0
This problem, however, scales very badly, so anything more than 512 samples will take a really long time to calculate. If you have the optimization toolbox I would advise you to use fmincon and then just use the ifft as a non-linear constrain. If you can really only use cvx, I would then advise to model your problem for a smaller ifft window, which should give you also good results.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by