My fault,i forgot that cvx_oma.。and my cvx version is 2.1
Now I picked a specific set of numbers. It should be reproducible now…and it is still different between cvx_optimal and the “recompute”.
Then i set all of them as 1 , it works cvx_optimal and “recompute” are equal…Actually,just set all the numbers which has e in it,in this case ,is “t”,“z” and "h"
but i don’t get it,Is z = 5.9700e-12 a semi-random expression or something?How do I deal with these numbers.
And I get some parameters from other functions,need i reform them?
n=2;
t=10e-4;
w=15000000;
z=5.9700e-12;
pnomamax=250;
speedr=500/15000;
% r=[0.00559072788641364,0.994409272111680];
% h=[1.46497117115015e-12,3.01110743301851e-12];
r=[0.5,0.5];
h=[1.5e-12,3e-12];
% t=1;
% w=1;
% z=1;
% h=[1,1];
% r=[1,1];
p1=250;p2=250;
h1=h(1,1);h2=h(1,2);
r1=r(1,1); r2=r(1,2);%parameters
cvx_begin
cvx_solver sedumi
variable px(1,2)
rate1=log(1+px(1,1)*h1/z)/log(2);
rate2=log((px(1,1)+px(1,2))*h2+z)/log(2);
rate=rate1+rate2-( log(p1*h2+z)/log(2)+ [h2/((p1*h2+z)*log(2)),0] *( [px(1,1),px(1,2)] -[p1,p2] )' );
ratest=rate2-( log(p1*h2+z)/log(2)+ [h2/((p1*h2+z)*log(2)),0] *( [px(1,1),px(1,2)] -[p1,p2] )' );
c=(r1+r2)*t*w*rate;
compute=(r1+r2)*t*w*( log(1+px(1,1)*h1/z)/log(2) + log((px(1,1)+px(1,2))*h2+z)/log(2) -( log(p1*h2+z)/log(2)+ [h2/((p1*h2+z)*log(2)),0] *( [px(1,1),px(1,2)] -[p1,p2] )' ));
maximize (compute)
subject to
px(:)<=pnomamax
rate1>=speedr
ratest>=speedr
px(:)>=0
cvx_end
recompute=(r1+r2)*t*w*( log(1+px(1,1)*h1/z)/log(2) + log((px(1,1)+px(1,2))*h2+z)/log(2) -( log(p1*h2+z)/log(2)+ [h2/((p1*h2+z)*log(2)),0] *( [px(1,1),px(1,2)] -[p1,p2] )' ));