how can we suppress warnings, pyomo + ipopt / jupyter

1,912 views
Skip to first unread message

Michel Jadoul

unread,
Aug 29, 2017, 3:50:17 AM8/29/17
to Pyomo Forum
Hello,

I have been struggling to suppress warnings when solving NLP with Pyomo+Ipopt .
I don't want to receive such messages, as this is not very nice, specially when there are many:

WARNING - Loading a SolverResults object with a warning status into model=unknown; message from solver=Ipopt 3.7.1\x3a 
Converged to a locally infeasible point. Problem may be infeasible.

I would instead prefer to handle these things myself without displaying any message.
(like removing these results from my calculations)
I tried things like:
  • opt.solve(model, options="print_level=0")
  • opt.options["print_level"] = 0
  • and many other that I don't even remember any more
Would you know how I can silence Pyomo+Ipopt ?

Thanks a lot,

Michel

Siirola, John D

unread,
Aug 29, 2017, 1:03:59 PM8/29/17
to pyomo...@googlegroups.com

Michel,

 

The warning is being tossed by Pyomo and not the solver, so setting the solver options will not suppress the warning.  The solution is to tell pyomo itself to suppress warnings.  The magic incantation is:

 

    import logging

    logging.getLogger('pyomo.core').setLevel(logging.ERROR)

 

That will suppress ALL warnings generated by Pyomo core components (technically, it suppresses everything with severity less than “ERROR”). 

 

Now having said that, you pointed out a bug in Pyomo – that specific warning hadn’t been moved over to use the Python logging functionality and is a hard-coded print statement.  I *just* changed it on master, so if you are feeling brave and want to live on the bleeding edge, you can check out the master branch from github.  Otherwise, that will be available in the next release, which hopefully will be out “soon” (probably within a couple weeks).

 

john

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michel Jadoul

unread,
Aug 30, 2017, 5:19:08 AM8/30/17
to Pyomo Forum
Thanks for this useful information.
Michel
Reply all
Reply to author
Forward
0 new messages