-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigating (and improving) file format handling in backends #660
base: main
Are you sure you want to change the base?
Conversation
…of "space in name" error)
…inalizes fix for "space in name" error)
…., due to a timelimit abort)
…ow passing pyomo arguments (symbolic_solver_labels and keepfiles) to solve. Allow setting problem format (to force LP or MPS passing).
@sstroemer thanks for this! A few minor points:
|
…o double underscores in the pyomo backend
Refactors the way defaults are handled and moves the puts the documentation into the abstract method definition.
Thanks for taking the time to check this out @brynpickering (really!). Note that none of this is meant as "should be improved", I'm perfectly happy to close this anytime and keep the few things I need as local patch!
(Un)Fortunately these achieve different things: Maybe a more generalized
I fully get the part of backends being "identical" to the user, that's what I kind of had in mind with some of the changes, see the following comparison on variables names:
Note: Other "problems" arise for spaces, e.g., The prefix is still not the same, but I assumed that was on purpose, so I just aligned the way the indices are used.
I understand that, the only "problem" I see with this, is that this means not being able to customize the functionality that you expose. For example, What about:
To better visualize that, I've drafted that in c64c089 Footnotes
|
Because the interaction with the |
I agree with the approach of making everything comparable. It's a pity it requires RE symbolic solver labels. I can see your reasoning although I tend to think that if you want verbose strings then you definitely want symbolic solver labels when saving to LP(/MPS?). I think you could use |
Sounds good - do you want me to still include a
Definitely! Sorry I meant the other way round: I may want symbolic solver labels even without verbose strings, since the non-verbose still contain some information.
I guess that could be changed, as long as it's changed in both backends? Not saying that this is ideal, but our model's equivalent of Maybe instead of
with |
Fixes: nothing
This is a (pre-vacation) draft of some local changes that I needed, with a few open questions, some findings, and maybe a few interesting updates.
Summary of changes in this pull request
The content below explains the changes, and I will add upcoming changes to this list. Benchmarks and insights, as well as open questions are given after that.
Step-by-step of new functionality
to_mps(...)
based onto_lp(...)
.kwargs
to bothto_lp(...)
andto_mps(...)
, to allow passing keyword arguments to the file writers. This, e.g., allows settingsymbolic_solver_labels
explicitly (previously it was active by default in the Pyomo backend).symbolic_solver_labels = True
was lost. To not break the expected default functionality, this internally enforces the default again.IgnoreNames
, which only affects objects added after it was set. This does not do anything write now, but was done while trying to prepare for "proper" names in the Gurobi backend.solve_kwargs
. This was previously initialized as empty dictionary, and then updating if logs are to be kept with{"symbolic_solver_labels": True, "keepfiles": True}
. This indicates that, e.g.,symbolic_solver_labels = False
is the assumed default, which may change without anyone immediately noticing it (Pyomo release notes can be long...). While doing that it also moves wheretee = True
is set, to allow overwriting it.opt.options
, some settings are done either via direct functions or using keyword arguments directly to thesolve(...)
function. To allow setting those, this now allows passing entries tosolver_options
that start withpyomo_
. Those are caught and handled accordingly. Currently this allows: Manually modifyingsolve_kwargs
(e.g., settingkeepfiles
without having to activatesave_logs
), and most importantly setting theProblemFormat
that Pyomo should use (which allows forcing, e.g.,cpxlp
ormps
formats) when passing models as file to a solver.,
too; this is fixed now.kwarg
problem pointed out by Bryn.Fixes
b68d2f3 fixes an error that occurs when a solver returns an "okay" status code (at least one that is interpreted as such) but does not return any solutions, which can happen, e.g., for a time limit abort with Gurobi. This lead the to the following error, that is now caught, including a warning for the user.
As indicated above, without b5d7860 and 293177b errors like the following occur when writing LPs with Gurobi:
Benchmarks
urban_scale
model, using a half year ("config.init.time_subset": ["2005-01-01", "2005-06-30"]
) or full year ("config.init.time_subset": ["2005-01-01", "2005-12-31"]
) override.urban_scale
(parse),build
(build),to_**
(write), andsolve
(pass).TimeLimit = 0
(for Gurobi) or-seconds 0
(for Cbc, command line).ssl
indicatessymbolic_solver_labels
.cbc model.lp -sec 0 solve
.Summary
write
andpass
than LP files.gurobipy
is used).-infinity
to-inf
has to be done). The Gurobi written LP and MPS files are slightly faster to read, with slightly below 10% (but I did not in-depth benchmark this).Compression
For compressed files from Gurobi, reading them is almost identical to reading the uncompressed files. Rough stats for the different compression formats, based on "full year":
.lp.7z
.lp.bz2
.lp.gz
.mps.7z
.mps.bz2
.mps.gz
Summary:
7z
for best file size, but slowbz2
for good file sizes, and good time spentgz
for basic compression, but fastResults
"half year"
"full year"
Questions
pyomo < 6.7.2
? Changes togurobi_direct
and the new "manual" IIS calculation could be interesting to include.Reviewer checklist
For myself:
pre-commit
checked (ruff and black should probably fail) - done in 294ce40mps
, and ???Original: