14

Whenever I run Python cvsopt solver in terminal, it will print:

     pcost       dcost       gap    pres   dres
 0: -8.0742e+00 -7.3715e+00  3e+03  5e+01  4e-15
 1: -6.6241e-01 -7.2834e+00  7e+01  1e+00  3e-15
......
Optimal solution found.

Can I silent this message? Thank you!

2 Answers2

19

Just add the following line before calling the solvers:

solvers.options['show_progress'] = False
sym44
  • 77
  • 5
sjm
  • 191
  • 1
  • 3
7

You may need to pass options specific to the particular solver you're using. For example, to silent the cvxopt LP solver output for GLPK: add the option

options={'glpk':{'msg_lev':'GLP_MSG_OFF'}}

E.g. result = cvxopt.solvers.lp(c, G, h, A, b, solver='glpk', options={'glpk':{'msg_lev':'GLP_MSG_OFF'}}). You may be better off using a less radical reduction of output, cf. http://glpk-java.sourceforge.net/apidocs/org/gnu/glpk/GLPKConstants.html for all allowed message levels.

FlorianH
  • 600
  • 7
  • 18
  • This did not work for me. I even combined this answer with sjm 's answer and it still prints out everything. – loganjones16 Apr 13 '19 at 16:51
  • @loganjones16 `solvers.lp(c, A, b, options={'show_progress': False})` works for me. But specifying the solver `solver='glpk'` messes it up for some reason. – Roland Pihlakas Feb 10 '20 at 17:50