https://github.com/normalhuman01/cplex-implementation
a simple solving a tsp with cplex c++ api
https://github.com/normalhuman01/cplex-implementation
Last synced: about 1 year ago
JSON representation
a simple solving a tsp with cplex c++ api
- Host: GitHub
- URL: https://github.com/normalhuman01/cplex-implementation
- Owner: normalhuman01
- License: gpl-3.0
- Created: 2024-01-16T18:53:33.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-16T19:56:44.000Z (over 2 years ago)
- Last Synced: 2025-02-01T12:45:25.109Z (over 1 year ago)
- Language: C++
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Small CPLEX C++ API tutorial
## Prerequisites
* CPLEX must be installed, of course. Academics can obtain it via the [IBM Academic Initiative](https://developer.ibm.com/academic/).
* You also need a modern version of GCC, that supports at least [C++14](https://en.wikipedia.org/wiki/C++14).
## Compile and run
* Get the code: `git clone https://github.com/normalhuman01/cplex-implementation.git`.
* Move to the new directory: `cd cplex-implementation`.
* Create a build directory: `mkdir build`.
* Move to the build directory: `cd build`.
* Run cmake: `cmake -DCPLEX_ROOT_DIR= -DCMAKE_BUILD_TYPE=Debug ..`.
* The path to your CPLEX installation must be such that `/cplex/include/ilcplex/cplex.h` exists.
* If your compiler is in a non-standard location, you can use `-DCMAKE_CXX_COMPILER=`.
* Change `Debug` into `Release` if you want to compile in release mode.
* Run make: `make`.
* Run the executable: `./cplex_implementation`.
## Structure
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.
## License
The present work is distributed under the terms of ghe GNU General Public License v3 (see the `LICENSE` file).