An interface for using MILP solvers in C++

By Wolfgang Keller
Last modified 2018-10-01

Table of contents

Obtaining and setting up the solvers

In this text, we consider the following MILP solvers:

CPLEX

The homepage of CPLEX Optimizer/CPLEX Optimization Studio is https://www.ibm.com/analytics/data-science/prescriptive-analytics/cplex-optimizer. The current version of CPLEX Optimization Studio is 12.8.0. If you are associated with an academic instituion, you can obtain a free license at https://ibm.onthehub.com/WebStore/ProductSearchOfferingList.aspx?srch=cplex after registering. If not, you can obtain the “Community Edition - Free Trial” version of CPLEX from https://www.ibm.com/products/ilog-cplex-optimization-studio/details. According to https://www.ibm.com/products/ilog-cplex-optimization-studio/pricing this version has the following limits for the model size:

As I understand this website one can alternatively obtain a time-limited trial without these limits upon request (but the “Community Edition - Free Trial” seems to have no time limit). You might ask how large this time limit is and how one can obtain this alternative free (trial) version. This information is rather well-hidden on the IBM website, but at https://www.ibm.com/developerworks/community/blogs/jfp/entry/free_cplex_trials?lang=en one can find an answer: the evalutation period of this version is 90 days and after that one can get an “extended evalutation”. This site also contains information how one can obtain these versions. But consider this just as some bit of additional information to facilitate your own search.

The installation of CPLEX Optimization Studio itself should be straight-forward. The installer should set an environment variable called CPLEX_STUDIO_DIR128 that points to the installation folder. Check that it is set correctly. So far so easy. Unlickily the header files of CPLEX contain a bug that reveals itself as soon as one uses the library of CPLEX Optimizer with Visual Studio 2017. Under https://www.ibm.com/developerworks/community/forums/html/topic?id=db967164-b2f9-448f-816a-1cbdc710a994 one can find a solution for this bug:

FICO Xpress Optimization

The homepage of FICO Xpress Optimization is http://www.fico.com/en/products/fico-xpress-optimization. The current version is 8.5.3. A free feature-reduced version of FICO Xpress Optimization called "FICO Xpress Optimization Community License" can be obtained at http://subscribe.fico.com/xpress-optimization-community-license. It has the following restrictions (according to the website where you land as soon as you register for the download):

If you want to do experiments with FICO Xpress Optimization's nonlinear solver, the following additional restrictions apply:

The installation should be straight-forward. The installer should set an environment variable called XPRESSDIR that points to the installation folder. Check that it is set correctly.

GLPK

GLPK's homepage is https://www.gnu.org/software/glpk/. Its current version is 4.65.

Very important: GLPK is licensed under GPLv3. Contrary to popular belief this does not mean that all the code that we write will be “infected” to be under GPLv3 license, too. For this consider that there are two possibilities of how one can create new works from existing ones:

Creating a Sammelwerk is possible under § 4 UrhG, Absatz 1, which says:

“(1) Sammlungen von Werken, Daten oder anderen unabhängigen Elementen, die aufgrund der Auswahl oder Anordnung der Elemente eine persönliche geistige Schöpfung sind (Sammelwerke), werden, unbeschadet eines an den einzelnen Elementen gegebenenfalls bestehenden Urheberrechts oder verwandten Schutzrechts, wie selbständige Werke geschützt.”

The following is my attempt to give a rough translation of this into English:

(1) Collections of works, data or other independent elements, which are because of the choice or ordering of the elements a personal intellectual creation (Sammelwerke [collections]), are, notwithstanding a possibly existing Urheberrecht [I refuse to translate “Urheberrecht” with “copyright”, since these are subtly different concepts] or a related intellectual property right [the German word “Schutzrecht” literally means “protection right”] of the individual elements, protected like independent works.

(if this sounds confusing to you: in German it is not uncommon to write sophisticated texts in such a style; most German laws are written in a similar style).

Luckily our code structure allows our code to be a Sammelwerk: The code is divided into a frontend and for each solver a backend. These are all individual works. Only the backend that we write to use GPLK is not independent from GLPK (e.g. it cannot be independently run without GLPK) and is thus a derived work of GPLK. Thus the only code that has to be licensed under the GNU General Public License, Version 3 (GPLv3) license, is the code for our GPLK backend. Not one single line of code more.

Gurobi

Gurobi's homepage is https://www.gurobi.com/. The current version of Gurobi is 8.0.1. There exist two ways to obtain a Gurobi license for free:

The installation of Gurobi should be straight-forward. The installer should set an environment variable called GUROBI_HOME that points to the installation folder. Check that it is set correctly.

lp_solve

lp_solve's homepage is http://lpsolve.sourceforge.net/. The current version (5.5.2.5) can be downloaded at https://sourceforge.net/projects/lpsolve/files/. For an overview of the various files cf. http://lpsolve.sourceforge.net/5.5/distribution.htm. If you work on Windows, you need the file lp_solve_5.5.2.5_dev_win64.zip. For GNU/Linux (Ubuntu 64 bit; note that GNU/Linux is not yet supported in our MILP solver interface) you need lp_solve_5.5.2.5_dev_ux64.tar.gz. Additionally you might be interested in the following files:

Create an environment variable called LPSOLVEDIR that points to the folder where you unzipped lp_solve_5.5.2.5_dev_win64.zip to.

MIPCL

MIPCL's homepage is http://www.mipcl-cpp.appspot.com/. The current version (1.4.1 for Windows, 1.6.1 for GNU/Linux) can be downloaded at http://www.mipcl-cpp.appspot.com/download.html. You want the file named mipcl-1.4.1.windows-x86_64.zip (or mipcl-1.6.1.linux-x86_64.tar.gz if you work under GNU/Linux; note that GNU/Linux is not yet supported in our MILP solver interface). The installer will set an environment variable called MIPCLDIR that points to the installation folder. Check that it is set correctly.

Important: On MIPCL: What Are The License Terms? [visited 2018-06-06T11:36:58Z], MIPCL's author Nicolai Pisaruk claims that MIPCL is released under the GNU Lesser Public License (LGPL). Indeed as part of the MIPCL distribution, one can find a copy of the LGPLv3 license. But no source code of MIPCL's library functions is provided in the MIPCL distribution (except for the functions that are implemented in the header file). So MIPCL is (despite deviatingclaims by MIPCL's author Nicolai Pisaruk) not an open source solver.

Remarks concerning various MILP solvers

Cbc

Since it is our impression that Cbc (https://projects.coin-or.org/Cbc) is more difficult to get to run under Windows, for now we do do not support it. But we do plan to support it in the future.

SAS/OR

We could not find any way how one can obtain a free (as beer) copy of SAS/OR (https://www.sas.com/en_us/software/or.html) that has no time limit (this is important, since we want to run a testsuite on all supported solvers after every important change). Thus we do not support it.

SCIP

If you have an overview about current MILP solvers, you might notice that SCIP ( http://scip.zib.de/) is missing in the list. This omission is a conscious decision by us. The reason lies in the fact that the ZIB Academic License (http://scip.zib.de/academic.txt), under which SCIP is distributed, explicitly requires the user to be a member of an institution that is both noncommercial and academic. This is an even harsher restriction on the users than what the producers of other commercial MILP solvers demand.

So we can only encourage people to stay far away from SCIP as long as this license restriction is not erased.

Which solver to choose?

On Decision Tree for Optimization Software [visited 2018-06-05T19:45:07Z], one can find benchmarks for various MILP solvers.

Desired features for an MILP solver interface

Feature descriptions

We clearly would like the following features for such an interface:

Implementation in the solvers' APIs

We now consider how the mentioned solvers implement these features in their APIs.

CPLEX

TODO

FICO Xpress Optimizer

TODO

Gurobi

TODO

GLPK

TODO

lp_solve

MIPCL

TODO

Implementing the interface

Frontend

TODO

Backend

TODO

CPLEX

TODO

FICO Xpress Optimizer

TODO

GLPK

TODO

Gurobi

TODO

lp_solve

TODO

MIPCL

TODO

Test cases

TODO