-
Notifications
You must be signed in to change notification settings - Fork 550
Model Observer #3695
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
base: main
Are you sure you want to change the base?
Model Observer #3695
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3695 +/- ##
==========================================
- Coverage 89.20% 89.17% -0.04%
==========================================
Files 892 894 +2
Lines 103018 103546 +528
==========================================
+ Hits 91894 92332 +438
- Misses 11124 11214 +90
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:
|
""" | ||
|
||
|
||
class AutoUpdateConfig(ConfigDict): |
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.
Is the intent that this lives here, not in pyomo.contrib.solver.common.config
? If so, delete it there; otherwise, import it.
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.
All of the deletions from pyomo.contrib.solver
related to this will be in a separate PR after I refactor those interfaces to use this. For now, it will have to be in both places.
) | ||
|
||
|
||
class Observer(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.
Channeling John here - does this need to inherit from abc.ABC
? What does it get us that NotImplemented
doesn't deliver?
Also, this is basically the same as part of PersistentSolverBase
. Again, what is the long term intent? Will PersistentSolverBase
end up inheriting from this?
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 will eventually delete PersistentSolverBase
.
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.
But not quite yet.
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.
ABC
forces all derived classes to implement the specified methods.
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 really don't understand the dislike of ABC
obs.add_parameters(params) | ||
|
||
def _check_for_new_vars(self, variables: List[VarData]): | ||
new_vars = {} |
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.
Isn't enough to make new_vars a list and append non referenced variables?
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.
Yes, you are right!
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 think also this pattern is repeated multiple times.
Summary/Motivation:
This PR extracts the code for detecting changes in models from the persistent solver interfaces to its own, independent functionality. I will have a separate PR shortly that removes the code from the solver interfaces and updates them to use this code.
Changes proposed in this PR:
observer
that can be used to inform other classes of what changed in a pyomo model.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: