我在Python上使用Gurobi,我的代码需要一个Model.optimize()函数循环.有没有办法静音这个功能,所以它不会产生段落的输出?
谢谢.
解决方法:
将Output Flag参数设置为零.
从输出标志的参考手册:
Enables or disables solver output. Use LogFile and LogToConsole for
finer-grain control. Setting OutputFlag to 0 is equivalent to setting
LogFile to “” and LogToConsole to 0.
我正在处理的项目中的代码块:
from gurobipy import Model, GRB, LinExpr, quicksum
dual_subproblem = Model('dual_subproblem_(0,0)')
dual_subproblem.setParam('OutputFlag', 0) # Also dual_subproblem.params.outputflag = 0
dual_subproblem.params.threads = 1
dual_subproblem.modelSense = GRB.MAXIMIZE
dual_subproblem.update()
然后,优化调用不会产生任何输出.
我希望这有帮助.