diff --git a/solutions/ex06/boeing_lqr_TODO_1.py b/solutions/ex06/boeing_lqr_TODO_1.py new file mode 100644 index 0000000000000000000000000000000000000000..649101b863582d56a84037200d9af8aa6f4f240a --- /dev/null +++ b/solutions/ex06/boeing_lqr_TODO_1.py @@ -0,0 +1 @@ + Q, R, q = compute_Q_R_q(model, dt) \ No newline at end of file diff --git a/solutions/ex06/boeing_lqr_TODO_2.py b/solutions/ex06/boeing_lqr_TODO_2.py new file mode 100644 index 0000000000000000000000000000000000000000..ba3dbc6d413831fcf93881aaa3cc7c57de0faa8a --- /dev/null +++ b/solutions/ex06/boeing_lqr_TODO_2.py @@ -0,0 +1 @@ + agent = LQRAgent(env, A=A, B=B, d=d, Q=Q, R=R, q=q) \ No newline at end of file diff --git a/solutions/ex06/boeing_lqr_TODO_3.py b/solutions/ex06/boeing_lqr_TODO_3.py new file mode 100644 index 0000000000000000000000000000000000000000..e5328ff95c26a95435a5b895e55ae51f313de1b6 --- /dev/null +++ b/solutions/ex06/boeing_lqr_TODO_3.py @@ -0,0 +1,3 @@ + Q = cost.Q * dt + R = cost.R * dt + q = cost.q * dt \ No newline at end of file diff --git a/solutions/ex06/boeing_lqr_TODO_4.py b/solutions/ex06/boeing_lqr_TODO_4.py new file mode 100644 index 0000000000000000000000000000000000000000..51001722bf435248844d7ff1017d944e8cb76515 --- /dev/null +++ b/solutions/ex06/boeing_lqr_TODO_4.py @@ -0,0 +1,2 @@ + B_discrete = scipy.linalg.inv(model.A) @ (A_discrete - np.eye(model.A.shape[0])) @ model.B + d_discrete = scipy.linalg.inv(model.A) @ (A_discrete - np.eye(model.A.shape[0])) @ d \ No newline at end of file diff --git a/solutions/ex06/dlqr_TODO_1.py b/solutions/ex06/dlqr_TODO_1.py new file mode 100644 index 0000000000000000000000000000000000000000..7615471215df32bb0a15c21521405bc6c5a98620 --- /dev/null +++ b/solutions/ex06/dlqr_TODO_1.py @@ -0,0 +1,2 @@ +import matplotlib +matplotlib.use('agg') \ No newline at end of file diff --git a/solutions/ex06/dlqr_TODO_2.py b/solutions/ex06/dlqr_TODO_2.py new file mode 100644 index 0000000000000000000000000000000000000000..f34eec89ded8b2cd4c0e26f7ae7c591acee7983c --- /dev/null +++ b/solutions/ex06/dlqr_TODO_2.py @@ -0,0 +1 @@ + V[N], v[N], vc[N] = QN, qN, qcN \ No newline at end of file diff --git a/solutions/ex06/dlqr_TODO_3.py b/solutions/ex06/dlqr_TODO_3.py new file mode 100644 index 0000000000000000000000000000000000000000..14bb8adaaca89f614c42617c8fc365d0942ef10a --- /dev/null +++ b/solutions/ex06/dlqr_TODO_3.py @@ -0,0 +1,4 @@ + Suu = R[k] + B[k].T @ (V[k+1] + mu * In) @ B[k] + Sux = H[k] + B[k].T @ (V[k+1] + mu * In) @ A[k] + Su = r[k] + B[k].T @ v[k + 1] + B[k].T @ V[k + 1] @ d[k] + L[k] = -np.linalg.solve(Suu, Sux) \ No newline at end of file diff --git a/solutions/ex06/lqr_agent_TODO_1.py b/solutions/ex06/lqr_agent_TODO_1.py new file mode 100644 index 0000000000000000000000000000000000000000..f82d69ea2e0a0dd9908e4225fc5d91d15aeba58d --- /dev/null +++ b/solutions/ex06/lqr_agent_TODO_1.py @@ -0,0 +1 @@ + (self.L, self.l), _ = LQR(A=[A]*N, B=[B]*N, d=[d]*N if d is not None else None, Q=[Q]*N, q=[q]*N if q is not None else None, R=[R]*N) \ No newline at end of file diff --git a/solutions/ex06/lqr_agent_TODO_2.py b/solutions/ex06/lqr_agent_TODO_2.py new file mode 100644 index 0000000000000000000000000000000000000000..e8994b09a036a2f4a3fdc42140cef04aa9f56c86 --- /dev/null +++ b/solutions/ex06/lqr_agent_TODO_2.py @@ -0,0 +1 @@ + u = self.L[k] @ x + self.l[k] \ No newline at end of file diff --git a/solutions/ex06/lqr_pid_TODO_1.py b/solutions/ex06/lqr_pid_TODO_1.py new file mode 100644 index 0000000000000000000000000000000000000000..920d0e7e101dad7c87a2df2be8ecd3209a946a8d --- /dev/null +++ b/solutions/ex06/lqr_pid_TODO_1.py @@ -0,0 +1,3 @@ + def pi(self,x, k, info=None): + action = self.L[0] @ x + self.l[0] + return action \ No newline at end of file diff --git a/solutions/ex06/lqr_pid_TODO_2.py b/solutions/ex06/lqr_pid_TODO_2.py new file mode 100644 index 0000000000000000000000000000000000000000..2f1ad2ab157ba7524df0a89e73c93cdf860e398f --- /dev/null +++ b/solutions/ex06/lqr_pid_TODO_2.py @@ -0,0 +1 @@ + Kp, Kd = (-L0).flat \ No newline at end of file