-
Notifications
You must be signed in to change notification settings - Fork 541
pyomo.doe adding more verbose output for sensitivity analysis #3525
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?
Conversation
@adowling2 @djlaky ready for early feedback |
Next step:
|
pyomo/contrib/doe/doe.py
Outdated
if abs(E_vals.imag[E_ind]) > 1e-8: | ||
self.logger.warning( | ||
"Eigenvalue has imaginary component greater than 1e-6, contact developers if this issue persists." | ||
"Eigenvalue has imaginary component greater than 1e-8, contact developers if this issue persists." |
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.
nit: this is why "embedded constants are evil". An improved solution would be to declare a module-level constant (maybe IMAG_THRESHOLD
) and then use that both in the test and in the message.
@smondal13 See #3532 for an example of what @jsiirola is suggesting |
…alue checking in compute_FIM_full_factorial()
…pute_FIM_metrics` function.
… doe object that uses the "reactor_experiment" example in doe directory. Also added the png files to gitignore that are stored when "reactor_example.py" is run.
6e68c2b
to
e9e83b6
Compare
…M_metrics.py` instead of importing idaes, only the solvers are imported.
… adding_eigen_values
…_compute_FIM_metric funciton in doe
…IM() staticmethod of DesignOfExperiments class
… in compute_FIM_full_factorial that is ready to be deleted.
@adowling2 Ready for review. |
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.
@smondal13 This looks really close. I left a few minor comments.
@blnicho @jsiirola @mrmundt This is ready for a design review from the Pyomo team. I am moving it on the project board.
pyomo/contrib/doe/doe.py
Outdated
"FIM provided matches expected dimensions from model and is approximately positive (semi) definite." | ||
) | ||
|
||
# TODO: Make this a static method |
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.
You can remove this TODO.
pyomo/contrib/doe/doe.py
Outdated
_compute_FIM_metrics(FIM) | ||
) | ||
""" | ||
Since we are using the `_compute_FIM_metrics()` to compute the metrics in this chunk of code., This chunk of code is ready to be deleted. |
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.
Please delete if you feel it is no longer needed. It is in the Git history in case we need to find it.
E_vals, E_vecs = np.linalg.eig(FIM) | ||
E_ind = np.argmin(E_vals.real) # index of smallest eigenvalue | ||
|
||
# Warn the user if there is a ``large`` imaginary component (should not be) |
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.
Will you ever get to this warning? Or will _check_FIM throw an error first?
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.
@adowling2 _check_FIM()
will not trigger this warning. _check_FIM()
only checks whether the FIM is square, symmetric, and positive definite. Although this method checks for the symmetry of the FIM with a tolerance, and it is unlikely that the FIM will have large imaginary eigenvalues, we have kept the warning there just in case there is a large imaginary eigenvalue.
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.
@smondal13 Thank you.
@blnicho @mrmundt Is there a best practice for testing this warning message is properly thrown?
Also, @smondal13, please remove the draft status. |
…_FIM_full_factorial()` which was replaced by function call `_compute_FIM_metrics()`
…ght that will be helpful for the user to understand the method.
@adowling2 I have implemented your suggestions. I have also added |
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.
Pending input from the Pyomo team, I think this PR is ready to merge.
E_vals, E_vecs = np.linalg.eig(FIM) | ||
E_ind = np.argmin(E_vals.real) # index of smallest eigenvalue | ||
|
||
# Warn the user if there is a ``large`` imaginary component (should not be) |
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.
@smondal13 Thank you.
@blnicho @mrmundt Is there a best practice for testing this warning message is properly thrown?
|
||
|
||
class TestFIMWarning(unittest.TestCase): | ||
def test_FIM_eigenvalue_warning(self): |
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.
Fixes # .
Summary/Motivation:
get_labeled_model()
.Changes proposed in this PR:
compute_FIM_full_factorial()
_check_FIM()
by separating it fromcheck_model_FIM()
_compute_FIM_metrics()
get_FIM_metrics()
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: