如何在纸浆上添加 GLPK 求解器,python

How to add GLPK solver on pulp, python

我想知道如何在纸浆上逐步添加 GLPK 求解器,python。 我安装了 python (v=3.6.5), pulp (v=1.6.8).

执行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

对于 Debian/Ubuntu 系统,您只需 运行

sudo apt-get install glpk-utils

您可以通过键入

来检查安装的版本和安装路径
glpsol --version

which glpsol

对于 OSX,命令是 brew install glpk 使用 Homebrew。

另一种解决方案是直接从官方网站 https://www.gnu.org/software/glpk/#downloading 下载 tarball 并构建和安装它。