How to cancel the print log when using "bonmin" solver?

257 views
Skip to first unread message

Xiaoxue Zhang

unread,
Jan 6, 2022, 3:57:44 AM1/6/22
to CasADi
Dear all,

When I use "bonmin" solver to solve an MINLP, it always displays the following log info, as shown in the following figures. 

I don't need these log info. Could you help me to stop printing it? Thank you!

Screenshot 2022-01-06 at 12.54.25 AM.png
Screenshot 2022-01-06 at 12.54.37 AM.png

Aygün Baltaci

unread,
Jan 10, 2022, 10:10:44 AM1/10/22
to CasADi
Hello, 

My research on the internet brought me to the conclusion that it is not possible to completely turn off the print logs on bonmin. Instead, I overwrite the standard output in Python to turn off the print logs on the terminal right before and after solving the nlp problem (based on the answer in [1]): 

def blockPrint():
    sys.stdout = open(os.devnull, 'w')

def enablePrint():
    sys.stdout = sys.__stdout__

...
blockPrint()
solution = opti.solve()
enablePrint()

If you don't want to turn off that way, there are some CasADi and bonmin parameters that can turn off some of these print outs to a certain level: 

opts['print_time'] = 0
opts[args.solver]['print_level'] = 0 # up to 12 level verbosity
opts[args.solver]['sb'] = "yes" # no ipopt banner
opts[args.solver]['bb_log_level'] = 0
opts[args.solver]["nlp_log_level"] = 0
opts[args.solver]["nlp_log_at_root"] = 0
opts[args.solver]["oa_log_level"] = 0
opts[args.solver]["lp_log_level"] = 0
opts[args.solver]["fp_log_level"] = 0
opts[args.solver]["milp_log_level"] = 0



Best Regards
Aygün
Reply all
Reply to author
Forward
0 new messages