-
Notifications
You must be signed in to change notification settings - Fork 234
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
Fix methods in SVD Toolbox #1288
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1288 +/- ##
==========================================
- Coverage 77.41% 77.40% -0.01%
==========================================
Files 390 390
Lines 63404 63399 -5
Branches 11658 11658
==========================================
- Hits 49082 49074 -8
- Misses 11793 11797 +4
+ Partials 2529 2528 -1 ☔ View full report in Codecov by Sentry. |
idaes/core/util/model_diagnostics.py
Outdated
@@ -1450,6 +1450,10 @@ def __init__(self, model: _BlockData, **kwargs): | |||
self._model, scaled=False, equality_constraints_only=True | |||
) | |||
|
|||
# Get list of equality constraint and variable names | |||
self.eq_con_list = self.nlp.get_pyomo_equality_constraints() |
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 you should make these private. There is no reason the user should be changing these.
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 don't think they should be changing them, but they might have the desire to look at them. We can still make them semiprivate, though.
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.
If they want to see them then they can access to the nlp
object themselves, so I would tend toward hiding them until w have a good case otherwise (and then consider making them properties so they can't be changed). "Private" in Python is just convention anyways.
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.
Only one minor request.
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.
Good fix. list.index
is indeed not safe here.
nonzeroes = self.jacobian[:, var_idx].nonzero() | ||
nonzeros = self.jacobian.getcol(var_idx).nonzero() |
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.
What is the type of self.jacobian
here? I.e. dense, COO, CSC, etc. I guess for a single variable, performance isn't an issue here.
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.
It's some sparse type, I forget whether it's row or column based. Performance probably isn't an issue, so this is probably unnecessary, but I'm familiar with the methods whereas it's unclear (at least to me) how indexing sparse matrices works.
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.
getcol
and indexing do the same thing AFAIK. So one of row/col is slow and one is fast depending on whether the matrix CSC or CSR. If the matrix is COO, both are slow.
Summary/Motivation:
Use PyNumero methods to get constraint/variable indices rather than
list.index
because (I think)list.index
uses==
to compare elements, which is not what should be done for Pyomo objects. Fixes #1285 .Also add in string formatting for magnitude of Jacobian elements. Now it uses scientific notation with three digits past the decimal place. It's a lot better than having to deal with 16 digits.
Legal Acknowledgement
By contributing to this software project, I agree to the following terms and conditions for my contribution: