You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@robertmartin8 That's a good point. When running the discrete allocation without any MI solvers (or only ECOS_BB), cvxpy raises a very informative error, detailing the issue. It also provides two quick fixes to the user:
Quick fix 1: if you install the python package CVXOPT (pip install cvxopt),
then CVXPY can use the open-source mixed-integer solver `GLPK`.
Quick fix 2: you can explicitly specify solver='ECOS_BB'. This may result
in incorrect solutions and is not recommended.
One could even go one step further and catch it early, but I do not think that would add a lot of value.
Another approach would be to switch the default MI solver to either CPLEX or XPRESS. Both run the tests just fine and I never had an issue with installation. Check the cvxpy Docs for the limitations. Even though they are installing the free editions by default, some users might have issues with closed source dependencies for various reasons.
I think the simplest fix is just to make CVXOPT optional like matplotlib and sklearn. Then, in the body of lp_portfolio, I'll check if GLPK_MI is installed and raise a warning/error if not.
It would indeed be easier to just wrap CVXPY's error message, but I don't think that's possible given the current design of lp_portfolio: it requires an argument specifying the solver, so there is no situation in which problem.solve() will be called with no explicit solver.
@robertmartin8 Sounds like a good plan.
I'd probably not check for GLPK_MI directly, but just if the specified solver (which must not be None), so advanced users can provide their own solver (this is already how it is implemented).
If one would like to allow None (i.e. let CVXPY check for available solvers), one would just have to change one line:
Activity
robertmartin8 commentedon Feb 17, 2021
New thread (based on #284) to reduce clutter.
I think the simplest fix is just to make CVXOPT optional like matplotlib and sklearn. Then, in the body of
lp_portfolio, I'll check ifGLPK_MIis installed and raise a warning/error if not.It would indeed be easier to just wrap CVXPY's error message, but I don't think that's possible given the current design of
lp_portfolio: it requires an argument specifying the solver, so there is no situation in whichproblem.solve()will be called with no explicit solver.phschiele commentedon Feb 17, 2021
@robertmartin8 Sounds like a good plan.
I'd probably not check for
GLPK_MIdirectly, but just if the specified solver (which must not beNone), so advanced users can provide their own solver (this is already how it is implemented).If one would like to allow
None(i.e. let CVXPY check for available solvers), one would just have to change one line:to
Both approaches seem fine to me.
Made cvxopt optional (#289)