Models

class staliro.models.Trace(elements: Mapping[T, S], /)
class staliro.models.Trace(*, times: Iterable[T], states: Iterable[S])

A time-annotated set of system states.

This class can be iterated over to access each time, state pair in time-ascending order. This class can also be indexed by time to access a specific state. The times property iterates over the times in the trace, and the states iterates over the states. Both properties also iterate in time-ascending order.

Parameters:
  • times (Mapping[T, S] | Iterable[T]) – The times values for each state or the time-state mapping

  • states (Iterable[S] | None) – The states of the system if not using a time-state mapping

Raises:
property states: Iterable[S]

An iterator over the states of the trace in time-ascending order.

property times: Iterable[float]

An iterator over the times of the trace in time-ascending order.

class staliro.models.Result(trace: Mapping[SupportsFloat, S], /, extra: E)
class staliro.models.Result(*, states: Iterable[S], times: Iterable[SupportsFloat], extra: E)

Specialized version of staliro.Result that constructs a Trace as the value.

Parameters:
  • states (Mapping[SupportsFloat, S] | Iterable[S]) – The states of the system, either as a list or a dictionary where the keys are the associated times

  • extra (E) – The user annotation data for the result

  • times (Iterable[SupportsFloat] | None) – The times associated with each state if the states are provided as a list

class staliro.models.Model

Representation of the simulation logic for the system under test (SUT).

abstractmethod simulate(sample)

Simulate a system and return a staliro.Result containing a Trace.

Parameters:

sample (Sample) – The sample containing the system inputs

Returns:

A result containing the Trace of system states and additional annotation data

Return type:

Result[Trace[S], E]

@staliro.model(f: Callable[[Sample], Trace[T]]) Model[T, None]
@staliro.model(f: Callable[[Sample], Result[Trace[T], E]]) Model[T, E]

Create an Model from a function.

The function provided to this model must accept a Sample value and return either a Trace value or a staliro.Result containing a Trace and additional annotation data.

Parameters:

f (Callable[[Sample], Trace[T] | Result[Trace[T], E]]) – The function representing the system

Returns:

A Model implementation wrapping the provided function

Return type:

Model[T, E | None]

Blackbox

class staliro.models.Blackbox.Inputs(static, times)

Interpolated inputs to a Blackbox model.

The times attributes will always contain as keys all of the interpolation times for the given tspan in the TestOptions. If no signals are defined in the TestOptions, then the value for each time will be empty.

Attribute static:

The static (time-invariant) inputs to the system

Attribute times:

Mapping from each interpolation time to the values of each signal at that time

Parameters:
class staliro.models.Blackbox(func, step_size)

General system model which does not make assumptions about the underlying system.

Parameters:
  • func (Callable[[Blackbox.Inputs], _Result[Trace[S], E]]) – User-defined function to evaluate given Blackbox.Inputs into a Trace or staliro.Result

  • step_size (float) – Time-step to use for interpolating signal values over the simulation interval

@staliro.blackbox

Create an Blackbox model from a function.

The function provided to this model must accept a Blackbox.Inputs value and return either a Trace value or a staliro.Result containing a Trace and additional annotation data. If no function is provided a decorator is returned, which can be called with the function instead. The size of the time step for signal evaluation can be customized using the step_size parameter.

Parameters:

step_size (float) – Size of the time step for signal evaluation

Returns:

A decorator to wrap a function into a Blackbox model implementation

Return type:

BlackboxDecorator

ODE

class staliro.models.Ode.Inputs(time, state, signals)

Set of inputs to an ODE model function.

Attribute time:

The current time of the integration

Attribute state:

Name-value map containing the state variables for the current time

Attribute signals:

Name-value map containing the signal values for the current time

Parameters:
class staliro.models.Ode(func, method)

Model for systems that can be modeled by an Ordinary Differential Equation (ODE).

This model is simulated by integration the state derivatives returned by the function. The integration method can be customized to provide different levels of fidelity. The default method is Runge-Kutta 4(5).

Parameters:
  • func (Callable[[Ode.Inputs], Mapping[str, float]]) – User-defined function which is given a Ode.Inputs value and returns the derivative of each state variable.

  • method (Ode.Method) – The integration method for the ODE solver

@staliro.ode

Create an Ode model from a function.

This function sets the integration method for the ODE model and returns a decorator to wrap a function into an ODE implementation. The function provided to the returned decorator must accept a Ode.Inputs value and return a dictionary where each key is the name of a state variable the value is the derivative of that variable for the given time.

Parameters:

method (Ode.Method) – The integration method for the ODE solver. Valid options are: ["RK45", "RK23", "DOP853", "Radau", "BDF", "LSODA"]

Returns:

A decorator to create an Ode model implementation wrapping the provided function

Return type:

Callable[[OdeFunc], Ode]