# If the corresponding code is correct (SOC)?

Hello,everyone!
I used CVX to solve a convex optimization problem and got an result of “Failed”. One of the constraints which is further rewritten as the SOC form(see the picture).
I want to know if the corresponding code is correct?.

constraint :

code :

%parameter
pai1_f=sla_v_ini.pai1; %(E,N)
pai2_f=sla_v_ini.pai2; %(E,N)
ga3=gamaPJ;

cvx_begin
cvx_quiet true
cvx_solver sdpt3;
variable s
variable pai1(E,N)
variable pai2(E,N) nonnegative
expression F_45(E,N) %(45)

for e=1:E %(F45)
for n=1:N
F_45(e,n)=(pai1_f(e,n)-pai2_f(e,n))
(pai1(e,n)-pai2(e,n))/4+ga3/2 -((pai1_f(e,n)-pai2_f(e,n))^2)/8-1/2;
end
end

maximize s;

subject to
for e=1:E %(45)
for n=1:N
norm([(pai1(e,n)+pai2(e,n))/2 F_45(e,n)])<=F_45(e,n)+1;%(45)
end
end

cvx_end

If you write them carefully, they will be correct. For SOC definition, check https://docs.mosek.com/modeling-cookbook/cqo.html

Please remove `cvx_quiet true`, and show all solver and CVX output.

Also, try a different solver, such as sedumi, and if available to you, mosek or gurobi.

One of the most common reasons for solver failure is “bad” input data, such as from poor scaling, with some input data many orders of magnitude from one.

The output is shown as below after removing `cvx_quiet true`:

That output shows that CVX"s successive approximation method was used, which means there must be some exponential cone (including log) type functions in your code. Apparently, they must be in code which you omitted. That was indeed a crucial omission.

In light of that, use CVX 2.2 with mosek as solver. If that is not available to you, follow the directions at CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions

Thank you for your help,I will consider using mosek as solver.

Hi, Mark!
Do you know what is wrong according to the result ? And my solver is mosek.

You are getting a rather suspicious infeasibility certificate. First fix the scaling (see all the warnings) to get a numerically more stable problem where the coefficients and the expected solution are in reasonable range. Sections 8.1, 8.2 here will be useful https://docs.mosek.com/latest/toolbox/debugging-tutorials.html

OK. Thank you very much!