When I solve an optimization problem with an eigenvalue constraint, it gets two different results under the different position of function value().

26 views
Skip to first unread message

风清扬

unread,
Nov 7, 2018, 9:27:44 AM11/7/18
to YALMIP
Dear Pro. Johan Lofberg
When I solve an optimization problem ,I meet a question.
The code of my optimization problem is:
%%%%%%%%%%%%%%
A = sdpvar(3,3,'full');
B = [1 0 0;0 1 1; 1 1 1];
cons = [max(abs(eig(A-B)))<=0.8];   %constrains
obj = trace((A - B)' * (A - B));  %objetive
solvesdp(cons,obj)            %solve
A_v = value(A);
type1 = eig(A_v-B)
type2 = value(eig(A-B))
%%%%%%%%%%%%%
the results of two variables are:

type1 =
   0.4158 + 2.2437i
   0.4158 - 2.2437i
   0.2080 + 0.0000i
type2 =
   -0.5604
    0.8000
    0.8000
%%%%%%%%%%%%%
But as far as I know, type1 should equal to type2. Why there are two different results? If it is wrong of my code, how to use yalmip to represent eigenvalue constraints?

Sincerely yours,

Johan Löfberg

unread,
Nov 7, 2018, 10:08:49 AM11/7/18
to YALMIP
don't use the eig operator. it is an experimental hack which really isn't supposed to be used (as it doesn't work). You will have to come up with a semidefinite representation (which looks impossible as you optimize over unsymmetric matrices)

song yang

unread,
Nov 7, 2018, 7:48:26 PM11/7/18
to YALMIP
It means that the eig operator is no use even though the solver gives a result. Is there only one solution to such an optimization problem which has eigenvalue constraint ?
If so, when (A-B) is symmetric in my code, how can I solve it? The norm-2 operator is ok?
thank you!

Johan Löfberg

unread,
Nov 8, 2018, 1:48:38 AM11/8/18
to YALMIP
For symmetric, you would simply write -0.8*I <= A-B <= 0.8*I

The quadratic objective is fine, although it is unnecessarily complicated for large problems to create the product (symbolic O(n^3) operation) and then take the trace. Either simply use norm(A-B,'fro')  or vectorize E = A-B;obj = E(:)'*E(:).

song yang

unread,
Nov 8, 2018, 2:40:50 AM11/8/18
to YALMIP
OK, thank you!
Reply all
Reply to author
Forward
0 new messages