Search code examples
pythoncplexdocplexdocplexcloud

TSP implementation in docplex 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?


Solution

  • 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.