Skip to content

Commit

Permalink
adding Lotka Volterra to model library
Browse files Browse the repository at this point in the history
  • Loading branch information
jfree-man committed Dec 14, 2023
1 parent 1d22b2c commit 8a5d7c1
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
19 changes: 19 additions & 0 deletions inst/starter_models/lotka_volterra/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: "Lotka-Volterra"
index_entry: "simple two-species competition model"
author: Jennifer Freeman
---

- $X$ - number of individuals in species $X$
- $Y$ - number of individuals in species $Y$
- $r_i$ - growth rate of species $I$
- $a_{ij}$ - intra/inter-specific density dependence, ``effect of species $j$ on species $i$'' (Hastings, 1997)

$$
\begin{align*}
\frac{dX}{dt} &= r_x X (1 - a_{xx}X - a_{xy}Y) \\
\frac{dY}{dt} &= r_y Y (1 - a_{yy}Y - a_{yx}X)
\end{align*}
$$

Hastings, A. (1997). Competition. In: Population Biology. Springer, New York, NY. https://doi.org/10.1007/978-1-4757-2731-9_7
39 changes: 39 additions & 0 deletions inst/starter_models/lotka_volterra/model.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
library(macpan2)

## expression lists
###################################################

## free form computations for convenience
## none

## absolute flow rates (per time only)
## reference
flow_rates = list(
## growth rate of species X and Y
growth_x ~ rx * X
, growth_y ~ ry * Y
## intraspecific effect
## species X on X
, intraspecific_x ~ growth_x * axx * X
## species Y on Y
, intraspecific_y ~ growth_y * ayy * Y
## interspecific effect
## species X on Y
, interspecific_xy ~ growth_x * ayx * Y
## species Y on X
, interspecific_yx ~ growth_y * axy * X
)

## state updates
state_updates = list(
X ~ X + growth_x - intraspecific_x - interspecific_xy
, Y ~ Y + growth_y - intraspecific_y - interspecific_yx
)

## simple unstructured scalar expression
expr_list = ExprList(
during = c(
flow_rates
, state_updates
)
)

1 comment on commit 8a5d7c1

@papsti
Copy link
Collaborator

@papsti papsti commented on 8a5d7c1 Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love it!

Please sign in to comment.