# Why do different values of K lead to different status of solution？

Hi everyone!
The following problem can be solved normally when K=1 (ie., when running the commented out part). However, when K=2, the status of the output is failed and the optimal value is NAN.
I would really appreciate if anybody has a solution for this.
The algorithm is
M=9;
N=2;
K=2;
%K=1;
p_tran=0.25ones(N,1);
order_b=[1;2]; %N
1
order_e=[1,1;2,2]; %NK
% order_e=[1;2]; %N
K
h_b=[1.09e-09 - 2.03e-16i,1.00e-09 - 1.96e-16i;
1.09e-09 - 2.03e-16i,1.05e-09 + 6.25e-10i;
1.09e-09 - 2.03e-16i,6.60e-10 + 1.11e-09i;
8.47e-10 - 3.98e-11i,7.49e-10 + 2.28e-11i;
8.47e-10 - 3.98e-11i,3.07e-10 + 3.43e-10i;
8.47e-10 - 3.98e-11i,-2.33e-10 + 2.7e-10i;
1.13e-09 - 9.63e-11i,1.12e-09 + 5.93e-11i;
1.13e-09 - 9.63e-11i,1.10e-09 + 7.14e-10i;
1.13e-09 - 9.63e-11i,6.40e-10 + 1.17e-09i;
4.89e-05 + 1.11e-05i,4.73e-05 + 1.08e-05i];% (M+1)N
h_e=[1.01e-09 - 1.55e-16i,9.41e-10 - 1.51e-16i;
1.01e-09 - 1.55e-16i,9.86e-10 + 5.84e-10i;
1.01e-09 - 1.55e-16i,6.16e-10 + 1.03e-09i;
9.52e-11 - 3.83e-10i,1.10e-10 - 3.31e-10i;
9.52e-11 - 3.83e-10i,1.94e-10 - 9.13e-11i;
9.52e-11 - 3.83e-10i,8.93e-11 + 1.40e-10i;
6.41e-11 - 1.21e-09i,2.25e-10 - 1.17e-09i;
6.41e-11 - 1.21e-09i,9.11e-10 - 1.05e-09i;
6.41e-11 - 1.21e-09i,1.33e-09 - 5.03e-10i;
4.73e-05 + 1.08e-05i,4.59e-05 + 1.04e-05i;
7.87e-10 - 1.00e-16i,7.28e-10 - 9.81e-17i;
7.87e-10 - 1.00e-16i,7.63e-10 + 4.51e-10i;
7.87e-10 - 1.00e-16i,4.77e-10 + 8.03e-10i;
-1.61e-10 - 2.28e-10i,-1.26e-10 - 2.12e-10i;
-1.61e-10 - 2.28e-10i,4.08e-11 - 1.46e-10i;
-1.61e-10 - 2.28e-10i,1.16e-10 + 1.70e-11i;
-3.80e-10 - 6.13e-10i,-2.88e-10 - 6.49e-10i;
-3.80e-10 - 6.13e-10i,8.56e-11 - 8.27e-10i;
-3.80e-10 - 6.13e-10i,4.79e-10 - 6.98e-10i;
4.55e-05 + 1.04e-05i,4.42e-05 + 1.01e-05i];%(K
(M+1))N
% h_e=[1.01e-09 - 1.55e-16i,9.41e-10 - 1.51e-16i;
% 1.01e-09 - 1.55e-16i,9.86e-10 + 5.84e-10i;
% 1.01e-09 - 1.55e-16i,6.16e-10 + 1.03e-09i;
% 9.52e-11 - 3.83e-10i,1.10e-10 - 3.31e-10i;
% 9.52e-11 - 3.83e-10i,1.94e-10 - 9.13e-11i;
% 9.52e-11 - 3.83e-10i,8.93e-11 + 1.40e-10i;
% 6.41e-11 - 1.21e-09i,2.25e-10 - 1.17e-09i;
% 6.41e-11 - 1.21e-09i,9.11e-10 - 1.05e-09i;
% 6.41e-11 - 1.21e-09i,1.33e-09 - 5.03e-10i;
% 4.73e-05 + 1.08e-05i,4.59e-05 + 1.04e-05i];
S_b_0=[1.58e+05;1.69e+05];%N
1
S_e_0=[1.69e+05,1.83e+05;1.80e+05,1.94e+05];%NK
% S_e_0=[1.69e+05;1.80e+05];%N
K
I_b_0=[1.59e-05;9.99e-06];%N1
cvx_begin sdp
cvx_solver mosek
variable U((M+1),(M+1)) hermitian semidefinite
variables S_b(N) S_e(N,K) I_b(N) I_e(N,K) wide_R_b(N) wide_R_en(N,K) wide_R_e(N)
variable s(N,K)
variable z_1(N,K) nonnegative
variable z_2(N,K) nonnegative
expressions cvx_inter_b(N,1) cvx_inter_e(N,K) R_b_lb(N,1) d_S_e_lb(N,K)
for k=1:K
for n=1:N
cvx_inter_b(n,1)=10^(-5);
cvx_inter_e(n,k)=10^(-5);
for i=1:N
if order_b(n,1)<order_b(i,1)
cvx_inter_b(n,1)=cvx_inter_b(n,1)+10^4
p_tran(i)real(trace(Uh_b(:,i)h_b(:,i)’));
end
if order_e(n,k)<order_e(i,k)
cvx_inter_e(n,k)=cvx_inter_e(n,k)+10^4
p_tran(i)real(trace(Uh_e((k-1)(M+1)+1:k(M+1),i)h_e((k-1)(M+1)+1:k*(M+1),i)’));
end
end
end
end
for k=1:K
for n=1:N
R_b_lb(n,1)=-rel_entr(1,1+1/(S_b_0(n)I_b_0(n)))/log(2)…
-(log(exp(1))/log(2)
(S_b(n,1)-S_b_0(n,1)))/(S_b_0(n,1)+S_b_0(n,1)^2I_b_0(n,1))…
-(log(exp(1))/log(2)
(I_b(n,1)-I_b_0(n,1)))/(I_b_0(n,1)+I_b_0(n,1)^2S_b_0(n,1));
d_S_e_lb(n,k)=1/(S_e_0(n,k))-(S_e(n,k)-S_e_0(n,k))/(S_e_0(n,k)^2);
end
end
maximize sum(wide_R_b-wide_R_e);
subject to
for k=1:K
for n=1:N
wide_R_e(n,1)>=wide_R_en(n,k);
z_1(n,k)+z_2(n,k)<=1;
s(n,k)-log(2)wide_R_en(n,k)+rel_entr(1,z_1(n,k))<=0;
-log(2)wide_R_en(n,k)+rel_entr(1,z_2(n,k))<=0;
s(n,k)-rel_entr(1,S_e(n,k))-rel_entr(1,I_e(n,k))>=0;
d_S_e_lb(n,k)>=10^4
p_tran(n)real(trace(Uh_e((k-1)
(M+1)+1:k
(M+1),n)h_e((k-1)(M+1)+1:k*(M+1),n)’));%44d
I_e(n,k)<=cvx_inter_e(n,k);
end
end
for n=1:N
wide_R_b(n,1)<=R_b_lb(n,1);
wide_R_b(n,1)>=wide_R_e(n,1);
inv_pos(S_b(n))<=10^4p_tran(n)real(trace(Uh_b(:,n)h_b(:,n)’));
I_b(n)>=cvx_inter_b(n,1);
end
for n=1:N
for i=1:N
if order_b(n,1)<order_b(i,1)
real(trace(U
h_b(:,n)h_b(:,n)’))>=real(trace(Uh_b(:,i)h_b(:,i)’));
end
end
end
for k=1:K
for n=1:N
for i=1:N
if order_e(n,1)<order_e(i,1)
real(trace(U
h_e((k-1)
(M+1)+1:k*(M+1),n)h_e((k-1)(M+1)+1:k*(M+1),n)’))>=real(trace(Uh_e((k-1)(M+1)+1:k*(M+1),i)h_e((k-1)(M+1)+1:k*(M+1),i)’));%44f
end
end
end
end
for m=1:(M+1)
U(m,m)==1;%
end
cvx_end

The output is

very likely an error that will produce unexpected results. Please check
the LMI; and, if necessary, re-enter the model.

very likely an error that will produce unexpected results. Please check
the LMI; and, if necessary, re-enter the model.

=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================
=====================================
cone with parameters m=3, k=3
=====================================

## Calling Mosek 9.1.9: 465 variables, 231 equality constraints

MOSEK Version 9.1.9 (Build date: 2019-11-21 11:34:40)
Platform: Windows/64-X86

Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 231
Cones : 100
Scalar variables : 365
Matrix variables : 1
Integer variables : 0

Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 12
Eliminator terminated.
Eliminator started.
Freed constraints in eliminator : 2
Eliminator terminated.
Eliminator - tries : 2 time : 0.00
Lin. dep. - tries : 1 time : 0.00
Lin. dep. - number : 0
Presolve terminated. Time: 0.02
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 231
Cones : 100
Scalar variables : 365
Matrix variables : 1
Integer variables : 0

Optimizer - solved problem : the primal
Optimizer - Constraints : 114
Optimizer - Cones : 94
Optimizer - Scalar variables : 308 conic : 282
Optimizer - Semi-definite variables: 1 scalarized : 210
Factor - setup time : 0.00 dense det. time : 0.00
Factor - ML order time : 0.00 GP order time : 0.00
Factor - nonzeros before factor : 569 after factor : 702
Factor - dense dim. : 0 flops : 5.99e+04
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 1.5e+00 3.2e+01 2.2e+01 0.00e+00 0.000000000e+00 -2.100000000e+01 1.0e+00 0.23
1 6.9e-01 1.5e+01 1.3e+01 -8.13e-01 -6.049866145e+01 -7.796533521e+01 4.6e-01 0.31
2 3.2e-01 6.9e+00 6.0e+00 -4.27e-01 -7.759831382e+01 -8.917538075e+01 2.2e-01 0.31
3 1.5e-01 3.3e+00 2.4e+00 1.57e-01 -4.712137725e+01 -5.397972144e+01 1.0e-01 0.33
4 3.2e-02 6.9e-01 2.9e-01 5.00e-01 -1.322976745e+01 -1.494201117e+01 2.1e-02 0.33
5 1.1e-02 2.4e-01 7.7e-02 6.04e-01 -2.451566929e+00 -3.157555846e+00 7.4e-03 0.33
6 6.3e-03 1.4e-01 4.4e-02 4.23e-01 3.182314751e-01 -1.832996046e-01 4.3e-03 0.33
7 2.5e-03 5.4e-02 2.8e-02 -3.44e-01 -7.845865666e-01 -1.030064774e+00 1.7e-03 0.34
8 1.1e-03 2.4e-02 1.4e-02 -4.44e-01 -7.053375449e-01 -5.806517905e-01 7.5e-04 0.34
9 4.1e-04 8.9e-03 7.2e-03 -5.28e-01 -1.995062264e-01 6.761921119e-01 2.8e-04 0.34
10 2.2e-04 4.7e-03 4.2e-03 -5.41e-01 -8.021969961e-02 1.188324745e+00 1.5e-04 0.34
11 7.8e-05 1.7e-03 1.8e-03 -4.46e-01 6.145714697e-02 2.087616577e+00 5.3e-05 0.36
12 4.4e-05 9.6e-04 1.1e-03 -3.63e-01 1.232214056e-01 2.785795300e+00 3.0e-05 0.38
13 1.3e-05 2.8e-04 3.6e-04 -2.85e-01 1.090530498e-01 3.500678482e+00 8.7e-06 0.38
14 5.1e-06 1.1e-04 1.2e-04 9.37e-02 5.347310896e-02 2.403323878e+00 3.4e-06 0.38
15 1.9e-06 4.1e-05 3.1e-05 4.21e-01 1.366720906e-02 1.218482885e+00 1.3e-06 0.39
16 6.9e-07 1.5e-05 6.6e-06 8.86e-01 -1.622696297e-02 3.911105362e-01 4.7e-07 0.39
17 3.6e-07 7.8e-06 2.7e-06 9.66e-01 -2.396398873e-02 2.175431915e-01 2.4e-07 0.39
18 1.5e-07 3.2e-06 7.6e-07 9.05e-01 -2.996418383e-02 8.856004796e-02 9.9e-08 0.41
19 1.0e-07 2.3e-06 5.0e-07 7.23e-01 -3.226816609e-02 7.078032260e-02 7.1e-08 0.41
20 3.7e-08 7.9e-07 1.3e-07 7.06e-01 -3.734040569e-02 1.768640809e-02 2.5e-08 0.41
21 1.5e-08 3.3e-07 4.4e-08 5.55e-01 -4.374561880e-02 -5.653977367e-03 1.0e-08 0.41
22 6.6e-09 1.3e-06 1.5e-08 5.49e-01 -5.222919913e-02 -2.838822048e-02 4.5e-09 0.42
23 3.5e-09 4.3e-06 8.1e-09 3.52e-01 -6.254578314e-02 -3.839414554e-02 2.4e-09 0.42
24 1.2e-09 5.4e-06 1.7e-09 5.91e-01 -6.755192908e-02 -5.839973339e-02 8.2e-10 0.42
25 5.9e-10 8.3e-05 8.7e-10 3.47e-01 -3.270114401e-02 -2.314099474e-02 4.0e-10 0.42
26 2.1e-10 1.0e-05 2.4e-10 5.24e-01 -3.633813015e-03 2.285855995e-03 1.4e-10 0.44
27 5.5e-11 3.7e-04 9.9e-11 4.47e-02 -1.497986516e-02 -2.778156632e-04 3.7e-11 0.44
28 5.5e-13 1.8e-03 1.2e-11 -7.66e-01 -8.015772047e-02 2.067403664e+00 3.7e-13 0.44
29 1.2e-15 6.0e-04 5.5e-13 -9.96e-01 -8.136070812e-02 1.028624851e+03 7.9e-16 0.44
30 2.3e-18 2.0e-04 4.9e-14 -1.00e+00 -8.094180516e-02 5.163695079e+05 1.6e-18 0.45
31 6.9e-17 7.7e-09 5.3e-14 -1.00e+00 -8.267923481e-19 5.547779235e-07 2.2e-23 0.45
Optimizer terminated. Time: 0.48

Interior-point solution summary
Problem status : ILL_POSED
Solution status : PRIMAL_ILLPOSED_CER
Dual. obj: 5.5477778726e-07 nrm: 5e+03 Viol. con: 0e+00 var: 8e-09 barvar: 7e-20 cones: 0e+00
Optimizer summary
Optimizer - time: 0.48
Interior-point - iterations : 31 time: 0.45
Basis identification - time: 0.00
Primal - iterations : 0 time: 0.00
Dual - iterations : 0 time: 0.00
Clean primal - iterations : 0 time: 0.00
Clean dual - iterations : 0 time: 0.00
Simplex - time: 0.00
Primal simplex - iterations : 0 time: 0.00
Dual simplex - iterations : 0 time: 0.00
Mixed integer - relaxations: 0 time: 0.00

Status: Failed
Optimal value (cvx_optval): NaN

Many thanks!

Have solved the issue

This linear matrix inequality appears to be unsymmetric. This is
very likely an error that will produce unexpected results. Please check
the LMI; and, if necessary, re-enter the model.

?

As @Erling pointed out, check to see what is going on with nonsymmetric LMIs, and fix that. As it is, CVX is not attempting to solve the problem you want to solve.

Also, the scaling of the input data is horrible.

Also, you should uninstall CVXQUAD’;s exponential.m replacementm which the Pade approximant output shows is being used. That way, this will be handled by Mosek’s native exponential cone capability instead, which is better.