Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLPK error #146

Closed
qtothec opened this issue May 12, 2017 · 3 comments
Closed

GLPK error #146

qtothec opened this issue May 12, 2017 · 3 comments

Comments

@qtothec
Copy link
Contributor

qtothec commented May 12, 2017

Hi folks,
I was trying to construct a tiny example problem for someone and ran across an error with the parsing of the GLPK solution file. Below is the script and output. This was replicated on the most recent version of master, which as of this writing is e3db130.

Script

from __future__ import division
from pyomo.environ import *
from pyomo.opt import SolverFactory

m = ConcreteModel()
m.x = Var([1, 2, 3], domain=NonNegativeReals)
m.c = Constraint(expr=m.x[1] + 2 * m.x[2] - 5 * m.x[3] == 7)
m.c2 = Constraint(expr=m.x[1] >= 1)

m.obj = Objective(expr=m.x[1], sense=minimize)

results = SolverFactory('glpk').solve(m, tee=True)
m.display()

Output

GLPSOL: GLPK LP/MIP Solver, v4.57
Parameter(s) specified in the command line:
 --write /tmp/tmpeK74sQ.glpk.raw --wglp /tmp/tmpDqqZ4U.glpk.glp --cpxlp /tmp/tmpdkt2tY.pyomo.lp
Reading problem data from '/tmp/tmpdkt2tY.pyomo.lp'...
3 rows, 4 columns, 5 non-zeros
26 lines were read
Writing problem data to '/tmp/tmpDqqZ4U.glpk.glp'...
19 lines were written
GLPK Simplex Optimizer, v4.57
3 rows, 4 columns, 5 non-zeros
Preprocessing...
1 row, 2 columns, 2 non-zeros
Scaling...
 A: min|aij| =  2.000e+00  max|aij| =  5.000e+00  ratio =  2.500e+00
Problem data seem to be well scaled
Constructing initial basis...
Size of triangular part is 1
*     0: obj =   7.000000000e+00 inf =   0.000e+00 (1)
*     1: obj =   1.000000000e+00 inf =   0.000e+00 (0)
OPTIMAL LP SOLUTION FOUND
Time used:   0.0 secs
Memory used: 0.0 Mb (40416 bytes)
Writing basic solution to '/tmp/tmpeK74sQ.glpk.raw'...
9 lines were written
ERROR: Expecting 's' row after 'c' rows
Traceback (most recent call last):
  File "/home/qichen/Downloads/small_lp.py", line 12, in <module>
    results = SolverFactory('glpk').solve(m, tee=True)
  File "/home/qichen/.solvers/pyomo/src/pyomo/pyomo/opt/base/solvers.py", line 610, in solve
    result = self._postsolve()
  File "/home/qichen/.solvers/pyomo/src/pyomo/pyomo/opt/solver/shellcmd.py", line 268, in _postsolve
    results = self.process_output(self._rc)
  File "/home/qichen/.solvers/pyomo/src/pyomo/pyomo/opt/solver/shellcmd.py", line 330, in process_output
    self.process_soln_file(results)
  File "/home/qichen/.solvers/pyomo/src/pyomo/pyomo/solvers/plugins/solvers/GLPK.py", line 362, in process_soln_file
    raise ValueError(msg)
ValueError: Error parsing solution data file, line 2
@ghackebeil
Copy link
Member

ghackebeil commented May 12, 2017

This example works for me with GLPK 4.61. I know a change was made to the GLPK solution format somewhere in the 4.5 series and we updated the GLPK plugin to use that new format. I'm not sure if we try to handle the old format, but it looks like it's not working either way.

@ghackebeil
Copy link
Member

ghackebeil commented Jun 25, 2017

I think this was probably fixed in c31d940. I was looking at Jenkins test failures this weekend, and the machine I happened to be working on had an older version of GLPK installed. I came across a similar error and noticed that the GLPK plugin was not being configured for the correct GLPK version until it was too late. Basically, the plugin for the old GLPK solution format would never be instantiated. This should be fixed now. Feel free to close this ticket when you can verify this.

@qtothec
Copy link
Contributor Author

qtothec commented Jun 26, 2017

Yup, confirmed that issue was resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants