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.
To suppress all Gurobi logging, including the license connection parameters, you can set the OutputFlag or LogToConsole parameter to 0 before the Gurobi environment is started. Specifically, you can do the following in Python:
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
# alternatively, to read the model from a file, you can use:
# with gp.read("glass4.mps", env) as model:
Note that this works when using a license file (gurobi.lic) that contains all license information. But you can also add all license parameters in the environment, for example:
with gp.Env(empty=True) as env:
env.setParam("OutputFlag", 0)
env.setParam("WLSAccessID", str)
env.setParam("WLSSECRET", str)
env.setParam("LICENSEID", int)
env.start()
with gp.Model(env=env) as model:
# Build the model here
Another option would be to create a gurobi.env file (see reference manual) in the current working directory of your script and add the following line to that file:
OutputFlag 0
or
LogToConsole 0
However, in order to also suppress all license and/or compute/token server information, all license parameters must be set in this gurobi.env file after the OutputFlag/LogToConsole parameter. If you are using a license file (gurobi.lic) instead, the logging of the license connection parameters is not suppressed, because a license file is read before the gurobi environment file.
When starting an environment, Gurobi reads parameters in the following order:
- Apply the parameters of the given environment (see Python code snippet above)
- Read a license file (if available and if license information not already set by 1)
- Read a gurobi.env file
Comments
0 comments
Article is closed for comments.