gemlib.deterministic.ode_model

Contents

gemlib.deterministic.ode_model#

gemlib.deterministic.ode_model(transition_rate_fn, incidence_matrix, initial_state, num_steps=None, initial_time=0.0, time_delta=1.0, times=None, solver='DormandPrince', solver_kwargs=None)#

Solve a system of differential equations

Parameters:
  • transition_rate_fn (list[Callable[[float, ArrayLike], Array]] | Callable[[float, ArrayLike], tuple[Array]]) – Either a list of callables of the form fn(t: float, state: Tensor) -> Tensor or a Python callable of the form fn(t: float, state: Tensor) -> tuple(Tensor,...) . In the first (preferred) form, each callable in the list corresponds to the respective transition in incidence_matrix. In the second form, the callable should return a tuple of transition rate tensors corresponding to transitions in incidence_matrix. Note: the second form will be deprecated in future releases of gemlib.

  • incidence_matrix (ArrayLike) – a [S, R] matrix describing the change in S resulting from transitions R.

  • initial_state (ArrayLike) – a [...,N, S] (batched) tensor with the state values for N units and S states.

  • num_steps (int | None) – python integer representing the size of the time step to be used.

  • initial_time (float) – an offset giving the time of the first time step in the model.

  • time_delta (float) – the size of the time step to be used.

  • times (ArrayLike | None) – a 1-D tensor of times for which the ODE solutions are required.

  • solver (str) – a string giving the ODE solver method to use. Can be “rk45” (default) or “BDF”. See the TensorFlow Probability documentation for details.

  • solver_kwargs (dict | None) – a dictionary of keyword argument to supply to the solver. See the solver documentation for details.

  • validate_args – check that the values of the parameters supplied to the constructor are all within the domain of the ODE function

  • name – the name of this distribution.