COIN-OR

COIN-OR is a collection of open source software for optimization. The official repository is www.coin-or.org.

This page collects introductory material and small examples that might be helpful to first time users. Most of the examples are related to BCP and Cbc, two packages for Branch-and-Cut and to Clp, one of the LP solvers available in COIN-OR.

If you are using (or planning to use) BCP as a pure Branch-and-Cut code (i.e. not using column generation), performance can be significantly improved by a few modification of the code. My favorite ones are available here.

It also mentions a cut generator for reduce-and-split cuts and interface to read and write LP files from the solvers.

Installing and Getting Started

The following are five small projects introducing basic operations of Clp, BCP and Cbc. The first project might be particularly useful to first time user, as it covers installation, generation of the html documentation and gives an overview of COIN-OR. Each project comes with a set of files serving as starting point for the associated project (for example, proj1.tar.gz) and an other set corresponding to the "solution" of the project (for example, proj1done.tar.gz). It is probably best to work the projects in sequence, as more advanced ones build on earlier ones.

These examples are written assuming that the underlying operating system is Linux Fedora 18 and using the bash shell. Adapting to others shells should be straightforward and most examples have also been used under Windows with cygwin installed. Before tackling projects 3 and 4, it is probably wise to spend time studying the BAC example.

Please note that while I will do my best to answer questions regarding installation and the material on this page, I can not guarantee reliable and fast answers to all kind of questions and problems that might arise. The best place to get help about COIN-OR in general is through the CoinHelp page and mailing lists of the COIN-OR repository.

The first four projects were initially developed for the Doctoral Course in Discrete Systems Optimization held at the Ecole Polytechnique Federale de Lausanne (Switzerland) in 2004. They are now based on the latest release versions (as of 1/1/14) Bcp-1.3.8 and Cbc-2.8.8.

Previous versions: Note: to compile older tar balls with gcc version 4.6.2 20111027 (Red Hat 4.6.2-1), it is necessary to add
#include < cstring >
at the top of Bcp/src/include/BCP_vector.hpp and CoinUtils/src/CoinSmartPtr.hpp.


BAC and SHELL Examples

The BAC example is a simple example illustrating basic features of BCP. It is part of the COIN-OR tree (in Bcp/examples/BAC) and is downloaded automatically when the BCP package of COIN-OR is downloaded.

The associated SHELL example is an almost empty example with a similar structure that can be used as a template for developing a new application.

For Bcp-1.3.8:
Note: to compile older tar balls with gcc version 4.6.2 20111027 (Red Hat 4.6.2-1), it is necessary to add
#include < cstring >
at the top of Bcp/src/include/BCP_vector.hpp and CoinUtils/src/CoinSmartPtr.hpp.

For Bcp-1.3.4: For Bcp-1.3.3: For Bcp-1.2.3: For Bcp-1.2.2: For Bcp-1.2.1: For Bcp-1.1.3:

Domcheck

Domcheck is a code for computing projections and removing redundancy in linear systems. It illustrates the use of the Lp solver Clp.

Reduce-and-Split cut generator

This generator implements a slight variation of the Reduce-and-Split cuts introduced in the paper by K. Anderson, G. Cornuejols, and Yanjun Li, "Reduce-and-Split Cuts: Improving the Performance of Mixed Integer Gomory Cuts", Management Science 51 (2005). It currently works only with the LP solver Clp of COIN-OR and Cplex. The generator is included in the cut generator library Cgl of COIN-OR. Assume that you have downloaded a COIN-OR package containing Cgl in the directory coin-Pkg and that the directory coin-Pkg/build is used for compiling and installing. After typing

make doxydoc

in coin-Pkg/build (assuming that Doxygen is installed on your machine), you can open in a browser coin-Pkg/doxydoc/html/index.html and find the documentation for CglRedSplit (Click on "Classes" at the top). If Doxygen is not available, read through Cgl/src/CglRedSplit/CglRedSplit.hpp or go to the Cgl documentation.


Support for LP files

COIN-OR has facilities for handling LP files. This code is included in the CoinUtils package of COIN-OR, and methods to use the LP file format are included in the Osi package. Assume that you have downloaded a COIN-OR package containing CoinUtils in the directory coin-Pkg and that the directory coin-Pkg/build is used for compiling and installing. After typing

make doxydoc

in coin-Pkg/build (assuming that Doxygen is installed on your machine), you can open in a browser coin-Pkg/doxydoc/html/index.html and find the documentation for CoinLpIO (Click on "Classes" at the top). If Doxygen is not available, read through CoinUtils/src/CoinLpIO.hpp or go to the CoinUtils documentation.

To read an LP file "any_name.lp" and write an LP file "aa.lp" using Clp, you can use:

OsiClpSolverInterface solver;
solver.readLp("any_name.lp");
solver.writeLp("aa", "lp", 1e-5, 10, 5);

And similarly with the other solvers working with Osi.

To get the optimal solution with associated names you can use:

solver->initialSolve();
const int numCols = solver->getNumCols();
const double *x = solver->getColSolution();

for (int j=0; j < numCols; j++){
    const char *name = solver->getColName(j);
    std::cout << name << " " << x[j] << "\n";
}

Note that a solver will lose names read from an Lp file except if its class derived from OsiSolverInterface has an implementation of the OsiSolverInterface::readLp() method dealing with names. The names used in the solver will be printed in an Lp file only if the derived class has an implementation of the OsiSolverInterface::writeLp() method dealing with names. Alternatively, you can use the method OsiSolverInterface::writeLpNative(). See the documentation of this method for more details.


Back to main page