Skip to content

Commit 45fdea9

Browse files
committed
Added tests for acker, and place_varga. Added an assert_raises test for repeated poles in place. Added placeholder tests in matlab_test for place and acker and reverted the repeated pole test for place varga.
1 parent 100eb1f commit 45fdea9

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

control/tests/matlab_test.py

+8
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,17 @@ def testModred(self):
400400
modred(self.siso_ss3, [1], 'matchdc')
401401
modred(self.siso_ss3, [1], 'truncate')
402402

403+
@unittest.skipIf(not slycot_check(), "slycot not installed")
404+
def testPlace_varga(self):
405+
place_varga(self.siso_ss1.A, self.siso_ss1.B, [-2, -2])
406+
403407
def testPlace(self):
404408
place(self.siso_ss1.A, self.siso_ss1.B, [-2, -2.5])
405409

410+
def testAcker(self):
411+
acker(self.siso_ss1.A, self.siso_ss1.B, [-2, -2.5])
412+
413+
406414
@unittest.skipIf(not slycot_check(), "slycot not installed")
407415
def testLQR(self):
408416
(K, S, E) = lqr(self.siso_ss1.A, self.siso_ss1.B, np.eye(2), np.eye(1))

control/tests/statefbk_test.py

+21
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,27 @@ def testPlace(self):
180180
np.testing.assert_raises(ControlDimension, place, A[1:, :], B, P)
181181
np.testing.assert_raises(ControlDimension, place, A, B[1:, :], P)
182182

183+
# Check that we get an error if we ask for too many poles in the same
184+
# location. Here, rank(B) = 2, so lets place three at the same spot.
185+
P_repeated = np.array([-0.5, -0.5, -0.5, -8.6659])
186+
np.testing.assert_raises(ValueError, place, A, B, P_repeated)
187+
188+
def testPlace_varga(self):
189+
A = np.array([[1., -2.], [3., -4.]])
190+
B = np.array([[5.], [7.]])
191+
192+
P = np.array([-2., -2.])
193+
K = place_varga(A, B, P)
194+
P_placed = np.linalg.eigvals(A - B.dot(K))
195+
# No guarantee of the ordering, so sort them
196+
P.sort()
197+
P_placed.sort()
198+
np.testing.assert_array_almost_equal(P, P_placed)
199+
200+
# Test that the dimension checks work.
201+
np.testing.assert_raises(ControlDimension, place, A[1:, :], B, P)
202+
np.testing.assert_raises(ControlDimension, place, A, B[1:, :], P)
203+
183204
def check_LQR(self, K, S, poles, Q, R):
184205
S_expected = np.array(np.sqrt(Q * R))
185206
K_expected = S_expected / R

0 commit comments

Comments
 (0)