6

I've been using Gurobi to solve an MILP problem, and Pyomo for generating the model. Gurobi supports returning a Solution pool, and I want to be able to generate multiple solutions using this pool. Is this supported in Pyomo?

I've tried using model.solCount, and model.params.SolutionNumber, but I found out that it works for gurobipy models, and not models in Pyomo.

Is it possible to somehow load(iteratively) these solutions into the model? If it isn't, what are my other options, if I have to do this with Pyomo?

Suhas Pai
  • 63
  • 4

1 Answers1

1

You should be able to use Gurobi's feature of writing solution files to disk. Just set the parameter SolFiles to some name and Gurobi will save all solutions:

from pyomo.opt import SolverFactory
opt = SolverFactory('gurobi')
opt.options['Solfiles'] = 'solution'
mattmilten
  • 6,242
  • 3
  • 35
  • 65
  • The does not return multiple solutions at optimum, it returns admissible variable values found along the path to optimum – DeepNet Jun 09 '21 at 09:08
  • You didn't specify this condition in your question. You need to use a different setting for [PoolSearchMode](https://www.gurobi.com/documentation/9.1/refman/poolsearchmode.html) then. – mattmilten Jun 09 '21 at 09:40