Search code examples
pythonpulpglpk

How to add GLPK solver on pulp, python


I'd like to know how to add GLPK solver step by step on pulp, python. I have installed python (v=3.6.5), pulp (v=1.6.8).

I get the result as below when I executed pulp.pulpTestAll().

 Testing zero subtraction
 Testing inconsistant lp solution
 Testing continuous LP solution
 Testing maximize continuous LP solution
 Testing unbounded continuous LP solution
 Testing Long Names
 Testing repeated Names
 Testing zero constraint
 Testing zero objective
 Testing LpVariable (not LpAffineExpression) objective
 Testing Long lines in LP
 Testing LpAffineExpression divide
 Testing MIP solution
 Testing MIP solution with floats in objective
 Testing MIP relaxation
 Testing feasibility problem (no objective)
 Testing an infeasible problem
 Testing an integer infeasible problem
 Testing column based modelling
 Testing dual variables and slacks reporting
 Testing fractional constraints
 Testing elastic constraints (no change)
 Testing elastic constraints (freebound)
 Testing elastic constraints (penalty unchanged)
 Testing elastic constraints (penalty unbounded)
* Solver <class 'pulp.solvers.PULP_CBC_CMD'> passed.
Solver <class 'pulp.solvers.CPLEX_DLL'> unavailable
Solver <class 'pulp.solvers.CPLEX_CMD'> unavailable
Solver <class 'pulp.solvers.CPLEX_PY'> unavailable
Solver <class 'pulp.solvers.COIN_CMD'> unavailable
Solver <class 'pulp.solvers.COINMP_DLL'> unavailable
Solver <class 'pulp.solvers.GLPK_CMD'> unavailable
Solver <class 'pulp.solvers.XPRESS'> unavailable
Solver <class 'pulp.solvers.GUROBI'> unavailable
Solver <class 'pulp.solvers.GUROBI_CMD'> unavailable
Solver <class 'pulp.solvers.PYGLPK'> unavailable
Solver <class 'pulp.solvers.YAPOSIB'> unavailable

Solution

  • For Debian/Ubuntu systems you just have to run

    sudo apt-get install glpk-utils
    

    You can check the installed version and the installation path by typing

    glpsol --version
    

    and

    which glpsol
    

    For OSX, the command is brew install glpk using Homebrew.

    Another solution consists in downloading the tarball directly from the official website https://www.gnu.org/software/glpk/#downloading and to build and install it.