Skip to content

How to get multiple optimal solutions for MIP in CPLEX?

An answer to this question on Stack Overflow.

Question

I constructed a Mixed Integer LP using CPLEX Python API and also a brute force checking program (which solves an LP) using MATLAB. I found that for a particular random example that I created, brute force checking finds 2 optimal solutions i.e. same objective value. Let's call them A and B. However, CPLEX only finds one of them, for example A.

So I tried to set different values for these parameters:

model.parameters.mip.pool.capacity
model.parameters.mip.pool.intensity
model.parameters.mip.limits.populate
model.parameters.mip.pool.absgap
model.parameters.mip.pool.replace

and finally called model.populate_solution_pool(). This gives me solution B but it does not find A. Are there other ways to find more than 1 optimal solutions?

Answer

Perhaps you can:

  • Find one optimal solution
  • Add a term to your objective function that penalizes that solution
  • Check to see if there's another feasible solution that matches the value (to tolerance) of the previously found optimal solution. If so, repeat.