On Windows 10, I have CBC installed through the coin-or optimization suite, but cvxpy raises a SolverError which complains "The solver CBC is not installed.".
I added the path to the CBC executable to my path to no avail. Being able to specify the executable of a solver would make things much easier (Pyomo already supports this).
problem.solve(solver='CBC', executable='path/to/solver')
ok, I just did some digging and found out that using CBC requires cylp to be installed.
First of all, it would be nice to provide a more specific error message, e.g.
try:
import cylp
except ImportError:
raise SolverError("cylp is required for CBC to work.")
Besides, cylp is well known for being poorly maintained and being a nightmare to install. Just have a look at this issue to understand how painful that is.
Since CBC is one of the few open-source MIP solvers, this is a huge blocker in terms of usability of cvxpy.
I understand developing and maintaining a CBC interface is probably a lot of work, but this is enough for me not to want to rely on cvxpy in production.
Thanks for pointing out the issues with cylp. Is there a different Python interface to CBC that would be better? I looked at how Pyomo interfaces with CBC and that's not an approach we can reasonably maintain.
ok, thanks for checking that. Again, it is completely understandable that maintaining a full CBC interface might not be sustainable.
I'm not aware of any alternatives, therefore the best approach is probably to work with cylp and try to get/help its developers to achieve the following:
pip install cylp should just work on any system)As a general suggestion, they might want to work with conda to make their own life easier: if numba can be installed through conda in a super straightforward way, I assumed it should also be possible to achieve the same with cylp.
Did you know CPLEX has a free edition that you can install with pip and conda? I just learned this.
yes, if I'm not wrong it's limited to 1000 variables and 1000 constraints, not something I am comfortable settling with. I think pushing an upgrade of cylp is the way to go.
Thank you for the support anyway - and the nice work on DCP/cvxpy.
I'm starting to try to fix some of the issues in CyLP, but I'm not sure how far I'll get before I run out of time. In the meantime, https://github.com/tuliotoffolo/python-mip is a newly implemented project that aims to provide some of the same functionality and is robustly maintained. It will be in COIN-OR soon.
@tkralphs this is great. Thanks for the effort on cylp and for pointing out python-mip, it looks like a very valid alternative indeed. It's good to know it will be included in COIN-OR, I was actually surprised that COIN-OR basically dropped support for CBC in Python.
I guess it's up to @SteveDiamond to see how much work it would be to switch dependency to python-mip. My two cents is that relying on a library written in modern Python is going to be way easier, especially since support for cylp still seems to be very limited.
By the way, the installation of python-mip seems quite straightforward through pip, and it should even install CBC for the user, which is a massive improvement.
@GiorgioBalestrieri do you want to take a stab at a python-mip interface? The only file you need to modify is the Cbc interface in cvxpy/reductions/solvers/conic_solvers/cbc_conif.py. The changes would be minor, just translating the CyLP API to the python-mip API. There are already unit tests for the interface in test_cbc.py.
@SteveDiamond I'd be very happy to help, but I have zero experience developing solver interfaces and right now I'm very time constrained, so I don't want to commit to something I might not be able to deliver. I also don't use cvxpy very much so it's honestly not a very high priority for me.
This being said, I think cvxpy is a great project and it would be very beneficial to make it easier to install and deploy.
At some point in April I'll be able to have a proper look at this and see if it's something I can realistically do at a level you want cvxpy to rely on.
I guess the python-mip developers would probably be interested as well in seeing their tool being used by cvxpy. I'm not sure who drives COIN-OR strategically, but it would probably make sense to align with them and make sure we take advantage of synergies here.
For what it's worth, I now have CyLP working in Python 3.7 and there are binary wheels for Python 3.6 and 3.7 for Windows that should work out of the box. Wheels are more difficult on OS X and Linux, but I can try to make the install a bit easier there. Building Cbc from source on those platforms is pretty straightforward and it should be possible to completely automate the downloading and building of source. Take a look at https://github.com/coin-or/CyLP/pull/67. I don't want to over-promise, but I guess I can keep CyLP going forward now for a while.
Most helpful comment
For what it's worth, I now have CyLP working in Python 3.7 and there are binary wheels for Python 3.6 and 3.7 for Windows that should work out of the box. Wheels are more difficult on OS X and Linux, but I can try to make the install a bit easier there. Building Cbc from source on those platforms is pretty straightforward and it should be possible to completely automate the downloading and building of source. Take a look at https://github.com/coin-or/CyLP/pull/67. I don't want to over-promise, but I guess I can keep CyLP going forward now for a while.