yalmip / YALMIP

MATLAB toolbox for optimization modeling
https://yalmip.github.io/
Other
478 stars 137 forks source link

Dual variables are complex conjugated #1375

Closed araujoms closed 4 months ago

araujoms commented 7 months ago

When I ask YALMIP to give me the dual variables, it gives me instead their complex conjugate. Below is a MWE with an SDP for calculating the least eigenvalue:

function test_duality(d)
    x = randn(d,d) + 1i*randn(d,d);
    x = x + x';
    lambda = sdpvar;
    constraints = [(x + lambda*eye(d) >= 0):'PPT'];
    ops = sdpsettings(sdpsettings,'verbose',1,'solver','sedumi');
    optimize(constraints,lambda,ops)
    lambda = value(lambda);
    W = dual(constraints('PPT'));
    trace(W*x) %wrong answer
    trace(W.'*x) %right answer
end
johanlofberg commented 7 months ago

Hmm, I'll have a look

araujoms commented 7 months ago

I've investigated a bit, and it seems that YALMIP reports correctly the dual variable that is returned by SeDuMi; it is when YALMIP is reading user input and sending it to SeDuMi in the first place that the complex conjugation must be happening.