lv_sens.ode

Adjoint method for the Lotka-Volterra ODE (predator-prey) using analytic model derivatives.

Forward ODE:

\[\begin{split}\frac{dx}{dt} = \alpha x - \beta xy \\ \frac{dy}{dt} = xy - \delta y\end{split}\]

Functions

LV(x, theta, dt)

Propagator of Lotka-Volterra system discretized with semi-implicit Euler method.

LV_da(x, theta, dt)

Partial derivative of ODE propagation operator with respect to the parameter, theta.

LV_dx(x, theta, dt)

Partial derivative of ODE propagation operator with respect to the state, x.

forward(theta, dt, N, x0)

Solve ODE.

lv_sens.ode.LV(x: ndarray[Any, dtype[float64]], theta: ndarray[Any, dtype[float64]], dt: float) ndarray[Any, dtype[float64]][source]

Propagator of Lotka-Volterra system discretized with semi-implicit Euler method.

Continuous ODE:

\[\begin{split}\frac{dx}{dt} = \alpha x - \beta xy \\ \frac{dy}{dt} = xy - \delta y\end{split}\]

Time-discretized ‘propagator’ form:

\[u_{n+1} = \mathcal{N}(u_n)\]

with the state \(u_n = (x_n^T,\ y_n^T)\) and

\[\begin{split}\mathcal{N}(u_n) = \left[I - \tau \begin{pmatrix}\alpha & -\beta x\\y & -\delta\end{pmatrix}\right]^{-1} u_n\end{split}\]
Parameters:
  • x – current state at time t

  • theta – parameter

  • dt – time step

Returns:

state at the next time step

lv_sens.ode.LV_da(x: ndarray[Any, dtype[float64]], theta: ndarray[Any, dtype[float64]], dt: float) ndarray[Any, dtype[float64]][source]

Partial derivative of ODE propagation operator with respect to the parameter, theta.

Parameters:
  • x – current state at time t

  • theta – parameter

  • dt – time step

Returns:

derivative of function evaluated in (x, theta, t)

lv_sens.ode.LV_dx(x: ndarray[Any, dtype[float64]], theta: ndarray[Any, dtype[float64]], dt: float) ndarray[Any, dtype[float64]][source]

Partial derivative of ODE propagation operator with respect to the state, x.

Parameters:
  • x – current state at time t

  • theta – parameter

  • dt – time step

Returns:

derivative of function evaluated in (x, theta, t)

lv_sens.ode.forward(theta: float, dt: float, N: int, x0: list[float]) ndarray[Any, dtype[float64]][source]

Solve ODE.

Parameters:
  • theta – parameter

  • dt – time step

  • N – number of timesteps

  • x0 – initial condition

Returns:

state trajectory (all timesteps)