The model is non-convex. Please re-read and carefully think about the link in my previous post.
Either change your model to a convex problem or use a tool which can handle non-convex problems.
The model is non-convex. Please re-read and carefully think about the link in my previous post.
Either change your model to a convex problem or use a tool which can handle non-convex problems.
clc
clear all;
close all;
B=10^6;eta=0.1;Pc=5;zeta = 0.38;
M=1;N=7;sigma = 0.031622;ee=[];
spow=0;Pmax=20;Rmin=2*(10^6);Emin=0.2;
term =[1:N]; ep=10^(-6);%Epsilon
x=rand(N,M);itr=10;
h=channel(x);ee1=[];ee2=[];ee3=[];
g=(abs(h)).^2;deep=[];
alph = linspace(0,1,N);
pwr = linspace(1,Pmax,N);
l=length(alph);
%__Interfering Users
k=input('Enter the index from which interference users start 1 to 7 : ');
for j = k+1 : length(term)
spow=spow+pwr(j);
end
%__Interfering Users
Ur=B*sum(alph.*log2(1+(g.*pwr/(sigma^2+(g*spow)))));
Ut=(zeta*sum(pwr))+Pc-eta*sum(pwr)*sum(g.*(1-alph));
q=Ur/Ut;
for i=1:itr
%for f=1:l
q(1) = 0;
cvx_begin
variable alph(length(term))
variable pwr(length(term))
%d = B*sum(alph*(-entr(1+(g*pwr/(sigma^2)+g*spow)))./(1+(g*pwr/(sigma^2)+g*spow)));%Express in DCP Ruleset form
d=B*(-rel_entr(1,(1+(g*pwr/(sigma^2)+g*spow))));
expression e=(zeta*sum(pwr))+Pc-eta*sum(pwr)*(sum(g*(1-alph)));
maximize d-q(i)*e;
subject to
sum(pwr)<=Pmax;
eta*(1-alph).*g*sum(pwr)>= Emin;
alph.*B*log2(1+(g.*pwr/(sigma^2)+g*spow))>=Rmin;
%0<=alph(f)<=1;
%pwr(f)>=0;
cvx_end
Ur(pwr) = B*sum(alph*(log(1+(g*pwr/(sigma^2)+g*spow)))/log2);%Express in DCP Ruleset form
Ut(pow) = (zeta*sum(pwr))+Pc-eta*sum(pwr)*(sum(g.*(1-alph)));
q(i) = Ur(pwr)/Ut(pow);
if Ur(pwr)-q(i)*Ut(pow)<=ep
fprintf('Optimal Power Allocation is');
disp(pwr);
end
%end
end
Here, as per the paper, the objective function is given to be concave and this problem is a convex maximization problem
You havenāt provided the channel function.
As I wrote before, donāt use
expression e = ...
just use
e = ....
And the right-hand-side of e = ...
is still non-convex (error message āInvalid quadratic form(s): not a square`.ā
So if indeed you have a convex optimization problem, then reformulation is required. But you havenāt shown us the paper, and we donāt really know what problem you are trying to solve.
Thatās what I am telling, if I remove the keyword expression the following error is coming -
Bdw this is the link for the paper. Here, I am trying to implement the algorithm given in TABLE I through CVX
https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8636993
OR
I believe that alph
should not be declared as a (CVX) variable within CVX. Rather, let CVX uses the value of alph
which was set in MATLAB prior to CXV being invoked.
Also, log2
can not be applied to a CVX expression. Use log
instead (or really, convert to rel_entr
to use CVXQUAD) by dividing by log(2).
After doing this, CVX will accept the problem. I am not saying however that the resulting program is correct. But it would be a convex optimization problem which CVX would accept and submit to the solver.
I have tried by removing the declaration of alph and pwr inside CVX. But still the same error is coming in this line -
expression e=(zetasum(pwr))+Pc-etasum(pwr)(g*(1-alph));*
The error coming is -
Error using expression (line 39)
Invalid variable specification: e=(zetasum(pwr))+Pc-etasum(pwr)(g(1-alph))
Error in swipt1 (line 32)
expression e=(zetasum(pwr))+Pc-etasum(pwr)(g(1-alph));
As I have been telling you, use
e=(zeta*sum(pwr))+Pc-eta*sum(pwr)*(sum(g*(1-alph)));
not
expression e=(zeta*sum(pwr))+Pc-eta*sum(pwr)*(sum(g*(1-alph)));
Thanks for your suggestion.
according to your suggestion, there exist some problem as following,
Error using .* (line 262)
Disciplined convex programming error:
Invalid quadratic form(s): not a square.
Error in * (line 36)
z = feval( oper, x, y );
Error in cvxTest (line 31)
e=(zetasum(pwr))+Pc-etasum(pwr)(sum(g(1-alph)));
do you have the further suggestion? Thanks
Please read my previous posts regarding non-convexity, or not declaring all variables as CVX variables in order to make it convex.