Hello everyone,
It is been i while that i can’t solve my problem. The code below is for an optimization including the cost function of a log function.
As you can see in the code, i used the entr function as sugggested for solving this kind of problem.
Please feel free to give me advise/suggestion concerning my following erroned code.
Thanks in advance.
Matlab code:
%%%%%%%%%Test Allocation secondaire%%%%%%%%%%%%%%
clear, clc,
M=5; %%
L=4; %%
Q_M=1; %%
Q=4; %%
H=randn(M,L); %%
Ki=randn(M,L); %%
sigma2=1; %%noise power
d_min=2*sqrt(3/(Q*(Q-1)));%
%%Choose a canal
m=randperm(M);
m=m(1);
%%Optimization problem
cvx_begin
variable q(L) nonnegative
fc=0;
for l=1:L
sinr=2*Ki(m,l)^2/(sigma2+abs(H(m,L))^2*q(l)); %sinr
P_es=2*(Q-1)/Q*erfc(sqrt((3/(Q^2-1))*sinr));
X2_ml=sigma2 + P_es*(Ki(m,l)^2)*d_min^2;
%fc=fc+log2(1+(abs(H(m,l))^2*q(l))/X2_ml);
fc=fc + (inv_pos(X2_ml + H(m,l)^2*q(l))*rel_entr(H(m,l)^2*q(l)+ X2_ml, X2_ml))
end
maximize(fc);
%subject to
%norm(q,1) <= Q_M
cvx_end
Use inv_pos
to avoid that error.
Thank you so much for your help,
I modify my code as you suggested. But it seems that the ERFC function is not recognized by the cvx.
The error signals : Undefined function ‘erfc’ for input arguments of type ‘cvx’.
Is there in equivalent function for erfc ? I don’t know if this is the main problem.
Matlab code:
%%%%%%%%%Test Allocation secondaire%%%%%%%%%%%%%%
clear, clc,
M=5; %%Canaux
L=4; %%Sous porteuses
Q_M=1; %%Puissance max
Q=4; %%modulation order
H=randn(M,L); %%coeff. canal pour le symbole secondaire
Ki=randn(M,L); %%coeff. symbole primaire (INCLURE LA SORTIR DU BIT LOADING ICI)
sigma2=1; %%noise power
d_min=2sqrt(3/(Q(Q-1)));%distance entre symboles
%%Choose a canal
m=randperm(M);
m=m(1);
%%Optimization problem
cvx_begin
variable q(L) nonnegative
fc=0;
%q=rand(L,1); %test
for l=1:L
sinr=2Ki(m,l)^2inv_pos((sigma2+abs(H(m,L))^2*q(l)));%sinr
P_es=(sqrt(Q)-1)inv_pos(sqrt(Q))pow_p(erfc((sinr3inv_pos(2*(Q-1)))),1/2);%probabilité d’erreur
X2_ml=sigma2 + P_es*(Ki(m,l)^2)*d_min^2;
%fc=fc+log2(1+(abs(H(m,l))^2q(l))/X2_ml);
fc=fc + (inv_pos(X2_ml + H(m,l)^2q(l))rel_entr(H(m,l)^2q(l)+ X2_ml, X2_ml));%Cette ligne est équivalente à la ligne précédente et utilise un fonction connu convace du cvx mais
end
maximize(fc);
%subject to
%norm(q,1) <= Q_M
cvx_end
erfc
is neither convex nor concave, ans is not supported by CVX. The closest CVX comes to supporting this is an approximation to the log of the Normal cumulative distribution function, log_normcdf
(note that erfc can be expressed in terms of Normal cumulative distribution function). But I don;t see how this will do what you need. So I suggest you use some other tool which can handle non-convex problems.
Hello Mark thanks a lot for you help, i appreciate. I think you’re right. Even replacing erfc function by log_normcdf doesn’t work and here is the obtained error(code in previous reply): Error using cvxprob/newcnstr (line 192)
Disciplined convex programming error:
Invalid constraint: {real affine} >= {concave}
What do you think about this error? knowing that i don’t include any constraint yet.
Otherwise, Do you know any tools that i can use to optimize this kind problems.
Thank again,
You can try using YALMIP.