Search code examples
pythonpyomocoin-or-cbc

How to turn off Pyomo Problem/Solver Information


I am using Pyomo to solve a problem which is running recursively in colab and there are over 1000 such linear equations.

I want to turn off all the Problem and Solver Information. I tried solutions provided here : how to make pyomo silent (verbosity 0) when solving a model but it isn't working for me.

TransformationFactory('gdp.chull').apply_to(Model)

SolverFactory('cbc').solve(Model, tee=False).write()

Here's a screenshot of the output which I want to turn off. Solver Information


Solution

  • It is silent (non-verbose) by default, I believe.

    You are getting the above because you are commanding it to .write() the result. Just use .solve() without the command to write the results.

    CAUTION: You must check the solver status on each solve or you risk junk results. I believe the command below works well for use with CBC

    solver = pyo.SolverFactory('cbc')
    result = solver.solve(model)
    assert(result.Solver()['Termination condition'].value == 'optimal')