LIRRA  1.0.0
Loading...
Searching...
No Matches
rl_stl.evaluation.patrol Namespace Reference

Classes

class  ExpertProposer
 
class  PatrolDIConfig
 
class  PatrolSetup
 

Functions

RecedingProblem build_patrol_problem (PatrolTask task, DiscreteLinearModel model, np.ndarray C_out, np.ndarray x_lo, np.ndarray x_hi, np.ndarray u_lo, np.ndarray u_hi, Tube tube, float delta, int n_plan, dict[str, tuple[tuple[int, int], int]] blocks_spec, tuple[str, str] plane, dict[str, int] position_index, np.ndarray track_weight, float gamma0, float effort_weight, int|None n_cost=None)
 
tuple[int, float] _face_axis (IntervalPredicate pred)
 
float interval_face_offset (not_s, np.ndarray C_out, np.ndarray x_lo, np.ndarray x_hi, np.ndarray r, float delta)
 
None verify_interval_faces (terminal, not_s, np.ndarray C_out, dict[str, int] position_index, np.ndarray r, float delta, float tol=1e-9)
 
dict uncertain_scores (PatrolTask task, np.ndarray Y, dict region)
 
PatrolSetup build_di (PatrolDIConfig cfg)
 
np.ndarray nominal_proposer (ProposalContext ctx)
 
np.ndarray disturbance_sequence (PatrolDIConfig cfg, int n, int seed)
 
dict run_di_episode (PatrolSetup setup, PatrolDIConfig cfg, RecedingSupervisor sup, int seed=0)
 
int waypoints_reached (PatrolSetup setup, np.ndarray X, float tol=0.25)
 
int waypoint_visits (PatrolSetup setup, np.ndarray X, float tol=0.25)
 
 _patrol_projection (PatrolSetup setup, np.ndarray X)
 
float waypoint_miss (PatrolSetup setup, np.ndarray X)
 
float patrol_progress (PatrolSetup setup, np.ndarray X)
 
dict episode_summary (PatrolSetup setup, dict ep)
 

Detailed Description

NAHS patrol experiment builders and the double-integrator closed loop.

:class:`PatrolDIConfig` fully determines the double-integrator benchmark: ``f_syn`` is the
exact ZOH model, ``f_sim = f_syn + B w`` with ``w`` sampled inside ``W`` (so the tube
assumption holds by construction), and the vehicle flies the supervisor's command directly.
The X2 and blimp experiments reuse :func:`build_patrol_problem` with their own ``f_syn`` and an
empirical constant tube.

The cube specs (``theta_plus``, ``phi_plus``) use the 3-D double integrator: the same per-axis
bounds, PD, LQR gains and disturbance bound on x, y and z, the signal ``y = (px, py, pz)``, six
terminal face sets and six waypoints.

Uncertain predicates (``*_u`` specs, :mod:`rl_stl.stl.nahs`): the face sets must satisfy the interval
predicate of their face with margin ``delta`` and the widest tube for every state in them. The face
offset ``c_out`` is the worst case over the face set's extent (tangential positions anywhere in the
tightened state box), computed by :func:`interval_face_offset` and verified on the built polygons by
:func:`verify_interval_faces`. :func:`uncertain_scores` scores an executed trace against the interval
predicates and against a drawn true region.

Function Documentation

◆ _face_axis()

tuple[int, float] rl_stl.evaluation.patrol._face_axis ( IntervalPredicate  pred)
protected
Signal coordinate and sign of a face predicate's nominal normal ``sign * e_j``.

◆ _patrol_projection()

rl_stl.evaluation.patrol._patrol_projection ( PatrolSetup  setup,
np.ndarray  X 
)
protected
Projection of the output samples onto the closed patrol polyline (waypoints in patrol order):
path parameter ``s`` in ``[0, n)`` and distance to the polyline, per sample.

◆ build_di()

PatrolSetup rl_stl.evaluation.patrol.build_di ( PatrolDIConfig  cfg)
Double-integrator patrol; ``d = 2`` axes for (24)/(25), ``d = 3`` for the cube specs.

◆ build_patrol_problem()

RecedingProblem rl_stl.evaluation.patrol.build_patrol_problem ( PatrolTask  task,
DiscreteLinearModel  model,
np.ndarray  C_out,
np.ndarray  x_lo,
np.ndarray  x_hi,
np.ndarray  u_lo,
np.ndarray  u_hi,
Tube  tube,
float  delta,
int  n_plan,
dict[str, tuple[tuple[int, int], int]]  blocks_spec,
tuple[str, str]  plane,
dict[str, int]  position_index,
np.ndarray  track_weight,
float  gamma0,
float  effort_weight,
int | None   n_cost = None 
)
Receding problem with the verified face terminal set for the patrol task.

◆ disturbance_sequence()

np.ndarray rl_stl.evaluation.patrol.disturbance_sequence ( PatrolDIConfig  cfg,
int  n,
int  seed 
)

◆ episode_summary()

dict rl_stl.evaluation.patrol.episode_summary ( PatrolSetup  setup,
dict  ep 
)

◆ interval_face_offset()

float rl_stl.evaluation.patrol.interval_face_offset (   not_s,
np.ndarray  C_out,
np.ndarray  x_lo,
np.ndarray  x_hi,
np.ndarray  r,
float  delta 
)
Smallest ``c`` such that ``sign * y_j >= c`` implies ``lower([a]^T [y - r, y + r] - [b]) >= delta``
for every face predicate of ``not_s`` and every tangential ``y`` in the box ``C [x_lo, x_hi]``.

The lower endpoint is separable, ``sum_k f_k(y_k) - b_hi`` with concave ``f_k``
(:func:`~rl_stl.stl.interval.interval_term_min`): tangential coordinates take their minimum at a box
corner; along the normal, ``f_j(sign c) = min(|a_lo_j|, |a_hi_j|) (c - r_j)`` for ``c >= r_j``.

◆ nominal_proposer()

np.ndarray rl_stl.evaluation.patrol.nominal_proposer ( ProposalContext  ctx)
Mission-only proposal: the nominal PD rollout (ignores the specification).

◆ patrol_progress()

float rl_stl.evaluation.patrol.patrol_progress ( PatrolSetup  setup,
np.ndarray  X 
)
Tolerance-free patrol progress in waypoint legs: every output sample is projected onto the closed
polyline through the waypoints in patrol order (parameter ``s`` in ``[0, n)``, leg ``i`` from waypoint
``i`` to ``i + 1``), and the signed advance of ``s`` is summed over the trajectory (backtracking
counts negatively; jumps are wrapped to ``(-n/2, n/2]``). One leg corresponds to one waypoint of
:func:`waypoints_reached`, without its distance tolerance or its stop after a missed waypoint.

◆ run_di_episode()

dict rl_stl.evaluation.patrol.run_di_episode ( PatrolSetup  setup,
PatrolDIConfig  cfg,
RecedingSupervisor  sup,
int   seed = 0 
)

◆ uncertain_scores()

dict rl_stl.evaluation.patrol.uncertain_scores ( PatrolTask  task,
np.ndarray  Y,
dict  region 
)
Scores of an executed output trace ``Y (T, p)`` of a ``_u`` spec: interval lower robustness (worst
case over the predicate uncertainty) and the exact robustness against the true ``region``, per window
``[s, s + h]`` as :func:`rl_stl.supervisor.receding.realised_robustness`.

◆ verify_interval_faces()

None rl_stl.evaluation.patrol.verify_interval_faces (   terminal,
  not_s,
np.ndarray  C_out,
dict[str, int]  position_index,
np.ndarray  r,
float  delta,
float   tol = 1e-9 
)
Raise unless every state of every face set satisfies its face's interval predicate.

The lower endpoint is separable and concave per signal coordinate, so its minimum over the face set
(a product of polygons) is a sum of minima of ``f_k`` at the endpoints of the coordinate's range over
its block polygon (computed from the polygons' vertices).

◆ waypoint_miss()

float rl_stl.evaluation.patrol.waypoint_miss ( PatrolSetup  setup,
np.ndarray  X 
)
Mean distance to a waypoint at the moments the patrol progress (:func:`patrol_progress`) passes it
[m], linearly interpolated between samples; NaN if no waypoint is passed. Complements the progress
count: how precisely the patrol goes through its waypoints.

◆ waypoint_visits()

int rl_stl.evaluation.patrol.waypoint_visits ( PatrolSetup  setup,
np.ndarray  X,
float   tol = 0.25 
)
Order-free patrol coverage: entries into the ``tol`` ball of a waypoint other than the one
visited last. :func:`waypoints_reached` stops counting after a missed waypoint; in 3-D the
detours around the cube edges can pass a waypoint just outside ``tol``, so both are reported.

◆ waypoints_reached()

int rl_stl.evaluation.patrol.waypoints_reached ( PatrolSetup  setup,
np.ndarray  X,
float   tol = 0.25 
)
Waypoints the trajectory ``X`` reaches in patrol order (within ``tol``), starting at the one
after the closest (the convention of the nominal controller).