LIRRA  1.0.0
Loading...
Searching...
No Matches
rl_stl.stl.jax_robustness Namespace Reference

Classes

class  CompiledRobustness
 

Functions

CompiledRobustness compile_robustness (STLFormula formula, int start_time=0)
 
CompiledRobustness compile_robustness_trace (STLFormula formula, Sequence[int] start_times)
 
jnp.ndarray stl_hinge_penalty (jnp.ndarray rho, float delta)
 

Variables

 Evaluator = Callable[[jnp.ndarray], jnp.ndarray]
 

Detailed Description

Compile ``stlpy`` formulas into jittable JAX robustness functions.

``stlpy`` owns formula construction; this module only evaluates the standard
discrete-time quantitative semantics (Donze and Maler) that ``stlpy``'s
``robustness()`` implements, so the same formula object can be scored inside a
JIT-compiled, vmapped MJX rollout:

- ``LinearPredicate``: ``rho = a^T y_t - b``
- ``STLTree`` "and": ``min_i rho(child_i, t + timesteps_i)``
- ``STLTree`` "or":  ``max_i rho(child_i, t + timesteps_i)``

The tree is walked **once in Python** at compile time. Children that are the same
object (``always``/``eventually`` repeat one subformula over a time interval) are
grouped, their time indices are deduplicated, and each group becomes a single
gather. The resulting function has only static shapes and indices.

Signals are ``(T+1, d)`` arrays (time first), unlike ``stlpy``'s ``(d, T+1)``.
``NonlinearPredicate`` is not supported (the MICP layer does not support it either).

Reward timing is *not* decided here; see :func:`stl_hinge_penalty` and the X2
environment docstring for how windowed robustness is turned into per-step rewards.

Function Documentation

◆ compile_robustness()

CompiledRobustness rl_stl.stl.jax_robustness.compile_robustness ( STLFormula  formula,
int   start_time = 0 
)
Robustness of ``formula`` at ``start_time`` for a ``(T+1, d)`` (or batched ``(..., T+1, d)``) signal.

◆ compile_robustness_trace()

CompiledRobustness rl_stl.stl.jax_robustness.compile_robustness_trace ( STLFormula  formula,
Sequence[int]  start_times 
)
Robustness at several start times at once, e.g. every window start of a buffer.

◆ stl_hinge_penalty()

jnp.ndarray rl_stl.stl.jax_robustness.stl_hinge_penalty ( jnp.ndarray  rho,
float  delta 
)
Capped STL term ``max(0, delta - rho)``: zero once the margin ``delta`` is met.

Variable Documentation

◆ Evaluator

rl_stl.stl.jax_robustness.Evaluator = Callable[[jnp.ndarray], jnp.ndarray]