如何在Winpython中安装glpk-solver和pyomo

时间:2022-03-18 22:16:02

I want to use "pyomo" for my studies. I installed pyomo via easy_install coopr install instructions, Pyomo needs a solver to work so I wanted to install the (GNU Linear Programming Kit) glpk_webpage, pyomo seems to be installed just right because I can import it in spyder (i am using WinPython-64bit-2.7.5.3) with import coopr.pyomo

我想用“pyomo”来学习。我通过easy_install coopr安装说明安装了pyomo,Pyomo需要一个求解器才能工作所以我想安装(GNU线性编程套件)glpk_webpage,pyomo似乎安装得恰到好处,因为我可以在spyder中导入它(我使用的是WinPython-64bit) -2.7.5.3)使用import coopr.pyomo

However, I cannot do anything without glpk I guess...

但是,如果没有glpk,我无法做任何事情......

I downloaded glpk-4.52 (latest version) from the ftp server but I do not know what to do with the batch files I found in the "w64"-folder I should use(?) according to "Installing GLPK"

我从ftp服务器下载了glpk-4.52(最新版本),但我不知道如何处理我在“w64”文件夹中找到的批处理文件,根据“安装GLPK”我应该使用(?)

I do not have Visual Studio installed - Isn't it possible to work without it?

我没有安装Visual Studio - 没有它可以工作吗?

3 个解决方案

#1


3  

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:

仅供参考,您现在可以在不安装本地求解器的情况下使用Coopr。最新的Coopr版本支持与NEOS解算器的接口。例如,如果您的MILP模型位于文件model.py中,则以下命令将使用CBC优化模型:

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

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

#2


3  

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.

我最近在Windows 7下安装了GLPK用于python 3.5和pyomo,并想报告我是如何成功的。我通过pip install安装了pyomo。

Download WinGLPK 4.55 from here: WinGLPK This does not work for newer versions at the moment.

从这里下载WinGLPK 4.55:WinGLPK目前不适用于较新版本。

Unzip it and copy the whole w64 fodler to C:\w64 Include C:\w64 in your PATH

解压缩并将整个w64 fodler复制到C:\ w64在PATH中包含C:\ w64

Check your installation using the simple example from the official pyomo documentation. pyomo solve abstract1.py abstract1.dat --solver=glpk

使用官方pyomo文档中的简单示例检查您的安装。 pyomo解决abstract1.py abstract1.dat --solver = glpk

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

文件abstract1.py和abstract1.dat也可以在pyomo doc中找到。

Hope this will help the next desperate glpk installer.

希望这将有助于下一个绝望的glpk安装程序。

#3


1  

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):

迟到总比没有好:为了使用GLPK(可执行文件glpsol.exe),它必须位于你的系统环境变量“Path”的某个地方。为了举例,我们假设您将GLPK可执行文件放入文件夹C:\ GLPK \ bin。然后(melhosseiny从这个答案复制的步骤):

  1. Hold Win and press Pause.
  2. 按住Win并按暂停。
  3. Click Advanced System Settings.
  4. 单击高级系统设置。
  5. Click Environment Variables.
  6. 单击“环境变量”。
  7. Append ;C:\GLPK\binto the Path variable.
  8. 追加; C:\ GLPK \ bin到Path变量。
  9. Restart command prompt.
  10. 重启命令提示符。

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

现在尝试从任何目录启动glpsol。如果找到,pyomo现在应该能够使用它。

#1


3  

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:

仅供参考,您现在可以在不安装本地求解器的情况下使用Coopr。最新的Coopr版本支持与NEOS解算器的接口。例如,如果您的MILP模型位于文件model.py中,则以下命令将使用CBC优化模型:

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

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

#2


3  

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.

我最近在Windows 7下安装了GLPK用于python 3.5和pyomo,并想报告我是如何成功的。我通过pip install安装了pyomo。

Download WinGLPK 4.55 from here: WinGLPK This does not work for newer versions at the moment.

从这里下载WinGLPK 4.55:WinGLPK目前不适用于较新版本。

Unzip it and copy the whole w64 fodler to C:\w64 Include C:\w64 in your PATH

解压缩并将整个w64 fodler复制到C:\ w64在PATH中包含C:\ w64

Check your installation using the simple example from the official pyomo documentation. pyomo solve abstract1.py abstract1.dat --solver=glpk

使用官方pyomo文档中的简单示例检查您的安装。 pyomo解决abstract1.py abstract1.dat --solver = glpk

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

文件abstract1.py和abstract1.dat也可以在pyomo doc中找到。

Hope this will help the next desperate glpk installer.

希望这将有助于下一个绝望的glpk安装程序。

#3


1  

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):

迟到总比没有好:为了使用GLPK(可执行文件glpsol.exe),它必须位于你的系统环境变量“Path”的某个地方。为了举例,我们假设您将GLPK可执行文件放入文件夹C:\ GLPK \ bin。然后(melhosseiny从这个答案复制的步骤):

  1. Hold Win and press Pause.
  2. 按住Win并按暂停。
  3. Click Advanced System Settings.
  4. 单击高级系统设置。
  5. Click Environment Variables.
  6. 单击“环境变量”。
  7. Append ;C:\GLPK\binto the Path variable.
  8. 追加; C:\ GLPK \ bin到Path变量。
  9. Restart command prompt.
  10. 重启命令提示符。

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

现在尝试从任何目录启动glpsol。如果找到,pyomo现在应该能够使用它。