# * why the **constraints** are not met (very often when H is very small, i.e. 10^-3 and lam>10) but the cvx status is 'Solved'?

Hi everyone, this is my first using CVX, after reading users’ guide, I try to use this tool to solve a simple SDP problem.

AND the problem is** why the constraints are not met (very often when H is very small, i.e. 10^-3 and lam>10) but the cvx status is ‘Solved’?

Here is my entire code as follow
**

## %%matlab code

**
gama=exp(10log(10)/10);
N0=10^(-176/10)/1000;%-176dBm
num=1e0;
lam =[10];
results = zeros(1, length(lam));
tic
for k=1:length(lam)
for i=1:num
%% channel
H=(randn(2,2)+1j
randn(2,2)); // H is complex
H1=H(1:end,1)*H(1:end,1)’; // H1 is semidefinte
H2=H(1:end,2)*H(1:end,2)’;

cvx_begin sdp
variable W1(2,2) hermitian
variable W2(2,2) hermitian

P=trace(W1)+trace(W2);

minimize lam(k)*P

subject to
real(trace(W1*H1))>=real((trace(W2*H1)+N0))*gama;
real(trace(W2*H2))>=real((trace(W1*H2)+N0))*gama;
W1>=0; // W1 is semidefinte
W2>=0;
cvx_end
results(k) = results(k) + cvx_optval/num;
end

end
toc
%%
disp(‘results=’)
disp(10log10(results1000))

real(trace(W1H1))>=real((trace(W2H1)+N0))gama %% FALSE very often
real(trace(W2
H2))>=real((trace(W1*H2)+N0))*gama%% FALSE very often

**

**

## Calling SDPT3 4.0: 10 variables, 2 equality constraints

num. of constraints = 2
dim. of socp var = 8, num. of socp blk = 2
dim. of linear var = 2

SDPT3: Infeasible path-following algorithms

## number of iterations = 14 primal objective value = 3.21696630e-09 dual objective value = 3.56631804e-19 gap := trace(XZ) = 8.68e-09 relative gap = 8.68e-09 actual relative gap = 3.22e-09 rel. primal infeas (scaled problem) = 5.52e-10 rel. dual " " " = 2.36e-10 rel. primal infeas (unscaled problem) = 0.00e+00 rel. dual " " " = 0.00e+00 norm(X), norm(y), norm(Z) = 4.4e-10, 1.0e+01, 4.0e+02 norm(A), norm(b), norm© = 6.2e+01, 1.0e+00, 2.9e+01 Total CPU time (secs) = 0.27 CPU time per iteration = 0.02 termination code = 0 DIMACS: 5.5e-10 0.0e+00 3.3e-10 0.0e+00 3.2e-09 8.7e-09

Status: Solved
Optimal value (cvx_optval): +3.21697e-09

Elapsed time is 0.899835 seconds.
results=
-54.9255

ans =

0

ans =

0

I just ran the code with SeDuMi, and the constraints “failed” by no more than 1e-14, which is well within allowed numerical tolerance. You are only checking for exact constraint compliance, but not allowing for numerical tolerance. If you re-read the CVX User’s Guide, you should see some discussion about this.

Many thanks for your kindly reply! I read once again the Guide’s section 8.5 Controlling precision and found ‘cvx_precision’ that can be used to adjust the numerical tolerances. SO, I refine the code as following:

cvx_solver sedumi
cvx_precision best
%% channel
H=randn(2,2)1e-7%+1jrandn(2,2);
H1=H(1:end,1)*H(1:end,1)’;
H2=H(1:end,2)*H(1:end,2)’;

cvx_begin sdp
.........%% same as before
cvx_end

BUT, still, I found the constraints not been met but problem was solved. I am confused how should I control the tolerances. And the 'cvx_slvtol ’ seemed to change every time, can you help me to understand this variable? Thank you for your help!

## Calling SeDuMi 1.34: 10 variables, 2 equality constraints

SeDuMi 1.34 (beta) by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 2, order n = 7, dim = 11, blocks = 3
nnz(A) = 18 + 0, nnz(ADA) = 4, nnz(L) = 3
it : by gap delta rate t/tP t/tD* feas cg cg prec
0 : 1.13E+03 0.000
1 : 2.40E-21 9.65E+01 0.000 0.0857 0.9900 0.9900 1.67 1 1 9.3E+00
2 : 6.07E-21 2.00E+01 0.000 0.2072 0.9000 0.9000 1.06 1 1 2.4E+00
3 : 7.53E-21 7.62E-01 0.000 0.0381 0.9900 0.9900 0.97 1 1 7.5E-01
4 : 7.56E-21 7.49E-05 0.000 0.0001 1.0000 1.0000 1.00 1 1 2.2E-04
5 : 7.56E-21 7.67E-12 0.000 0.0000 1.0000 1.0000 1.00 1 1 2.3E-11

iter seconds digits cx by
5 0.1 8.7 3.2738852695e-14 7.5638892446e-21
|Ax-b| = 3.3e-13, [Ay-c]_+ = 0.0E+00, |x|= 3.7e-13, |y|= 2.6e-01

## Detailed timing (sec) Pre IPM Post 8.600E-02 1.220E-01 2.200E-02 Max-norms: ||b||=2.511886e-20, ||c|| = 2, Cholesky |add|=0, |skip| = 0, ||L.L|| = 1.

Status: Solved
Optimal value (cvx_optval): +3.27389e-14

Elapsed time is 0.663565 seconds.
results=
-104.8494

ans =

1

ans =

0 **//second constrain not be met**

I think you just need to understand that your constraints will not necessarily be satisfied exactly. If you need an inequality to be satisfied exactly, you’ll need to instead provide a modified constraint, which even when not satisfied exactly, will ensure your true constraint is satisfied. So, for example,
real(trace(W1*H1)) >= real((trace(W2*H1)+N0))*gama + fudge_factor
where fudge_factor is some small positive number.

OK, thanks for your help! I’ll try that.