CVX Solver time

Hello everyone. I am solving a problem using Mosek via CVX in MATLAB. I used Tic and Toc to get the total time consumed by CVX to give me the final solution. The total elapsed time is around 11 seconds. However in the solution report, as you can see, the TIME variable in the last column is 0.30 seconds. What is the reason for this huge difference? Does it mean the CVX needs almost 10 seconds to prepare the problem for MOSEK and the actual time spent by MOSEK was 0.30 seconds?

Yes, your conclusion is the most probable one. Not necessarily CVX spends 10 seconds, but the whole Matlab code executed between tic and tac takes 11 seconds, out of which the solver spends 0.30. You did not post reproducible code so we don’t know what’s in it.

Thanks. The optimization is a part of a code that contains too many subfunctions and JSON data so I could not post the code as a single file here. The tic and toc come exactly before and after the cvx_begin and cvx_end. An interesting thing to me is that when I use Gurobi to solve a problem, the total execution time reduces from 11 seconds to 3 seconds, out of which the solver takes 0.1 seconds. I do not know why changing the solver even reduces the time that CVX builds the problem!

Just the fact that total times might differ for different solvers is not that surprising because a different input form matching the solver’s interface must be compiled.

It is more surprising that the discrepancy is so large, and that the compile time is so large compared to solver time.

That might indicate that you would be better off rewriting the model directly in the solver’s API.

If you can package a fully runnable example and send to Mosek support then I can look at it there and investigate what happens in the Mosek case.