DataModel#
The DataModel
class is the base class for all data-based models. It is a subclass of PrognosticsModel
, allowing it to be used interchangeably with physics-based models.
Examples:
Training DataModels#
There are a few ways to construct a DataModel
object, described below.
From Data#
This is the most common way to construct a DataModel
object, using the DataModel.from_data()
method. It involves using one or more runs of data to train the model. Each DataModel class expects different data from the following set: times, inputs, states, outputs, and event_states. See documentation for the specific algorithm to see what it expects. Below is an example if it’s use with the LSTMStateTransitionModel, which expects inputs and outputs.
example
>>> from progpy.models import LSTMStateTransitionModel
>>> input_data = [run1.inputs, run2.inputs, run3.inputs]
>>> output_data = [run1.outputs, run2.outputs, run3.outputs]
>>> m = LSTMStateTransitionModel.from_data(input_data, output_data)
From Another PrognosticsModel (i.e., Surrogate)#
Surrogate models are constructed using the DataModel.from_model()
Class Method. These models are trained using data from the original model, i.e., as a surrogate for the original model. The original model is not modified. Below is an example if it’s use. In this example a surrogate (m2) of the original ThrownObject Model (m) is created, and can then be used interchangeably with the original model.
example
>>> from progpy.models import ThrownObject
>>> from progpy.models import LSTMStateTransitionModel
>>> m = ThrownObject()
>>> def future_loading(t, x=None):
>>> return m.InputContainer({}) # No input for thrown object
>>> m2 = LSTMStateTransitionModel.from_model(m, future_loading)
Note
Surrogate models are generally less accurate than the original model. This method is used either to create a quicker version of the original model (see DMDModel
) or to test the performance of a DataModel
approach.
See also
PrognosticsModel.generate_surrogate()
Using Constructor#
This method is the least frequently used, and it is very specific to the DataModel
class being constructed. For example: DMDModel
classes are constructed using the DMD Matrix, and LSTMStateTransitionModel
classes are constructed using a trained Keras Model.
See example examples.custom_model
Included DataModels#
The following DataModels are included in the package. A new DataModel can be created by subclassing DataModel
, implementing the abstract methods of both DataModel
and PrognosticsModel
.
DMDModel#
- class progpy.data_models.DMDModel(dmd_matrix, *_, **kwargs)#
New in version 1.3.0.
A subclass of
progpy.LinearModel
andprogpy.data_models.DataModel
that uses Dynamic Mode Decomposition to simulate a system throughout time.Given an initial state of the system and the expected input throughout time, this class defines a model that can approximate the dynamics of the system throughout time until threshold is met. This model can be fully data-driven (using from_data) or a surrogate of another model (using from_model) where internal states of a high-fidelity model augment the purely data-driven method.
- Parameters
dmd_matrix (np.ndarray) – Matrix used by DMD
- Keyword Arguments
Note
DMD does not generate accurate approximations for all models, especially highly non-linear sections, and can be sensitive to the training data time step.
In general, the approximation is less accurate if the DMD matrix is unstable. Additionally, this implementation does not yet include all functionalities of DMD (e.g. reducing the system’s dimensions through SVD). Further functionalities will be included in future releases.
- classmethod from_data(times, inputs, outputs, states=None, event_states=None, **kwargs)#
Create a DMD model from data
- Parameters
times (list[list]) – list of input data for use in data. Each element is the times for a single run of size (n_times)
inputs (list[np.array]) – list of input data for use in data. Each element is the inputs for a single run of size (n_times, n_inputs)
outputs (list[np.array]) – list of output data for use in data. Each element is the outputs for a single run of size (n_times, n_outputs)
states (list[np.array], optional) – list of state data for use in data. Each element is the states for a single run of size (n_times, n_states)
event_states (list[np.array], optional) – list of event state data for use in data. Each element is the event states for a single run of size (n_times, n_event_states)
- Keyword Arguments
trim_data_to (float, optional) –
Fraction (0-1) of data resulting from
progpy.PrognosticsModel.simulate_to_threshold()
used to train DMD surrogate model e.g. if trim_data_to = 0.7 and the simulated data spans from t=0 to 100, the surrogate model is trained on the data from t=0 to 70Note: To trim data to a set time, use the ‘horizon’ parameter
stability_tol (float, optional) – Value that determines the tolerance for DMD matrix stability
training_noise (float, optional) – Noise added to the training data sampled from a standard normal distribution with standard deviation of training_noise. Adding noise to the training data results in a slight perturbation that removes any linear dependencies among the data
Additionally, other keyword arguments from
progpy.PrognosticsModel.simulate_to_threshold()
- dmd_matrix#
Dynamic Mode Decomposition Matrix
- Type
np.array
- Returns
Model generated from data
- Return type
- classmethod from_model(m, load_functions, **kwargs)#
Create a Data Model from an existing PrognosticsModel (i.e., a surrogate model). Generates data through simulation with supplied load functions. Then calls
from_data()
to generate the model.- Parameters
m (PrognosticsModel) – Model to generate data from
load_functions (list[function]) – Each index is a callable loading function of (t, x = None) -> z used to predict future load at a given time (t) and state (x)
- Keyword Arguments
add_dt (bool) – If the timestep should be added as an input
Addditional configuration parameters from
progpy.PrognosticsModel.simulate_to_threshold()
. These can be an array (of same length as load_functions) of config for each individual sim, or one value to apply to all Additional configuration parameters from from_data- Returns
Trained PrognosticsModel
- Return type
LSTMStateTransitionModel#
- class progpy.data_models.LSTMStateTransitionModel(output_model, state_model=None, event_state_model=None, t_met_model=None, **kwargs)#
New in version 1.4.0.
A State Transition Model with no event using an Keras LSTM Model. State transition models map from the input at time t and output at time t-1 plus historical data from a set window to the output at time t.
Most users will use the
LSTMStateTransitionModel.from_data()
method to create a model, but the model can be created by passing in a model directly into the constructor. The LSTM model in this method maps from [u_t-n+1, z_t-n, …, u_t, z_t-1] to z_t. Past input are stored in the model internal state. Actual calculation of output is performed whenLSTMStateTransitionModel.output()
is called. When using in simulation that may not be until the simulation results are accessed.- Parameters
output_model (keras.Model) – If a state model is present, maps from the state_model outputs to model output. Otherwise, maps from model inputs to model output
state_model (keras.Model, optional) – Keras model to use for state transition
event_state_model (keras.Model, optional) – If a state model is present, maps from the state_model outputs to event state. Otherwise, maps from model inputs to event state
t_met_model (keras.Model, optional) – If a state model is present, maps from the state_model outputs to if the threshold has been met. Otherwise, maps from model inputs to if the threshold has not been met
- Keyword Arguments
- model#
Keras model to use for state transition
- Type
keras.Model
See also
LSTMStateTransitionModel.from_data LSTMStateTransitionModel.from_model examples.lstm_model
- classmethod from_data(inputs, outputs, event_states=None, t_met=None, **kwargs)#
Generate a LSTMStateTransitionModel from data
- Parameters
inputs (list[np.array]) – list of input data for use in data. Each element is the inputs for a single run of size (n_times, n_inputs)
outputs (list[np.array]) – list of output data for use in data. Each element is the outputs for a single run of size (n_times, n_outputs)
event_states (list[np.array], optional) – list of event state data for use in data. Each element is the event state for a single run of size (n_times, n_events)
t_met (list[np.array], optional) – list of threshold met data for use in data. Each element is if the threshold has been met for a single run of size (n_times, n_events)
- Keyword Arguments
window (int) – Number of historical points used in the model. I.e, if window is 3, the model will map from [t-3, t-2, t-1] to t
input_keys (list[str]) – List of keys to use to identify input. If not supplied u[#] will be used to idenfiy inputs
output_keys (list[str]) – List of keys to use to identify output. If not supplied z[#] will be used to idenfiy outputs
event_keys (list[str]) – List of keys to use to identify events for event state and threshold met. If not supplied event[#] will be used to identify events
validation_percentage (float) – Percentage of data to use for validation, between 0-1
epochs (int) – Number of epochs (i.e., iterations) to train the model. More epochs means better results (to a point), but more time to train. Note: large numbers of epochs may result in overfitting.
layers (int) – Number of LSTM layers to use. More layers can represent more complex systems, but are less efficient. Note: 2 layers is typically enough for most complex systems. Default: 1
units (int or list[int]) – number of units (i.e., dimensionality of output state) used in each lstm layer. Using a scalar value will use the same number of units for each layer.
activation (str or list[str]) – Activation function to use for each layer
dropout (float) – Dropout rate to be applied. Dropout helps avoid overfitting
normalize (bool) – If the data should be normalized. This is recommended for most cases.
early_stopping (bool) – If early stopping is desired. Default is True
early_stop.cfg (dict) – Configuration to pass into early stopping callback (if enabled). See keras documentation (https://keras.io/api/callbacks/early_stopping) for options. E.g., {‘patience’: 5}
workers (int) – Number of workers to use when training. One worker indicates no multiprocessing
- Returns
Generated Model
- Return type
- classmethod from_model(m: progpy.prognostics_model.PrognosticsModel, load_functions: list, **kwargs) progpy.data_models.data_model.DataModel #
Create a Data Model from an existing PrognosticsModel (i.e., a surrogate model). Generates data through simulation with supplied load functions. Then calls
from_data()
to generate the model.- Parameters
m (PrognosticsModel) – Model to generate data from
load_functions (list[function]) – Each index is a callable loading function of (t, x = None) -> z used to predict future load at a given time (t) and state (x)
- Keyword Arguments
add_dt (bool) – If the timestep should be added as an input
Addditional configuration parameters from
progpy.PrognosticsModel.simulate_to_threshold()
. These can be an array (of same length as load_functions) of config for each individual sim, or one value to apply to all Additional configuration parameters from from_data- Returns
Trained PrognosticsModel
- Return type
PolynomialChaosExpansion#
- class progpy.data_models.PolynomialChaosExpansion(models, times, input_keys, **kwargs)#
New in version 1.5.0.
Polynomial Chaos Expansion direct data model. Uses chaospy to generate a polynomial chaos expansion from data or a model to learn the relationship between future inputs and time of event.
Generally this is used as a surrogate for a model that is too expensive to simulate. This is done using the
PolynomialChaosExpansion.from_model()
method. The model is used to generate data, which is then used to train the polynomial chaos expansion. The polynomial chaos expansion can then be used to predict the time of event for future inputs.- Parameters
- Keyword Arguments
event_keys (list[str], optional) – List of event keys for the events. If not provided, will be generated as e0, e1, e2, etc.
See also
progpy.data_models.DataModel
PolynomialChaosExpansion.from_data PolynomialChaosExpansion.from_modelNote
The generated model is only valid for the intial state at which the data was generated. If the initial state is different, the model will not be valid.
- classmethod from_data(times, inputs, time_of_event, input_keys, **kwargs)#
Create a PolynomialChaosExpansion from data.
- Parameters
times (list[float]) – list of times data for use in data. Each element is the time such that inputs[i] is the inputs at time[i]
inputs (np.array) – list of input data for use in data. Each eelement is the inputs for a single run of size (n_samples, n_inputs*n_times)
time_of_event (np.array) – Array of time of event data for use in data. Each element is the time of event for a single run of size (n_samples, n_events)
- Keyword Arguments
J (chaospy.Distribution, optional) – Joint distribution to sample from. Must include distribution for each timepoint for each input [u0_t0, u0_t1, …, u1_t0, …]. If not included, input_dists must be provided
input_dists (list[chaospy.Distribution], optional) – List of chaospy distributions for each input for each timepoint
order (int, optional) – Order of the polynomial chaos expansion
- classmethod from_model(m, x, input_dists, times, **kwargs)#
Create a PolynomialChaosExpansion from a model.
- Parameters
m (Model) – Model to create PolynomialChaosExpansion from
x (StateContainer) – Initial state to use for simulation
input_dists (dict[key, chaospy.Distribution]) –
” List of chaospy distributions for each input
times (list[float]) – List of coordinates along the time axis used to estimate the expansion coefficients (collocation points).
- Keyword Arguments
DataModel Interface#
- class progpy.data_models.DataModel(**kwargs)#
Bases:
progpy.prognostics_model.PrognosticsModel
,abc.ABC
New in version 1.4.0.
Abstract Base Class for all Data Models (e.g.,
LSTMStateTransitionModel
). Defines the interface and all common tools. To create a new Data-Driven model, first subclass this, then define the abstract methods from this class andprogpy.PrognosticsModel
.See also
PrognosticsModel
- calc_error(times: List[float], inputs: List[progpy.utils.containers.DictLikeMatrixWrapper], outputs: List[progpy.utils.containers.DictLikeMatrixWrapper], _loc=None, **kwargs) float #
Calculate Error between simulated and observed data using selected Error Calculation Method
- Parameters
- Keyword Arguments
method (str, optional) –
Error method to use when calculating error. Supported methods include:
MSE (Mean Squared Error) - DEFAULT
RMSE (Root Mean Squared Error)
MAX_E (Maximum Error)
MAE (Mean Absolute Error)
MAPE (Mean Absolute Percentage Error)
DTW (Dynamic Time Warping)
x0 (StateContainer, optional) – Initial state
dt (float, optional) – Maximum time step in simulation. Time step used in simulation is lower of dt and time between samples. Defaults to time between samples.
stability_tol (double, optional) –
Configurable parameter. Configurable cutoff value, between 0 and 1, that determines the fraction of the data points for which the model must be stable. In some cases, a prognostics model will become unstable under certain conditions, after which point the model can no longer represent behavior. stability_tol represents the fraction of the provided argument times that are required to be met in simulation, before the model goes unstable in order to produce a valid estimate of mean squared error.
If the model goes unstable before stability_tol is met, a ValueError is raised. Else, model goes unstable after stability_tol is met, the mean squared error calculated from data up to the instability is returned.
aggr_method (func, optional) – When multiple runs are provided, users can state how to aggregate the results of the errors. Defaults to taking the mean.
- Returns
error
- Return type
See also
calc_error.MSE()
calc_error.RMSE()
calc_error.MAX_E()
calc_error.MAPE()
calc_error.MAE()
:func:’calc_error.DTW’
- estimate_params(runs: List[tuple] = None, keys: List[str] = None, times: List[float] = None, inputs: List[progpy.utils.containers.DictLikeMatrixWrapper] = None, outputs: List[progpy.utils.containers.DictLikeMatrixWrapper] = None, method: str = 'nelder-mead', **kwargs) None #
Estimate the model parameters given data. Overrides model parameters
- Keyword Arguments
inputs (list[InputContainer]) – Array of input containers where input[x] corresponds to time[x]
outputs (list[OutputContainer]) – Array of output containers where output[x] corresponds to time[x]
method (str, optional) – Optimization method- see scipy.optimize.minimize for options
tol (int, optional) – Tolerance for termination. Depending on the provided minimization method, specifying tolerance sets solver-specific options to tol
error_method (str, optional) – Method to use in calculating error. See calc_error for options
bounds (tuple or dict, optional) – Bounds for optimization in format ((lower1, upper1), (lower2, upper2), …) or {key1: (lower1, upper1), key2: (lower2, upper2), …}
options (dict, optional) – Options passed to optimizer. see scipy.optimize.minimize for options
runs (list[tuple], depreciated) – data from all runs, where runs[0] is the data from run 0. Each run consists of a tuple of arrays of times, input dicts, and output dicts. Use inputs, outputs, states, times, etc. instead
- Returns
Scipy minimize Optimization Result from estimating parameters. See scipy’s scipy.optimize.OptimizeResult documentation for details.
- Return type
OptimizeResult
See: examples.param_est
- abstract classmethod from_data(**kwargs) progpy.data_models.data_model.DataModel #
Create a Data Model from data. This class is overwritten by specific data-driven classes (e.g.,
LSTMStateTransitionModel
)- Keyword Arguments
times (list[list]) – list of input data for use in data. Each element is the times for a single run of size (n_times)
inputs (list[np.array]) – list of input data for use in data. Each element is the inputs for a single run of size (n_times, n_inputs)
states (list[np.array]) – list of state data for use in data. Each element is the states for a single run of size (n_times, n_states)
outputs (list[np.array]) – list of output data for use in data. Each element is the outputs for a single run of size (n_times, n_outputs)
event_states (list[np.array]) – list of event state data for use in data. Each element is the event states for a single run of size (n_times, n_event_states)
time_of_event (np.array) – Array of time of event data for use in data. Each element is the time of event for a single run of size (n_samples, n_events)
See specific data class for more additional keyword arguments
- Returns
Trained PrognosticsModel
- Return type
Example
Replace DataModel with specific classname : m = DataModel.from_data(data)
- classmethod from_json(data: str)#
Create a new prognostics model from a previously generated model that was serialized as a JSON object
- Parameters
data (str) – JSON serialized parameters necessary to build a model See to_json method
- Returns
Model generated from serialized parameters
- Return type
See also
Note
This serialization only works for models that include all parameters necessary to generate the model in model.parameters.
- classmethod from_model(m: progpy.prognostics_model.PrognosticsModel, load_functions: list, **kwargs) progpy.data_models.data_model.DataModel #
Create a Data Model from an existing PrognosticsModel (i.e., a surrogate model). Generates data through simulation with supplied load functions. Then calls
from_data()
to generate the model.- Parameters
m (PrognosticsModel) – Model to generate data from
load_functions (list[function]) – Each index is a callable loading function of (t, x = None) -> z used to predict future load at a given time (t) and state (x)
- Keyword Arguments
add_dt (bool) – If the timestep should be added as an input
Addditional configuration parameters from
progpy.PrognosticsModel.simulate_to_threshold()
. These can be an array (of same length as load_functions) of config for each individual sim, or one value to apply to all Additional configuration parameters from from_data- Returns
Trained PrognosticsModel
- Return type
- generate_surrogate(load_functions: List[collections.abc.Callable], method: str = 'dmd', **kwargs)#
Generate a surrogate model to approximate the higher-fidelity model
- Parameters
load_functions (List[abc.Callable]) – Each index is a callable loading function of (t, x = None) -> z used to predict future loading (output) at a given time (t) and state (x)
method (str, optional) – list[ indicating surrogate modeling method to be used
- Keyword Arguments
dt (float or abc.Callable, optional) – Same as in simulate_to_threshold; for DMD, this value is the time step of the training data
save_freq (float, optional) – Same as in simulate_to_threshold; for DMD, this value is the time step with which the surrogate model is generated
state_keys (List[str], optional) – List of state keys to be included in the surrogate model generation. keys must be a subset of those defined in the PrognosticsModel
input_keys (List[str], optional) – List of input keys to be included in the surrogate model generation. keys must be a subset of those defined in the PrognosticsModel
output_keys (List[str], optional) – List of output keys to be included in the surrogate model generation. keys must be a subset of those defined in the PrognosticsModel
event_keys (List[str], optional) – List of event_state keys to be included in the surrogate model generation. keys must be a subset of those defined in the PrognosticsModel
... (optional) – Keyword arguments from simulate_to_threshold (except save_pts)
- Returns
SurrogateModel() – Instance of SurrogateModel class
- Return type
class
Example
See examples/generate_surrogate
- property is_continuous: bool#
returns: is_continuous – True if model is continuous, False if discrete :rtype: bool
- property is_direct: bool#
New in version 1.5.0.
If the model is a “direct model” - i.e., a model that directly estimates time of event from system state, rather than using state transition. This is useful for data-driven models that map from sensor data to time of event, and for physics-based models where state transition differential equations can be solved.
- Returns
if the model is a direct model
- Return type
- property is_discrete: bool#
returns: is_discrete – True if model is discrete, False if continuous :rtype: bool
- property is_state_transition_model: bool#
New in version 1.5.0.
If the model is a “state transition model” - i.e., a model that uses state transition differential equations to propagate state forward.
- Returns
if the model is a state transition model
- Return type
- simulate_to(time: float, future_loading_eqn: collections.abc.Callable = <function PrognosticsModel.<lambda>>, first_output=None, **kwargs) collections.namedtuple #
Simulate prognostics model for a given number of seconds
- Parameters
time (float) –
Time to which the model will be simulated in seconds (≥ 0.0)
e.g., time = 200
future_loading_eqn (abc.Callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)
first_output (OutputContainer, optional) – First measured output, needed to initialize state for some classes. Can be omitted for classes that don’t use this
- Returns
times (list[float]) – Times for each simulated point
inputs (SimResult) – Future input (from future_loading_eqn) for each time in times
states (SimResult) – Estimated states for each time in times
outputs (SimResult) – Estimated outputs for each time in times
event_states (SimResult) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurrence, for each time in times
- Raises
ProgModelInputException –
Note: – See simulate_to_threshold for supported keyword arguments
See also
Example
>>> from progpy.models import BatteryCircuit >>> m = BatteryCircuit() # Replace with specific model being simulated >>> def future_load_eqn(t, x = None): ... if t < 5.0: # Load is 2.0 for first 5 seconds ... return m.InputContainer({'i': 2.0}) ... else: ... return m.InputContainer({'i': 2.2}) >>> first_output = m.OutputContainer({'v': 3.2, 't': 295}) >>> (results) = m.simulate_to(200, future_load_eqn, first_output)
- simulate_to_threshold(future_loading_eqn: collections.abc.Callable = None, first_output=None, threshold_keys: list = None, **kwargs) collections.namedtuple #
Simulate prognostics model until any or specified threshold(s) have been met
- Parameters
future_loading_eqn (abc.Callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)
- Keyword Arguments
t0 (float, optional) – Starting time for simulation in seconds (default: 0.0)
dt (float, tuple, str, or function, optional) –
float: constant time step (s), e.g. dt = 0.1
function (t, x) -> dt
tuple: (mode, dt), where modes could be constant or auto. If auto, dt is maximum step size
str: mode - ‘auto’ or ‘constant’
integration_method (str, optional) – Integration method, e.g. ‘rk4’ or ‘euler’ (default: ‘euler’)
save_freq (float, optional) – Frequency at which output is saved (s), e.g., save_freq = 10. A save_freq of 0 will save every step.
save_pts (list[float], optional) – Additional ordered list of custom times where output is saved (s), e.g., save_pts= [50, 75]
eval_pts (list[float], optional) – Additional ordered list of custom times where simulation is guarenteed to be evaluated (though results are not saved, as with save_pts) when dt is auto (s), e.g., eval_pts= [50, 75]
horizon (float, optional) – maximum time that the model will be simulated forward (s), e.g., horizon = 1000
first_output (OutputContainer, optional) – First measured output, needed to initialize state for some classes. Can be omitted for classes that don’t use this
threshold_keys (abc.Sequence[str] or str, optional) – Keys for events that will trigger the end of simulation. If blank, simulation will occur if any event will be met ()
x (StateContainer, optional) – initial state, e.g., x= m.StateContainer({‘x1’: 10, ‘x2’: -5.3})
thresholds_met_eqn (abc.Callable, optional) – custom equation to indicate logic for when to stop sim f(thresholds_met) -> bool
print (bool, optional) –
toggle intermediate printing, e.g., print = True
e.g., m.simulate_to_threshold(eqn, z, dt=0.1, save_pts=[1, 2])
progress (bool, optional) – toggle progress bar printing, e.g., progress = True
- Returns
times (list[float]) – Times for each simulated point
inputs (SimResult) – Future input (from future_loading_eqn) for each time in times
states (SimResult) – Estimated states for each time in times
outputs (SimResult) – Estimated outputs for each time in times
event_states (SimResult) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurrence, for each time in times
- Raises
See also
Example
>>> from progpy.models import BatteryCircuit >>> m = BatteryCircuit() # Replace with specific model being simulated >>> def future_load_eqn(t, x = None): ... if t< 5.0: # Load is 3.0 for first 5 seconds ... return m.InputContainer({'i': 2.0}) ... else: ... return m.InputContainer({'i': 2.2}) >>> first_output = m.OutputContainer({'v': 3.2, 't': 295}) >>> (results) = m.simulate_to_threshold(future_load_eqn, first_output)
Note
configuration of the model is set through model.parameters.
- state_at_event(x, future_loading_eqn=<function PrognosticsModel.<lambda>>, **kwargs)#
New in version 1.5.0.
Calculate the state at the time that each event occurs (i.e., the event threshold is met). state_at_event can be implemented by a direct model. For a state transition model, this returns the state at which threshold_met returns true for each event.
- Parameters
x (StateContainer) –
state, with keys defined by model.states
e.g., x = m.StateContainer({‘abc’: 332.1, ‘def’: 221.003}) given states = [‘abc’, ‘def’]
future_loading_eqn (abc.Callable, optional) – Function of (t) -> z used to predict future loading (output) at a given time (t). Defaults to no outputs
- Returns
state at each events occurrence, with keys defined by model.events
e.g., state_at_event = {‘impact’: {‘x1’: 10, ‘x2’: 11}, ‘falling’: {‘x1’: 15, ‘x2’: 20}} given events = [‘impact’, ‘falling’] and states = [‘x1’, ‘x2’]
- Return type
Note
Also supports arguments from
simulate_to_threshold()
See also
threshold_met
- summary(file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)#
Print a summary of the model
- time_of_event(x, future_loading_eqn=<function PrognosticsModel.<lambda>>, **kwargs) dict #
New in version 1.5.0.
Calculate the time at which each event occurs (i.e., the event threshold is met). time_of_event must be implemented by any direct model. For a state transition model, this returns the time at which threshold_met returns true for each event. A model that implements this is called a “direct model”.
- Parameters
x (StateContainer) –
state, with keys defined by model.states
e.g., x = m.StateContainer({‘abc’: 332.1, ‘def’: 221.003}) given states = [‘abc’, ‘def’]
future_loading_eqn (abc.Callable, optional) – Function of (t) -> z used to predict future loading (output) at a given time (t). Defaults to no outputs
- Returns
- time_of_event (dict)
time of each event, with keys defined by model.events
e.g., time_of_event = {‘impact’: 8.2, ‘falling’: 4.077} given events = [‘impact’, ‘falling’]
Note
Also supports arguments from
simulate_to_threshold()
See also
threshold_met