Despite setting the OutputFlag or LogToConsole parameters to 0, Gurobi may still print license and/or compute server information to the standard output:
Compute Server job ID: 11a531ac-9fd9-453d-9c66-e4fc606f97de
Capacity available on 'server:1234' - connecting...
Established HTTP unencrypted connection
Using license file /home/gurobiuser/gurobi.lic
Academic license - for non-commercial use only
This can be undesirable, especially when solving many optimization problems in sequence. Below are two ways to prevent Gurobi from printing out this information.
To suppress all Gurobi logging including the license connection parameters, you can set the parameter OutputFlag or LogToConsole to 0 on an empty environment before it is started. Please note that this only works if you set these parameters before starting the environment.
Specifically, you can do the following in Python:
with gp.Env(empty=True) as env:
env.setParam("WLSAccessID", str)
env.setParam("WLSSECRET", str)
env.setParam("LICENSEID", int)
env.setParam("OutputFlag", 0)
env.start()
# To read the model from a file, you can use:
# with gp.read("glass4.mps", env) as model:
with gp.Model(env=env) as model:
# Build the model here
- To suppress all Gurobi logging including the license connection parameters, you can set the parameter OutputFlag or LogToConsole parameter to 0 before the Gurobi environment is started. To do this, create an empty Gurobi environment, set the OutputFlag parameter, and then start the environment. For example, in Python this can be done as follows:
import gurobipy as gp
with gp.Env(empty=True) as env:
env.setParam('OutputFlag', 0)
env.start()
with gp.Model(env=env) as m:
# Build model m here - Create a gurobi.env file (see the reference manual) in the current working directory of your script and add the following line to that file:
OutputFlag 0
orLogToConsole 0
Gurobi automatically looks in the current working directory for a gurobi.env file. If it finds one, it applies the listed parameters to new Gurobi environments. As long as there is a gurobi.env file in the same directory as your scripts, your scripts don't need to explicitly create and start an empty environment:import gurobipy as gp
with gp.Env() as env, gp.Model(env=env) as m:
# Build model m here
Comments
0 comments
Please sign in to leave a comment.