Skip to content

Python solvers for MINLP in Pyomo in Google Colab

An answer to this question on the Scientific Computing Stack Exchange.

Question

I am looking for a MINLP solver that works with Pyomo models which can be used in the Google Colab environment. I have already found MindtPy but it doesn't work in google colab.

Answer

There are so many MINLP solvers out there that this isn't really a well-defined question.

Anyway, here's how you can get some:

# Install some solvers
# GLPK probably includes GLPK_MI which does MIP
!apt-get install -y -qq glpk-utils  
# CBC does MIP
!apt-get install -y -qq coinor-cbc  
# Ipopt does MINLP
!wget -N -q "https://ampl.com/dl/open/ipopt/ipopt-linux64.zip"
!unzip -o -q ipopt-linux64
# Bonmin does MINLP by mixing CBC and Ipopt
!wget -N -q "https://ampl.com/dl/open/bonmin/bonmin-linux64.zip"
!unzip -o -q bonmin-linux64
# Couenne is another MINLP solver
!wget -N -q "https://ampl.com/dl/open/couenne/couenne-linux64.zip"
!unzip -o -q couenne-linux64
#OSQP is a fast solver for quadratic programs. This makes it available via Python
!pip install osqp
#XPRESS is a commercial solver of many sorts of programs including MIPs. This installs it along with a community license that makes it free, but only for smallish problems
!pip install xpress

When you're done, the solvers will be located at:

glpk      /usr/bin/glpsol
cbc       /usr/bin/cbc
ipopt     /content/ipopt
bonmin    /content/bonmin
couenne   /content/couenne
osqp      available via import in Python
xpress    available via import in Python

Further tests and explanations of some of the above are available here.