Unable to run GLPK solver with PuLP

4,901 views
Skip to first unread message

Akhil

unread,
Oct 28, 2014, 1:35:11 PM10/28/14
to pulp-or...@googlegroups.com
Hi,

I've downloaded PuLP 1.5.6 to run with Python 2.7.8 (32 bit, Windows 7 OS). I've also downloaded and setup GLPK 4.34 solver with PuLP. The command pulp.pulpTestAll() returns:
Solver pulp.solvers.PULP_CBC_CMD passed.
Solver pulp.solvers.GLPK_CMD passed.

thus indicating that GLPK has been installed correctly with PuLP.

I now considered the simplest possible Integer programming problem:

from pulp import *
prob = LpProblem('dummy ', LpMinimize)
a = LpVariable('a ',0,1,LpInteger)
prob += a, "Objective function"
prob.solve(GLPK())

I get the following error:

Traceback (most recent call last):
  File "<pyshell#9>", line 1, in <module>
    prob.solve(GLPK())
  File "E:\Python27\lib\site-packages\pulp\pulp.py", line 1619, in solve
    status = solver.actualSolve(self, **kwargs)
  File "E:\Python27\lib\site-packages\pulp\solvers.py", line 366, in actualSolve
    raise PulpSolverError("PuLP: Error while executing "+self.path)
PulpSolverError: PuLP: Error while executing glpsol.exe

GLPK 4.34 is already available in my system path. How does one solve this problem?

Stuart Mitchell

unread,
Oct 28, 2014, 5:19:47 PM10/28/14
to pulp-or...@googlegroups.com
Hi can you try

prob.solve(GLPK_CMD())

Just to see if there is any difference?

Stu


--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discu...@googlegroups.com.
To post to this group, send email to pulp-or...@googlegroups.com.
Visit this group at http://groups.google.com/group/pulp-or-discuss.
For more options, visit https://groups.google.com/d/optout.



--
Stuart Mitchell
PhD Engineering Science
Extraordinary Freelance Programmer and Optimisation Guru

Akhil

unread,
Oct 30, 2014, 4:47:21 AM10/30/14
to pulp-or...@googlegroups.com
Hi,

Writing prob.solve(GLPK_CMD()) instead of prob.solve(GLPK()) still returns the same error.

An observation -  Same code, I've just added a dummy constraint:

prob = LpProblem('dummy ', LpMaximize)
a  =  LpVariable('a ',0,1, LpInteger)
prob += a, "Objective function"
prob += a <= 2, ""

prob.solve(GLPK())

for v in prob.variables():
    print v.name, " = ", v.varValue

and I get the correct answer "a_ = 1". So adding a (dummy) constraint to the formulation produces a correct O/P from GLPK !!

I also wanted to know how to specify % tolerance for GLPK solver in PuLP. My MILP objective function value quickly converges to 1% of optimum, but time taken to solve complete problem is very large. Hence I want a way to terminate the solver when it is around 1% of the optimal solution. 

Stuart Mitchell

unread,
Oct 30, 2014, 5:49:33 PM10/30/14
to pulp-or...@googlegroups.com
Right the GLPK interface needs some changes. is there a reason why you are not using the default cbc solver?

Stu

Akhil

unread,
Nov 4, 2014, 3:21:09 AM11/4/14
to pulp-or...@googlegroups.com
Hi,

For some problem cases, the default solver CBC returns decimal numbers for integer variables. For the problems which are correctly solved by CBC, running time of CBC is far superior to GLPK.

However, because of the above issue, I am forced to use GLPK.

Stuart Mitchell

unread,
Nov 4, 2014, 4:26:52 AM11/4/14
to pulp-or...@googlegroups.com

Did you check the Optimization status sounds like the problem may be infeasible. If not make sure you have the latest version of pulp https://pypi.python.org/pypi/PuLP/1.5.6
And send me the problems.

Stu

Akhil

unread,
Dec 28, 2014, 9:13:41 AM12/28/14
to pulp-or...@googlegroups.com
Hi,

Sorry for delayed response. Those problem instances were actually infeasible. By using CBC solver I save around 4 hours of execution time. Thanks for your help.

aziz amer

unread,
Dec 2, 2018, 4:43:55 PM12/2/18
to pulp-or-discuss
Did you solve the problem? I have the same problem. 

aziz amer

unread,
Dec 2, 2018, 9:25:25 PM12/2/18
to pulp-or...@googlegroups.com
Thank you so much for your response. I tried the Anaconda platform and was able to solve the problem. 

Best, 
Aziz 

--
New posters to this group are moderated which can take up to 48 hours, so please be patient if your first post takes a while to turn up.
---
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discu...@googlegroups.com.
To post to this group, send email to pulp-or...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages