pulp icon indicating copy to clipboard operation
pulp copied to clipboard

How to configure pulp to use libCoinMP.so

Open ferranmc opened this issue 10 years ago • 13 comments
trafficstars

Hi,

I'm trying to setup pulp to work with the dynamic library from CoinMP in linux. I've downloaded and compiled the CoinMP project, but I am not able to setup pulp to use the dynamic libs. I've been looking at the documentation but it is not specified. Can you indicate where I can find some guidance on how to setup and test pulp with libCoinMP.so under linux?

I can use pulp with the cbc standalone, but I would like to have a faster interface between python and the solver as I generate a lot smalls models to be solved. In my case the overhead of accessing the solver through files is important. Will using the dynamic library speed up the data transfer between both programs?

Thanks in advance,

Ferran

ferranmc avatar Apr 17 '15 17:04 ferranmc

DipPy is a modeling language built on PuLP and includes a C extension that accesses Cbc in the way you describe. We didn't really have in mind that it would be used this way (it's purpose is to be an interface to the decomposition-based algorithms of DIP, which require an underlying MILP solver). However, the parameters of DIP can be set to allow the underlying solver (DIP, SYMPHONY, or CPLEX) to be called directly, bypassing DIP itself. This would do what you want. Let me do some testing and I'll post some instructions about how to make this work.

tkralphs avatar Apr 17 '15 22:04 tkralphs

@tkralphs Curious why is DIP not part of PuLP?

dassouki avatar Apr 17 '15 22:04 dassouki

DIP is a solution framework with an extensive underlying C++ library that can be used to build applications and as a command-line solver in itself (just like Cbc). It pre-dates PuLP and is much more than just a modeling language. The DipPy modeling language is only one small part of it that was added after it had already been developed for nearly a decade. DipPy was originally a free-standing project, but was incorporated into DIP so that the releases could be synchronized.

Hence, the reason DIP is not part of PuLP is basically the same reason that Cbc is not part of PuLP. On the other hand, DipPy is not part of PuLP because the C extension of DipPy really has to be developed in tandem with DIP itself.

tkralphs avatar Apr 17 '15 22:04 tkralphs

Actually, another way to do this, which I don't know how I forgot, is to use yaposib. This also has an associated C extension and can be used to link PuLP to any solver that has an OSI interface (see here.

It's a bit of a pain to build, mainly because it requires Boost Python, but I've managed to build it on Linux, OS X, and Windows. On Windows and OS X, it is a major undertaking (Linux was easy I think). When I find some time, I'll upload binaries for Windows to Pypi (this is the toughest platform on which to make it build). What OS are you on? Hopefully not OS X :).

tkralphs avatar Apr 18 '15 00:04 tkralphs

Hi Ted, Thanks for the feedback. I'm trying to get a minimal setup and yaposib seems to require a lot more than other options to get it installed. So even if it looks ok I think I'll need to stay either with pulp or dippy. I've finally managed to get pulp loading the coinmp_dll and from the code it seems it does interface directly to the C routines of the DLL. Is dippy interface faster than accessing the dll functions or gives some additional support? Just for me to consider if it is worth loading dippy on top of pulp.

Thanks

ferranmc avatar Apr 20 '15 13:04 ferranmc

I pretty much don't support CoinMP anymore as it is such a pain to build statically, and is not updated, does COIN_CMD (cbc commandline) not give you the performance you need?

stumitchell avatar Jun 03 '15 10:06 stumitchell

Hi Stuart,

At the moment I have to solve very small models but lots of them. The overhead of writing each model to disk and then run cbc externally is noticeable. Is there some way of sending the data back and forth cbc in a faster way?

Thanks a lot,

Ferran

On Wed, Jun 3, 2015 at 12:14 PM Stuart Mitchell [email protected] wrote:

I pretty much don't support CoinMP anymore as it is such a pain to build statically, and is not updated, does COIN_CMD (cbc commandline) not give you the performance you need?

— Reply to this email directly or view it on GitHub https://github.com/coin-or/pulp/issues/79#issuecomment-108287154.

ferranmc avatar Jun 03 '15 10:06 ferranmc

Have you tried using a ram disk?

stumitchell avatar Jun 03 '15 10:06 stumitchell

Hi Stuart,

I have not. I did some trials with pipes, but ram disk seems easier and more transparent. I will give it a try.

Thanks a lot,

Ferran

ferranmc avatar Jun 03 '15 10:06 ferranmc

try putting cbc on the ram disk as well for extra speed

stumitchell avatar Jun 03 '15 10:06 stumitchell

On Linux you can do ld --shared -o coinmp.so $(pkg-config --libs coinmp) and have PuLP load coinmp.so. You may need to use -rpath and PKG_CONFIG_PATH if CoinMP is installed outside the shared library path. That should be safe, although with CoinMP 1.8 it seems enough simply to load libCoinMP.so: it is linked to load its dependencies.

tkorvola avatar May 11 '16 08:05 tkorvola

I got the CoinMP solver to work by adding CoinMPPath to pulp.cfg.linux (with the same list of libraries as it appears in pulp.cfg.buildout) and editing the paths to the exact paths where the libraries are. (This has to be done before running setup.py install.) The solver fails the repeated names test (in pulpTestAll) but it solves the LPs I throw at it. I'm also using it to solve a lot of small LPs, and its runtime is about 1/3rd compared to using the default (CBC_CMD?) solver.

patrikhaslum avatar Dec 20 '16 04:12 patrikhaslum

See also pull request #105.

tkorvola avatar Dec 20 '16 10:12 tkorvola