How to turn my constraints into something that's easy to solve, in CVX

Here is my problem:

CVX often gives NAN in the first iteration. I suspect that my constraints are not suitable for CVX. I want to replace my constraints equivalently with something easier to solve.

Here is my code:

In the future, please copy and paste code and use preformatted text icon, rather than post image of code.

You haven’t shown us the solver and CVX output. Presumably, CVX has declared it infeasible, or unbounded, or the solver failed.

You mention “in the first iteration”. Are you using Successive Convex Approximation?

sorry for inconvenience.Here is the cvx output:

Calling SDPT3 4.0: 1601 variables, 773 equality constraints
For improved efficiency, SDPT3 is solving the dual problem.

num. of constraints = 773
dim. of socp var = 1594, num. of socp blk = 5
dim. of linear var = 4
dim. of free var = 3 *** convert ublk to lblk


SDPT3: Infeasible path-following algorithms


version predcorr gam expon scale_data
NT 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap prim-obj dual-obj cputime

0|0.000|0.000|2.2e+01|4.3e+00|2.5e+03| 8.769265e+00 0.000000e+00| 0:0:00| chol 1 1
1|0.923|0.690|1.7e+00|1.4e+00|4.9e+02|-1.915369e+00 -2.038948e+01| 0:0:00| chol 1 1
2|1.000|0.964|1.5e-06|5.2e-02|3.1e+01|-6.610996e-01 -1.802572e+01| 0:0:01| chol 1 1
3|1.000|0.920|2.7e-07|4.4e-03|3.6e+00|-8.387682e+00 -1.137203e+01| 0:0:01| chol 1 1
4|0.802|0.768|1.7e-07|1.0e-03|6.9e-01|-1.048174e+01 -1.106302e+01| 0:0:01| chol 1 1
5|0.177|0.396|1.4e-07|6.3e-04|4.5e-01|-1.056156e+01 -1.089980e+01| 0:0:01| chol 1 1
6|0.253|0.358|1.0e-07|4.1e-04|3.0e-01|-1.066405e+01 -1.083465e+01| 0:0:01| chol 1 1
7|0.154|0.074|8.8e-08|3.9e-04|2.9e-01|-1.077922e+01 -1.083358e+01| 0:0:01| chol 1 1
8|0.378|0.090|5.6e-08|3.8e-04|3.5e-01|-1.080118e+01 -1.084556e+01| 0:0:01| chol 1 1
9|0.112|0.302|5.0e-08|2.7e-04|2.6e-01|-1.116289e+01 -1.092461e+01| 0:0:01| chol 1 1
10|0.293|0.250|3.5e-08|2.0e-04|2.2e-01|-1.187357e+01 -1.098205e+01| 0:0:02| chol 1 1
11|0.344|0.115|2.3e-08|2.0e-04|6.2e-01|-1.610271e+01 -1.112598e+01| 0:0:02| chol 1 1
12|0.193|0.034|2.7e-08|2.2e-04|7.5e+00|-1.162522e+02 -1.102814e+01| 0:0:02| chol 1 1
13|0.009|0.007|2.7e-08|2.5e-04|2.2e+01|-3.390905e+02 -1.118099e+01| 0:0:02| chol 1 1
14|0.034|0.015|8.0e-08|3.0e-04|1.7e+02|-3.798798e+03 -1.108970e+01| 0:0:02| chol 1 1
15|0.336|0.014|6.5e-07|3.7e-04|2.1e+04|-6.858025e+05 -1.115731e+01| 0:0:02| chol 1 1
16|0.014|0.006|3.3e-05|4.7e-04|3.0e+05|-1.223336e+07 -1.111377e+01| 0:0:02| chol 2 2
17|0.007|0.003|2.7e-04|6.0e-04|3.3e+06|-1.575751e+08 -1.123580e+01| 0:0:02| chol 2 2
18|0.001|0.002|1.1e-03|7.6e-04|1.4e+07|-7.217593e+08 -1.198582e+01| 0:0:02| chol 2 2
19|0.005|0.002|2.1e-02|9.9e-04|2.1e+08|-1.223496e+10 -1.408241e+01| 0:0:03| chol 2 2
20|0.000|0.002|5.5e-03|1.3e-03|5.1e+08|-3.134692e+10 -5.815159e+01| 0:0:03| chol 2 2
stop: primal infeas has deteriorated too much, 3.0e-01
21|0.002|0.001|5.5e-03|1.3e-03|5.1e+08|-3.134692e+10 -5.815159e+01| 0:0:03|
prim_inf,dual_inf,relgap = 5.48e-03, 1.27e-03, 1.61e-02
sqlp stop: dual problem is suspected of being infeasible

number of iterations = 21
residual of dual infeasibility
certificate X = 8.42e-02
reldist to infeas. <= 1.01e-05
Total CPU time (secs) = 2.84
CPU time per iteration = 0.14
termination code = 2
DIMACS: 3.5e-08 0.0e+00 1.2e-03 0.0e+00 -3.7e-02 9.3e-03


Status: Infeasible
Optimal value (cvx_optval): +Inf

I’m not using SCA, I just iterating through the loop to achieve the objective function minimum

if CVX reports infeasible, all except for section 1 of https://yalmip.github.io/debugginginfeasible also applies to CVX.

I want to know if “get rid of the objective function” means take the minimize line out of CVX.

When I removed it, I found that the problem was still infeasible

here is the output:

Calling SDPT3 4.0: 797 variables, 28 equality constraints

num. of constraints = 28
dim. of socp var = 793, num. of socp blk = 4
dim. of linear var = 4


SDPT3: Infeasible path-following algorithms


version predcorr gam expon scale_data
NT 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap prim-obj dual-obj cputime

0|0.000|0.000|3.3e+01|3.9e+01|1.3e+03| 0.000000e+00 0.000000e+00| 0:0:00| chol 1 1
1|0.862|0.952|4.6e+00|2.0e+00|1.8e+02| 0.000000e+00 -7.157078e+00| 0:0:00| chol 1 1
2|0.980|1.000|9.3e-02|1.0e-02|9.9e+00| 0.000000e+00 -6.658126e+00| 0:0:00| chol 1 1
3|0.804|0.973|1.8e-02|2.0e-02|7.7e-01| 0.000000e+00 -4.889396e-01| 0:0:00| chol 1 1
4|0.429|0.595|1.0e-02|1.2e-02|3.7e-01| 0.000000e+00 -1.570149e-01| 0:0:00| chol 1 1
5|0.493|0.357|5.3e-03|9.6e-03|2.1e-01| 0.000000e+00 -6.292605e-02| 0:0:00| chol 1 1
6|0.413|0.228|3.1e-03|8.5e-03|1.3e-01| 0.000000e+00 -1.855645e-03| 0:0:00| chol 2 2
7|0.355|0.511|2.0e-03|4.8e-03|8.3e-02| 0.000000e+00 9.585544e-02| 0:0:00| chol 2 2
8|0.200|0.111|1.6e-03|4.6e-03|6.1e-02| 0.000000e+00 2.808496e-01| 0:0:00| chol 2 2
9|0.113|0.801|1.4e-03|1.2e-03|3.7e-01| 0.000000e+00 1.220810e+01| 0:0:00| chol 2 2
10|0.020|1.000|1.4e-03|2.8e-04|1.2e+02| 0.000000e+00 1.515593e+04| 0:0:00| chol 3 3
11|1.000|1.000|5.2e-04|2.8e-04|3.1e+03| 0.000000e+00 5.839633e+04| 0:0:00| chol 3 3
12|0.694|1.000|5.0e-04|1.0e-04|2.4e+04| 0.000000e+00 1.972054e+05| 0:0:00| chol 2 3
13|0.350|0.040|5.5e-04|2.0e-04|1.1e+05| 0.000000e+00 3.110283e+05| 0:0:00| chol 2 2
14|0.119|1.000|5.0e-04|1.1e-04|8.9e+05| 0.000000e+00 3.981959e+06| 0:0:00| chol 2 2
15|0.155|1.000|4.3e-04|1.2e-04|4.9e+06| 0.000000e+00 1.190144e+08| 0:0:00| chol 2 3
16|0.018|1.000|4.2e-04|4.0e-02|1.7e+09| 0.000000e+00 8.651313e+10| 0:0:00| chol 3 3
17|0.007|1.000|4.2e-04|1.5e+02|2.8e+12| 0.000000e+00 2.752970e+14| 0:0:00|
sqlp stop: primal problem is suspected of being infeasible

number of iterations = 17
residual of primal infeasibility
certificate (y,Z) = 5.40e-13
reldist to infeas. <= 9.02e-18
Total CPU time (secs) = 0.25
CPU time per iteration = 0.01
termination code = 1
DIMACS: 4.2e-04 0.0e+00 1.5e+02 0.0e+00 -1.0e+00 1.0e-02


Status: Infeasible
Optimal value (cvx_optval): +Inf

Does this mean that my model is unbounded?

"Get rid of the objective function” means take the minimize (or maximize) line out of CVX.

Your problem is infeasible, not unbounded. Try the other advice about removing constraints, and using slack variables For instance, minimize slacks, instead of the original objective function, to help diagnose infeasibility.

Thank you for your advice