A (Runner-Kaleidoscope compatible) C++ framework for Combinatorial Optimization research.
Some common tasks are done in many algorithms for solving Combinatorial Optimization problems. Generally, Mixed Integer Linear Programming (MILP) is used to deal with such cases. Dealing with MILP solvers some times is not a straightforward task, and it can add some noise to the actual code that is needed to solve the problem.
GOC is a C++ library that comes with classes and functions to ease the process of writing code for MILP. Its main contributions are the following:
- Abstraction from a specific MILP Solver by definitions of model and solver interfaces.
- Standardization of the output of solvers and compatibility with Kaleidoscope formats.
- Some collection util functions such as printing and JSON serialization functions for STDLIB.
- Graph and Digraph classes, designed for a trade-off between performance and cleanness of code.
- Math related objects: Interval, Linear Function, Piecewise Linear Function, Point2D, etc.
- String resources.
- Time handling functions and classes.
To view the full documentation of the library visit the Wiki.
The following instructions will guide you through the steps to have GOC compiled and ready to use.
- CPLEX >=12.8 (more info)
- Boost Graph Library >=1.66 (more info)
- On Linux:
sudo apt-get install libboost-all-dev
- On Linux:
- CMake >=2.8.4 (more info)
- On Linux:
sudo apt-get install cmake
- On Linux:
- C++14 or higher (more info)
- Download the code folder.
- Add two environment variables to bash with CPLEX include and library paths.
export CPLEX_INCLUDE=<path_to_cplex_include_dir>
- Usually on Linux: /opt/ibm/ILOG/CPLEX_Studio<VERSION>/cplex/include
export CPLEX_BIN=<path_to_cplex_lib_binary_file>
- Usually on Linux: /opt/ibm/ILOG/CPLEX_Studio<VERSION>/cplex/lib/x86-64_linux/static_pic/libcplex.a
- Add two environment variables to bash with BOOST Graph Library include and library paths.
export BOOST_INCLUDE=<path_to_boost_include_dir>
- Usually on Linux: /usr/include
export BOOST_BIN=<path_to_boost_lib_binary_file>
- Usually on Linux: /usr/lib/x86_64-linux-gnu/libboost_graph.a
- Run:
cmake .
- Run
make
- A compiled library file libgoc.a should be generated.
Note: the environment variables can be added permanently by adding those lines to the /etc/environment file.
- Add a lib/goc/ directory to your project.
- Copy the include folder of GOC to the lib/goc directory.
- Copy the libgoc.a file to the lib/goc/ directory.
- Add the include folder to your CMakeLists.txt file
include_directories(lib/goc)
- Link the goc library to your executables in CMakeLists.txt
target_link_libraries(<executable_name> lib/goc/libgoc.a)
- Include goc in your C++ files using
#include <goc/goc.h>
- GOC library is ready to use.
We include a series of examples on the usage of the different solvers with their different options. The examples include:
- Fractional Knapsack: Example of solving the fractional knapsack using a Linear Programming solver.
- 0-1 Knapsack: Example of solving the 0-1 knapsack using a Branch a Bound solver.
- Traveling Salesman Problem: Example of solving the TSP using a branch and bound solver with lazy constraints.
- Vertex Coloring Problem (BC): Example of solving the vertex coloring problem using a branch and cut algorithm.
- Vertex Coloring Problem (CG): Example of an algorithm to get a lower bound on the chromatic number of a graph using column generation.
- Download GOC repository.
- Add two environment variables to bash with CPLEX include and library paths.
export CPLEX_INCLUDE=<path_to_cplex_include_dir>
- Usually on Linux: /opt/ibm/ILOG/CPLEX_Studio<VERSION>/cplex/include
export CPLEX_BIN=<path_to_cplex_lib_binary_file>
- Usually on Linux: /opt/ibm/ILOG/CPLEX_Studio<VERSION>/cplex/lib/x86-64_linux/static_pic/libcplex.a
- Add two environment variables to bash with BOOST Graph Library include and library paths.
export BOOST_INCLUDE=<path_to_boost_include_dir>
- Usually on Linux: /usr/include
export BOOST_BIN=<path_to_boost_lib_binary_file>
- Usually on Linux: /usr/lib/x86_64-linux-gnu/libboost_graph.a
- Run
cmake .
on the root directory. - Run
make
. - Run the example executable.
Gonzalo Lera-Romero
This project is licensed under the MIT License - see the LICENSE.md file for details