Learn through the super-clean Baeldung Pro experience:
>> Membership and Baeldung Pro.
No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.
Last updated: March 18, 2024
In this tutorial, we’ll test a few open-source solvers for mixed integer programming.
In mixed integer programming (MIP), we optimize an objective function that has at least one integer argument. For example:
(1)
Solving MIP problems can be demanding. We use specialized solvers to find their optimal solutions. Ready-to-use solvers offer several benefits:
Using an off-the-shelf solver means we don’t have to code them from scratch, which saves time. However, with many solvers available, it’s hard to choose or even identify the best one.
We focus on three commonly used free and open-source MIO solvers:
We’ll evaluate each solver on a benchmark instance of problem instances, running every solver on every instance ten times. In doing so, we’ll record the optimality gap and solving time. The former is the relative difference between the found and optimal values:
(2)
We calculate the optimality gap as the difference between the objective value of the best-known feasible solution (or current solution) and the optimal objective value (i.e., best bound). The solving time is the time a solver takes to produce an output.
To account for statistical fluctuations and randomness, we’ll compare the solvers using the median gaps and their median deviations since medians are less sensitive to outliers than means.
We used the following standard benchmark instances consisting of:
Additionally, we evaluated the solvers on Equation (1) while varying the problem size.
We used the default settings of each solver in Python.
Evaluating MIP solvers on different problem sizes serves several purposes, including:
Let’s check the results.
We added to Equation (1) a generic linear constraint of the form:
(3)
where size is the problem size because increasing it makes the search space larger.
As the problem size increases, the solution time for each solver shows a non-monotonic behavior. Both COIN-OR CBC and PuLP have a sharp increase up to around a size of 50, after which their solving time varies within more or less the same interval:
GLPK shows a stable behavior with a deviation of around seconds and was also the fastest. COIN-OR CBC and PuLP were slower than GLPK and had comparable performances to one another.
All the solvers found the optimal solution in all the runs.
When it comes to time, each solver’s time varies on the instance:
There doesn’t seem to be a significant difference in median times ( median absolute deviations).
However, we can see that their deviations differ in the cases of bnatt500 and neos-631710. PuLP shows more time variability on the latter, while its variability is roughly the same as for CBC on the former. In general, if the median solving times are similar for a bunch of solvers, we prefer the one whose time is variable the least.
Let’s summarize the results:
| Criterion | COIN-OR CBC (s) | GLPK (s) | PuLP (s) |
|---|---|---|---|
| Time vs. problem size | – | ✓ | – |
| Median time | ✓ | ✓ | ✓ |
| Median gap | ✓ | ✓ | ✓ |
Overall, GLPK outperformed other solvers on our custom example in terms of solving time. The solvers’ overall performances on the four benchmark instances are approximately the same.
However, using different benchmarks or different optimization formulations might lead to other results.
In this article, we described some open-source mixed integer optimization solvers. These solvers are suitable for solving problems in many areas due to their accuracy and scalability. We compared three open-source solvers: GLPK, COIN-OR CBC, and PuLP. There is no clear winner, although GLPK was the fastest on our custom example.