-
Notifications
You must be signed in to change notification settings - Fork 543
Solver Refactor Pt. 2: Restructure for Future Redesign #3476
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
Conversation
from pyomo.core.expr.numvalue import NumericConstant | ||
from pyomo.contrib.solver.util import collect_vars_and_named_exprs, get_objective | ||
from pyomo.contrib.solver.common.results import Results | ||
from pyomo.contrib.solver.common.util import collect_vars_and_named_exprs, get_objective | ||
|
||
|
||
class PersistentSolverUtils(abc.ABC): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOT TODO for this PR:
- What is the intent of this class?
- To manage automatic checking of state / checking differences in the model and updating them; implements the "Auto" part of APPSI
- What is a better name?
PersistentSolverStateTracker
? This is the classic "is-a" vs. "has-a". Other ideas:PersistentSolverChangeDetector
,PersistentModelStateManager
,PersistentSolverUpdater
Summary: We don't want the persistent solver interfaces to inherit from this; we want the classes to be able to contain one of these classes and use it. ModelChangeObserver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also probably won't need the _func_name
and func_name
standard here when re-worked.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3476 +/- ##
==========================================
- Coverage 88.64% 88.62% -0.02%
==========================================
Files 881 882 +1
Lines 100873 101370 +497
==========================================
+ Hits 89421 89843 +422
- Misses 11452 11527 +75
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this PR is merged, we need to port some of the recent changes in appsi to here.
I have now gone through all of the changed files. |
return default_config_block(self, init)[0] | ||
|
||
def set_options(self, options): | ||
""" | ||
Method to manually set options; can be called outside of the solve method | ||
""" | ||
opts = {k: v for k, v in options.value().items() if v is not None} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation implicitly assumes options
is a ConfigDict
. We should update the documentation to include argument type specification, and then update the implementation to accept dict
or ConfigDict
(by dropping the call to value()
:
opts = {k: v for k, v in options.items() if v is not None}
return objective | ||
|
||
|
||
class _VarAndNamedExprCollector(ExpressionValueVisitor): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO (later): this should be ported to the StreamBasedExpressionVisitor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have lots of these conversions to do...
Fixes #1030 (doesn't actually fix it; just the next step)
Summary/Motivation:
This is meant to be a "mid-point" for the ongoing solver refactor. It is currently working in this form, so this PR is intended to merge changes up to now so we can start making more fine-tuned changes that are easier to track.
Changes proposed in this PR:
pylint
)Legal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: