|
| int | formula_horizon (STLFormula formula) |
| |
| Iterator[tuple[LinearPredicate, int]] | iter_predicates (STLFormula formula, int t=0) |
| |
| float | _pred_value (LinearPredicate pred, np.ndarray y_t) |
| |
| Interval | _pred_value_range (LinearPredicate pred, np.ndarray y_t) |
| |
| Interval | _pred_box_range (LinearPredicate pred, np.ndarray lo, np.ndarray hi) |
| |
| float | robustness (STLFormula formula, np.ndarray signal, int t=0, int|None observed_until=None) |
| |
| Interval | robustness_interval (STLFormula formula, np.ndarray prefix, np.ndarray signal_lo, np.ndarray signal_hi, int t=0, int|None observed_until=None) |
| |
| float | interval_lower_robustness (STLFormula formula, np.ndarray signal, np.ndarray|float radius=0.0, int t=0) |
| |
| dict[str, Interval] | top_level_intervals (STLFormula formula, np.ndarray prefix, np.ndarray signal_lo, np.ndarray signal_hi) |
| |
| float | stlpy_robustness (STLFormula formula, np.ndarray signal, int t=0) |
| |
| float | lipschitz_sup_norm (STLFormula formula) |
| |
Independent STL robustness evaluation and online (prefix) interval semantics.
Signals in this module are **time-first** arrays of shape ``(T, d)``, the
project convention for trajectories. ``stlpy``'s own ``robustness(y, t)`` uses
``(d, T)``; :func:`stlpy_robustness` performs that conversion.
The evaluator here is written separately from ``stlpy`` (memoised, iterative
over the formula tree) so that robustness of every synthesised trajectory can be
recomputed independently of both the solver and ``stlpy``'s implementation.
Online semantics
----------------
For an observed prefix ``y_0..y_k`` and a formula whose horizon extends past
``k``, ordinary robustness is undefined. :func:`robustness_interval` returns
``[rho_lower, rho_upper]`` enclosing the robustness of **every completion whose
unknown samples lie in the signal box** ``[signal_lo, signal_hi]``:
* ``rho_lower > 0`` every admissible completion satisfies;
* ``rho_upper < 0`` no admissible completion satisfies;
* otherwise inconclusive.
This is a trace-only (model-free) enclosure: unknown samples are treated
independently at each predicate, so the interval is sound but not tight. It
ignores dynamics, so ``rho_upper >= 0`` does *not* imply that the system can
still satisfy the formula (see the dynamics-constrained oracle in
``rl_stl.evaluation.oracle``).
Future-margin robustness
------------------------
Ordinary robustness of ``y_0:k ++ y_hat`` is capped by the worst *observed*
sample, which can no longer be perturbed. For runtime margins the project uses
the future-margin robustness ``rho_F`` (``observed_until=k``): predicates at
observed times ``<= k`` evaluate to ``+inf`` if satisfied and ``-inf`` if
violated; later predicates keep their quantitative value. Then
* ``rho_F >= 0`` iff ``rho >= 0`` (same Boolean satisfaction), and
* ``rho_F >= delta`` means every perturbation of the unobserved samples with
``L * sup-norm < delta`` preserves satisfaction (``L`` from
:func:`lipschitz_sup_norm`).
Interval predicates
-------------------
For an :class:`~rl_stl.stl.interval.IntervalPredicate` ``[a]^T y - [b] >= 0`` every evaluator here
uses the I-STL interval of the predicate's value over ``[a]`` and ``[b]``: :func:`robustness` (and
``stlpy``'s own ``robustness``) returns the **lower** robustness (worst case over the predicate
uncertainty, each predicate occurrence independently), :func:`robustness_interval` encloses
``[lower, upper]``, and :func:`interval_lower_robustness` additionally widens each sample to a box
``[y_t - r_t, y_t + r_t]`` (the tube of a predicted sample). Exact predicates keep their values.
| float rl_stl.stl.robustness.interval_lower_robustness |
( |
STLFormula |
formula, |
|
|
np.ndarray |
signal, |
|
|
np.ndarray | float |
radius = 0.0, |
|
|
int |
t = 0 |
|
) |
| |
I-STL lower robustness of the interval signal ``[y_t - r_t, y_t + r_t]`` (``signal``, ``radius``:
``(T, d)``, ``radius`` may broadcast): each predicate occurrence takes the lower endpoint of its value
over the sample box and, for interval predicates, over ``[a]`` and ``[b]``; min/max combine the lower
endpoints (both are monotone). ``radius = 0`` gives :func:`robustness`.