murefi.ode
- class murefi.ode.BaseODEModel(parameter_names: tuple, independent_keys: tuple)
Bases:
object
A dynamic model that uses ordinary differential equations.
Methods
dydt
(y, t, ode_parameters)First derivative of the transient variables.
predict_dataset
(template, parameter_mapping, ...)Simulates an experiment that is comparable to the Dataset template. Args: parameter_mapping (ParameterMapping): maps elements in [parameters] to replicates in the [template] template (Dataset): template that the prediction will be comparable with parameters (array-like): prediction parameters, can be symbolic.
predict_replicate
(parameters, template)Simulates an experiment that is comparable to the Replicate template.
solver
(y0, t, ode_parameters)Solves the dynamic system for all T timepoints in t.
solver_vectorized
(y0, t, ode_parameters)Solves the dynamic system for all T timepoints in t with many parameter sets.
- abstract dydt(y, t, ode_parameters)
First derivative of the transient variables. Needs to be overridden by subclasses.
- Args:
y (array): current state of the system (n_y0,) t (float): time since intial state ode_parameters (array): system parameters (n_ode_parameters,)
- Returns:
array: change in y at time t
- predict_dataset(template: Dataset, parameter_mapping: ParameterMapping, parameters: Sequence | dict)
Simulates an experiment that is comparable to the Dataset template. Args:
- parameter_mapping (ParameterMapping):
maps elements in [parameters] to replicates in the [template]
- template (Dataset):
template that the prediction will be comparable with
- parameters (array-like):
prediction parameters, can be symbolic
- Returns:
prediction (Dataset): prediction result
- predict_replicate(parameters: Sequence, template: Replicate) Replicate
Simulates an experiment that is comparable to the Replicate template. Supports symbolic prediction and vectorized prediction from a matrix of parameters.
- Args:
- parameters (array-like):
The [parameters] sequence must be a tuple, list or numpy.ndarray, with the elements being a concatenation of y0 and ode_parameters.
Symbolic prediction requires a (n_parameters,) parameter vector of type {tuple, list, numpy.ndarray}. Elements may be a mix of scalars and PyTensor tensor variables.
Prediction of distributions requires a (n_parameters,) parameter vector of type {tuple, list, numpy.ndarray}. Elements may be a mix of scalars and vectors, as long as all vectors have the same length.
- template (Replicate):
template that the prediction will be comparable with
- Returns:
pred (Replicate): prediction result (contains Timeseries with y being numpy.arrays or Tensors)
- solver(y0, t, ode_parameters) dict
Solves the dynamic system for all T timepoints in t. Uses scipy.integrate.odeint and self.dydt to solve the system.
- Args:
y0 (array): initial states (n_y0,) t (array): timepoints of the solution ode_parameters (array): system parameters (n_ode_parameters,)
- Returns:
- y_hat (dict):
keys are the independent keys of the model values are model states of shape (T,)
- solver_vectorized(y0, t, ode_parameters) dict
Solves the dynamic system for all T timepoints in t with many parameter sets. Uses scipy.integrate.odeint and self.dydt to solve the system.
- Args:
y0 (array): initial states (n_y0, n_sets) t (array): timepoints of the solution ode_parameters (array): system parameters (n_ode_parameters, n_sets)
- Returns:
- y_hat (dict):
keys are the independent keys of the model values are model states of shape (T, n_sets)