How to add time limit in CVX while using the Gurobi solver?

Hello,

For some folds in my 10-fold CV, CVX solver takes very long time. I am using Gurobi solver underneath, and it does have a TimeLimit setting. But I don’t know if I can use that through CVX or, maybe CVX has its own way to set a time limit? . If yes, how to do that and how to interpret the returned results (if there is any)?

Thank you,

Yijun

I think you can use CVX’s advanced solver settings, described in http://cvxr.com/cvx/doc/solver.html#advanced-solver-settings , to pass the TimeLimit setting to Gurobi. I don’t know whether that will work correctly and do what you want. This time limit should be applied separately for each invocation of Gurobi by CVX. There is no other time limit you can set for CVX.

If GUROBI is terminated due to reaching the time limit, it may not have reached an optimal solution. I don’;t know what gets returned from GUROBO to CVX to you in that situation. If you are solving individual problems with GUROBI as part of CV, then there could be consequences to either using a non-optimal solution or tossing out the run from your CV calculations. In such case, you coudl be biasing results, as for instance, the runs which hit the time limit might be “harder” or would produce less favorable results than average, if allowed to run to completion. I’ve seen many people introduce bias by tossing out runs (stochastic (Monte Carlo) simulation replications) which reach a time limit, though this was in different contexts than CV. Someone running a faster or less loaded computer might get a systematically different (worse) result.

Thank you Mark. I got the cvx_solver_settings(‘TIMELIMIT’, num) working and will experiment what is the best way to deal with suboptimal solutions.

Regards,

Yijun