(self, m, eta, augment=True)
return fCm, fcv
Compute cost estimates used in the LQR backward pass.
Compute cost estimates used in the LQR backward pass.
Compute cost estimates used in the LQR backward pass .
def compute_costs(self, m, eta, augment=True):
        """ Compute cost estimates used in the LQR backward pass. """
        traj_info, traj_distr = self.cur[m].traj_info, self.cur[m].traj_distr
        if not augment:  # Whether to augment cost with term to penalize KL
            return traj_info.Cm, traj_info.cv

        multiplier = self._hyperparams['max_ent_traj']
        fCm, fcv = traj_info.Cm / (eta + multiplier), traj_info.cv / (eta + multiplier)
        K, ipc, k = traj_distr.K, traj_distr.inv_pol_covar, traj_distr.k

        # Add in the trajectory divergence term.
        for t in range(self.T - 1, -1, -1):
            fCm[t, :, :] += eta / (eta + multiplier) * np.vstack([
                np.hstack([
                    K[t, :, :].T.dot(ipc[t, :, :]).dot(K[t, :, :]),
                    -K[t, :, :].T.dot(ipc[t, :, :])
                ]),
                np.hstack([
                    -ipc[t, :, :].dot(K[t, :, :]), ipc[t, :, :]
                ])
            ])
            fcv[t, :] += eta / (eta + multiplier) * np.hstack([
                K[t, :, :].T.dot(ipc[t, :, :]).dot(k[t, :]),
                -ipc[t, :, :].dot(k[t, :])
            ])

        return fCm, fcv
def compute_costs ( self , m , eta , augment = True ) : traj_info , traj_distr = self . cur [ m ] . traj_info , self . cur [ m ] . traj_distr if not augment : # Whether to augment cost with term to penalize KL return traj_info . Cm , traj_info . cv multiplier = self . _hyperparams [ 'max_ent_traj' ] fCm , fcv = traj_info . Cm / ( eta + multiplier ) , traj_info . cv / ( eta + multiplier ) K , ipc , k = traj_distr . K , traj_distr . inv_pol_covar , traj_distr . k # Add in the trajectory divergence term. for t in range ( self . T - 1 , - 1 , - 1 ) : fCm [ t , : , : ] += eta / ( eta + multiplier ) * np . vstack ( [ np . hstack ( [ K [ t , : , : ] . T . dot ( ipc [ t , : , : ] ) . dot ( K [ t , : , : ] ) , - K [ t , : , : ] . T . dot ( ipc [ t , : , : ] ) ] ) , np . hstack ( [ - ipc [ t , : , : ] . dot ( K [ t , : , : ] ) , ipc [ t , : , : ] ] ) ] ) fcv [ t , : ] += eta / ( eta + multiplier ) * np . hstack ( [ K [ t , : , : ] . T . dot ( ipc [ t , : , : ] ) . dot ( k [ t , : ] ) , - ipc [ t , : , : ] . dot ( k [ t , : ] ) ] ) return fCm , fcv