ampl / mp

An open-source library for mathematical programming
https://mp.ampl.com
Other
229 stars 42 forks source link

Wrong solve_result_num in Gurobi solution pool #219

Open 4er4er4er opened 1 year ago

4er4er4er commented 1 year ago

The attached run file uses gurobiasl to find 5 MIP solutions. Then it reads the resulting .sol files one at a time. The solve_result and solve_result_num values are all solved and 0 as expected:

ampl: include multmip_pool.run
Gurobi 10.0.2: ams_stub=multmip
ams_mode=2
ams_limit=5
Gurobi 10.0.2: optimal solution; objective 235625
468 simplex iterations
76 branch-and-cut nodes
plus 34 simplex iterations for intbasis
Alternative MIP solution 1, objective = 235625
Alternative MIP solution 2, objective = 237125
Alternative MIP solution 3, objective = 238225
Alternative MIP solution 4, objective = 239900
Alternative MIP solution 5, objective = 242025
5 alternative MIP solutions written to "multmip1.sol"
... "multmip5.sol".
Alternative solutions do not include dual variable values.
Best solution is available in "multmip1.sol".

suffix npool OUT;
solve_result = solved
solve_result_num = 0

Alternative MIP solution 1, objective = 235625
solve_result = solved
solve_result_num = 0

Alternative MIP solution 2, objective = 237125
solve_result = solved
solve_result_num = 0

Alternative MIP solution 3, objective = 238225
solve_result = solved
solve_result_num = 0

Alternative MIP solution 4, objective = 239900
solve_result = solved
solve_result_num = 0

Alternative MIP solution 5, objective = 242025
solve_result = solved
solve_result_num = 0

When option solver gurobiasl; is replaced by option solver gurobi; the solutions are the same, and the solve_result and solve_result_num values reported by the solver are the same. But the values taken from the .sol files are incorrectly reported as solved? and 100:

ampl: include multmip_pool.run
Gurobi 10.0.2: sol:stub=multmip
sol:poolmode=2
sol:poollimit=5
Gurobi 10.0.2: optimal solution; objective 235625
423 simplex iterations
58 branching nodes

suffix nsol OUT;
suffix npool OUT;
solve_result = solved
solve_result_num = 0

Gurobi 10.0.2: Alternative solution; objective 235625
solve_result = 'solved?'
solve_result_num = 100

Gurobi 10.0.2: Alternative solution; objective 237125
solve_result = 'solved?'
solve_result_num = 100

Gurobi 10.0.2: Alternative solution; objective 238225
solve_result = 'solved?'
solve_result_num = 100

Gurobi 10.0.2: Alternative solution; objective 239900
solve_result = 'solved?'
solve_result_num = 100

Gurobi 10.0.2: Alternative solution; objective 242025
solve_result = 'solved?'
solve_result_num = 100

(Note also that the messages about the solution pool from gurobiasl are longer -- but also more informative -- than the messages from gurobi.)

glebbelov commented 1 year ago

Changing as follows:

ampl: include multmip_pool__mp.run
Gurobi 10.0.2:   sol:stub = multmip
  sol:poolmode = 2
  sol:poollimit = 5
Gurobi 10.0.2: optimal solution; objective 235625
331 simplex iterations
68 branching nodes
5 alternative solution(s)
  with objective values 242025..235625
  written to multmip1.sol..multmip5.sol.

suffix nsol OUT;
suffix npool OUT;
solve_result = solved
solve_result_num = 0

Gurobi 10.0.2: Alternative solution 1, objective 235625
solve_result = solved
solve_result_num = 0

Gurobi 10.0.2: Alternative solution 2, objective 237125
solve_result = solved
solve_result_num = 0

Gurobi 10.0.2: Alternative solution 3, objective 238225
solve_result = solved
solve_result_num = 0

Gurobi 10.0.2: Alternative solution 4, objective 239900
solve_result = solved
solve_result_num = 0

Gurobi 10.0.2: Alternative solution 5, objective 242025
solve_result = solved
solve_result_num = 0

The solve status of the alternative solutions is going to be that of the final solution.