Skip to content

Make CVXOPT optional  #289

Closed
Closed

Description

@robertmartin8

@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.

Originally posted by @phschiele in #284 (comment)

Activity

  1. added
    maintenance
    on Feb 17, 2021
  2. robertmartin8 commented on Feb 17, 2021

    @robertmartin8
    CollaboratorAuthor

    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 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.

  3. phschiele commented on Feb 17, 2021

    @phschiele
    Contributor

    @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:

    if solver not in cp.installed_solvers():

    to

    if solver is not None and solver not in cp.installed_solvers():

    Both approaches seem fine to me.

  4. added a commit that references this issue on Feb 18, 2021
  5. linked a pull request that will close this issuev1.4.1 #299on Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintenance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions