How to write equality constraints with tolerance?

I’m working on a semidefinite programming (SDP) problem using CVX, but I’m running into issues with my equality constraint. Here’s my current code:

cvx_begin SDP
  variable R(D,D) semidefinite
  expression r(d_r, d_r)
  % other instructions
  r = PartialTrace(R, [N-1, N], DIM) / DIM(N-1);
  subject to PartialTrace(R, N, DIM) == kron(r, eye(DIM(N-1)));

The problem is that my results are coming out incorrect. I suspect this is due to rounding errors in floating-point arithmetic causing the equality constraint to be unsatisfiable.

What I want to do is implement this equality constraint with a small tolerance, say 10^-6. In other words, I want the constraint to be considered satisfied if the difference between the left and right sides is within ±10^-6.

Perhaps loosening up the equality constraint is not the best thing to do? But if you want to do that, you could change the equality constraint to twice the number of inequality constraints with desired buffers.

changed to
RHS - buffer_left <= LHS <= RHS + buffer_right

Or maybe you want the buffers to not be the same for the individual matrix elements?

As for your original formulation, is there (at most) only one feasible solution of the semidefinite constraint (given the PartialTrace constraint), and no interior (strictly positive definite) solution/? You could investigate by changing semidefinite constraint to R - min_eig*eye(D) == semidefinite(D) for some small positive value of min_eig, and see whether the problem is still feasible.

You could also try making buffers be nonnegative CVX variables, and minimizing their sum, and see what happens.

I presume you’re using QETLAB? So maybe @Nathaniel_Johnston can make a more informed assessment than me.

1 Like

norm(LHS((:)-RHS(:)) <= tolerance
in whatever norm you want (1, 2, inf, or any p >= 1)

Thank you for answering my question. I gained new insights from your response, and this particular issue is now resolved.
By the way, I actually found that the root cause of the original problem lies elsewhere, so I’m planning to start a new topic on that.