coin-or / SYMPHONY

SYMPHONY is an open-source solver, callable library, and development framework for mixed-integer linear programs (MILPs) written in C with a number of unique features
https://github.com/coin-or/SYMPHONY/wiki
Other
68 stars 17 forks source link

how to use SYMPHONY in python? #173

Closed redinton closed 4 years ago

redinton commented 4 years ago

Hi there, I think I might see the description in this link that SYMPHONY could be called by Pulp, a python-based platform. But I can't figure out how to call the SYMPHONY in Pulp, neither in the GitHub or the doc can I see the instructions. Can somebody help me out? thx!

tkralphs commented 4 years ago

Sorry, yeah, this is rather vague. There are two options:

  1. PuLP itself doesn't have a direct link to SYMPHONY at the moment, but you can still build a model in PuLP, then write it out to a file (using this function) and read it into SYMPHONY. This can be done within a single Python script so in that sense, you can use SYMPHONY with PuLP. However, some of the post-solve features of PuLP won't be available. It would be nice to see a PuLP interface to SYMPHONY, but I don't have much time to work on that.

  2. Another (probably better) option is to use DipPy, which is an extension of PuLP designed to handle block-structured MILPs and to support decomposition-based algorithms, such as Dantzig-Wolfe decomposition and Lagrangian relaxation. DipPy is built on top of DIP, which is a decomposition-based solver that has SYMPHONY embedded as a sub-solver. If you build a plain MILP in DipPy (which would be identical to building it in PuLP) and then set the parameter doDirect to True, then the instance will be solved directly with SYMPHONY instead of Dip. Basically, you build your model in DipPy, as in PuLP, and then call

    dippy.Solve(prob, {'doCut':'1','doDirect:'1'})

    One caveat is that the doDirect option doesn't seem to be working as it should right now. If this is of interest, I can check into it. to get DipPy, you need to install it with

    pip install coinor.dippy