python-mip icon indicating copy to clipboard operation
python-mip copied to clipboard

Changing preprocess parameter of model does not have any impact

Open sebheger opened this issue 4 years ago • 6 comments

Describe the bug When changing the preprocess-parameter of the model preprocess is still performed as default.

To Reproduce Set preprocess parameter to 0, still observe preprocess to be performed in the log of cbc

Expected behavior No preprocess, if parameter is set to 0.

Desktop (please complete the following information):

  • OSX 10.15.5
  • 3.5.4

sebheger avatar Jun 17 '20 12:06 sebheger

seems to work in 1.9.3, your version is 3.5.4 ? We do not support older releases (too few developers now), but I can help you to port a fix .

h-g-s avatar Jun 17 '20 21:06 h-g-s

ops, now I see that you probably referred to the Python version, well, if it is in 1.9.3, which message did you saw ?

h-g-s avatar Jun 17 '20 21:06 h-g-s

Hi @h-g-s,

3.5.4 is the python version. The corresponding mip version is 1.8.2 (we could not upgrade as long as the in-place operators are not reintroduced as mentioned in #108). I have recognized that you have updated the bug report template, that someone might not forget to give you both python and mip version ;-)

After some additional research, I recognized, that disabling preprocess is working correctly because I originally wanted to switch off presolve. This setting is need to get some of our models solved successfully (https://github.com/coin-or/Cbc/issues/305). But there is no parameter exposed in the mip interface.

So most likely the issue is not a bug, it is a feature request instead :-)

sebheger avatar Jun 18 '20 09:06 sebheger

Hi @h-g-s,

3.5.4 is the python version. The corresponding mip version is 1.8.2 (we could not upgrade as long as the in-place operators are not reintroduced as mentioned in #108). I've saw some code that was broken due to the remove of in-place operators. The code that I saw could be easily translated to a "more pythonic" style IMHO:

create LinExpr l for ... l += element for ... l += element m += l <= 10

could be replaced by m += xsum( some list comprehension here ) + xsum(another lc here) <= 10

So, I'm inclined to think that the speed gain obtained with the removal of these operators is not a big problem. If you have an example where in-place operators make the code clearer or more efficient please share with us.

I have recognized that you have updated the bug report template, that someone might not forget to give you both python and mip version ;-)

After some additional research, I recognized, that disabling preprocess is working correctly because I originally wanted to switch off presolve. This setting is need to get some of our models solved successfully (coin-or/Cbc#305). But there is no parameter exposed in the mip interface.

So most likely the issue is not a bug, it is a feature request instead :-)

Hmm, ok, presolve is the pre-processing for the LP solver in CBC. I'll add this option. One think, your model has only continuous variables or it is a mixed integer program ?

h-g-s avatar Jun 18 '20 13:06 h-g-s

Regarding the in-place operators: We as company with a set of complex optimization products, customers and use-cases (partially with a long historic development) as well as a set of different "developers" (from full python experts up to consultants with programming skills) could not upgrade to any new version easily if it is not compatible to existing code. It is not a true matter of speed or efficient code or good style. Porting our code would be a lot of work, otherwise we have to maintain a fork to extend this functionality, which is also not our primary intent. At the moment we are evaluating if cbc solver could be beneficial for our productive environment (as addition to the commercial solver), so that's why i am contributing to projects with our observations, because i see the potential.

The problem I have reported in https://github.com/coin-or/Cbc/issues/305 is an IP, no cont. variables at all. But as jjhforrest reported, the presolve mechanism makes the formulatiun "worse" for MIP solving. Switching it off (via console) solves the problem in reasonable time. That's why i also tried to switch it off in python-mip.

sebheger avatar Jun 18 '20 19:06 sebheger

Hi,

A quick hack to disable presolve is:

In cbc.py, before the line

    cbclib.Cbc_solve(self._model)

add cbc_set_parameter(self, "presolve", "off")

h-g-s avatar Jun 19 '20 15:06 h-g-s