Problem with keepfiles

169 views
Skip to first unread message

Joe DeCarolis

unread,
Jul 28, 2015, 5:40:05 PM7/28/15
to Pyomo Forum
I ran into another issue with Pyomo 4.1. This bit of code is supposed to retain the lp file:

    opt = SolverFactory( options.solver )
    if opt:
        if options.keepPyomoLP:
            opt.keepfiles = True
            opt.symbolic_solver_labels = True


But instead produces the following error:

Traceback (most recent call last):
  File "/home/jdecarolis/anaconda/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/home/jdecarolis/anaconda/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/jdecarolis/temoa/temoa_model/__main__.py", line 26, in <module>
    temoa_solve( model )
  File "temoa_model/temoa_lib.py", line 2281, in temoa_solve
    opt.keepfiles = True
AttributeError: can't set attribute


If I invoke pyomo solve with '--keepfiles' directly rather than invoking the Temoa python script, it produces the relevant solver files without a problem.

Any idea what's going on?

Thanks,
Joe

Gabriel Hackebeil

unread,
Jul 28, 2015, 7:11:35 PM7/28/15
to pyomo...@googlegroups.com
We made a decision in the latest release to remove support for directly setting attributes likes these on the solver object. They must instead be passed as keywords into the solve command.

We used to support doing both, but it lead to confusion about whether or not they were persistent across multiple calls to the solve command. For instance, in the following scenario one would expect the first and the third solve() commands to use keepfiles=False, but that was not the case (the third command kept around the previous change in state to keepfiles).

opt.solve()
...
opt.solve(keepfiles=True)
opt.solve()

I meant for a more helpful error message to appear by turning common attributes like these into property methods that raise an exception with information about the change, but it turns out I forgot to add a property.setter. You are getting an error as I intended, but it’s lacking the information I meant to provide. I’m going to fix that on Pyomo trunk now. However, you are going to have to contact the developers of Temoa about fixing this. They can support pre- and post- Pyomo 4.1 code by setting ‘keepfiles’ and ‘symbolic_solver_labels’ through keywords in the solve() command rather than as attributes on the solver.

Gabe

--
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