coin-or / pulp

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

Add warm start, gap retrieval and better solution statuses for SCIP_PY (pyscipopt) #624

Closed supremeBaboon closed 9 months ago

supremeBaboon commented 1 year ago

This PR aims to improve the SCIP_PY solver by :

  1. Adding a boolean warmStart parameter. When True, variables set to an initial value will be used by SCIP to fasten the optimization. In particular, one can warm start only a few variables, as SCIP does not need a complete solution to start from.
  2. Improving the solution statuses when a MIP reaches time or gap limit, as such cases are currently returned as LpStatusNotSolved, even when a feasible (but non optimal solution) exists. This correction is pretty similar to that of #473 for SCIP_CMD*.
  3. Adding a getGap method to retrieve SCIP's gap after an optimization. As SCIP is particularly verbose, I usually disable its logs, then using this method to still get a (concise) information about the optimization.

I have not made any unit test, but I have (sucessfully) tested those additions on a custom MIP on which I am working.

*Does anyone have any news about that PR ? It has been open for ~1 year and a half now, and looks almost complete...

CLAassistant commented 1 year ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

:white_check_mark: supremeBaboon
:x: agautier


agautier seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

supremeBaboon commented 1 year ago

I was initially pretty unsure about pyscipopt's warm start, since I've only found 2 related links : this one (whose formulation is used in this PR) and this one. Yet, after multiple tests, it seems to work just fine. The only downside I found lies in SCIP itself, as feeding it with only a few variables to warm start can 'freeze' it in finding a first solution from these initial values. In particular, SCIP can find a first solution faster without that partial initial solution (but its cost might be worse).

supremeBaboon commented 1 year ago

@pchtsp could you review this PR please ?

sam-slrx commented 1 year ago

@supremeBaboon have you run into any issues with this approach (specifically the solution statuses fix)? I'm planning on forking your fork :)

supremeBaboon commented 1 year ago

@sam-slrx Sorry for late answer, I've been using these changes extensively for the past 2 months and I've never encountered any issue, both for the warm-start and the solution statuses, so I assume it's safe to say they work as expected. Note however that I only tested those on MIP, not on LP.

pchtsp commented 1 year ago

I think you need to apply the black linter to the project, as explained here: https://coin-or.github.io/pulp/develop/contribute.html#applying-the-black-linter-formatter

supremeBaboon commented 1 year ago

@pchtsp done, is there anything more to do ?

pchtsp commented 1 year ago

looks good! It seems one contributor (agautier) has not signed the CLA. Once that's done, I can merge.

supremeBaboon commented 1 year ago

@pchtsp is it signed now ?

pchtsp commented 1 year ago

No, it's still pending.

image

pchtsp commented 1 year ago

image

supremeBaboon commented 1 year ago

But it keeps telling me it is signed

image

tmaarse commented 1 year ago

@supremeBaboon The last commit was made by agautier adrien.gautier@soprasteria.com, who hasn't signed the CLA yet. You might be able to replace their commit with one where you ran Black, or get them to sign it as well.