coin-or / python-mip

Python-MIP: collection of Python tools for the modeling and solution of Mixed-Integer Linear programs
Eclipse Public License 2.0
525 stars 92 forks source link

Saving models with SOS in LP format don't work #107

Open bonelli opened 4 years ago

bonelli commented 4 years ago

Hi there, my problem has quite a lot of SOS of type 1 (mutually exclusive), and when I save it (CBC solver) in LP format it doesn't create a SOS section.

Here is a link with reference to that SOS section: https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/FileFormats/topics/LP_MIP.html

I haven't looked at the CBC code yet, might this be an issue with python-mip or is it for sure a CBC issue?

h-g-s commented 4 years ago

Recently I'm talking with the CBC wizard @jjhforrest to learn more about the CBC SOS1 and 2 implementations.

More specifically considering the problem of saving it to a file, I think that it is probably due to a design issue: the code to save LP is in the Osi/CoinUtils library, while the SOS are added in the CBC Library CbcSOS class. Cbc depends on CoinUtils and Osi (but not the contrary, or we would have a cyclic dependency). What do you think @tkralphs , @svigerske ?

Edit1: Just learning that CoinUtils has a CoinSets implementation to store SOS, I'll probably have to use CoinUtils CoinLPIo directly instead of loading/saving using OsiSolverInterface.

Edit2: Looking at the OsiSolverInterface readLp code, I'm wondering why the SOS readed in CoinLPIo are not used there. Is there an specific reason or it was just not implemented ?

h-g-s commented 4 years ago

Just saw that CoinLPIO has support for SOS, I'll check where it stores it...

svigerske commented 4 years ago

CoinUtils shouldn't have to store SOS in a CbcSOS class, but within some datastructure that lives in CoinUtils. The same for all other things (semicontinuous, indicator, quadratic, nonlinear instructions, etc) that are supported by the formats that CoinUtils can read or write (LP, MPS, GMPL, AMPL .nl). But in reality, things are distributed over several projects, sometimes even using global variables.

There are also a number of issues regarding the LP, MPS, and GMPL readers (https://github.com/coin-or/CoinUtils/issues) which are open for a long tme. That may give you some idea how well these things are maintained.