Sir,sorry, I didn’t make it clear.I’m very sorry to take up your time.
I run the diagnostic program you mentioned the other day, as follows.
For diagnostic purposes, replace
variable p(6);
variable m(6,6)
...
minimize(obj)
with
p = ones(6,1);
m = ones(6,6);
...
my_objective = obj
whos my_objective
I can run it and get an image with no data but coordinates.
警告: Empty cvx model; no action taken.
In cvx_end (line 22)
In ceshi2 (line 74)
However, running the original program later will still prompt me that there is no scalar. What could be the reason for this?
错误使用 cvx_end (line 267)
Your objective function is not a scalar.
出错 ceshi2 (line 74)
cvx_end
For the convenience of explanation, the original code is attached:
syms V;%非负控制参数
syms t;%时隙
n=0.9;%基站间传输能量的损耗率
G= 18;%
r=1000000;%用户设备传输速率,bit,1Mb/s
c=0.2;%冷却时间的约束,最多占时隙的百分比
d=200;%m,
q= 100;%噪声功率电平10DB的平方
for V=0:20:100
for t=0:1:5000
L=normrnd(0,5.8);%生成一个正态分布随机数
L=(6.14+20log10(200)+L)18;
if t==0 %冷却时间和能量队列的初始值
F=[0,0,0,0,0,0];
E=[0,0,0,0,0,0];
B=[0,0,0,0,0,0];
end
a= unifrnd(0,20,1,1);%dBm
b=unifrnd(20,40,1,1);%dBm
e =unifrnd (a,b,1,6);%dBm,
cvx_clear
cvx_begin
variable p(6) nonnegative;%非负
variable m(6,6) nonnegative;%非负
Obj = 0;
expression m1(6)
expression m2(6)
for j=1:6
for x=1:6
if x~=j
m1(j)=m1(j)+m(j,x);
end
end
for x=1:6
if x~=j
m2(j)=m2(j)+m(x,j);
end
end
F0=F(j);
E0=E(j);
B0=B(j);
e0=e(j);
p0=p(j);
Obj = Obj + (F0+V)(c/r)(3r-(log(1+(p0L)/300)/log(2))+3B0)+(E0+V)p0+E0e0+(V(1-n)-E0)m1+nE0m2;
end
minimize(Obj)
subject to
for j=1:1:6
for x=1:6
if x~=j
m1(j)=m1(j)+m(j,x);
end
end
for x=1:6
if x~=j
m2(j)=m2(j)+m(x,j);
end
end
p(j) <=E(j)+nm2(j)-m1(j);
end
cvx_end
E1=0;
F1=0;
m3=[0,0,0,0,0,0];
m4=[0,0,0,0,0,0];
for j=1:6
for x=1:6
if x~=j
m3(j)=m3(j)+m(j,x);
end
end
for x=1:6
if x~=j
m4(j)=m4(j)+m(x,j);
end
end
F(j)=F(j)+1-log2(3q+p(j)L)/(3r)-B(j)/r+log2(3q)/(3r)-c;
E(j)=E(j)-p(j)+e(j)-m3(j)+nm4(j) ;
B(j)=B(j)-r*(log2(3q+p(j)L)/(3r)+B(j)/r-log2(3q)/(3*r))+log2(1+p(j)L/q)/3;
E1=E1+E(j);
F1=F1+3F(j);
end
end
figure(1);
plot(V,E1);
figure(2);
plot(V,F1);