Rework SolutionLoader#3701
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3701 +/- ##
==========================================
+ Coverage 89.93% 89.96% +0.03%
==========================================
Files 902 903 +1
Lines 106454 106604 +150
==========================================
+ Hits 95744 95911 +167
+ Misses 10710 10693 -17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@michaelbynum, @mrmundt: I implemented the things that @michaelbynum and I discussed. Once either/both of you look it over, then I think we can merge. |
| class PersistentSolutionLoader(SolutionLoaderBase): | ||
| """ | ||
| import_suffixes = {} | ||
| for suffix in self._pyomo_model.component_objects( |
There was a problem hiding this comment.
We should probably make _pyomo_model an attribute on the SolutionLoader class. Right now, this just assumes the derived classes create the attribute.
| class GDXFileData: | ||
| """ | ||
| Defines the data types found within a .gdx file | ||
| """ | ||
|
|
||
| def __init__(self) -> None: | ||
| self.primals: List[float] = [] | ||
| self.duals: List[float] = [] | ||
| self.var_suffixes: Dict[str, Dict[int, Any]] = {} | ||
| self.con_suffixes: Dict[str, Dict[Any]] = {} | ||
| self.obj_suffixes: Dict[str, Dict[int, Any]] = {} | ||
| self.problem_suffixes: Dict[str, List[Any]] = {} | ||
| self.other: List[str] = [] | ||
|
|
There was a problem hiding this comment.
I don't remember deleting this. Did you change this, @jsiirola?
There was a problem hiding this comment.
I see - this class was not being used. Thanks.
There was a problem hiding this comment.
Right - I was going through and updating type hints to Python 3.10+, which caused those lines to be added to the PR's "patch" - and they were uncovered. I dug around, and that class is never used (I think it was left over from when the LP writer was used as a base for the rewrite of the GAMS writer). Removing it seemed right.
michaelbynum
left a comment
There was a problem hiding this comment.
I think this looks great. Thanks for all the effort you put into this, @jsiirola. I love the new solution loader view and context manager. That was a great idea. I'm also glad you updated the ASL and Ipopt solution loaders to generalize the reduced costs.
|
Okay, I'm happy to hit merge if tests pass. |
Summary/Motivation:
This PR updates the solution loader in pyomo/contrib/solver based on recent design discussions.
Changes proposed in this PR:
get_number_of_solutionsmethodget_solution_idsmethodload_solutionmethodload_import_suffixesmethodsolution()to provide (through a view or a context manager) access to solutions from the solution poolLegal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: