What the problem about my model or code?


(Qiang Tang) #1

function CVXOptimization()
clc;

m=2;n=5;
al = 1/(n*n); bl = 1/n; cl = 0;
mev = 2.0; r = 300; plast = 2.0; belta = 0.02;

x=zeros(1,2*(1+m+n*m))’;

Npile=1 + round(2*rand(1,m));
e=n/sum(Npile)*0.1;

A=zeros(2+3m-1,2(1+m+nm));
b=zeros(1,2+3
m-1)’;

A(1,2)=-1;
b(1)=0;
for col=3+m:1:3+2*m-1
A(1,col)=1;
end

for col=1:1:m
A(2+col-1,1)=1;
A(2+col-1,2+col)=-1;
b(1+col)=0;
end

for row=1:1:m
for node=1:1:n
A(row+m+1,(row-1)+(node-1)m+3+2m+n*m)=1/Npile(row);
end
b(row+m+1)=e+n/sum(Npile);
end

for row=1:1:m
for node=1:1:n
A(row+2m+1,(row-1)+(node-1)m+3+2m+nm)=-1/Npile(row);
end
b(row+2*m+1)=e-n/sum(Npile);
end

Aeq=zeros(n,2*(1+m+nm));
beq=zeros(1,n)’;
for row=1:1:n
for col=1:1:m
Aeq(row,3+2
m+n*m+(row-1)*m+col-1)=1;
end
beq(row)=1;
end

maxXIJ=5+45rand(1,n);
minXIJ=zeros(1,n);
for i=1:1:n
minXIJ(i)=maxXIJ(i)rand(1);
end
maxXIJC=zeros(1,n
m)’;
minXIJC=zeros(1,n
m)’;

for i=1:1:n
for j=1:1:m
maxXIJC((i-1)*m+j)=maxXIJ(i);
minXIJC((i-1)*m+j)=minXIJ(i);
end
end

mk=2.0;
r=15.0;
pl=2.0;
belta=0.02;

Xev=50rand(n);
Yev=50
rand(n);
Xcs=50rand(m);
Ycs=50
rand(m);

D=zeros(1,n*m);
for i=1:1:n
for j=1:1:m
dij=sqrt( (Xev(i)-Xcs(j))^2 + (Yev(i)-Ycs(j))^2 );
D((i-1)*m+j)=dij;
end
end

cvx_begin
expressions X(2*(1+m+nm))
expressions XIJ AIJ SIJ(n) C(m);
f1=X(1)sum(X(3+m:3+2m-1))-(al
X(2)^2+blX(2)+cl);
XIJ=X(3+2
m:3+2m+nm-1);
AIJ=X(3+2m+nm:3+2m+nm+n*m-1);
f2=0.0;
for j=1:1:m
for i=1:1:n
f2=f2+X(3+j-1)*AIJ((i-1)*m+j)*XIJ((i-1)*m+j);
end
f2=f2-X(1)*X(3+m+j-1);
end

f3=0.0;
for i=1:1:n 
    for j=1:1:m 
        f3=f3+AIJ((i-1)*m+j)*((mk)*r*log(XIJ((i-1)*m+j)+1)-x(3+j-1)*XIJ((i-1)*m+j)-pl*D((i-1)*m+j)*belta);
    end
end
f=-(f1+f2+f3);

Lcs=X(3+m:3+2*m-1);
for j=1:1:m
    for i=1:1:n
        SIJ(i)=AIJ((i-1)*m+j)*XIJ((i-1)*m+j);
    end
    C(j)=sum(SIJ)-Lcs(j);
end


minimize(X(1))
subject to
A*X<=b 
Aeq*X==beq 

minXIJC<=XIJ<=maxXIJC 
X(1)>=0
zeros(1,n*m)'<=X(3+2*m+n*m:3+2*m+n*m+n*m-1)<=ones(1,n*m)'
C<=zeros(1,m)'

cvx_end

Output:
Calling SDPT3 4.0: 6 variables, 0 equality constraints
For improved efficiency, SDPT3 is solving the dual problem.

num. of constraints = 1
dim. of linear var = 6
dim. of free var = 1 *** convert ublk to lblk


SDPT3: Infeasible path-following algorithms


version predcorr gam expon scale_data
NT 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap prim-obj dual-obj cputime

0|0.000|0.000|4.5e+00|3.0e+00|6.3e+02| 2.199629e+01 0.000000e+00| 0:0:00| chol 1 1
1|1.000|0.676|1.6e-06|1.0e+00|1.5e+02|-7.509120e+01 -6.031389e+00| 0:0:00| chol 1 1
2|1.000|0.072|5.4e-08|9.4e-01|3.3e+02|-1.478805e+04 -6.622733e+00| 0:0:00| chol 1 1
3|1.000|0.007|7.3e-08|9.5e-01|1.9e+05|-2.315411e+08 -6.871582e+00| 0:0:00| chol 1 1
4|1.000|0.001|1.6e-05|9.7e-01|2.9e+10|-3.641513e+14 -2.351271e+01| 0:0:00| chol 1 1
stop: primal infeas has deteriorated too much, 2.8e-02
5|1.000|0.000|1.6e-05|9.7e-01|2.9e+10|-3.641513e+14 -2.351271e+01| 0:0:00|
prim_inf,dual_inf,relgap = 1.59e-05, 9.68e-01, 7.97e-05
sqlp stop: dual problem is suspected of being infeasible

number of iterations = 5
residual of dual infeasibility
certificate X = 6.76e-05
reldist to infeas. <= 2.95e-04
Total CPU time (secs) = 0.07
CPU time per iteration = 0.01
termination code = 2
DIMACS: 5.4e-08 0.0e+00 1.2e+00 0.0e+00 -1.0e+00 2.2e-02


Status: Infeasible
Optimal value (cvx_optval): +Inf

I really don’t know why this happened. Please help me, thanks.


(Mark L. Stone) #2

Your problem has been determined to be infeasible.

Do you believe your problem really is feasible? if so, can you produce a feasible solution and show that it satisfies all the constraints? If not, you need to diagnose which constraint(s) are causing infeasibility.

EDIT: See my next post, which supersedes the first sentence of this post.


(Qiang Tang) #3

Yes, I can provide a solution that satisfies all the constraints. And I have used the MATLAB function fmincon, which need a initial value x0, and we have set a feasible solution.


(Mark L. Stone) #4

You need to declare (at least) X as a CVX variable, not an expression.

I was able to reproduce an infeasible result with the following “incorrect” CVX problem:

cvx_begin
expression X
minimize(X)
X >= 1
cvx_end

If variable X is used instead of expression X, X = 1 is found as the optimal value.

However, you still need to follow the CVX DCP rules, and your program does not. f1 is in violation of the rules, as are some other statements. I will presume your problem is non-convex, unless you can show otherwise. Of course, FMINCON will “accept” problems whether or not they are convex.


(Qiang Tang) #5

Thank you very much, I’ll try that.