Solving a TSP with the CPLEX C++ API.
git clone https://github.com/alberto-santini/cplex-example.git
.cd cplex-example
.mkdir build
.cd build
.cmake -DCPLEX_ROOT_DIR=</path/to/ilog> -DCMAKE_BUILD_TYPE=Debug ..
.
</path/to/ilog>/cplex/include/ilcplex/cplex.h
exists.-DCMAKE_CXX_COMPILER=</path/to/compiler>
.Debug
into Release
if you want to compile in release mode.make
../cplex_example
.The Graph
class (src/graph.h
) is a minimal description of a graph; it only stores the number of nodes and the distance matrix. The graph is created randomly, with nodes lying on a plane and euclidean distances. The Solver
class (src/solver.h
) does all the CPLEX magic: it builds the model, it solves it, and it prints the solution.
The present work is distributed under the terms of ghe GNU General Public License v3 (see the LICENSE
file).