feat: optimize stretch using a Hessian matrix#204
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #204 +/- ##
==========================================
+ Coverage 77.50% 82.00% +4.50%
==========================================
Files 3 3
Lines 40 50 +10
==========================================
+ Hits 31 41 +10
Misses 9 9
🚀 New features to boost your workflow:
|
| gra = gra.flatten() | ||
| return fun, gra | ||
|
|
||
| def hessian(stretch_vec): |
There was a problem hiding this comment.
do we need a test for this?
There was a problem hiding this comment.
Good idea. I have added a test checking for some of the expected properties (right shape, symmetric, correct ordering/cross-coupling).
| return fun, gra | ||
|
|
||
| def _regularize_function_hessian(self, stretch): | ||
| residuals, d_stretch_comps, dd_stretch_comps = ( |
There was a problem hiding this comment.
this could use some dicumentation and also maybe a more descriptive variable name. Stretch is a verb usually and I would expect a noun here.
We were pretty lazy about documenting code in the early part of the project because we wanted it to get going from a low place, but we are at the point of the project where we can take the time to make the code more maintainable moving forward.
This is another PR bringing us closer to parity with MATLAB. Proper use of a Hessian was key to the speed and quality of convergence they were able to obtain. I had tried this a few times before, but it never worked even though the Hessian had the right shape. By properly regularizing, it now works.