Skip to content

qe.solve_discrete_riccati versus scipy.linalg.solve_discrete_are #360

Closed
@oyamad

Description

@oyamad

Related to #84 and #356, but open a separate issue.

The claim in the docstring in solve_discrete_riccati

Note that SciPy also has a discrete riccati equation solver. However it
cannot handle the case where :math:R is not invertible, or when :math:N
is nonzero.

is no longer true.

  • See this for nonzero N, and
  • see below for singular R.

dare_test_tjm_2:

A = [[0, -1],
     [0, 2]]
B = [[1, 0],
     [1, 1]]
Q = [[1, 0],
     [0, 0]]
R = [[4, 2],
     [2, 1]]
A, B, Q, R = np.atleast_2d(A, B, Q, R)
# X = qe.solve_discrete_riccati(A, B, Q, R)  # LinAlgError on my osx
X_sp = scipy.linalg.solve_discrete_are(A, B, Q, R)
Y = np.zeros((2, 2))
Y[0, 0] = 1
np.max(np.abs(X_sp - Y))
1.2591976102547471e-16

dare_test_tjm_3:

r = 0.5
I = np.identity(2)
A = [[2 + r**2, 0],
     [0,        0]]
A = np.array(A)
B = I
R = [[1, r],
     [r, r*r]]
Q = I - np.dot(A.T, A) + np.dot(A.T, np.linalg.solve(R + I, A))
# X = qe.solve_discrete_riccati(A, B, Q, R)  # LinAlgError on my osx
X_sp = scipy.linalg.solve_discrete_are(A, B, Q, R)
Y = np.identity(2)
np.max(np.abs(X_sp - Y))
1.2510407154664449e-08

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions