Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added unit test for riccati equation
  • Loading branch information
Daniel Bankmann
Daniel Bankmann committed Mar 21, 2019
commit 3ece9aa539e75f2e3a9524f8b6c10564d96702fa
30 changes: 30 additions & 0 deletions examples/test-riccati.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import numpy as np
import control


#unit test for stabilizing and anti-stabilizing feedbacks
#continuous-time

A = np.diag([1,-1])
B = np.identity(2)
Q = np.identity(2)
R = np.identity(2)
S = 0 * B
E = np.identity(2)
X, L , G = control.care(A, B, Q, R, S, E, stabilizing=True)
assert np.all(np.real(L) < 0)
X, L , G = control.care(A, B, Q, R, S, E, stabilizing=False)
assert np.all(np.real(L) > 0)


#discrete-time
A = np.diag([0.5,2])
B = np.identity(2)
Q = np.identity(2)
R = np.identity(2)
S = 0 * B
E = np.identity(2)
X, L , G = control.dare(A, B, Q, R, S, E, stabilizing=True)
assert np.all(np.abs(L) < 1)
X, L , G = control.dare(A, B, Q, R, S, E, stabilizing=False)
assert np.all(np.abs(L) > 1)