How to suppress WLS license credentials from printing to console output?
回答済みEvery time I call the Gurobi API, I always get my WLS credentials printed. For instance, if I do model.write_iis() in Python, it outputs the WLS credentials at the top. How do you suppress this from printing to the console?
-
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 -
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 -
Have you had a chance to try the suggestions in the article How do I suppress all console output from Gurobi?
0
サインインしてコメントを残してください。
コメント
3件のコメント