我是一个Python和优化方面的新手。我遇到了一些错误,请帮我解决。我在运行Anaconda 3的PyCharm中尝试运行下面提到的代码。
from pulp import *
x = LpVariable("x", 0, 3)
y = LpVariable("y", 0, 1)
prob = LpProblem("myProblem", LpMinimize)
prob += x + y <= 2
prob += -4*x + y
status = prob.solve(GLPK(msg = 0))
value(x)
我遇到了一个错误
Traceback (most recent call last): File "D:/Projects/RH Analytics/RNN/TestPulp.py", line 10, in status = prob.solve(GLPK(msg = 0)) File "C:\Users\rahul.bajaj\AppData\Local\Continuum\Anaconda3\lib\site-packages\pulp\pulp.py", line 1643, in solve status = solver.actualSolve(self, **kwargs) File "C:\Users\rahul.bajaj\AppData\Local\Continuum\Anaconda3\lib\site-packages\pulp\solvers.py", line 346, in actualSolve raise PulpSolverError("PuLP: cannot execute "+self.path) pulp.solvers.PulpSolverError: PuLP: 无法执行 glpsol.exe
进一步,我从这里下载了glpk包,从zip文件中提取出来并放在C盘的一个文件夹中。在路径变量中,我添加了"C:\winglpk-4.57\glpk-4.57\w64"。
但即使现在我在PyCharm IDE中运行程序仍然会出现相同的错误。请帮助我找出我错过了什么。
pulp.pulpTestAll()
,得到以下输出:* Solver <class 'pulp.solvers.GLPK_CMD'> passed. 但我仍然遇到错误 PulpSolverError: PuLP: Error while executing glpsol.exe。 - KHAN irfan