Open wangzhixuan opened 6 years ago
The only working interface we have to GLPK is through the glpsol command-line executable, using an LP or MPS file as input. The command-line flag to activate the interior-point solver for the glpsol executable is “--interior”. The syntax for specifying this kind of option through Pyomo is
glpk = SolverFactory("glpk")
glpk.options["interior"] = ""
That is, for command-line options that do not take a value, you just set them to an empty string in the solver options dictionary and Pyomo will take care of the rest.
Thanks @ghackebeil
I followed your instruction and tried the following code
import pyomo.environ as pe
m = pe.ConcreteModel()
m.x = pe.Var(range(3), bounds=(0,5))
m.y = pe.Var(bounds=(0,None))
m.obj = pe.Objective(expr=m.x[0] + m.x[1] + m.x[2] + m.y)
m.c = pe.Constraint(expr=m.y >= -2*m.x[0] - 2*m.x[1] - m.x[2] + 5)
opt = pe.SolverFactory('glpk')
opt.options['interior'] = ''
results = opt.solve(m)#
m.display()
print m.x[0].value
print m.x[1].value
print m.x[2].value
print m.y.value
It worked fine is I removed line output interior point method, but with that line, it now gives me this error.
ERROR: 'GLPKSHELL' object has no attribute '_process_soln_ipt'
Traceback (most recent call last):
File "test_pyomo3.py", line 9, in <module>
results = opt.solve(m)#
File "/Library/Python/2.7/site-packages/pyomo/opt/base/solvers.py", line 631, in solve
result = self._postsolve()
File "/Library/Python/2.7/site-packages/pyomo/opt/solver/shellcmd.py", line 268, in _postsolve
results = self.process_output(self._rc)
File "/Library/Python/2.7/site-packages/pyomo/opt/solver/shellcmd.py", line 329, in process_output
self.process_soln_file(results)
File "/Library/Python/2.7/site-packages/pyomo/solvers/plugins/solvers/GLPK.py", line 363, in process_soln_file
raise ValueError(msg)
ValueError: Error parsing solution data file, line 8
How should I resolve this problem? Or did I miss anything?
Thanks, Zhixuan
Well it looks like someone needs to implement a parser for a GLPK interior point solution (_process_soln_ipt
in pyomo/solvers/plugins/solvers/GLPK.py
). I'm going to convert this ticket to be an action item for that. We would gladly accept a pull request if you want to figure out how to do that yourself, using _process_soln_mip
and _process_soln_bas
in that same file as examples.
hey guys I tried to already point that out in this issues #275 but I was not clear enough sorry. Anyhow I'd try to work on it too.
To whom it may concern,
For some reason, I have to use an interior point solver to my problem. I know GLPK has a interior point solver function
glp_interior
. (Actually it is mentioned in the deprecated codeglpk_direct
)However, I don't see such options in the main
glpk
class. And I could not find any examples/documents on that neither.So I'm wondering
pyomo
?pyomo
?Thanks, Zhixuan