[英]How to extract CBC elapsed time in Pulp?
Is there any command to extract the CBC elapsed time with pulp?有没有用纸浆提取CBC经过时间的命令?
With using prob.solve(pulp.PULP_CBC_CMD(msg=True))
we can have the details of the process in the log.使用
prob.solve(pulp.PULP_CBC_CMD(msg=True))
我们可以在日志中获得该过程的详细信息。 But I was wondering if there is any command to extract the elapsed time and write it into a file.但我想知道是否有任何命令可以提取经过的时间并将其写入文件。
if you do prob.solutionTime
you should get the time it took to solve the problem measured by pulp (not necessarily the one reported by CBC but probably close).如果你做
prob.solutionTime
你应该得到解决由纸浆测量的问题所花费的时间(不一定是 CBC 报告的问题,但可能接近)。
A complete example:一个完整的例子:
from pulp import *
prob = LpProblem("test", const.LpMinimize)
x = LpVariable("x", 0, 4)
y = LpVariable("y", -1, 1)
z = LpVariable("z", 0)
w = LpVariable("w", 0)
prob += x + 4 * y + 9 * z, "obj"
prob += x + y <= 5, "c1"
prob += x + z >= 10, "c2"
prob += -y + z == 7, "c3"
prob += w >= 0, "c4"
prob.solve()
print(prob.solutionTime)
If you want a way to parse the CBC log files, then you could check this library I made that returns a dictionary from a CBC, GUROBI or CPLEX log file: https://github.com/pchtsp/orloge如果您想要一种解析 CBC 日志文件的方法,那么您可以查看我创建的这个库,它从 CBC、GUROBI 或 CPLEX 日志文件返回字典: https://github.com/pchtsp/orloge
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.