Cplex Python API 中间 LB 和 UB 打印输出

Cplex Python API intermediate LB and UB printout

我希望使用 docplex 求解 python 中的 TSP,并希望在 CPLEX Optimization Studio 中开发类似于统计图的东西,并为找到的每个可行解打印出下限和上限。

The results I wish to receive from the engine, but using docplex

我最初的想法是应用“model.solve_details.mip_relative_gap”,但它只打印出最优解的最后差距。我希望找出如何在优化过程中调用此结果,但我没有成功,因为我对 Python 的经验很少。任何提示将不胜感激。

我的代码的基本逻辑如下:

`from docplex.mp.model import Model 
model = Model("My_model") 
#(...add_constraints...) 
model.minimize(My_objective_function) 
solution = model.solve() 
status = model.solve_details.mip_relative_gap 
print(status) 
print(model.solution)`

IBM 论坛也有人问过这个问题:https://www.ibm.com/mysupport/s/forumsquestion?id=0D50z00006abxNkCAI

查看此处描述的进度侦听器:

https://github.com/IBMDecisionOptimization/docplex-examples/blob/master/examples/mp/jupyter/progress.ipynb

此 API 让您可以在 MIP 求解过程中接收和处理信息,特别是绘制进度曲线。