2
$\begingroup$

In Python, I would like to solve a collection of problems, that are all solvable via MOSEK's conic optimization solvers (ExpCone, SOCP, etc.)

I have tried CVXPY. I get very robust and reliable results, however, the problem formulation times are quite expensive. I am looking for an efficient alternative.

To this end, given that I only use MOSEK, I thought maybe I don't need CVXPY (i.e., I won't switch between solvers, happy just with MOSEK).

Hence, I found the MOSEK API for Python, but it looks less intuitive than CVXPY to formulate disciplined optimization problems. There is also MOSEK Fusion, which looks simpler, but I don't really understand what the difference is.

Hence, I am wondering: given that I need to only use MOSEK, cannot afford large problem-formulation times, and also do not know the MOSEK API but am familiar with CVXPY, what would you recommend me? Which option is the most reasonable one for me?

$\endgroup$
7
  • $\begingroup$ If you have a lot of problem instances which differ only in input data, and you are willing to use MATLAB, you can use YALMIP with "optimizer" (with Mosek as solver) which incurs a one-time expenditure of processing time to create the optimizer (object), and then incurs only a small problem formulation processing time for each problem instance. It's about as easy to use as CVXPY, if you know MATLAB,, and about the same ease of use as CVX for the problems CVX can handle, but provides more flexibility and can handle many more problem types and solvers. $\endgroup$ Commented Nov 8, 2023 at 0:51
  • $\begingroup$ You want to take a look at groups.google.com/g/mosek/c/t0T8aFJsnwg/m/45vsWF3fAgAJ $\endgroup$ Commented Nov 8, 2023 at 6:33
  • $\begingroup$ Fusion seems like a good choice. It incurs some overhead compared to the lower level optimizer API, because, after all, there is some processing/modeling to be done, like in CVXPY, but these days this overhead is almost always very small compared to the solver time. (Actually I would expect the same from CVXPY, so maybe you hit some special case or your model could be streamlined). $\endgroup$ Commented Nov 8, 2023 at 9:56
  • $\begingroup$ @MichalAdamaszek @ Mark L. Stone @ ErlingMOSEK Thank you for your answers. I have used YALMIP for many years. It was extremely good, had a great synchrony with MOSEK. Unfortunately, though, my current research community does not approve MATLAB. My experience with Julia is great, accepted by the community, fast. Unfortunately, JuMP gives some unstable results right now (JuMP is great, but my specific problem is not resolved yet), and I want to compare it with an alternative. MOSEK's Julia support is outdated (on GitHub it was last updated more than a year ago), so Julia is also not possible. $\endgroup$ Commented Nov 8, 2023 at 17:35
  • $\begingroup$ +@MichalAdamaszek @ Mark L. Stone @ ErlingMOSEK Hence, I am benchmarking in Python. So far, I can see CVXPY is very stable. But, as mentioned, it is slow in formulation. MOSEK's APIs are great, but I am not familiar. My research is on some machine learning problems, and I have so many different decision variables, x,y,z, matrix variables, etc. So, API will be hard to manage with vectorized variables. Do you think I can speed up CVXPY? My problem has a specific structure, think of something like a logistic regression, but many times in a for-loop, I need to add new constraints and re-optimize. $\endgroup$ Commented Nov 8, 2023 at 17:39

1 Answer 1

1
$\begingroup$

Having come here with the same question --- can we reformulate a CVXPY problem using the MOSEK solver in a way that cuts formulation time --- I'll get an answer posted with what worked in my case:

Reformulating using the MOSEK Fusion API has demonstrated significant time savings in the model reduction in my experience. I also found it to be closer to the level of modeling abstraction afforded by CVXPY than the MOSEK Optimizer API. There are (potentially) non-trivial adjustments required in the articulation of the model, but in my case, I didn't find the adjustment to be excessively hard.

You can also try changing the canonicalization backend in the CVXPY solver options (i.e. problem.solve(canon_backend=cp.SCIPY_CANON_BACKEND) ), which would be an easy first step, but I found that swapping to the Fusion API was the key.

$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.