Setting parameters in pyomo

2019-09-01 04:41发布

问题:

I am using CPLEX with pyomo. I would like to set the parameter mip.limits.solutions = 1. How to do this with either .options( or .set_options( or any other way?

I have tried the following but nothing works:

   from pyomo.environ import *

   opt = SolverFactory("cplex")

   opt.set_options('miplimitssolutions=1')  # does not work
   opt.set_options('mip.limits.solutions=1')  # does not work

   opt.options['mip'] = 'limits'  # this works up to here but how to continue?

回答1:

Pyomo's (LP file-based) CPLEX interface passes options using CPLEX's "Interactive" API. In this case, the interactive version of that option is "mip limits solutions":

from pyomo.environ import *
opt = SolverFactory("cplex")
opt.options['mip limits solutions'] = 1