robertmartin8 / PyPortfolioOpt

Financial portfolio optimisation in python, including classical efficient frontier, Black-Litterman, Hierarchical Risk Parity
https://pyportfolioopt.readthedocs.io/
MIT License
4.25k stars 928 forks source link

What's the best solver? #522

Closed nicorne closed 1 year ago

nicorne commented 1 year ago

I understand that the default solver for convex problems is the CVXOPT solver, while for non-convex problems, the default is the SLSQP from scipy. However, I'm not sure if these are the best choices for my problem, and I would appreciate any advice or recommendations.

My portfolio optimization problem involves the following features:

Should I consider using a commercial solver like CPLEX or are there open-source solvers that would be suitable? Also, are there any other considerations that I should take into account when selecting a solver?

Any guidance or recommendations would be greatly appreciated. Thank you!

nicorne commented 1 year ago

Update: Using CVXPY, there is no default solver, I got mistaken by the convex_objectiveand nonconvex_objective in base_optimizer.py. I should have dug deeper into the question before posting here... CVXPY is designed to automatically select a solver for a given problem based on the problem characteristics. See docs.

I am still interested in your experiences with different solvers for portfolio optimization. Thanks :)

88d52bdba0366127fffca9dfa93895 commented 1 year ago

I'll give my thoughts:

  1. There is no best solver, but commercial solvers are more likely to successfully solve optimization problems.
  2. Yes, you are right, there is no default solver in CVXPY.
  3. With your requirements above, you could use this library.

However, if you have many constraints or any constraint is too strict, then the optimization problem may be difficult to optimize. In this case, you should use commercial solvers.

I hope this is helpful.