I am not able to solve this

(Deeptanu Datta) #1

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=Bsum(alph.log2(1+(g.pwr/(sigma^2+(gspow)))));
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 quiet
variable alph(length(term))
variable pwr(length(term))
d = Bsum(alph(log(1+(gpwr/(sigma^2)+gspow)))/log2);
e=(zetasum(pwr))+Pc-etasum(pwr)(sum(g.(1-alph)));
maximize d-q(i)e;
%maximize (B
sum(alph.(log(1+(g.pwr/(sigma^2)+gspow)))/log2))-q((zetasum(pwr))+Pc-etasum(1-alph).gsum(pwr));

        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);
        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

(Mark L. Stone) #2

Do not use quiet mode until everything is running properly. Re-run the problem without quiet. What specifically happens when you run it? Your problem is not reproducible (for instance, what is channel).

Given use of log, I recommend you follow the advice in CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions .

(Deeptanu Datta) #3

d = B sum(alph (log(1+(g pwr/(sigma^2)+g spow)))/log2);

I have modified this line as
d = Bsum(alph(-entr(1+(gpwr/(sigma^2)+gspow)))./(1+(gpwr/(sigma^2)+gspow)));

Because as per CVX Manual
entropy of x, given by x.*log(x) is written in cvx as entr(x)

But, as I need only log(x),so I have used -entr(x)./x

Now, I am getting the error
Disciplined convex programming error:
Cannot perform the operation {affine}*{convex}

(Deeptanu Datta) #4

Anyway after removing the quiet mode also, I am getting the same error

(Deeptanu Datta) #5

channel is another function Definition. In this program, I have just called it, feeding x as input

(Mark L. Stone) #6

Replace
log(cvx_expression)
with
-rel_entr(1,cvx_expresion)

But that won’t do you any good unless you install CVXQUAD and its exponential.m replacement, following the directions in CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions

(Deeptanu Datta) #7

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

(Deeptanu Datta) #8

When I am running the exponential.m file the following error is coming

Undefined function or variable ‘op_rel_entr_epi_cone’.

Error in exponential (line 46)
op_rel_entr_epi_cone([1 1 sx],0,m,k);

I opened this function in MATLAB, run it. I got the error

Error using op_rel_entr_epi_cone (line 48)
Wrong number of arguments

Again I run the exponential.m file, now the following error is coming

Error using cvx_end (line 140)
Internal cvx data corruption.
Error in exponential (line 47)
cvx_end

I then opened the cvx_end file and run it, I got the following error

Error using cvx_end (line 13)
No CVX model exists in this scope.

What to do now?

(Mark L. Stone) #9

Try starting a fresh MATLAB session. Perhaps there is a conflict due to having previously used the original CVX version of exponential.m in the same session in which you later try to use the CVXQUAD version.

Please be sure you are using CVX 2.1, not CVX3.0beta. Deinstall 3.0beta and install CVX2.1 if necessary.

If that doesn’t solve your difficulty, you can try opening an issue at https://github.com/hfawzi/cvxquad/issues where the CVXQUAD developer can help you.