问题
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?
回答1:
The exact same question was asked here. Here is my (slightly modified) answer from there:
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.
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.
来源:https://stackoverflow.com/questions/60513452/tsp-implementation-in-docplex-python