CPLEX.jl icon indicating copy to clipboard operation
CPLEX.jl copied to clipboard

How to get the Solution Pool using Julia/CPLEX?

Open GiAbreu opened this issue 7 years ago • 18 comments

Hi everyone,

I need the solution pool for storing multiple solutions of a MIP model. I using Julia and the packages JuMP and CPLEX as a solver. So I need to collect solutions within a given percentage of the optimal solution but I don’t know how to do it in Julia, anybody can help me, please?

GiAbreu avatar Oct 23 '18 21:10 GiAbreu

I don't think it's available on the JuMP layer since it's solver specific. If you are ready to do a bit of hacking, then you can maybe try using setincumbentcallbackfunc of CPLEX.jl

IssamT avatar Oct 24 '18 13:10 IssamT

I set the parameters as explained on the IBM website, but I don't know how to call the populate solution pool. Using callbacks I only got the values ​of the objective function, best bound, numbers of nodes of B&B tree, but I need the values ​​of the multiple solutions for the variables that have the same objective function value, which means populate the solution pool.

GiAbreu avatar Oct 24 '18 19:10 GiAbreu

We now wrap CPXpopulate(model.env, model.lp), but there is still no nice way of accessing multiple solutions via MOI. Ideally, we would have something like the following:

model = CPLEX.Optimizer()
x = MOI.add_variable(model)
# ... model definition ...
MOI.optimize!(model)
CPXpopulate(model.env, model.lp)
for n = 1:MOI.get(model, MOI.ResultCount())
    x_n = MOI.get(model, MOI.VariablePrimal(n), x)
    println("Value of x in solution $(n) is $(x_n)")
end

This is all possible via the exposed C API, so it just needs some plumbing. I won't be implementing this, but I will leave the issue open for a motivated person in the community.

odow avatar Oct 05 '20 20:10 odow

Hi, are there updates on this issue? More and more solvers are now providing solution pools and it would be an useful feature Thank you

davide-f avatar Nov 16 '21 15:11 davide-f

@jd-foster worked out the details here: https://github.com/jump-dev/jump-dev.github.io/pull/58. It just needs implementing at the MOI level. PRs accepted.

odow avatar Nov 16 '21 18:11 odow