Cbc icon indicating copy to clipboard operation
Cbc copied to clipboard

Pulp misreporting objective and feasible solution on packaged CBC 2.10.3

Open paul-scott opened this issue 3 years ago • 8 comments

Details for the issue

What did you do?

Using pulp 2.5.0 with the packaged (PULP_CBC_CMD) CBC 2.10.3.

I attempt to solve an MIP with a timeLimit. The problem has an optimality gap of ~10% when it times out, according to the CBC messages. After returning the objective returned by pulp is massive (i.e., 100000000000000007629769841091887003294964970946560.00000000) and unrelated to the best feasible solution CBC was reporting. Similarly, while it reports "Optimal" the populated solution in pulp is not integer feasible despite CBC finding such solutions.

This is after running with a timeout of 90 seconds and branching to around 42000 nodes.

What did you expect to see?

The same values returned as CBC is reporting, including the best integer feasible solution found.

The following appears to be a problem specific to 2.5.0 using the packed CBC 2.10.3. I have tried the following combinations and all give the expected result:

  • pulp 2.5.0 with external CBC 2.9.9
  • pulp 2.5.0 with external CBC 2.10.5
  • pulp 2.4 with packaged CBC 2.9.0

I'm not sure if it is something wrong with CBC 2.10.3 itself (I haven't tried an independent compilation), or the way it is packaged in 2.5.0.

Sorry I can't provide a code example right now because this is a student assignment and I don't want to tempt them with some some solutions, but I can provide it in a couple of weeks after the due date.

Useful extra information

The info below often helps, please fill it out if you're able to. :)

What operating system are you using?

  • [ ] Windows: ( version: ___ )
  • [x] Linux: ( _distro: archlinux)
  • [ ] Mac OS: ( version: ___ )
  • [ ] Other: ___

I'm using python version:

  • [ ] 2.7
  • [ ] 3.4
  • [ ] 3.5
  • [ ] 3.6
  • [x] Other: 3.9

I installed PuLP via:

  • [x] pypi (python -m pip install pulp)
  • [ ] github (python -m pip install -U git+https://github.com/coin-or/pulp)
  • [ ] Other: ___ (conda?)

Did you also

  • [x] Tried out the latest github version: https://github.com/coin-or/pulp
  • [x] Searched for an existing similar issue: https://github.com/coin-or/pulp/issues?utf8=%E2%9C%93&q=is%3Aissue%20

paul-scott avatar Aug 20 '21 05:08 paul-scott

Hi, I found the similar (same?) problem today. Pulp reported "Stopped on time limit", but the status is "Optimal". I found that prob.status == pulp.LpStatusOptimal (this is same as the return value of prob.solve method), but prob.sol_status != pulp.LpSolutionOptimal (so i can check the status with this variable). These values are set here: https://github.com/coin-or/pulp/blob/master/pulp/apis/coin_api.py#L323 I don't know if it is expected behavior.

unnonouno avatar Aug 30 '21 17:08 unnonouno

Hey I think what you are describing is expected behaviour. If you take a look where the "constants" are defined you'll see that the regular "status" doesn't have an option for representing integer feasible solutions, while the "sol_status" does. I ran into this confusion also but looking at the code I concluded it was expected although unintuitive behaviour.

At the core of my problem I think is some numerical overflow or memory corruption issue...

paul-scott avatar Aug 31 '21 03:08 paul-scott

@paul-scott could you try exporting the mps file from pulp and then executing the packaged version of cbc via command line with this file as argument? This would help us see if the problem is in the packaged CBC or in PuLP itself.

pchtsp avatar Aug 31 '21 08:08 pchtsp

Actually this is also what I observed and reported in coin-or/pulp#474 . I close the other issue then

tomaszG247 avatar Aug 31 '21 13:08 tomaszG247

I exported a MPS file and then ran it through cbc 2.9.9 and the pulp-packaged cbc 2.10.3 with 90 second timeouts. I wrote the solution to a plain text solution file with the -solu cbc command line option. 2.9.9 works as expected, the packaged 2.10.3 doesn't:

First the cbc logging to stdout is making sense. It reports finding integer feasible solutions and making improvements on it. It is working up to the point where it prints out the summary statistics:

Result - Stopped on time limit

Objective value:                100000000000000007629769841091887003294964970946560.00000000
Lower bound:                    -169.697
...

Strangely enough the solution file has something different altogether:

Stopped on time - objective value -170.50753608
      0 bait_0_0              0.088757396                       0
      2 bait_0_2              0.088757396                       0
      3 bait_1_0             0.0066292593                       0
...

Those first few variables are binary so this isn't an integer feasible solution. Based on the reported objective this appears to be the solution of the linear relaxation at the root node (matching up with the other cbc logs). The 2.9.9 solution file has an integer feasible solution as expected.

So to summarise, this appears to be a problem in the packaged cbc 2.10.3. I still don't know if it is a problem with the packaged version itself (assuming you're compiling it specifically for pulp) or if it is an issue with that cbc release in general. I tried looking through the cbc project closed issues to see if there was something that got fixed for 2.10.5 but couldn't find anything obvious.

I could attempt to compile cbc 2.10.3 myself to see if it is the release vs the packaged version if you think that is useful? Otherwise perhaps just a cbc version bump in pulp is the simplest thing? Anyway I can send the mps file through in about 1 weeks time (once the assignment is complete!) if others want to take a look at it.

paul-scott avatar Sep 01 '21 00:09 paul-scott

can you check with 2.10.5 ??

otherwise you are suggesting we regress to 2.9.9 right?

stumitchell avatar Sep 01 '21 00:09 stumitchell

Ok I see in the first comment that 2.10.5 works, maybe worth reporting with the mps to cbc, as it might just have hit a code path in 2.10.3 that still needs to be fixed in 2.10.5 if there is no specific issue that seems to cover it.

stumitchell avatar Sep 01 '21 00:09 stumitchell

It is easy to directly transfer issues from PuLP to Cbc, which I will do, but it would be helpful to have the MPS file itself attached so we can replicate.

tkralphs avatar Sep 01 '21 15:09 tkralphs