simplify hessian matrix structure initialization#349
Conversation
There was a problem hiding this comment.
Pull request overview
This PR simplifies initialization of the robust-homotopy Hessian sparse structure by deriving it directly from the Jacobian product J' * J (instead of building the structure via a graph-based neighbor traversal), motivated by profiling/performance.
Changes:
- Remove the custom graph-based
_create_hessian_matrix_structureimplementation. - Allocate the Hessian sparsity pattern by temporarily filling
J.Jv.nzval, computingHv = J.Jv' * J.Jv, and zeroing stored values afterward.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Performance ResultsPrecompile Time
Solve Time
|
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Copilot was right — verified that ac_power_flow_jacobian.jl:331-332 sets the LCC angle-constraint diagonals to 1.0 at structure creation, and edit: turns out the RH method as written isn't compatible with LCCs anyway...but it's a one-time cost, so I'll leave the save-and-restore. |
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Turns out these safeguards aren't strictly necessary: at the moment, |
LCCs add state variables to the Jacobian that the homotopy Hessian formulation does not account for, producing a dimension mismatch deep inside the solve. Fail fast at HomotopyHessian construction with a clear error message. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
I added a "no LCCs" guard on the RH method path and a basic test that exercises said guard. |
The problem is going to the that in real systems like WECC and the EI there will be LCCs in the data. |
Sure, I can work on an LCC-compatible robust homotopy method. But I'd still vote for merging this: throwing a human-readable error is improvement over "dimension mismatch." edit: there's a couple other things in this PR too, besides the LCC error |
Yeah, I don't think is blocking. Just nothing that it will be a consideration |
Currently there's some graph stuff for figuring out the sparse structure of the hessian of the homotopy function. I did some profiling a while back and found that simply computing
J^T Jis faster. Both give the same results: we want (2-or-fewer)-hop neighbors. Also usingJ^T J's structure generalizes better: e.g. proportional-to-headroom slack.