5

To instance a solver in pyomo, usually a solver factory is used:

from pyomo.opt import SolverFactory
opt = SolverFactory('glpk')

Is there a way to know which strings will SolverFactory accept? A solution would look like:

print(SolverFactory.list_detected_solvers())
jabozzo
  • 591
  • 1
  • 6
  • 17

3 Answers3

6

Pyomo is not distributed with any solvers, but rather provides a variety of interfaces to solvers that are called upon demand. Because of this, there is no master list of solvers.

You can get something that approximates the desired behavior with the terminal command pyomo help -s. You can also check SolverFactory('glpk').available() == True for various solvers.

Both AMPL and GAMS provide listings of solvers on their websites. Since Pyomo is able to interface to either problem formats, you can also use that as a reference. Keep in mind that the relevant solver does still need to be installed on your system.

Qi Chen
  • 1,648
  • 1
  • 10
  • 19
3

Based on the reply from Qi Chen, I came up with this brute solution:

import pyomo.environ as pyo
from itertools import compress

pyomo_solvers_list = pyo.SolverFactory.__dict__['_cls'].keys()
solvers_filter = []
for s in pyomo_solvers_list:
    try:
        solvers_filter.append(pyo.SolverFactory(s).available())
    except (ApplicationError, NameError, ImportError) as e:
        solvers_filter.append(False)
pyomo_solvers_list = list(compress(pyomo_solvers_list,solvers_filter))

0

Has been solved here by the creators! https://or.stackexchange.com/questions/7145/how-to-install-ipopt-on-google-colab-for-pyomo

!pip install pyomo 
from pyomo.environ import *
import matplotlib.pyplot as plt
!wget -N -q "https://ampl.com/dl/open/ipopt/ipopt-linux64.zip"
!unzip -o -q ipopt-linux64

and in the modelling code :

opt=SolverFactory('ipopt', executable='/content/ipopt')
AKΛ
  • 53
  • 3