TSP在docplex python中的实现 [英] TSP implementation in docplex python
问题描述
使用IBM cplex工具,使用Dantzig-Fulkerson-Johnson公式,TSP是否有可用的python实现。
Is there any python implementation available of TSP using the IBM cplex tool, with Dantzig-Fulkerson-Johnson formulation.
如果有,我可以获取以下链接:
If there is any can I get the link for it?
推荐答案
此处。这是我的(略作修改的)答案:
The exact same question was asked here. Here is my (slightly modified) answer from there:
该发行版在Python中没有示例实现,但在OPL中有一个实现:安装中的opl / examples / opl / models / TravelingSalesmanProblem / tsp.mod
。
The distribution does not have an example implementation in Python, but there is one in OPL: opl/examples/opl/models/TravelingSalesmanProblem/tsp.mod
in your installation. This could serve as a good starting point when implementing things in Python.
在该示例中,问题被循环解决:在每次求解之后,子行程消除约束被分离。在Python中,您可能希望使用惰性约束回调来做到这一点。
In the example the problem is solved in a loop: after each solve, subtour elimination constraints are separated. In Python you would probably want to do this using a lazy constraint callback.
通常,子行程消除约束通常不直接添加到模型中,因为其中有成倍的约束
In general, subtour elimination constraints are usually not added directly to the model since there exponentially many of them.
这篇关于TSP在docplex python中的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!