gpt4 book ai didi

python - 如何禁用 PuLP 的计算日志

转载 作者:行者123 更新时间:2023-11-30 22:53:19 27 4
gpt4 key购买 nike

我在Python中使用“pulp”和GUROBI来解决一些优化问题。例如GUROBI的计算日志为:

Optimize a model with 12 rows, 25 columns and 39 nonzeros
Coefficient statistics:
Matrix range [1e+00, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [1e+00, 1e+00]
RHS range [1e+00, 1e+00]
Found heuristic solution: objective 12
Presolve removed 3 rows and 12 columns
Presolve time: 0.00s
Presolved: 9 rows, 13 columns, 27 nonzeros
Variable types: 0 continuous, 13 integer (13 binary)

Root relaxation: objective 7.000000e+00, 11 iterations, 0.00 seconds

Nodes | Current Node | Objective Bounds | Work
Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time

* 0 0 0 7.0000000 7.00000 0.00% - 0s

Explored 0 nodes (11 simplex iterations) in 0.00 seconds
Thread count was 4 (of 4 available processors)

Optimal solution found (tolerance 1.00e-04)
Best objective 7.000000000000e+00, best bound 7.000000000000e+00, gap 0.0%
('Gurobi status=', 2)

我想禁用此输出,因为我要解决 800k 优化问题,并且在输出中写入这些日志会使我的代码太慢。有禁用这些日志的想法吗?

最佳答案

您需要显式声明一个求解器,因此替换此行

p.solve()

有了这个

p.solve(PULP_CBC_CMD(msg=0))

或将“PULP_CBC_CMD”替换为您正在使用的任何解算器。

关于python - 如何禁用 PuLP 的计算日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38237449/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com