How do I limit computation time?

Is there a way to put an upper bound to the computation time that CVX requires to solve a general problem?

I tried to modify the solver options:
cvx_solver_settings('TIMELIMIT', 30)

as suggested in a different question but it didn’t work on my case which is not a mixed integer problem. Thanks!

Perhaps the best you can do is to limit the number of iterations allowed by the solver. That won’t include CVX processing time, nor account for any uncertainty as to how long each iteration will take.

To limit the solver to 50 iterations, say, use:
In SDPT 3, cvx_solver_settings('maxit',50)
In SeDuMi,cvx_solver_settings('maxiter',50)


I’m using CVX within a parfor loop on a large cluster job, by calling it through a function.
While it typically runs without problems, there are sometimes where a node appear to stall when using CVX.
Using an upper limit on the computation time there could potentially help me bypass these issues.


For me I actually want to limit the time from the point where cvx_begin is called ( so including the processing/modeling time). How would I do this?
Thank you for your help!

I don’t think that is doable.

You can use cvx_solver_settings to set whatever options the solver provides to limit solver time. For example, if Gurobi is the solver, you can use cvx_solver_settings('TimeLimit',3600) to limit Gurobi solver time to one hour, but that would not address CVX processing/modeling time.