lq/pgrl.py
def uniform_random_search_linpolicy(self, K0, N, T, linf_norm=3):
        '''
        Uniform random search
        Initialization is not important
        :param N: Number of rollouts
        :param T: Time horizon
        :param linf_norm: Maximum controller value
        :return: Controller by uniform random linear policy
        '''

        Lin_gain = LinK(copy.copy(K0))
        best_K = Lin_gain.K
        best_reward = -float("inf")
        for k in range(N):
            Lin_gain.K = Lin_gain.uniform_sample_gain(linf_norm)
            _, _, costs, _ = self.dyn.one_rollout(Lin_gain.lin_policy, T)
            reward = - np.sum(costs)/T
            if reward > best_reward:
                best_reward = reward
                best_K = Lin_gain.K
        return best_K

        Uniform random search
        Initialization is not important
        :param N: Number of rollouts
        :param T: Time horizon
        :param linf_norm: Maximum controller value
        :return: Controller by uniform random linear policy
        
Uniform random search
Initialization is not important
Uniform random search Initialization is not important
def uniform_random_search_linpolicy(self, K0, N, T, linf_norm=3):
        Lin_gain = LinK(copy.copy(K0))
        best_K = Lin_gain.K
        best_reward = -float("inf")
        for k in range(N):
            Lin_gain.K = Lin_gain.uniform_sample_gain(linf_norm)
            _, _, costs, _ = self.dyn.one_rollout(Lin_gain.lin_policy, T)
            reward = - np.sum(costs)/T
            if reward > best_reward:
                best_reward = reward
                best_K = Lin_gain.K
        return best_K
def uniform_random_search_linpolicy ( self , K0 , N , T , linf_norm = 3 ) : Lin_gain = LinK ( copy . copy ( K0 ) ) best_K = Lin_gain . K best_reward = - float ( "inf" ) for k in range ( N ) : Lin_gain . K = Lin_gain . uniform_sample_gain ( linf_norm ) _ , _ , costs , _ = self . dyn . one_rollout ( Lin_gain . lin_policy , T ) reward = - np . sum ( costs ) / T if reward > best_reward : best_reward = reward best_K = Lin_gain . K return best_K
Uniform random search
Initialization is not important
Uniform random search Initialization is not important
'''
        Uniform random search
        Initialization is not important
        :param N: Number of rollouts
        :param T: Time horizon
        :param linf_norm: Maximum controller value
        :return: Controller by uniform random linear policy
        '''
Controller by uniform random linear policy
Controller by uniform random linear policy
self
K0
N
Number of rollouts
Number of rollouts
T
None
linf_norm
Maximum controller value
Maximum controller value