Python/Pyomo with glpk Solver - Error
Question: I am trying to run some simle example with Pyomo + glpk Solver (Anaconda2
64bit Spyder):

    
    
    from pyomo.environ import *
    model = ConcreteModel()
    model.x_1 = Var(within=NonNegativeReals)
    model.x_2 = Var(within=NonNegativeReals)
    model.obj = Objective(expr=model.x_1 + 2*model.x_2)
    model.con1 = Constraint(expr=3*model.x_1 + 4*model.x_2 >= 1)
    model.con2 = Constraint(expr=2*model.x_1 + 5*model.x_2 >= 2)
    
    opt = SolverFactory("glpk")
    instance = model.create()
    #results = opt.solve(instance)
    #results.write()
    

But i get the following error message:

    
    
    invalid literal for int() with base 10: 'c'
    Traceback (most recent call last):
    
      File "<ipython-input-5-e074641da66d>", line 1, in <module>
        runfile('D:/..../Exampe.py', wdir='D:.../exercises/pyomo')
    
      File "C:\...\Continuum\Anaconda21\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 699, in runfile
        execfile(filename, namespace)
    
      File "C:\....\Continuum\Anaconda21\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 74, in execfile
        exec(compile(scripttext, filename, 'exec'), glob, loc)
    
      File "D:/...pyomo/Exampe.py", line 34, in <module>
        results = opt.solve(instance)
    
      File "C:\....\Continuum\Anaconda21\lib\site-packages\pyomo\opt\base\solvers.py", line 580, in solve
        result = self._postsolve()
    
      File "C:\...Continuum\Anaconda21\lib\site-packages\pyomo\opt\solver\shellcmd.py", line 267, in _postsolve
        results = self.process_output(self._rc)
    
      File "C:\...\Continuum\Anaconda21\lib\site-packages\pyomo\opt\solver\shellcmd.py", line 329, in process_output
        self.process_soln_file(results)
    
      File "C:\....\Continuum\Anaconda21\lib\site-packages\pyomo\solvers\plugins\solvers\GLPK.py", line 454, in process_soln_file
        raise ValueError(msg)
    
    ValueError: Error parsing solution data file, line 1
    

I downloaded glpk from <http://winglpk.sourceforge.net/> \--> unziped + added
parth to the environmental variable "path".

Hope someone can help me - thank you!


Answer: This is a known problem with GLPK 4.60 (glpsol changed the format of their
output which broke Pyomo 4.3's parser). You can either download an older
release of GLPK, or upgrade Pyomo to 4.4.1 (which contains an updated parser).

