get_safe_sample

safe_learning.get_safe_sample(lyapunov, perturbations=None, limits=None, positive=False, num_samples=None, actions=None)

Compute a safe state-action pair for sampling.

This function returns the most uncertain state-action pair close to the current policy (as a result of the perturbations) that is safe (maps back into the region of attraction).

Parameters:
lyapunov : instance of `Lyapunov’

A Lyapunov instance with an up-to-date safe set.

perturbations : ndarray

An array that, on each row, has a perturbation that is added to the baseline policy in lyapunov.policy.

limits : ndarray, optional

The actuator limits. Of the form [(u_1_min, u_1_max), (u_2_min,..)…]. If provided, state-action pairs are clipped to ensure the limits.

positive : bool

Whether the Lyapunov function is positive-definite (radially increasing). If not, additional checks are carried out to ensure safety of samples.

num_samples : int, optional

Number of samples to select (uniformly at random) from the safe states within lyapunov.discretization as testing points.

actions : ndarray

A list of actions to evaluate for each state. Ignored if perturbations is not None.

Returns:
state-action : ndarray

A row-vector that contains a safe state-action pair that is promising for obtaining future observations.

var : float

The uncertainty remaining at this state.