kernel_sr_max#

Kernel-based stochastic reachability.

Maximal stochastic reachability.

class gym_socks.algorithms.reach.kernel_sr_max.KernelMaximalSR(time_horizon=None, constraint_tube=None, target_tube=None, problem='THT', regularization_param=None, kernel_fn=None, batch_size=None, verbose=False, *args, **kwargs)[source]#

Stochastic reachability using kernel distribution embeddings.

Computes an approximation of the maximal safety probabilities of the stochastic reachability problem using kernel methods.

Parameters
  • time_horizon (int) – Number of time steps to compute the approximation.

  • constraint_tube (list) – List of spaces or constraint functions. Must be the same length as time_horizon.

  • target_tube (list) – List of spaces or target functions. Must be the same length as time_horizon.

  • problem (str) – One of {“THT”, “FHT”}. “THT” specifies the terminal-hitting time problem and “FHT” specifies the first-hitting time problem.

  • kernel_fn – Kernel function used by the approximation.

  • regularization_param (float) – Regularization parameter used in the solution to the regularized least-squares problem.

  • batch_size (int) – The batch size for more memory-efficient computations. Omit this parameter or set to None to compute without batch processing.

  • verbose (bool) – Boolean flag to indicate verbose output.

fit(S, A)[source]#

Run the algorithm.

Parameters
  • S (numpy.ndarray) – Sample of (x, u, y) tuples taken iid from the system evolution. The sample should be in the form of a list of tuples.

  • A (numpy.ndarray) – Collection of admissible control action to choose from. Should be in the form of a 2D-array, where each row indicates a point.

Returns

Instance of KernelMaximalSR class.

Return type

self

predict(T)[source]#

Predict.

Parameters

T – Evaluation points to evaluate the safety probabilities at. Should be in the form of a 2D-array, where each row indicates a point.

Returns

An array of safety probabilities of shape {len(T), time_horizon}, where each row indicates the safety probabilities of the evaluation points at a different time step.

score()[source]#
gym_socks.algorithms.reach.kernel_sr_max.kernel_sr_max(S, A, T, time_horizon=None, constraint_tube=None, target_tube=None, problem='THT', regularization_param=None, kernel_fn=None, batch_size=None, verbose=False)[source]#

Stochastic reachability using kernel distribution embeddings.

Computes an approximation of the maximal safety probabilities of the stochastic reachability problem using kernel methods.

Parameters
  • S (numpy.ndarray) – Sample of (x, u, y) tuples taken iid from the system evolution. The sample should be in the form of a list of tuples.

  • A (numpy.ndarray) – Collection of admissible control action to choose from. Should be in the form of a 2D-array, where each row indicates a point.

  • T (numpy.ndarray) – Evaluation points to evaluate the safety probabilities at. Should be in the form of a 2D-array, where each row indicates a point.

  • time_horizon (Optional[int]) – Number of time steps to compute the approximation.

  • constraint_tube (Optional[list]) – List of spaces or constraint functions. Must be the same length as time_horizon.

  • target_tube (Optional[list]) – List of spaces or target functions. Must be the same length as time_horizon.

  • problem (str) – One of {“THT”, “FHT”}. “THT” specifies the terminal-hitting time problem and “FHT” specifies the first-hitting time problem.

  • kernel_fn – Kernel function used by the approximation.

  • regularization_param (Optional[float]) – Regularization parameter used in the solution to the regularized least-squares problem.

  • batch_size (Optional[int]) – The batch size for more memory-efficient computations. Omit this parameter or set to None to compute without batch processing.

  • verbose (bool) – Boolean flag to indicate verbose output.

Returns

An array of safety probabilities of shape {len(T), time_horizon}, where each row indicates the safety probabilities of the evaluation points at a different time step.