Effacer les filtres
Effacer les filtres

How to give conditions on transformations of variables in cvx?

12 vues (au cours des 30 derniers jours)
Mudit Batra
Mudit Batra le 9 Août 2020
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.
variable H(4096)
minimize(max(abs(H- R)))
subject to
How to impose that conditions here?

Réponses (1)

Thiago Henrique Gomes Lobato
Modifié(e) : Thiago Henrique Gomes Lobato le 9 Août 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:
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
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
% Verify result
hMat = ifft(H);
Constrain = ones(1,n)*hMat
AnyRealBelowZero = any(real(hMat)<0)
% output
DifferenceNorm =
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 =
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.


En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by