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
518 stars 92 forks source link

Problems with mipstart #154

Open demnl opened 3 years ago

demnl commented 3 years ago

I don't think it is a bug but I am facing issues with the mipstart option of the cbc solver. I have a problem I would like to decompose into two steps and I would like to initialize the second problem with the results from the first step.

I attached the scripts for both problems (mip2151 for the first step and mip 2152 for the second one). The problem is quite small here but when I will succeed to pass an initial solution, I will significantly increase the size of the problem. script2152.txt script2151.txt

After solving the first problem, I saved the results into a .sol file with save_mipstart(mip_start, '.sol') attribute. Here is the content of this .sol file (mipstart2151_10.txt) However, when I introduce this file into the second problem with the following lines:

mip_start = load_mipstart('mipstart2151_10.sol')
var_list=[]
for name, value in mip_start:
    var = model.var_by_name(name)
    if var is not None:
        var_list.append((var, value))
model.start= var_list
model.validate_mip_start()

I get the following error message: NOT OK, optimization status: OptimizationStatus.INFEASIBLE Even with a one-period problem, I get the same message. Then, if I execute model.optimize() the results are exactly the same than without initialization (even the number of iterations and explored nodes), which let me think that the solver does not take into account the results from the first step. I don't know if it because the results are not indexed in the .sol file or if I missed some steps.

I am using Spyder to execute the script (Ipython version 7.12.0) and I have the version 1.9.3 of python-mip.

Thank you in advance for any advice or comment

sebheger commented 1 year ago

Maybe related to #107