如何设置 Pyomosolve() 方法的超时?更具体地说,告诉 pyomo,在 x 秒后,返回当前找到的最优解?
所以我能够通过 pyomo 文档找到答案,我认为分享会有所帮助。
设置 Pyomo 的超时时间solve()
method:
solver.solve(model, timelimit=5)
然而这会抛出pyutilib.common._exceptions.ApplicationError: "Solver (%s) did not exit normally" % self.name )
如果求解器没有终止。我真正想要的是通过timelimit
我的解算器的选项。就我而言cplex
求解器,代码如下:
solver = SolverFactory('cplex')
solver.options['timelimit'] = 5
results = solver.solve(model, tee=True)
More on pyomo https://software.sandia.gov/downloads/pub/pyomo/PyomoOnlineDocs.html#SolverOpts and cplex 文档 http://www-01.ibm.com/support/knowledgecenter/SSSA5P_12.2.0/ilog.odms.cplex.help/Content/Optimization/Documentation/CPLEX/_pubskel/CPLEX1072.html.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)