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
timesproperty iterates over the times in the trace, and thestatesiterates 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:
ValueError – If the length of
timesandstatesis not equalValueError – If not using a time-state mapping and states is omitted
- 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.Resultthat constructs aTraceas 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).
- staliro.models.model(func: Callable[[Sample], Result[Trace[S], E]]) ModelWrapper[S, E]#
- staliro.models.model(func: Callable[[Sample], Trace[R]]) ModelWrapper[R, None]
- staliro.models.model(func: None = None) ModelDecorator
Create an
Modelfrom a function.The function provided to this model must accept a
Samplevalue and return either aTracevalue or astaliro.Resultcontaining aTraceand additional annotation data. If no function is provided a decorator is returned, which can be called with the function instead.- Parameters:
func – The function representing the system
- Returns:
A
Modelor a decorator to create aModel
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
tspanin theTestOptions. If nosignalsare defined in theTestOptions, then the value for each time will be empty.
- 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.Inputsinto aTraceorstaliro.Resultstep_size (float) – Time-step to use for interpolating signal values over the simulation interval
- staliro.models.blackbox(func: Callable[[Inputs], Result[Trace[S], E]], *, step_size: float = 0.1) Blackbox[S, E]#
- staliro.models.blackbox(func: Callable[[Inputs], Trace[R]], *, step_size: float = 0.1) Blackbox[R, None]
- staliro.models.blackbox(func: None = None, *, step_size: float = 0.1) BlackboxDecorator
Create an
Blackboxmodel from a function.The function provided to this model must accept a
Blackbox.Inputsvalue and return either aTracevalue or astaliro.Resultcontaining aTraceand 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 thestep_sizeparameter.- Parameters:
func – The function representing the system
step_size – Size of the time step for signal evaluation
- Returns:
A
Blackboxmodel or a decorator to create aBlackbox
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.Inputsvalue and returns the derivative of each state variable.method (Ode.Method) – The integration method for the ODE solver
- staliro.models.ode(func: Callable[[Inputs], Mapping[str, float]], *, method: Literal['RK45', 'RK23', 'DOP853', 'Radau', 'BDF', 'LSODA'] = 'RK45') Ode#
- staliro.models.ode(func: None = None, *, method: Literal['RK45', 'RK23', 'DOP853', 'Radau', 'BDF', 'LSODA'] = 'RK45') OdeDecorator
Create an
Odemodel from a function.The function provided to this model must accept a
Ode.Inputsvalue 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. If no function is provided a decorator is returned, which can be called with the function instead.- Parameters:
func – The function representing the system ODE
method – The integration method for the ODE solver. Valid options are:
["RK45", "RK23", "DOP853", "Radau", "BDF", "LSODA"]
- Returns:
An
Odemodel or a decorator to create anOdemodel