(states, actions, perturbations, limits=None)
return state_actions
Create state-action pairs by perturbing the actions.

    Parameters
    ----------
    states : ndarray
        An (N x n) array of states at which we want to generate state-action
        pairs.
    actions : ndarray
        An (N x m) array of baseline actions at these states. These
        corresponds to the actions taken by the current policy.
    perturbations : ndarray
        An (X x m) array of policy perturbations that are to be applied to
        each state-action pair.
    limits : list
        List of action-limit tuples.

    Returns
    -------
    state-actions : ndarray
        An (N*X x n+m) array of state-actions pairs, where for each state
        the corresponding action is perturbed by the perturbations.
Create state-action pairs by perturbing the actions.
Create state - action pairs by perturbing the actions .
def perturb_actions(states, actions, perturbations, limits=None):
    """Create state-action pairs by perturbing the actions.

    Parameters
    ----------
    states : ndarray
        An (N x n) array of states at which we want to generate state-action
        pairs.
    actions : ndarray
        An (N x m) array of baseline actions at these states. These
        corresponds to the actions taken by the current policy.
    perturbations : ndarray
        An (X x m) array of policy perturbations that are to be applied to
        each state-action pair.
    limits : list
        List of action-limit tuples.

    Returns
    -------
    state-actions : ndarray
        An (N*X x n+m) array of state-actions pairs, where for each state
        the corresponding action is perturbed by the perturbations.

    """
    num_states, state_dim = states.shape

    # repeat states
    states_new = np.repeat(states, len(perturbations), axis=0)

    # generate perturbations from perturbations around baseline policy
    actions_new = (np.repeat(actions, len(perturbations), axis=0)
                   + np.tile(perturbations, (num_states, 1)))

    state_actions = np.column_stack((states_new, actions_new))

    if limits is not None:
        # Clip the actions
        perturbations = state_actions[:, state_dim:]
        np.clip(perturbations, limits[:, 0], limits[:, 1], out=perturbations)
        # Remove rows that are not unique
        state_actions = unique_rows(state_actions)

    return state_actions
def perturb_actions ( states , actions , perturbations , limits = None ) : num_states , state_dim = states . shape # repeat states states_new = np . repeat ( states , len ( perturbations ) , axis = 0 ) # generate perturbations from perturbations around baseline policy actions_new = ( np . repeat ( actions , len ( perturbations ) , axis = 0 ) + np . tile ( perturbations , ( num_states , 1 ) ) ) state_actions = np . column_stack ( ( states_new , actions_new ) ) if limits is not None : # Clip the actions perturbations = state_actions [ : , state_dim : ] np . clip ( perturbations , limits [ : , 0 ] , limits [ : , 1 ] , out = perturbations ) # Remove rows that are not unique state_actions = unique_rows ( state_actions ) return state_actions