I was trying to do the following simple example optimization problem before starting a bigger problem. The code:
from pulp import *
x = LpVariable("x", 0, 3)
y = LpVariable("y", 0, 1)
prob = LpProblem("myProblem", LpMinimize)
prob += x + y <= 2
#objective function
prob += -4*x + y
status = prob.solve(GLPK(msg = 0))
#results
value(x)
I am getting the following error:
Traceback (most recent call last):
File "C:\Users\mahabubalam\Desktop\Works\GUI\whiskas.py", line 85, in <module>
status = prob.solve(GLPK(msg = 0))
File "C:\Python34\lib\site-packages\pulp-1.5.6-py3.4.egg\pulp\pulp.py", line 1619, in solve
status = solver.actualSolve(self, **kwargs)
File "C:\Python34\lib\site-packages\pulp-1.5.6-py3.4.egg\pulp\solvers.py", line 335, in actualSolve
raise PulpSolverError("PuLP: cannot execute "+self.path)
pulp.solvers.PulpSolverError: PuLP: cannot execute glpsol.exe
Can anyone please help me to understand why is that?
I have successfully run your code after doing the following two steps:
Download GLPK from
http://sourceforge.net/projects/winglpk/files/latest/download (as mentioned by oyvind)
C:\glpk_is_here\Add GLPK binaries to your system path before running python
C:\>set PATH=%PATH%;C:\glpk_is_here\glpk-4.55\w64
Using the same cmd window from (3), use python/ipython to run your code:
C:\>ipython your_code.py
See the results
Out[4]: 2.0
Good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With