coin-or / pulp

A python Linear Programming API
http://coin-or.github.io/pulp/
Other
2.05k stars 381 forks source link

using the MIPCL solver #213

Closed sdementen closed 4 years ago

sdementen commented 5 years ago

hello,

I read that the MIPCL solver is the fastest free MILP solver and that it can handle MPS files. Is there any interest to add the MIPCL solver to pulp ? and if so, how complex would that be ?

pchtsp commented 5 years ago

I'm interested, I haven't heard of it before. Do you have any benchmarks that compare it with CBC or SCIP or with commercial solvers? What license does it use?

Do you have the documentation link for the command line version of the solver?

F.

On Wed, Aug 14, 2019, 14:55 sdementen notifications@github.com wrote:

hello,

I read that the MIPCL solver is the fastest free MILP solver and that it can handle MPS files. Is there any interest to add the MIPCL solver to pulp ? and if so, how complex would that be ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=ABJUZ44FL2CE4EMKAB6BTQ3QEP6ENA5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HFGKZAA, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJUZ4YRDO7NAKEBLB24YH3QEP6ENANCNFSM4ILUSKKQ .

sdementen commented 5 years ago

The license is LGPL (des https://mipcl-cpp.appspot.com/licence.html). I haven't yet found the doc of the CLI but running the CLI will display the help message with enough details to start (see https://github.com/Pyomo/pyomo/issues/138#issuecomment-312118916 for a screenshot). Regarding performance, a Google search on "cbc mipcl cplex" returns the informs2018.pdf results comparing different solvers.

Btw, can the SCIP solver be called from pulp? I see https://github.com/msakai/pulp-scip/blob/master/pulp_scip.py but it looks unmaintained

pchtsp commented 5 years ago

Hey. Not sure about the SCIP interface, I have never tested it.

It should be fairly straightforward to add a new solver by using the "COIN_CMD" class in solvers.py ( https://github.com/coin-or/pulp/blob/master/src/pulp/solvers.py ) as example (or CPLEX_CMD or GUROBI_CMD, they all follow the same style).

I've taken a look at the site. An alternative to using the command I guess would be using the existing MIPCL-PY interface. Just like with CPLEX_PY and GUROBI classes.

I'm going to download it and give it a try.

F.

On Wed, Aug 14, 2019, 21:56 sdementen notifications@github.com wrote:

The license is LGPL (des https://mipcl-cpp.appspot.com/licence.html). I haven't yet found the doc of the CLI but running the CLI will display the help message with enough details to start (see Pyomo/pyomo#138 (comment) https://github.com/Pyomo/pyomo/issues/138#issuecomment-312118916 for a screenshot). Regarding performance, a Google search on "cbc mipcl cplex" returns the informs2018.pdf results comparing different solvers.

Btw, can the SCIP solver be called from pulp? I see https://github.com/msakai/pulp-scip/blob/master/pulp_scip.py but it looks unmaintained

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=ABJUZ4Y5DQ3YHV5KCOX6B4DQERPOBA5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4J5UNA#issuecomment-521394740, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJUZ46RNTEJ73HNC3LSPL3QERPOBANCNFSM4ILUSKKQ .

pchtsp commented 5 years ago

hey @sdementen if you want to try / give a look, I've made a branch with support for the solver MIPCL. https://github.com/pchtsp/pulp-or/tree/MIPCL.

There are a few things to do before doing a PR. Namely adding it to the tests suite and maybe getting a better status for the solution (optimal vs integer feasible).

You need to have the mps_mipcl executable in your PATH for it to work,

sdementen commented 5 years ago

That's fantastic! I'll try it a soon as I can (Monday at the latest) Thanks a lot!

sdementen commented 5 years ago

Hello @pchtsp , I have tried the solver and it works excepts for the objectif/direction of optimisation. I had to revert the sign of the objective (to maximise) to get the same solution as with the CBC solver

sdementen commented 5 years ago

In fact, changing the lp.sense doesn't change the solution (MIPCL solver always minimizing) even though I see at the beginning of the solver either

Reading data...
*SENSE:Maximize
NAME          lp

or

Reading data...
*SENSE:Minimize
NAME          lp

which is consistent with the lp.sense I am setting for each case

pchtsp commented 5 years ago

The problem is with the solver it is not possible to configure that in mps_mipcl. I need to raise an exception instead of solving if it's maximize.

It's up to the user to always change the objective sense.

On Sat, Aug 17, 2019, 08:55 sdementen notifications@github.com wrote:

In fact, changing the lp.sense doesn't change the solution (MIPCL solver always minimizing) even though I see at the beginning of the solver either

Reading data... *SENSE:Maximize NAME lp

or

Reading data... *SENSE:Minimize NAME lp

which is consistent with the lp.sense I am setting for each case

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=ABJUZ43UECLGC54DW3VT5OLQE6OE7A5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4QE7OA#issuecomment-522211256, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJUZ47OSE4OCTP3KHAJREDQE6OE7ANCNFSM4ILUSKKQ .

sdementen commented 5 years ago

Can the objective be negated while writing the MPS file in the solver class and negated back when reading from the mipcl output ?

On Sat, Aug 17, 2019, 10:47 Franco Peschiera notifications@github.com wrote:

The problem is with the solver it is not possible to configure that in mps_mipcl. I need to raise an exception instead of solving if it's maximize.

It's up to the user to always change the objective sense.

On Sat, Aug 17, 2019, 08:55 sdementen notifications@github.com wrote:

In fact, changing the lp.sense doesn't change the solution (MIPCL solver always minimizing) even though I see at the beginning of the solver either

Reading data... *SENSE:Maximize NAME lp

or

Reading data... *SENSE:Minimize NAME lp

which is consistent with the lp.sense I am setting for each case

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=ABJUZ43UECLGC54DW3VT5OLQE6OE7A5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4QE7OA#issuecomment-522211256 , or mute the thread < https://github.com/notifications/unsubscribe-auth/ABJUZ47OSE4OCTP3KHAJREDQE6OE7ANCNFSM4ILUSKKQ

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=AAJ6S5WVETZ3SQIIS5P564DQE63JNA5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4QGWJA#issuecomment-522218276, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJ6S5VW3G3SX7DBYK2G5Y3QE63JNANCNFSM4ILUSKKQ .

pchtsp commented 5 years ago

It thought about it. In fact only the first of both negations would be needed since we do not report the objective function value to the user. But the problem is that the log files / progress info would show different information from what the user expects and it would cause confusion, I think.

It's simplier to just tell the user to swap the sense by themselves.

F.

On Sun, Aug 18, 2019 at 11:48 AM sdementen notifications@github.com wrote:

Can the objective be negated while writing the MPS file in the solver class and negated back when reading from the mipcl output ?

On Sat, Aug 17, 2019, 10:47 Franco Peschiera notifications@github.com wrote:

The problem is with the solver it is not possible to configure that in mps_mipcl. I need to raise an exception instead of solving if it's maximize.

It's up to the user to always change the objective sense.

On Sat, Aug 17, 2019, 08:55 sdementen notifications@github.com wrote:

In fact, changing the lp.sense doesn't change the solution (MIPCL solver always minimizing) even though I see at the beginning of the solver either

Reading data... *SENSE:Maximize NAME lp

or

Reading data... *SENSE:Minimize NAME lp

which is consistent with the lp.sense I am setting for each case

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <

https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=ABJUZ43UECLGC54DW3VT5OLQE6OE7A5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4QE7OA#issuecomment-522211256

, or mute the thread <

https://github.com/notifications/unsubscribe-auth/ABJUZ47OSE4OCTP3KHAJREDQE6OE7ANCNFSM4ILUSKKQ

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=AAJ6S5WVETZ3SQIIS5P564DQE63JNA5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4QGWJA#issuecomment-522218276 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AAJ6S5VW3G3SX7DBYK2G5Y3QE63JNANCNFSM4ILUSKKQ

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=ABJUZ462OTS7KT7CPZEKLV3QFELHZA5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4Q4M6Y#issuecomment-522307195, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJUZ42UNW2DYJN737XTKCDQFELHZANCNFSM4ILUSKKQ .

sdementen commented 5 years ago

But then the burden is on the user shoulders and he/she cannot swap solvers easily. What puzzles me is the line

*SENSE:Maximize

Does it come from pulp? If so, this could be adapted to "maximize (objective sign flipped)". If not, does it come from mps_mipcl?

On Sun, Aug 18, 2019, 16:13 Franco Peschiera notifications@github.com wrote:

It thought about it. In fact only the first of both negations would be needed since we do not report the objective function value to the user. But the problem is that the log files / progress info would show different information from what the user expects and it would cause confusion, I think.

It's simplier to just tell the user to swap the sense by themselves.

F.

On Sun, Aug 18, 2019 at 11:48 AM sdementen notifications@github.com wrote:

Can the objective be negated while writing the MPS file in the solver class and negated back when reading from the mipcl output ?

On Sat, Aug 17, 2019, 10:47 Franco Peschiera notifications@github.com wrote:

The problem is with the solver it is not possible to configure that in mps_mipcl. I need to raise an exception instead of solving if it's maximize.

It's up to the user to always change the objective sense.

On Sat, Aug 17, 2019, 08:55 sdementen notifications@github.com wrote:

In fact, changing the lp.sense doesn't change the solution (MIPCL solver always minimizing) even though I see at the beginning of the solver either

Reading data... *SENSE:Maximize NAME lp

or

Reading data... *SENSE:Minimize NAME lp

which is consistent with the lp.sense I am setting for each case

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <

https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=ABJUZ43UECLGC54DW3VT5OLQE6OE7A5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4QE7OA#issuecomment-522211256

, or mute the thread <

https://github.com/notifications/unsubscribe-auth/ABJUZ47OSE4OCTP3KHAJREDQE6OE7ANCNFSM4ILUSKKQ

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <

https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=AAJ6S5WVETZ3SQIIS5P564DQE63JNA5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4QGWJA#issuecomment-522218276

, or mute the thread <

https://github.com/notifications/unsubscribe-auth/AAJ6S5VW3G3SX7DBYK2G5Y3QE63JNANCNFSM4ILUSKKQ

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=ABJUZ462OTS7KT7CPZEKLV3QFELHZA5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4Q4M6Y#issuecomment-522307195 , or mute the thread < https://github.com/notifications/unsubscribe-auth/ABJUZ42UNW2DYJN737XTKCDQFELHZANCNFSM4ILUSKKQ

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=AAJ6S5VIAVTK6G3CI2VULTDQFFKJVA5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4RA5AY#issuecomment-522325635, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJ6S5V5TK5BIGBB5IV47G3QFFKJVANCNFSM4ILUSKKQ .

pchtsp commented 5 years ago

Well, either way you have to adapt the options for each solver according to their format so plug and play is not perfect already in pulp (can definitively be improved). The SENSE:maximize comes from pulp. It’s part of the way it writes the mps file. But this is not interpreted by the mps_mipcl as far as I know. But I haven’t done much research.

You could ask the MIPCL people if there is a way to change the sense of the optimisation when using the mps_mipcl command and then we can adapt pulp for that. If not, we would have to create a wrapper for their python library… but that would surely take more time.

Finally, if you want to do experiments yourself, you can create the mps file by activating the keepFiles=True option when solving. Then editing the mps file and feeding it directly to the mps_mipcl solver and see how it responds.

Franco

On Sun, Aug 18, 2019 at 5:13 PM sdementen notifications@github.com http://mailto:notifications@github.com wrote:

But then the burden is on the user shoulders and he/she cannot swap solvers

easily. What puzzles me is the line

*SENSE:Maximize

Does it come from pulp? If so, this could be adapted to "maximize (objective sign flipped)". If not, does it come from mps_mipcl?

On Sun, Aug 18, 2019, 16:13 Franco Peschiera notifications@github.com wrote:

It thought about it. In fact only the first of both negations would be needed since we do not report the objective function value to the user. But the problem is that the log files / progress info would show different information from what the user expects and it would cause confusion, I think.

It's simplier to just tell the user to swap the sense by themselves.

F.

On Sun, Aug 18, 2019 at 11:48 AM sdementen notifications@github.com wrote:

Can the objective be negated while writing the MPS file in the solver class and negated back when reading from the mipcl output ?

On Sat, Aug 17, 2019, 10:47 Franco Peschiera <notifications@github.com

wrote:

The problem is with the solver it is not possible to configure that in mps_mipcl. I need to raise an exception instead of solving if it's maximize.

It's up to the user to always change the objective sense.

On Sat, Aug 17, 2019, 08:55 sdementen notifications@github.com wrote:

In fact, changing the lp.sense doesn't change the solution (MIPCL solver always minimizing) even though I see at the beginning of the solver either

Reading data... *SENSE:Maximize NAME lp

or

Reading data... *SENSE:Minimize NAME lp

which is consistent with the lp.sense I am setting for each case

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <

https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=ABJUZ43UECLGC54DW3VT5OLQE6OE7A5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4QE7OA#issuecomment-522211256

, or mute the thread <

https://github.com/notifications/unsubscribe-auth/ABJUZ47OSE4OCTP3KHAJREDQE6OE7ANCNFSM4ILUSKKQ

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <

https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=AAJ6S5WVETZ3SQIIS5P564DQE63JNA5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4QGWJA#issuecomment-522218276

, or mute the thread <

https://github.com/notifications/unsubscribe-auth/AAJ6S5VW3G3SX7DBYK2G5Y3QE63JNANCNFSM4ILUSKKQ

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <

https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=ABJUZ462OTS7KT7CPZEKLV3QFELHZA5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4Q4M6Y#issuecomment-522307195

, or mute the thread <

https://github.com/notifications/unsubscribe-auth/ABJUZ42UNW2DYJN737XTKCDQFELHZANCNFSM4ILUSKKQ

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=AAJ6S5VIAVTK6G3CI2VULTDQFFKJVA5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4RA5AY#issuecomment-522325635 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AAJ6S5V5TK5BIGBB5IV47G3QFFKJVANCNFSM4ILUSKKQ

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/coin-or/pulp/issues/213?email_source=notifications&email_token=ABJUZ4YMY5ZRZGHYAH4AQODQFFRIJA5CNFSM4ILUSKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4RCAGI#issuecomment-522330137, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJUZ42QAT562UJTVRUSCVDQFFRIJANCNFSM4ILUSKKQ .

pchtsp commented 4 years ago

Now there is a PR (https://github.com/coin-or/pulp/pull/245) with these changes. I've not yet done the objective sense swapping in case of a maximization. We just generate a PulpSolverError now.

In case we do flip it, we would have to, at the very least, show a warning to the user. On top of that we could:

  1. Just modify the lp object. This has the issue of modifying the problem while solving, which I don't like (for multiple reasons).
  2. Do a copy of the lp problem, do the modifications on that model and solve. This has the issue that the user may require performance and copying the object could take some (although little) time.

If someone has any other ideas, they're welcome.

pchtsp commented 4 years ago

As we discussed with @stumitchell , I have done option 1 above. So I close the issue. It is in PR https://github.com/coin-or/pulp/pull/263