Is there a way to monitor the value of the
mipgap while running an optimization model Pyomo? I would like to know how far I am from the optimality gap. Here is my code:
solver = SolverFactory('cbc', executable='path/to/cbc.exe') solver.options['mipgap'] = 1e-3 solver.options['tee'] = True solver.options['keepfiles'] = True results = solver.solve(Model, logfile='path/to/logfile.log')
I can report the last value of mipgap AFTER solver is finished as follows:
__data = results.Problem._list LB = __data.lower_bound UB = __data.upper_bound __gap = abs(UB - LB) * 100/max(0.1, abs(UB)) print(__gap)
But this is not what I am looking for. I am looking for a sort of live streaming from
solver which updates me about the current value of the
mipgap; then I can determine how far I am from the optimality; or whether there is any progress in the model.