How can I change the final duality gap?

Calling SDPT3 4.0: 6661 variables, 321 equality constraints
   For improved efficiency, SDPT3 is solving the dual problem.
------------------------------------------------------------

 num. of constraints = 321
 dim. of socp   var  = 6040,   num. of socp blk  = 20
 dim. of linear var  = 620
 dim. of free   var  =  1 *** 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|1.9e+02|7.9e+01|7.7e+05| 5.153741e+03  0.000000e+00| 0:0:00| chol  1  1 
 1|0.974|0.824|4.9e+00|1.4e+01|1.4e+05| 4.984902e+03 -2.764888e+01| 0:0:01| chol  1  1 
 2|1.000|0.981|7.8e-07|3.6e-01|7.3e+03| 4.217334e+03 -3.059662e+01| 0:0:01| chol  1  1 
 3|0.123|0.001|8.1e-06|3.6e-01|6.7e+03| 3.572003e+03 -3.044209e+01| 0:0:02| chol  1  1 
 4|0.974|0.835|4.3e-06|6.6e-02|7.8e+02| 4.155288e+02 -1.368001e+01| 0:0:02| chol  1  1 
 5|0.990|0.980|7.0e-06|3.7e-03|5.5e+01| 4.130050e+01 -6.974684e-01| 0:0:02| chol  1  1 
 6|0.986|0.827|2.7e-07|1.2e-03|2.5e+00| 1.743883e+00 -5.013177e-01| 0:0:03| chol  1  1 
 7|0.879|0.274|3.4e-08|9.2e-04|3.6e-01|-1.552745e-01 -4.906518e-01| 0:0:03| chol  1  1 
 8|0.636|0.764|1.3e-08|2.2e-04|1.3e-01|-3.401472e-01 -4.650332e-01| 0:0:04| chol  1  1 
 9|0.148|0.210|1.3e-08|1.8e-04|1.1e-01|-3.529494e-01 -4.591465e-01| 0:0:04| chol  1  1 
10|0.126|0.838|1.2e-08|2.9e-05|8.8e-02|-3.644045e-01 -4.519992e-01| 0:0:04| chol  1  1 
11|0.207|0.322|1.1e-08|1.9e-05|7.0e-02|-3.798011e-01 -4.495155e-01| 0:0:05| chol  1  1 
12|0.492|0.438|6.0e-09|1.1e-05|3.8e-02|-4.072044e-01 -4.451512e-01| 0:0:05| chol  1  1 
13|0.261|0.603|4.4e-09|4.4e-06|2.6e-02|-4.146660e-01 -4.409448e-01| 0:0:05| chol  2  2 
14|0.287|0.385|3.2e-09|2.7e-06|1.9e-02|-4.203834e-01 -4.391031e-01| 0:0:06| chol  1  2 
15|0.501|0.506|1.6e-09|1.3e-06|9.9e-03|-4.268073e-01 -4.366563e-01| 0:0:06| chol  2  2 
16|0.335|0.563|1.1e-09|5.9e-07|6.2e-03|-4.289585e-01 -4.351069e-01| 0:0:07| chol  2  2 
17|0.318|0.611|7.0e-10|2.4e-07|3.9e-03|-4.303139e-01 -4.341814e-01| 0:0:07| chol  2  2 
18|0.329|0.472|4.6e-10|1.3e-07|2.6e-03|-4.312418e-01 -4.337945e-01| 0:0:07| chol  2  2 
19|0.626|0.714|3.1e-10|4.9e-08|9.8e-04|-4.324077e-01 -4.333849e-01| 0:0:08| chol  2  2 
20|0.721|0.787|2.2e-10|1.5e-08|2.9e-04|-4.329219e-01 -4.332074e-01| 0:0:08| chol  2  2 
21|0.856|0.894|2.4e-10|4.0e-09|4.8e-05|-4.331016e-01 -4.331496e-01| 0:0:09| chol  2  2 
22|0.967|0.905|9.1e-11|6.7e-10|2.9e-06|-4.331363e-01 -4.331392e-01| 0:0:09| chol  2  2 
23|0.976|0.942|1.6e-10|4.7e-11|1.4e-07|-4.331378e-01 -4.331379e-01| 0:0:09| chol  2  2 
24|0.488|0.867|1.3e-10|3.1e-11|4.0e-08|-4.331378e-01 -4.331378e-01| 0:0:10| chol  2  2 
25|0.483|0.930|1.8e-10|2.8e-11|1.6e-08|-4.331378e-01 -4.331378e-01| 0:0:10|
  stop: max(relative gap, infeasibilities) < 1.49e-08
-------------------------------------------------------------------
 number of iterations   = 25
 primal objective value = -4.33137796e-01
 dual   objective value = -4.33137812e-01
 gap := trace(XZ)       = 1.58e-08
 relative gap           = 8.49e-09
 actual relative gap    = 8.46e-09
 rel. primal infeas (scaled problem)   = 1.80e-10
 rel. dual     "        "       "      = 2.82e-11
 rel. primal infeas (unscaled problem) = 0.00e+00
 rel. dual     "        "       "      = 0.00e+00
 norm(X), norm(y), norm(Z) = 1.2e+00, 5.4e-01, 8.2e+00
 norm(A), norm(b), norm(C) = 8.6e+01, 2.0e+00, 7.8e+00
 Total CPU time (secs)  = 10.26  
 CPU time per iteration = 0.41  
 termination code       =  0
 DIMACS: 1.8e-10  0.0e+00  1.3e-10  0.0e+00  8.5e-09  8.5e-09
-------------------------------------------------------------------
 
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +0.433138

The value of variable cvx_slvtol is 8.489593604822530e-09. I want to change this (the stopping criterion). How to? Thanks.

Have you read http://cvxr.com/cvx/doc/solver.html#controlling-precision ?

If you want more control over solver parameters, you can use cvx_solver_settings http://cvxr.com/cvx/doc/solver.html#advanced-solver-settings

Using a second order solver, such as SDPT3, on a continuous variable problem, you are not likely to get a much smaller duality gap. And trying for a larger duality gap might not save you much, if any, computing time…

Thanks for your kind help.
Yes, I am just trying to set a larger duality gap as the stopping criterion, such as 1e-5. I’ve read the two links shared by you but I didn’t obtain enough information. Could you please tell me the exact matlab code? Thanks!

help cvx_precision

cvx_precision Controls CVX solver precision.
The cvx_precision command controls the precision-related stopping criteria
for the numerical solver. Up to 3 precision levels can be specified:
0 <= PBEST <= PHIGH <= PLOW << 1.
— PBEST: the solver’s target precision. The solver is instructed
to iterate until it achieves this precision OR until it can
make no further progress.
— PHIGH: the ‘standard’ precision level. Any problem achieving
PRECISION <= PHIGH is considered accurately solved (returning
cvx_status = ‘Solved’).
— PLOW: the ‘minimum acceptable’ precision level. Any problem
achieving PHIGH < PRECISION <= PLOW is considered inaccurately
solved (returning cvx_status = ‘Inaccurate/Solved’).
Problems which cannot achieve PRECISION <= PLOW are considered unsolved
(returning cvx_status = ‘Failed’). These precision levels apply in
appropriate ways to infeasible and unbounded problems as well.

cvx_precision(TOL), where TOL is a positive scalar, sets
    PBEST = MAX(TOL,eps^0.5), PHIGH = TOL, 
    PLOW = min(sqrt(TOL),max(TOL,eps^0.25)).
Note that if TOL>eps^0.25, then PLOW=PHIGH.

cvx_precision(TOL), where TOL is a nonnegative 2-vector, 
    PBEST = MAX(MIN(TOL),eps^0.5), PHIGH = MIN(TOL), and PLOW = MAX(TOL).

cvx_precision(TOL), where TOL is a 3-vector, sets
    PBEST = MIN(TOL), PHIGH = MEDIAN(TOL), and PLOW = MAX(TOL).
MIN(TOL) may be zero, but the other two elements must be positive.

A number of text-based options are provided for convenience:
    cvx_precision DEFAULT: [eps^0.5,  eps^0.5,   eps^0.25 ]
    cvx_precision HIGH   : [eps^0.75, eps^0.75,  eps^0.375] 
    cvx_precision MEDIUM : [eps^0.5,  eps^0.375, eps^0.25 ]
    cvx_precision LOW    : [eps^0.5,  eps^0.25,  eps^0.25 ]
    cvx_precision BEST   : [0,        eps^0.5,   eps^0.25 ]

cvx_precision([]) is the same as cvx_precision DEFAULT.

cvx_precision BEST creates a 'best effort' mode. By setting PBSET=0,
it instructs the solver to proceed as long as it can make any useful
progress. By setting PLOW and PHIGH to their default values, it returns
exactly the same CVX_STATUS values as the DEFAULT setting. Therefore,
it yields higher precision when it can be achieved, without penalizing
models for which it cannot. Of course, higher precision comes at a cost
of increased computation time as well.

If cvx_precision(TOL) is called within a model---that is, between the
statements CVX_BEGIN and CVX_END---then the new precision applies only to
that particular model. If called outside of a model, then the change 
applies to all subsequent models.

On exit, cvx_precision(TOL) returns the *previous* precision, so that it
can be saved and restored later; for example:
    otol = cvx_precision(tol);
    cvx_begin
        ...
    cvx_end
    cvx_precision(otol);
Of course, this is equivalent to
    cvx_begin
        cvx_precision(tol);
        ...
    cvx_end
but the former syntax it may come in handy if you wish to solve several 
models in a row with a different precision.

cvx_precision, with no arguments, returns the current precision value.

You can try
cvx_precision(1e-5)

It’s very kind if you. Thanks a lot!!!

Dear Mark,

I use Gurobi as the CVX solver and I am not sure how can I change the Gap. I used cvx_solver_settings( ‘{name}’, {value} ), however I don’t now exactly what should I use for the name to change the Gap. I also tried https://www.gurobi.com/documentation/9.0/refman/mipgapabs.html#parameter:MIPGapAbs method, but no change.
I would appreciate it, if you could help me with this problem.

Choose your parameters from https://www.gurobi.com/documentation/9.0/refman/parameters.html .

Are you solving a Mixed-Integer problem? If so, perhaps you want to change one or both of these.

MIPGap : Relative MIP optimality gap

MIPGapAbs : Absolute MIP optimality gap

cvx_solver_settings('MIPGap',1e-2)
cvx_solver_settings('MIPGapAbs',1e-3)

Thank you very much. I really appreciate it.