How do you install glpk-solver along with pyomo in Winpython

余生颓废 提交于 2019-12-01 00:09:56
Friederike Meier

I recently installed GLPK for use with python 3.5 and pyomo under windows 7 and would like to report how I succeeded. I installed pyomo via:

pip install pyomo

Then, download WinGLPK 4.55 from here: WinGLPK
This does not work for newer versions at the moment.
Unzip it and copy the whole w64 folder to C:\w64
Include folder C:\w64 in your system PATH (so that glpsol.exe is found).

Check your installation using the simple example from the official pyomo documentation:

pyomo solve abstract1.py abstract1.dat --solver=glpk 

The files abstract1.py and abstract1.dat can also be found in the pyomo documentation.

I hope this will help the next desperate GLPK installer.

Bill Hart

FYI, you can now use Coopr without installing local solvers. The latest Coopr release supports an interface with the NEOS solver. For example, if your MILP model is in the file model.py, then the following command would optimize the model using CBC:

pyomo --solver-manager=neos --solver=cbc model.py
ojdo

Better late than never: in order to use GLPK (executable glpsol.exe), it must be somewhere on your sytem environment variable "Path". For sake of an example, let's assume you put the GLPK executable into the folder C:\GLPK\bin. Then (steps copied from this answer by melhosseiny):

  1. Hold Win and press Pause.
  2. Click Advanced System Settings.
  3. Click Environment Variables.
  4. Append ;C:\GLPK\binto the Path variable.
  5. Restart command prompt.

Now try to launch glpsol from any directory. If it is found, pyomo should now be able to use it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!