Closed
Description
The cplex interface reports a mipgap, but gurobi's does not
""" To RUN do something like:
cd pyomo/examples/pysp/sizes/models
cp ~/gapbug.py .
python gapbug.py
"""
import pyomo.environ as pyo
from ReferenceModel import model
def solve_and_report_migap(instance, solvername):
solve_keyword_args = {"tee": True, "load_solutions": False}
solver = pyo.SolverFactory(solvername)
solver.options["mipgap"] = 0.5
results = solver.solve(instance, **solve_keyword_args)
if len(results.solution) > 0:
absgap = results.solution[0].gap
else:
absgap = None
print ("Solver={}; absolute mipgap={}".format(solvername, absgap))
instance = model.create_instance("../SIZES3/Scenario1.dat")
solve_and_report_migap(instance, "cplex")
solve_and_report_migap(instance, "gurobi")