尽管设置OutputFlag或LogToConsole参数为0时,Gurobi仍然可以打印许可证和/或计算服务器信息到标准输出:
计算服务器作业ID: 11a531ac-9fd9-453d-9c66-e4fc606f97de
可用容量'服务器:1234' -连接…
建立HTTP非加密连接
使用license文件/home/gurobiuser/ gurobier .lic
学术许可-仅用于非商业用途
这可能是不可取的,特别是在按顺序解决许多优化问题时。下面是防止Gurobi打印此信息的两种方法。
- 将OutputFlag或LogToConsole参数设置为0Gurobi环境已启动。为此,创建一个空的Gurobi环境,设置OutputFlag参数,然后启动环境。例如,在Python中可以这样做:
导入gurobipy作为gp
将gp.Env(empty=True)作为env:
env。setParam (OutputFlag, 0)
env.start ()
gp.Model(env=env)为m:
#在这里建立模型 - 创建一个gurobi.env文件(见参考手册),并在该文件中添加以下行:
OutputFlag 0
或LogToConsole 0
Gurobi自动在当前工作目录中查找Gurobi。env文件。如果找到一个参数,它就将列出的参数应用到新的Gurobi环境。只要有古罗比。Env文件和你的脚本在同一个目录下,你的脚本不需要显式地创建和启动一个空的环境:导入gurobipy作为gp
gp.Env()为env, gp.Model(env=env)为m:
#在这里建立模型