Hello, I want to create a diagonal matrix, the value of his diagonal is 1 or 0, and he is the variable of the optimization problem, how can I express or. I want to write in constraint: lambda(:,:)==1|0. But this is not allowed
Both of the following construct diagonal_matrix
as an expression, and don’t use constraints.
If you want all ones or all zeros
variable b binary
diagonal_matrix = b*eye(n);
If you want to allow an arbitrary mixture of ones and zeros
variable b(n) binary
diagonal_matrix = diag(b);
Thanks a lot for your answer.
I still have a question, the SDPT3_solver that comes with cvx cannot solve the binary, can I solve it by installing MOSEK_solver?
Mosek or Gurobi can be used (unless it’s a Binary SDP, in which case neither can be used)