Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up the solver() #70

Closed
lemon234071 opened this issue Feb 14, 2022 · 11 comments
Closed

Speed up the solver() #70

lemon234071 opened this issue Feb 14, 2022 · 11 comments

Comments

@lemon234071
Copy link

Is there any method to make the solve() faster, for example to use multi cpu or gpu?

@dcajasn
Copy link
Owner

dcajasn commented Feb 14, 2022

Hi @lemon234071,

It depends on the solver that you choose. To reduce computation time is better to use a commercial solver like GUROBI, CEPLEX or MOSEK. All of them offer academic licenses, but personally I prefer MOSEK because its academic license is less restrictive and also supports all kind of cones. On the other hand, for linear models GUROBI is a little faster in academic version but has more restrictions in the number of variables and constraints.

Best,
Dany

@lemon234071
Copy link
Author

Hi @lemon234071,

It depends on the solver that you choose. To reduce computation time is better to use a commercial solver like GUROBI, CEPLEX or MOSEK. All of them offer academic licenses, but personally I prefer MOSEK because its academic license is less restrictive and also supports all kind of cones. On the other hand, for linear models GUROBI is a little faster in academic version but has more restrictions in the number of variables and constraints.

Best, Dany

I found that the rp.Portfolio() has the default self.solvers = ["ECOS", "SCS", "OSQP", "CVXOPT"].
So, all i need to do is change it like self.solvers = ["MOSEK"] ? Will there any hidden danger?

@dcajasn
Copy link
Owner

dcajasn commented Feb 14, 2022

I use these solvers by default because are open source and are installed by default with CVXPY.
Yes, that's the idea but first you must install MOSEK and get an academic license in its website. If you see Entropic Value at Risk tutorial, I use MOSEK to reduce computation time.

@lemon234071
Copy link
Author

Thank you first, i just tried MOSEK with just pip install MOSEK . It faster but it return the None solution while other solvers return a weights....

@dcajasn
Copy link
Owner

dcajasn commented Feb 14, 2022

It's because you need a valid license. In riskfolio-lib install instructions are the links to get an academic license.

@lemon234071
Copy link
Author

Thank you very much i ll try it.

@lemon234071
Copy link
Author

lemon234071 commented Feb 15, 2022

It works thank you very much, btw, did you try the Cvxpylayers on GPU? Would it be faster???

@dcajasn
Copy link
Owner

dcajasn commented Feb 15, 2022

No, I didn't try cvxlayers. I use a Macbook air, so I don't have a GPU to try cvxlayers, but based on the information I read on papers, blogs and forums; commercial solvers like GUROBI, CPLEX, XPRESS and MOSEK are the best.

@dcajasn dcajasn closed this as completed Feb 15, 2022
@lemon234071
Copy link
Author

Thank you very much!

@lemon234071
Copy link
Author

lemon234071 commented Feb 18, 2022

Hello there, me again! Thank you for your time first!

I still have some problems with the speed:

1, With constraints "upperlng“ and “nea”, my problem should be solved with numerical methods.
Do the different objective functions heavily affect the speed?
(i mean I saw that optimization of sharpe is realized by minimizing the risk with constraints. I mean do the different forms of the function with constraints will be solved by different methods detected by mosek?).
2, Do the parameters of Mosek affect the speed and the performance? (i mean in self.sol_params)

My sincerest thanks!
Best wishes!

Some info with cvxpy
2cfc64328c420bb16bcaf4cb126d876

@dcajasn
Copy link
Owner

dcajasn commented Feb 18, 2022

  1. Yes
  2. Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants