Specifying executable for GLPK does not work

1,260 views
Skip to first unread message

Ted Boydston

unread,
May 31, 2017, 8:22:14 AM5/31/17
to pyomo...@googlegroups.com
Greetings,

Regarding these Pyomo versions

Pyomo 5.1.1 (CPython 2.7.11 on Linux 2.6.32-642.6.2.el6.x86_64)
Pyomo 5.2 (CPython 2.7.11 on Linux 2.6.32-642.6.2.el6.x86_64)

It seems that specifying the solver executable at the command line or via the API for GLPK does not work.  Pyomo appears to lose the executable or does not use the executable at all.

Example using the command line:

cae_elec.none[166](0)> /programs/cae_elec/apps/anaconda_2.1.0/bin/pyomo solve --solver=glpk --solver-executable=/programs/cae_elec/apps/glpk/install/glpk_4.55/bin/glpsol license.py model.dat
[    0.00] Setting up Pyomo environment
[    0.00] Applying Pyomo preprocessing actions
[    0.00] Creating model
[    2.40] Applying solver
WARNING: "[base]/site-packages/pyomo/solvers/plugins/solvers/GLPK.py", 150, _default_executable
    Could not locate the 'glpsol' executable, which is required for solver 'glpk'
[    2.40] Pyomo Finished
ERROR: Unexpected exception while running model:
    No executable found for solver 'glpk'
cae_elec.none[167](0)> ls -l /programs/cae_elec/apps/glpk/install/glpk_4.55/bin/glpsol 

-rwxr-xr-x 1 tboydsto users 6.5K Feb 15 17:24 /programs/cae_elec/apps/glpk/install/glpk_4.55/bin/glpsol


The above shows that glpsol is specified in the command line with --solver-executable and see that the executable exists on the filesystem via ls, yet Pyomo claims it cannot find the glpsol executable.

Similarly, using the API:

    opt = SolverFactory("glpk", executable="/programs/cae_elec/apps/glpk/install/glpk_4.55/bin/glpsol")

Produces this error when run:

GLPSOL: GLPK LP/MIP Solver, v4.55
Parameter(s) specified in the command line:
 --write /tmp/tmpST7HwW.glpk.raw --wglp /tmp/tmp_uNaAH.glpk.glp --cpxlp /tmp/tmpmeAGO4.pyomo.lp
Reading problem data from '/tmp/tmpmeAGO4.pyomo.lp'...
/tmp/tmpmeAGO4.pyomo.lp:100561: warning: lower bound of variable 'x1' redefined
/tmp/tmpmeAGO4.pyomo.lp:100561: warning: upper bound of variable 'x1' redefined
14577 rows, 13522 columns, 34945 non-zeros
13521 integer variables, all of which are binary
114082 lines were read
Writing problem data to '/tmp/tmp_uNaAH.glpk.glp'...
85564 lines were written
GLPK Integer Optimizer, v4.55
14577 rows, 13522 columns, 34945 non-zeros
13521 integer variables, all of which are binary
Preprocessing...
14160 rows, 13312 columns, 34944 non-zeros
13312 integer variables, all of which are binary
Scaling...
 A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00
Problem data seem to be well scaled
Constructing initial basis...
Size of triangular part is 14160
Solving LP relaxation...
GLPK Simplex Optimizer, v4.55
14160 rows, 13312 columns, 34944 non-zeros
      0: obj =   2.836552165e+05  infeas =  3.980e+02 (0)
    500: obj =   2.801720221e+05  infeas =  1.840e+02 (0)
   1000: obj =   2.541176700e+05  infeas =  4.000e+01 (0)
*  1020: obj =   2.536857584e+05  infeas =  0.000e+00 (0)
*  1500: obj =   8.497174492e+04  infeas =  0.000e+00 (0)
*  2000: obj =   8.096363135e+04  infeas =  0.000e+00 (0)
*  2089: obj =   8.080844993e+04  infeas =  0.000e+00 (0)
OPTIMAL LP SOLUTION FOUND
Integer optimization begins...
+  2089: mip =     not found yet >=              -inf        (1; 0)
+  2418: >>>>>   8.080844993e+04 >=   8.080844993e+04   0.0% (1; 0)
+  2418: mip =   8.080844993e+04 >=     tree is empty   0.0% (0; 1)
INTEGER OPTIMAL SOLUTION FOUND
Time used:   3.6 secs
Memory used: 19.8 Mb (20793800 bytes)
Writing MIP solution to '/tmp/tmpST7HwW.glpk.raw'...
28101 lines were written
ERROR: Expecting 's' row after 'c' rows
Traceback (most recent call last):
  File "./assign-lics.py", line 525, in <module>
    main()
  File "./assign-lics.py", line 489, in main
    results = opt.solve(instance, tee=True)
  File "/programs/cae_elec/apps/anaconda_2.1.0/lib/python2.7/site-packages/pyomo/opt/base/solvers.py", line 609, in solve
    result = self._postsolve()
  File "/programs/cae_elec/apps/anaconda_2.1.0/lib/python2.7/site-packages/pyomo/opt/solver/shellcmd.py", line 267, in _postsolve
    results = self.process_output(self._rc)
  File "/programs/cae_elec/apps/anaconda_2.1.0/lib/python2.7/site-packages/pyomo/opt/solver/shellcmd.py", line 329, in process_output
    self.process_soln_file(results)
  File "/programs/cae_elec/apps/anaconda_2.1.0/lib/python2.7/site-packages/pyomo/solvers/plugins/solvers/GLPK.py", line 360, in process_soln_file
    raise ValueError(msg)
ValueError: Error parsing solution data file, line 2


Both of these errors are resolved when the glpsol executable is added to the PATH.

Has anyone else seen this behavior?

Thanks,
Ted Boydston

Gabriel Hackebeil

unread,
May 31, 2017, 11:54:03 AM5/31/17
to Pyomo Forum
A few things:

(1) There are a few versions of the GLPK plugin in Pyomo. The default version is supposed to work with GLPK 4.58 and after. A change in GLPK’s solution format occurred in 4.58, so the previously existing solver plugin no longer worked. The older version is compatible with GLPK 4.42 - 4.57. To force the use of the newer version use “_glpk_shell” as the solver name (rather than “glpk”). For the older version, use “_glpk_shell_4_42”.

(2) Unfortunately, the check for which version of the solver plugin to use only occurs once, then it is cached, and it uses what the solver it found in your PATH for the initial version check. That means, for example, if you have the older version of GLPK in your PATH, but you set the executable to a new version it will use the wrong solver plugin (but with the executable that you wanted). Is suspect something like that is going on here.

(3) In the case, of the pyomo command, the executable option was being ignored. Thanks for reporting this. I’ve pushed a fix.

(4) For the scripting API (and when the fix to the pyomo command makes it into a release), to get around (2), you can use the underscored names I showed in (1) in combination with the executable keyword. You will have to map the GLPK version of the executable you want to use to the correct version of the solver plugin.

Gabe

On May 31, 2017, at 8:22 AM, Ted Boydston <ted.bo...@gmail.com> wrote:

Greetings,

Regarding these Pyomo versions

Pyomo 5.1.1 (CPython 2.7.11 on Linux 2.6.32-642.6.2.el6.x86_64)
Pyomo 5.2 (CPython 2.7.11 on Linux 2.6.32-642.6.2.el6.x86_64)

It seem that specifying the solver executable at the command line or via the API for GLPK does not work.  Pyomo appears to lose the executable or does not use the executable at all.

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages