Skip to content
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

Using pivot perturbation for ill-conditioned state estimation #862

Merged
merged 62 commits into from
Jan 24, 2025

Conversation

TonyXiang8787
Copy link
Member

@TonyXiang8787 TonyXiang8787 commented Dec 30, 2024

Closes #853

Mathematical approach

This PR attempts to fix the problem by using pivot perturbation. This is an alternative method than partial/full pivoting method in the LU factorization. In this way, the structure of the sparse matrix is not changed. The methods are described in [Li99] and [Schenk04].

This PR applies the methods with following aspects:

  1. The perturbation threshold is set to $\epsilon = 10^{-13}$, same as used in MKL PARDISO. This applied for both perturbed pivot and iterative refinement.
  2. The infinite-norm of the matrix is calculated block-wise. First the infinite norm of each block is calculated, then the norm of the whole matrix by treating each block as a single value. When calculating the whole matrix, the diagonal blocks are ignored. In Power System State Estimation, we sometimes have huge diagonal values. We do not want those values to influence the norm of the matrix.
  3. The backward error is calculated by capping the denominators to a minimum to avoid scenarios where both $|x|$ and $|b|$ are zero.

$$ D_{\max} = \max_i {(|A||x| + |b|)_i} $$

$$berr = \max_{ i } {\frac{|r|_i}{\max ( (|A||x| + |b|)_i, \epsilon_{berr} D_{\max}) }}$$ $$\epsilon_{berr} = 10^{-4}$$
  1. The iterative refinement is capped at 5 times. The convergence criteria is $berr < \epsilon$.

Implementation

We adjust LUSparseSolver to allow optionally pivot perturbation. To do this, the original matrix has to be cached to do the iterative refinement. Optional member data are defined in the class to store the cache. This perturbation is an opt-in feature which should only be enabled if we suspect ill-conditioned scenario. Currently, it is only enabled in State Estimation (both NR and IL) when the following two conditions are met:

  1. The system is sufficiently observable. We need this to make sure that we do not create fake observability by perturbation.
  2. The system could be possibly ill-conditioned. That means the following conditions are met:
    1. The bus does not have (zero) injection measurement.
    2. All upstream branches, i.e. branches between this bus and the buses with higher bus numbers, do not have branch measurement.
    3. The bus does not have a phasor voltage measurement.

Check list

  • Implement the core
  • Unit test
  • Extensive validation test
  • Documentation
  • Run Nightly

Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
Signed-off-by: Tony Xiang <[email protected]>
@TonyXiang8787 TonyXiang8787 added improvement Improvement on internal implementation bug Something isn't working do-not-merge This should not be merged labels Dec 30, 2024
Signed-off-by: Tony Xiang <[email protected]>
@TonyXiang8787 TonyXiang8787 changed the title Experimental fix on Experimental fix using pivot perturbation for ill-conditioned state estimation Dec 30, 2024
Signed-off-by: Tony Xiang <[email protected]>
@figueroa1395
Copy link
Contributor

Since this is both a big and a very important PR, this is a friendly reminder to run the Nightly build manually once it is "ready" to be merged.

Signed-off-by: Tony Xiang <[email protected]>
@mgovers
Copy link
Member

mgovers commented Jan 21, 2025

For future reference purposes only

Signed-off-by: Martijn Govers <[email protected]>
@TonyXiang8787 TonyXiang8787 changed the title Experimental fix using pivot perturbation for ill-conditioned state estimation Using pivot perturbation for ill-conditioned state estimation Jan 23, 2025
@TonyXiang8787
Copy link
Member Author

@mgovers
Copy link
Member

mgovers commented Jan 23, 2025

Running the benchmark yields comparatively similar results. I found no significant regressions. In fact, the new implementation often appears to give slightly better results, in particular for ClangCL, but it is most most likely within run differences on my machine and therefore not significant.

output.zip

@mgovers
Copy link
Member

mgovers commented Jan 23, 2025

Profiling results

using the Visual Studio 2022 Profiler on msvc-release on power_grid_model_benchmark_cpp

Very similar results between main and this branch up to the IterativePFLUSolver (Root in the profiles below), and even into the SparseLUSolver. After that, the implementation changes a lot and therefore, the implementation is also different.

Note: the threaded version has almost identical behavior, as expected; see included .diagsession files

main

image

this branch

image

Diagsessions

msvc-release-profile-report.zip
s/assets/61aeb8e5-e172-4d3c-bc42-b8d03dd72ff8)

@TonyXiang8787
Copy link
Member Author

Copy link
Member

@mgovers mgovers left a comment

Choose a reason for hiding this comment

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

I hereby approve the current set of changes

@TonyXiang8787 TonyXiang8787 added this pull request to the merge queue Jan 24, 2025
Merged via the queue into main with commit e3d9c4f Jan 24, 2025
51 checks passed
@TonyXiang8787 TonyXiang8787 deleted the experimental/pivot-perturbation branch January 24, 2025 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working improvement Improvement on internal implementation
Projects
None yet
5 participants