An interface for using MILP solvers in C++

By Wolfgang Keller
Draft
Originally written 2018-10-01
Last modified 2024-01-03

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.9.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.

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.10. A free feature-reduced version of FICO Xpress Optimization called "FICO Xpress Optimization Community License" can be obtained at https://community.fico.com/s/fico-xpress-optimization-licensing-optio []. It has the following restrictions:

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 (i.e. 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.

Building GLPK under Windows

Run “x64 Native Tools Command Prompt for VS 2019” and switch to the subfolder w64 of where GLPK was extracted to. In the file Build_GLPK_with_VC14_DLL.bat (which you should best backup before), comment the lines (add a rem before each line)

set HOME="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC"

call %HOME%\vcvarsall.bat x64

and replace the lines

%HOME%\bin\nmake.exe /f Makefile_VC_DLL
%HOME%\bin\nmake.exe /f Makefile_VC_DLL check

by

nmake.exe /f Makefile_VC_DLL
nmake.exe /f Makefile_VC_DLL check

Remove the line

glp_netgen_prob

from glpk_5_0.def.

Run Build_GLPK_with_VC14_DLL.bat.

Finally, set an environment variable GLPK_DIR with the directory of GLPK.

Gurobi

Gurobi's homepage is https://www.gurobi.com/. The current version of Gurobi is 8.1.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.9) 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.9_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.9_dev_ux64.tar.gz. Additionally you might be interested in the following files:

Create an environment variable called LPSOLVE_DIR 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 (2.2.0) can be downloaded at http://www.mipcl-cpp.appspot.com/download.html. You want the file named mipcl-2.2.0.windows-x86_64.zip (under Windows). 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.

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