lq/model_estimation.py
def nominal_PK(self, K0, N, T, explore_mag=10, res_time=100):
        '''
        An iterative approach to find the optimal controller based on learning the dynamics.
        In each iteration, the system is rolled out with the current controller gain. Then, A_nom and B_nom
        are estimated and then the optimal controller gain K is computed by solving the Algebraic Riccati Equation
        Args:
            K0: Initial controller gain
            N: Number of iterations
            T: Rollout length
            explore_mag: Noise magnitude for excitement during data collection
            res_time: time to reset the initial condition of the system to have numerical stability

        Returns: P, K
        '''
        K = K0
        for n in range(N):
            if self.dyn.is_stable(K):
                A_nom, B_nom = self.nominal_AB(K, 1, T, explore_mag=explore_mag, res_time=res_time)
                try:
                    P = LA.solve_discrete_are(A_nom, B_nom, self.dyn.Q, self.dyn.R)
                    K = -LA.inv(B_nom.T @ P @ B_nom + self.dyn.R) @ B_nom.T @ P @ A_nom
                except:
                    P, K = self.unstable_P_and_K()
            else:
                P, K = self.unstable_P_and_K()
        return P, K

        An iterative approach to find the optimal controller based on learning the dynamics.
        In each iteration, the system is rolled out with the current controller gain. Then, A_nom and B_nom
        are estimated and then the optimal controller gain K is computed by solving the Algebraic Riccati Equation
        Args:
            K0: Initial controller gain
            N: Number of iterations
            T: Rollout length
            explore_mag: Noise magnitude for excitement during data collection
            res_time: time to reset the initial condition of the system to have numerical stability

        Returns: P, K
        
An iterative approach to find the optimal controller based on learning the dynamics.
In each iteration, the system is rolled out with the current controller gain. Then, A_nom and B_nom
are estimated and then the optimal controller gain K is computed by solving the Algebraic Riccati Equation
An iterative approach to find the optimal controller based on learning the dynamics . In each iteration the system is rolled out with the current controller gain . Then A_nom and B_nom are estimated and then the optimal controller gain K is computed by solving the Algebraic Riccati Equation
def nominal_PK(self, K0, N, T, explore_mag=10, res_time=100):
        K = K0
        for n in range(N):
            if self.dyn.is_stable(K):
                A_nom, B_nom = self.nominal_AB(K, 1, T, explore_mag=explore_mag, res_time=res_time)
                try:
                    P = LA.solve_discrete_are(A_nom, B_nom, self.dyn.Q, self.dyn.R)
                    K = -LA.inv(B_nom.T @ P @ B_nom + self.dyn.R) @ B_nom.T @ P @ A_nom
                except:
                    P, K = self.unstable_P_and_K()
            else:
                P, K = self.unstable_P_and_K()
        return P, K
def nominal_PK ( self , K0 , N , T , explore_mag = 10 , res_time = 100 ) : K = K0 for n in range ( N ) : if self . dyn . is_stable ( K ) : A_nom , B_nom = self . nominal_AB ( K , 1 , T , explore_mag = explore_mag , res_time = res_time ) try : P = LA . solve_discrete_are ( A_nom , B_nom , self . dyn . Q , self . dyn . R ) K = - LA . inv ( B_nom . T @ P @ B_nom + self . dyn . R ) @ B_nom . T @ P @ A_nom except : P , K = self . unstable_P_and_K ( ) else : P , K = self . unstable_P_and_K ( ) return P , K
An iterative approach to find the optimal controller based on learning the dynamics.
An iterative approach to find the optimal controller based on learning the dynamics .
'''
        An iterative approach to find the optimal controller based on learning the dynamics.
        In each iteration, the system is rolled out with the current controller gain. Then, A_nom and B_nom
        are estimated and then the optimal controller gain K is computed by solving the Algebraic Riccati Equation
        Args:
            K0: Initial controller gain
            N: Number of iterations
            T: Rollout length
            explore_mag: Noise magnitude for excitement during data collection
            res_time: time to reset the initial condition of the system to have numerical stability

        Returns: P, K
        '''
self
K0
Initial controller gain
Initial controller gain
N
Number of iterations
Number of iterations
T
None
explore_mag
Noise magnitude for excitement during data collection
Noise magnitude for excitement during data collection
res_time
time to reset the initial condition of the system to have numerical stability
time to reset the initial condition of the system to have numerical stability