# My program failed in using CVX

``````AT0=AT_k;
BT0=BT_k;
A=[(A_m.*A_m);2];
xi1=zeros(K,1);

lamda_k=zeros(K,1);
e_k=zeros(K,M+1);
for k=1:K
Vm_k=V(:,:,k);
[x y]=eig(Vm_k);
eigenvalue=diag(y);
lamda_k(k,:)=max(eigenvalue);
for i=1:length(Vm_k)
if lamda_k(k,:)==eigenvalue(i)
break;
end
end
e_k(k,:)=x(:,i)';
end
[~,R_sum] = SINR_generate(K,N,M,H_r,H_t,h_k,f_k,G,w_k,sigma1,sigma2,v,lamda_k);
Rt_k=R_sum;
for k=1:K
v1=V(:,:,k);
v0=real(e_k(k,:)*v1*e_k(k,:)')/real(trace(v1))+delta;
xi1(k,:)=min(1,v0);
end
fprintf("优化之前的xi1\n");
disp(xi1);
fprintf("V求解\n");
cvx_begin   %quiet % sdp
%     cvx_solver   sedumi   %mosek %sedumi                %
%     cvx_precision low

variables V(M+1,M+1,K) semidefinite ;
variables AT0(K,1) BT0(K,1) Rt_k(K,1) nonnegative;
maximize  sum(Rt_k)
subject to
sum0=0;
inv_pos(AT0)<=inv_pos(AT_k);
BT0>=BT_k;
for k=1:K
v1=V(:,:,k);
g1=Gb_k(:,:,k);
sum0=sum0+real(trace(v1*g1));
diag(v1)<=A;
real(e_k(k,:)*v1*e_k(k,:)')>=real(xi(k,:)*trace(v1));
end
sum0<=P_out;
for k=1:K
AT_k0=AT0_k(k,:);
BT_k0=BT0_k(k,:);
RBT_k=log2(1+1/(AT_k0*BT_k0))-(AT0(k,:)-AT_k0)/(AT_k0*log(2)*(1+BT_k0*BT_k0))-(BT0(k,:)-BT_k0)/(AT_k0*log(2)*(1+AT_k0*BT_k0));
RBT_k >= Rt_k(k,:);
end
Rt_k>=R_kmin;
cvx_end

for k=1:K
v1=V(:,:,k);
v0=abs(real(e_k(k,:)*v1*e_k(k,:)'/trace(v1))+delta);
xi1(k,:)=min(1,v0);
end
% fprintf("优化之后的xi1\n");
% disp(xi1);
xi=xi1;
AT0_k=AT0;
BT0_k=BT0;
end``````

The result is failed.
V求解

## Calling SDPT3 4.0: 858 variables, 9 equality constraints

num. of constraints = 9
dim. of socp var = 6, num. of socp blk = 2
dim. of linear var = 14
dim. of free var = 838
6 linear variables from unrestricted variable.

*** convert ublk to linear blk
*** convert ublk to linear blk

SDPT3: homogeneous self-dual path-following algorithms

## number of iterations = 30 primal objective value = 7.86905553e-01 dual objective value = 3.11215418e+01 gap := trace(XZ) = 5.16e+01 relative gap = 3.04e+00 actual relative gap = -9.22e-01 rel. primal infeas = 1.54e+00 rel. dual infeas = 4.12e-01 norm(X), norm(y), norm(Z) = 3.6e+06, 1.3e+07, 1.3e+07 norm(A), norm(b), norm© = 6.3e+01, 1.2e+01, 1.4e+00 Total CPU time (secs) = 0.40 CPU time per iteration = 0.01 termination code = -7 DIMACS: 1.5e+00 0.0e+00 4.1e-01 0.0e+00 -9.2e-01 1.6e+00

Status: Failed
Optimal value (cvx_optval): NaN

And I can not find the reason why it is failed.

You have not provided all the input data to make the problem reproducible. have you tired other solvers, such as Mosek, which is commented out?

Also, I believe you need to declare semidefinite and nonnegative one at a time using `variable`, not `variables`. I think you are declaring `semidefinite` and `nonnegative` as variables, not constraining your declared variables as you intended. So fix this problem first. Then re-try.

The one limitation of the variables command is that it cannot declare complex, integer, or structured variables. These must be declared one at a time, using the singular variable command.

I have modified the code and use mosek to solve it. But the result is still infeasible. The code pasted is a part of the whole program and I have the input data below. The output is the process of mosek.

1.0e+07 *

``````0.7704
3.6352
``````

B_k
1.0e-07 *

``````0.1000
0.5101
``````

iterV:1
AT_k
1.0e+07 *

``````0.3518
3.4580
``````

BT_k
1.0e-07 *

``````0.1000
0.1876
``````

V求解

## Calling Mosek 9.1.9: 527 variables, 57 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 : 57
Cones : 2
Scalar variables : 65
Matrix variables : 2
Integer variables : 0

Optimizer started.
Presolve started.
Eliminator - tries : 0 time : 0.00
Lin. dep. - tries : 0 time : 0.00
Lin. dep. - number : 0
Presolve terminated. Time: 0.00
Optimizer terminated. Time: 0.11

Interior-point solution summary
Problem status : PRIMAL_INFEASIBLE
Solution status : PRIMAL_INFEASIBLE_CER
Dual. obj: 4.7175148767e-01 nrm: 1e+07 Viol. con: 0e+00 var: 7e-24 barvar: 0e+00 cones: 0e+00
Optimizer summary
Optimizer - time: 0.11
Interior-point - iterations : 0 time: 0.03
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: Infeasible
Optimal value (cvx_optval): -Inf

Did you change ‘variables’ to individual `variable’ statements?

You should change the scaling of input data so that it is close to 1 in magnitude, not 1e-7.

If it’s still infeasible, follow the advice at https://yalmip.github.io/debugginginfeasible , all of which, except for section 1, also applies to CVX.

Yes,I have modified the code as you advised.
variable V(M+1,M+1,K) semidefinite ;
variable AT0(K,1) nonnegative;
variable BT0(K,1) nonnegative;
variable Rt_k(K,1) nonnegative;
But I want to know how to achieve the scaling of input data, just achieved by normalizing or standardizing real-valued input and output variables?

Change the units …

Thanks for your response. I will have a try.