Why CVX has different response to the same code?

Hi. I have 2 questions. this is part of my code:

for rePCC_idx=1:length(NPQloc)
QCC_idx=NPQloc(rePCC_idx);
nu2(rePCC_idx)>= max(abs([Sensq1(rePCC_idx,:slight_smile: 0]));
for QCC_smp_idx=1:Sampnum
CC_ZQ(rePCC_idx,QCC_smp_idx)+gama2(rePCC_idx)<=-100trace(Y_k_bar(:,:,QCC_idx)W)…
+Qmax(QCC_idx)-QD(QCC_idx)…
-[Sensq1(rePCC_idx,:slight_smile: 0]unc(:,QCC_smp_idx);
CC_ZQ(rePCC_idx,QCC_smp_idx)+gama2(rePCC_idx)<=100
trace(Y_k_bar(:,:,QCC_idx)W)…
-Qmin(QCC_idx)+QD(QCC_idx)…
-[Sensq1(rePCC_idx,:slight_smile: 0]
-unc(:,QCC_smp_idx);
CC_ZQ(rePCC_idx,QCC_smp_idx)<=0;
end
WD_ep
nu2(rePCC_idx)-ep_q
gama2(rePCC_idx)<=(1/Sampnum)*sum(CC_ZQ(rePCC_idx,:));
end

where nu2(5,1), gama 2(5,1), CC_ZQ(5,20) are variables and rest of it are parameters. WD_ep and ep_q are scalars. when I ran this code:
Interior-point solution summary
Problem status : PRIMAL_AND_DUAL_FEASIBLE
Solution status : OPTIMAL
Primal. obj: -9.7111023875e+04 nrm: 4e+05 Viol. con: 1e-03 var: 1e-06 barvar: 0e+00
Dual. obj: -9.7111023588e+04 nrm: 1e+04 Viol. con: 0e+00 var: 6e-06 barvar: 2e-08
Optimizer summary
Optimizer - time: 0.77
Interior-point - iterations : 36 time: 0.73
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: Solved
Optimal value (cvx_optval): +97111

After that, I changed
WD_epnu2(rePCC_idx)-ep_qgama2(rePCC_idx)<=(1/Sampnum)*sum(CC_ZQ(rePCC_idx,:));

to
WD_epnu2-ep_qgama2<=(1/Sampnum)sum(CC_ZQ,2); (**)

and put (***) out of the for loop. the results will be:

Interior-point solution summary
Problem status : UNKNOWN
Solution status : UNKNOWN
Primal. obj: -9.7111100192e+04 nrm: 4e+05 Viol. con: 2e-02 var: 2e-07 barvar: 0e+00
Dual. obj: -9.7111100151e+04 nrm: 1e+04 Viol. con: 0e+00 var: 9e-07 barvar: 3e-09
Optimizer summary
Optimizer - time: 0.69
Interior-point - iterations : 28 time: 0.66
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: Inaccurate/Unbounded
Optimal value (cvx_optval): -Inf

it is weirs since those 2 constraints are equivalent but I got different values for parameters and values. why?

Thanks.

This is the first code.

Probably for some internal reason CVX generates a slightly different MOSEK model, or you don’t have identically the same data. As you can see the solutions in both cases are almost identical, the constraint violation is large-ish, so it is possible that the model is numerically poor and small variations can be a game changer. Maybe you could post both complete log outputs of MOSEK.