Skip to content

Commit 3ece9aa

Browse files
author
Daniel Bankmann
committed
added unit test for riccati equation
1 parent cf77e23 commit 3ece9aa

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

examples/test-riccati.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import numpy as np
2+
import control
3+
4+
5+
#unit test for stabilizing and anti-stabilizing feedbacks
6+
#continuous-time
7+
8+
A = np.diag([1,-1])
9+
B = np.identity(2)
10+
Q = np.identity(2)
11+
R = np.identity(2)
12+
S = 0 * B
13+
E = np.identity(2)
14+
X, L , G = control.care(A, B, Q, R, S, E, stabilizing=True)
15+
assert np.all(np.real(L) < 0)
16+
X, L , G = control.care(A, B, Q, R, S, E, stabilizing=False)
17+
assert np.all(np.real(L) > 0)
18+
19+
20+
#discrete-time
21+
A = np.diag([0.5,2])
22+
B = np.identity(2)
23+
Q = np.identity(2)
24+
R = np.identity(2)
25+
S = 0 * B
26+
E = np.identity(2)
27+
X, L , G = control.dare(A, B, Q, R, S, E, stabilizing=True)
28+
assert np.all(np.abs(L) < 1)
29+
X, L , G = control.dare(A, B, Q, R, S, E, stabilizing=False)
30+
assert np.all(np.abs(L) > 1)

0 commit comments

Comments
 (0)