Skip to content

Extended Parmest Capability for weighted SSE objective #3535

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

Open
wants to merge 36 commits into
base: main
Choose a base branch
from

Conversation

slilonfe5
Copy link

Fixes # .

Summary/Motivation:

Currently, the Parmest SSE objective does not support measurements in different units. This work adds a new capability (i.e., weighted SSE) to Parmest to handle measurements in different units.

Changes proposed in this PR:

  • Added a new weighted SSE calculation
  • Added a new covariance matrix calculation for the weighted SSE objective

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:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@slilonfe5
Copy link
Author

@adowling2 @djlaky

@adowling2
Copy link
Member

@slilonfe5 Here is some quick feedback

compute_jacobian function

  • Make this a private method by adding _ to the function name
  • Add as an argument to the function relative_perturbation
  • In the document string, explain this is using forward (?) finite difference
  • Add as an argument the solver object. You can make the default Ipopt.

Feedback on the compute_FIM method:

  • Add relative_tolerance and solver as arguments
  • Also add a check that error_list must be the same length as y_hat_list
  • Add a debugging step for the linear algebra error, compute the condition number of the Jacobian matrix and print it out
  • Why would you ever get a linear algebra error for just matrix multiplication? Is this check even needed?

@slilonfe5
Copy link
Author

slilonfe5 commented Apr 19, 2025

@adowling2 @djlaky I also updated the calculation for the normal SSE such that we can use the user-supplied measurement error if defined; otherwise, we calculate the measurement error as usual.

Copy link
Member

@adowling2 adowling2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice progress. I think it is time to start writing tests for the new capabilities.

@adowling2
Copy link
Member

@slilonfe5 Once you have the tests ready, tag us for feedback. Also, I think you can skip adding this to the depreciated class.

Copy link
Member

@adowling2 adowling2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is more feedback as you work on getting this ready for the Pyomo team to review.

@slilonfe5
Copy link
Author

@adowling2 @djlaky I have created a separate method (cov_est) for computing the covariance matrix, supporting three calculation methods (jacobian, kaug, and reduced_hessian). I implemented these covariance calculation methods for both the SSE and SSE_weighted objectives. Lastly, as you suggested, I did not add the new capability to the deprecated interface.

I tested these with three examples (2 steady state and 1 dynamic), and all work well. I'm yet to write the test file for these.

@slilonfe5 slilonfe5 marked this pull request as ready for review May 20, 2025 17:06
@slilonfe5
Copy link
Author

@adowling2 @djlaky @jsiirola @blnicho @mrmundt The new capabilities we are introducing in the parmest.py file are ready for review. The test file (test_new_parmest_capabilities.py) is almost ready, I have questions during today's meeting.

@mrmundt
Copy link
Contributor

mrmundt commented May 20, 2025

I did not review the test file at all yet - I wanted to at least give you all initial feedback to look over.

@adowling2
Copy link
Member

@mrmundt Thank you for leaving some starter comments. @slilonfe5 and I spoke today about moving the new tests back into the original file and removing the 'new_capabilities' testing file. But your overall comments are helpful!

@slilonfe5
Copy link
Author

@adowling2 @djlaky @mrmundt @blnicho @jsiirola
I have implemented the comments on the parmest.py and test_parmest.py files. I moved the test from the previous test_new_parmest_capabilities.py file to the test_parmest.py file. In the test_parmest.py file, the Rooney-Biegler paper example is used to test the 'SSE' and 'SSE_weighted' objectives for all covariance calculation methods ('reduced_hessian', 'finite_difference', and 'automatic_differentiation_kaug'), as well as the two cases of measurement errors (user-supplied and not supplied by the user). To keep the test file short and clean, I didn't consider the reactor design example. Also, I removed the test for the deprecated interface since this will eventually be removed. The above tests passed without issues.

However, I encountered an issue with the test for other functions, such as bootstrap and likelihood ratio. I plan to discuss it today at the Pyomo Dev meeting.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

5 participants