qpsolvers / qpbenchmark

Benchmark for quadratic programming solvers available in Python
Apache License 2.0
111 stars 10 forks source link

Compute eigenvalues to determine if a matrix is positive definite #68

Closed darnstrom closed 1 year ago

darnstrom commented 1 year ago

Some Hessians that are singular are currently not filtered out in is_posdef by using the Cholesky factorization because of numerical reasons. For example, the problem HS51 in the MM test set is clearly singular, but is_posdef still returns true.

A more robust (although more expensive) approach is to directly ensure that all eigenvalues are positive.

stephane-caron commented 1 year ago

The rank of $P \in \mathbb{R}^{5 \times 5}$ in HS51 is indeed at most 4. Differences between the former and proposed checks appear on four problems:

problem.name='GENHS28', is_posdef_cholesky=True, is_posdef_eigvals=False, min(eigvals)=-1.9958188852377765e-16
problem.name='HS51', is_posdef_cholesky=True, is_posdef_eigvals=False, min(eigvals)=-6.735404111281064e-17
problem.name='HS53', is_posdef_cholesky=True, is_posdef_eigvals=False, min(eigvals)=-6.735404111281064e-17
problem.name='HS52', is_posdef_cholesky=True, is_posdef_eigvals=False, min(eigvals)=-1.7634110012218942e-16

The smallest eigenvalues on all four problems are negative so the fix is :heavy_check_mark: Thanks :smiley: