Skip to main content

How to suppress WLS license credentials from printing to console output?

Answered

Comments

3 comments

  • Riley Clement
    Gurobi Staff Gurobi Staff

    Hi William,

    I've tried a few different approaches, both using Gurobi and not using Gurobi, and this is good as I can get it:

    with gp.Env(params={"LogToConsole":0}) as env, gp.Model("my_model", env=env) as m:
        m.params.LogToConsole=1
        x = m.addVar()
        m.optimize()

    The idea is to turn logging to console off when the environment is started, which is when Gurobi will look to print WLS parameters, then turn it back on when you call optimize, so that you can see the output of the solver.

    With this approach you still get "WLS license - registered to ..." but your license ID won't be printed.

    There may possibly be an approach where you hook into sys.stdout and filter the output, but it is likely to be tedious if it exists.

    Can I ask what your motivation is for wanting to suppress these lines from the output?

    - Riley

     

    0
  • IGH
    First Comment

    One motivation for needing this is solving many optimizations in parallel/sequence. In my use-case, I have many thousands of jobs running simultaneously. Currently for ease of use I'm using a python file to execute the actual optimization, but am calling it within a jupyter notebook. Jupyter gets noticeably slower if you have a lot of things printed out. So it would be best for the sake of my notebook for any text to be surprised that isn't errors. 

    The easy solution is to redirect stdout during the optimization process, and then restoring it. However, it turns out that doing this in an interactive python environment like a jupyter notebook doesn't quite work how you would expect. 

    Point being, it would be nice if there was a simple way to suppress and I see no reason why I need to be reminded of my Academic license every time that I run an optimization. 

    0
  • Gwyneth Butera
    Gurobi Staff Gurobi Staff

    Have you had a chance to try the suggestions in the article How do I suppress all console output from Gurobi?

    0

Please sign in to leave a comment.