N=4;
Psat=0.02;
Psen=10^-7;
etan=0.8;
dpbn=[2 3 4 5];
dbbn=[1 1 1 1];
hn=dpbn.^-3;
fn=dbbn.^-3;
sig=10^-8;
Pbc=10^-3;
Psc=10^-4;
Rmin=0.02;
Es=2;
etaE=0;
for j=1:1:2
cvx_begin
variables barp(N) tilp(N) t(N)
expressions R(N) E(N) Esc(N) Ebr(N) Eps(N)
maximize sum(R)-etaE*sum(E)
subject to
for n=1:N
R(n)=-rel_entr(t(n),t(n)+barp(n)*hn(n)^2/sig);
for i=1:n-1
Esc(i)=t(i)*Psc;
end
E(n)=barp(n)+t(n)*Pbc+sum(Esc);
end
sum(t)<=1;
sum(barp)<=Es;
for n=1:N
for i=1:n-1
Ebr(i)=tilp(i)*etan*hn(i)*fn(n);
Eps(i)=barp(i)*etan*hn(n);
end
Eh(n)=(barp(n)-tilp(n))*etan*hn(n)+sum(Ebr)+sum(Eps);
end
for n=1:N
0<=tilp(n)<=barp(n);
R(n)>=Rmin;
for i=1:n-1
Esc(i)=t(i)*Psc;
end
Eh(n)>=t(n)*Pbc+sum(Esc);
end
cvx_end
etaE=sum(R)/sum(E);
optEE(j)=etaE;
end
You need to add Eh(N)
to the expressions
statement.
Thank you, I have fixed it. However, after I give 5 iterations, the result that appears is unchanged, what is the reason for this
I don’t know. I have no idea what you are doing in the grand scheme of things. Perhaps your overall “algorithm” has converged to something?
If you have some overall algorithm which invokes a sequence of CVX optimization problems, the performance of the algorithm is your responsibility, and is essentially out of scope of the forum.