Constraints not satisfied even though problem successfully solved

23 views
Skip to first unread message

Hossein Ghafarian

unread,
Jan 11, 2016, 9:36:46 AM1/11/16
to YALMIP
Dear Dr Johan,
I write the following problem using YALMIP(mosek) and the solver reports it is solved and it is near optimal. But some of the constraints not satisfied. A minimal problem is 
%%%%
initL=[1,2];
n=4;
c=10;
n_l=2;
n_u=2;
n_Vt=2;
nap=6;
dSize=1;

V     =sdpvar(nap+1,nap+1);
Vt=sdpvar(n_u,1);
r=sdpvar(n_u,1);
beta_p=sdpvar(nap,1);
eta_p =sdpvar(nap,1);
t     =sdpvar(1,1);

setall   =1:n;
setunlab =setdiff(setall,initL);
setVtuery =n+1:nap;

y_l     =[-1;1];

KVMatrix     = sdpvar(nap+1,nap+1);
s=sdpvar(nap,1);

KVt= [1     ,0.5794,0.7166,0.8211,0.7166,0.8211;...
     0.5794,1     ,0.8084,0.7057,0.8084,0.7057;...
     0.7166,0.8084,1     ,0.8727,1     ,0.8727;...
     0.8211,0.7057,0.8727,1     ,0.8727,1     ;...
     0.7166,0.8084,1     ,0.8727,1     ,0.872 ;...
     0.8211,0.7057,0.8727,1     ,0.8727,1     ];
 KVt=(KVt+KVt')/2;%force symmetry
KVMatrix = [KVt.*V(1:nap,1:nap) ,1-s+eta_p-beta_p;(1-s+eta_p-beta_p)',2*t];
cObjective = t+sum(beta_p)+sum(eta_p(n+1:nap))+c*sum(r);

cConstraint=[beta_p>=0,eta_p>=0,V>=0,KVMatrix>=0];
cConstriant=[cConstraint,sum(Vt)==dSize,0<=Vt,Vt<=1];
cConstraint=[cConstraint,V(nap+1,nap+1)==1,diag(V(1:nap,1:nap))<=1,V(initL,nap+1)==y_l];
cConstraint=[cConstraint,r>=V(n_l+1:n,nap+1),r>=-V(n_l+1:n,nap+1),r+Vt==1];
cConstraint=[cConstraint,V(n+1:nap,nap+1)==Vt,s==zeros(nap,1),s(setunlab)==Vt];

sol = optimize(cConstraint,cObjective);
if sol.problem==0
    info.primal=true;
    info.Vprimal     = value(V);
    info.primalVt     = value(Vt);
    beta_pr  = value(beta_p);
    eta_pr   = value(eta_p);
    info.r=value(r);
    info.s=value(s);
end
sum(value(Vt))==dSize % this constraint is not satisfied.
%%%%
I don't know why, and what I have to do in order to make it correct. I checked constraints using checkset, it has a slight infeasibility,-1e^-9. 
Thank you very much. 

Johan Löfberg

unread,
Jan 11, 2016, 9:48:58 AM1/11/16
to YALMIP
See any difference on the left-hand side?

Hossein Ghafarian

unread,
Jan 11, 2016, 9:56:35 AM1/11/16
to YALMIP
Dear Johan, 
Thank you very much. you are excellent.
Reply all
Reply to author
Forward
0 new messages