Skip to content

Commit 384e36a

Browse files
committed
update lqcontrol
1 parent 1b2394b commit 384e36a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

quantecon/_lqcontrol.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,18 @@ def update_values(self):
183183
"""
184184
# === Simplify notation === #
185185
Q, R, A, B, N, C = self.Q, self.R, self.A, self.B, self.N, self.C
186-
P, d = self.P, self.d
186+
P, d = map(np.atleast_2d, (self.P, self.d))
187+
187188
# == Some useful matrices == #
188-
S1 = Q + self.beta * B.T @ np.dot(P, B)
189-
S2 = self.beta * B.T @ np.dot(P, A) + N
190-
S3 = self.beta * A.T @ np.dot(P, A)
189+
S1 = Q + self.beta * B.T @ P @ B
190+
S2 = self.beta * B.T @ P @ A + N
191+
S3 = self.beta * A.T @ P @ A
191192
# == Compute F as (Q + B'PB)^{-1} (beta B'PA + N) == #
192193
self.F = solve(S1, S2)
193194
# === Shift P back in time one step == #
194195
new_P = R - S2.T @ self.F + S3
195196
# == Recalling that trace(AB) = trace(BA) == #
196-
new_d = self.beta * (d + np.trace(np.dot(P, C @ C.T)))
197+
new_d = self.beta * (d + np.trace(P @ C @ C.T))
197198
# == Set new state == #
198199
self.P, self.d = new_P, new_d
199200

0 commit comments

Comments
 (0)