Yalmip does not give acceptable answers

118 views
Skip to first unread message

malihe karbasian

unread,
Aug 24, 2013, 12:43:18 PM8/24/13
to yal...@googlegroups.com
Hi every on

I am trying to solve a linear optimization problem by Yalmip

my problem is :
% constraints---
%           min d
%           s.t
%      [dI             | CiXi-UiCi;
%      XiCi'-Ci'Ui'   |       dI]>=0
    
%     [Ji | BiWi+XiCi'|  XiF1i'+Ci'Vi'F2i' | MXi     | 0;
%      *  | L(i,i)Yi     |  Wi'F2i'              | 0        | MYi;
%      *  | *             |  -aiI                   | 0        | 0;
%      *  | *             |  *                      | NXi     | 0;
%      *  | *             |  *                      | *        | NYi]<0

% where Ai,Bi,Ci,Ei,F1i,F2i,L are set as mode parameters for i-1 and i=2
%   and  Xi,Yi,Ui,Vi,Wi are variables
%   and other matrices are defined in my code which is attached

I know that answers are small numbers, but Yalmip give responses in the order of 10^7
I change the solvers, also sedumi precision (epsilon), response becomes smaller but yet too far from the answers

can anybody help me with that? what is wrong with my codes? should i change my solver?
I am new to Yalmip  so I have attached my problem definition and also my Codes

thanks thanks thanks
Problem definition.png
Codes.m

Johan Löfberg

unread,
Aug 24, 2013, 2:18:57 PM8/24/13
to yal...@googlegroups.com
Looks like an badly posed problem (note that the optimal objective tends to 0, and essentially all variables go to zero in the optima too). You can see this clearly by the fact that the following problem is feasible

solution=solvesdp([F,X1==0,X2==0,Y1==0,Y2==0,U1==0,U2==0,W1==0,U2==0],d,ops)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|    ID|      Constraint|                     Type|   Primal residual|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|    #1|   Numeric value|        Matrix inequality|       -1.8472e-15|
|    #2|   Numeric value|        Matrix inequality|       -2.5204e-15|
|    #3|   Numeric value|        Matrix inequality|        5.0144e-15|
|    #4|   Numeric value|        Matrix inequality|        5.0599e-15|
|    #5|   Numeric value|        Matrix inequality|       -1.1589e-15|
|    #6|   Numeric value|        Matrix inequality|       -1.8401e-15|
|    #7|   Numeric value|        Matrix inequality|        9.4342e-17|
|    #8|   Numeric value|        Matrix inequality|        1.2199e-16|
|    #9|   Numeric value|   Elementwise inequality|       -9.6474e-17|
|   #10|   Numeric value|   Elementwise inequality|       -3.6091e-17|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

BTW, in the code it looks like you are trying to work with strict inequalities. This is not really possible.
http://users.isy.liu.se/johanl/yalmip/pmwiki.php?n=Blog.Prepare-your-code

malihe karbasian

unread,
Aug 25, 2013, 4:51:48 AM8/25/13
to yal...@googlegroups.com
Dear Mr Lofberg

thanks for your kindly answer
in fact I have changed the equality of the form CiXi=UiCi to the following inequality and optimization problem,


% constraints---
%           min d
%           s.t
%      [dI             | CiXi-UiCi;
%      XiCi'-Ci'Ui'   |       dI]>=0

is it possibale to use YAlMIP to solve the following two constraints, one equality and one inequality?

%     CiXi==UiCi
    
%     [Ji | BiWi+XiCi'|  XiF1i'+Ci'Vi'F2i' | MXi     | 0;
%      *  | L(i,i)Yi     |  Wi'F2i'              | 0        | MYi;
%      *  | *             |  -aiI                   | 0        | 0;
%      *  | *             |  *                      | NXi     | 0;
%      *  | *             |  *                      | *        | NYi]<0

I have tried this one two, but the same problem exists.
would you please help me solving these?

by not using strict inequalities, do you mean that I should change >,< to =>, <=?

Johan Löfberg

unread,
Aug 25, 2013, 6:15:59 AM8/25/13
to
Of course, if you have a linear inequality you should write it as a linear inequality. 

If you have a strict inequality, you simply replace it with a suitably strict. X>0 means, to you X>=eye(n)*somenumber, and it is up to you to decide that number. Too small, and the strictness will drown in the overall numerical tolrances of the solver, and too large might lead to a substantially different solution, or even an infeasible problem.

However, the problem still seems horribly ill-conditioned. 

Consider the following version (with the equalities above) where we try to recover "nice" solutions by trying to get P1 and P2 as you report

obj = norm([-4.9311 2.19;9.0843 6.5243]*U1-V1)+norm([1.4530 1.2455;-0.5835 0.3357]*U2-V2)
solution
=solvesdp([F],obj,sdpsettings('solver','sedumi'))


OK values on the once we tried to recover
>> double(V1)*inv(double(U1))

ans =

   -4.9316    2.1915
    9.0840    6.5271

>> double(V2)*inv(double(U2))

ans =

    1.4530    1.2455
   -0.5835    0.3357


but the other once tend to infinity
>> double(W1)*inv(double(Y1))

ans =

   1.0e+08 *

   -1.8626    4.0610
    0.7629    2.2752

>> double(W2)*inv(double(Y2))

ans =

   1.0e+09 *

    0.7100    1.0352
   -0.2578    0.5424


also note that we have some negative residuals here with sedumi
>> checkset(F)
 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|    ID|      Constraint|                     Type|   Primal residual|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|    #1|   Numeric value|        Matrix inequality|       -4.1274e-10|
|    #2|   Numeric value|        Matrix inequality|       -1.0626e-09|
|    #3|   Numeric value|      Equality constraint|       -5.3538e-14|
|    #4|   Numeric value|      Equality constraint|       -4.8815e-15|
|    #5|   Numeric value|        Matrix inequality|           0.36725|
|    #6|   Numeric value|        Matrix inequality|           0.83513|
|    #7|   Numeric value|        Matrix inequality|        7.0844e-10|
|    #8|   Numeric value|        Matrix inequality|        5.0414e-10|
|    #9|   Numeric value|   Elementwise inequality|         0.0028111|
|   #10|   Numeric value|   Elementwise inequality|          0.035669|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

which indicates that the residuals are in the same order (and even infeasible) as the variables of interest (i.e. the variables essentially drowns in the numerical tolerance)


>> double(Y1)

ans =

   1.0e-08 *

    0.1099   -0.0038
   -0.0038    0.0712

Now try were we try to get everything as the numbers you report
obj = norm([-4.9311 2.19;9.0843 6.5243]*U1-V1)+norm([1.4530 1.2455;-0.5835 0.3357]*U2-V2)
obj = obj + norm([-0.1797 0.2152;0.0641 0.1020]*Y1-W1)+norm([0.1030 0.0048;-0.1531 0.1479]*Y2-W2)


The optimal objective is 0.6, so when linearized the discreprancy as we have done in the objective, we are pretty close. However, the two last items are still long from the reported once. The problem is simply extremely ill-conditioned 
solvesdp(F,obj)

>> double(V1)*inv(double(U1))

ans =

   -4.9434    2.2432
    9.0671    6.6701

>> double(V2)*inv(double(U2))

ans =

    1.4530    1.2455
   -0.5835    0.3357

>> double(W1)*inv(double(Y1))

ans =

   1.0e+08 *

   -1.2400    2.7879
    0.5025    1.6349

>> double(W2)*inv(double(Y2))

ans =

   1.0e+09 *

    0.5717    1.0999
   -0.2261    0.7445




My guess: There is no strictly feasible solution to the problem, or if there is, it constitutes an extremely small ill-conditioned region
Reply all
Reply to author
Forward
0 new messages