0

I'm using PYOMO to solve a linear program with CPLEX as my solver. I would like to access the final simplex tableau somehow, either by outputting it to a log file or saving it to a variable within my workspace. The following script is what I am using to solve my LP. Likely, there is an option I can pass to the CPLEX solver to save the final tableau, but so far my search has been fruitless.

self.solver = pyomo.opt.SolverFactory('cplex')
self.results = self.solver.solve(self.m, tee=True, keepfiles=True, options_string='lpmethod=1')

Thanks.

Dan Kinn
  • 151
  • 2
  • 5

2 Answers2

1

I don't know of any way to do this with Pyomo. I think the first step would be figuring out how to do this with Cplex and then adding a feature request (or pull request) on Pyomo's GitHub page, if it requires any additional interaction with the solver.

I think your best best bet would be to look for methods in Cplex's Python API. That is where Pyomo has the most flexibility to interact with the Cplex. Any other interfaces (e.g., LP files, NL files) are limited to functionality Cplex provides with command-line options.

Gabe Hackebeil
  • 1,376
  • 1
  • 8
  • 10
  • Thanks Gabe. I spent a chunk of time digging through the CPLEX Python API and was able to pull some sensitivity information using the PYOMO Suffix method (see examples below), but couldn't figure out how to pull the tableau. `self.m.dual = Suffix(direction=Suffix.IMPORT)` `self.m.lrc = Suffix(direction=Suffix.IMPORT)` `self.m.urc = Suffix(direction=Suffix.IMPORT)` `self.m.slack = Suffix(direction=Suffix.IMPORT)` `self.m.rc = Suffix(direction=Suffix.IMPORT)` – Dan Kinn Jun 19 '17 at 05:26
0

I ended up using scipy.optimize.linprog to get the simplex tableau. It is working for the small to medium-sized problems I'm testing my code on, although I'd guess it doesn't work quite as well as CPLEX for larger problems. The key to getting the tableau was to use a callback function from which I can pull the tableau, as well as some other information about the LP.

Dan Kinn
  • 151
  • 2
  • 5