Signals#

In \(\Psi\)-TaLiRo signals are continuous, time-varying inputs to a system over a given interval defined in the test options.

Control Points#

Since it is impossible to randomly generate continuous functions, a signal in \(\Psi\)-TaLiRo is constructed from a set of points called control points. These points are fixed values of the signal at specific moments in time, and the values between each control point are generated using different interpolation techniques. This allows the approximation of randomly generated continuous functions, which can be refined to an arbitrary precision by increasing the number of control points.

Base Class#

To implement a custom signal, you can inherit from the Signal class. This class has only one required method, called at_time(), and one method that can be optionally overridden called at_times(). The at_time method evaluates the signal for a single time, and the at_times method evaluates multiple times. The default at_times implementation calls the at_time method for each time provided, which is sufficient for simple use-cases but users can choose to provide their own implementations if a more efficient one exists.

from collections.abc import Iterable

from staliro.signals import Signal


class Constant(Signal):
    def __init__(self, value: float):
        self.constant = value

    def at_time(self, time: float) -> float:
        return self.constant

    def at_times(self, times: Iterable[float]) -> list[float]:
        # This implementation is slightly more efficient because it omits a call to `at_time`
        # for every time in `times`
        return [self.constant for _ in times]

Factories#

In order to provide a custom signal as a system input, you will need to create implement a SignalFactory, which is a function to create an instance of a signal for a given set of times and control points. This function can be used for the factory attribute of a SignalInput, like so:

from staliro import SignalInput, TestOptions


def constant(times: list[float], control_points: list[float]) -> Constant:
    return Constant(control_points[0])


options = TestOptions(
    signals={
        "rho": SignalInput(control_points=[(0, 1)], factory=constant)
    }
)

Basic Signals#

Some basic signal implementations are provided with this library. Most of the provided implementations are based on interpolators provided by the SciPy library.

Name

Description

pchip()

A third-degree cubic hermite spline interpolation.

piecewise_linear()

Piecewise interpolation where each control point is connected linearly.

piecewise_constant()

Piecewise interpolation where the function is constant between control points.

harmonic()

Sum of sinusoidal components with different frequencies/amplitudes.

Combinators#

This library also provides a set of combinators for modifying the behaviors of other signals.

Name

Description

clamped()

Ensure the output of the signal is within the provided bounds.

delayed()

Shift the time interval of the signal the start after a given amount of time.

sequenced()

Given two signals, switch which one is active at a specific time.