yalmip / YALMIP

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

Dualize: Error using |, operands must be real #1171

Closed johanlofberg closed 1 year ago

johanlofberg commented 2 years ago

Discussed in https://github.com/yalmip/YALMIP/discussions/1169

Originally posted by **alastair-abbott** August 17, 2022 Hi, Yalmip has been crashing on some relatively large SDP problems I have when dualize is set to 1 (for smaller problems of this type I have found faster convergence using scs-direct with this option, which is why I'm using it here). I get the error: ``` Error using | Operands must be real. Error in dualize>detect_diagonal_terms (line 875) candidates = find((B(:,1) == 0) & (sum(B | B,2) == 1) & (sum(B,2) == 1)); Error in dualize (line 175) implicit_positive = detect_diagonal_terms(F); ``` On closer inspection, we can see the issue is that B has an epsilon imaginary part: ``` K>> imag(B) ans = 1.0e-17 * (1,1) 0.3578 (128,1) 0.3578 ``` Can we generically remove the imaginary part of B, or use a more robust way of converting it to a logical here?