Population Models and Harvesting
Population dynamics is where differential equations meet data most directly: fisheries, wildlife management, bacteria in a bioreactor, users of an app. This lesson collects the standard single-species models, fits one to data, and studies harvesting policies, using tools from Separable Equations and Autonomous Equations.
Three models
| Model | Equation | Behaviour |
|---|---|---|
| Exponential (Malthus) | unlimited growth, doubling time | |
| Logistic (Verhulst) | S-curve to the carrying capacity | |
| Gompertz | S-curve with an earlier, slower approach; used for tumour growth | |
| Allee effect | extinction below the threshold |
The Allee effect models species that need a minimum density to find mates or defend themselves: and are stable, is an unstable threshold.
import numpy as np
from scipy.integrate import solve_ivp
r, K, A = 0.5, 1000.0, 100.0
models = {
"logistic": lambda t, P: r * P * (1 - P / K),
"Gompertz": lambda t, P: r * P * np.log(K / P),
"Allee": lambda t, P: r * P * (P / A - 1) * (1 - P / K),
}
for name, f in models.items():
for P0 in (50.0, 150.0):
sol = solve_ivp(f, (0, 30), [P0], t_eval=[5, 10, 30], rtol=1e-9, atol=1e-9)
print(f"{name:9s} P0 = {P0:5.0f}: P(5, 10, 30) =", np.round(sol.y[0], 1))logistic P0 = 50: P(5, 10, 30) = [ 390.7 886.5 1000. ]
logistic P0 = 150: P(5, 10, 30) = [ 682.5 963.2 1000. ]
Gompertz P0 = 50: P(5, 10, 30) = [ 782. 980. 1000.]
Gompertz P0 = 150: P(5, 10, 30) = [ 855.8 987.3 1000. ]
Allee P0 = 50: P(5, 10, 30) = [8. 0.7 0. ]
Allee P0 = 150: P(5, 10, 30) = [1000. 1000. 1000.]
With (below the Allee threshold 100), the Allee population dies out while the others thrive.
Fitting the logistic model to data
Given counts over time, estimate and by least squares on the closed-form solution. The data below are synthetic, generated from known parameters with a seeded random generator, so we can check the fit recovers them.
import numpy as np
from scipy.optimize import curve_fit
def logistic(t, r, K, P0):
return K / (1 + (K / P0 - 1) * np.exp(-r * t))
rng = np.random.default_rng(42)
t = np.arange(0, 21, 2.0)
true = (0.45, 800.0, 20.0)
data = logistic(t, *true) * (1 + 0.05 * rng.normal(size=t.size))
params, cov = curve_fit(logistic, t, data, p0=(0.3, 600, 10))
err = np.sqrt(np.diag(cov))
for name, p, e, tv in zip(("r", "K", "P0"), params, err, true):
print(f"{name:2s} = {p:8.3f} +- {e:6.3f} (true {tv})")r = 0.419 +- 0.027 (true 0.45)
K = 809.194 +- 14.599 (true 800.0)
P0 = 22.879 +- 4.908 (true 20.0)
All three estimates lie within about one standard error of the true values. is the best determined parameter (2 % relative error) because the data reach the plateau.
Harvesting: constant quota versus constant effort
Constant quota : the maximum sustainable yield is , taken at . But at that quota the equilibrium is semistable, and any bad year drives the stock to collapse. Quotas near the maximum are dangerous.
Constant effort (catch proportional to stock): the equilibrium is stable for , and the yield is largest at , giving the same , but now the system recovers from shocks.
import numpy as np
from scipy.integrate import solve_ivp
r, K = 0.5, 1000.0
quota = lambda t, P: r * P * (1 - P / K) - 0.95 * r * K / 4
effort = lambda t, P: r * P * (1 - P / K) - (r / 2) * P
for name, f in (("95% of max quota", quota), ("optimal effort ", effort)):
for P0 in (500.0, 300.0): # healthy stock, and a stock hit by a bad year
dead = lambda t, P: P[0] - 1.0; dead.terminal = True
sol = solve_ivp(f, (0, 200), [P0], events=dead, rtol=1e-9)
end = "collapse at t = %.1f" % sol.t_events[0][0] if sol.t_events[0].size else "P(200) = %.1f" % sol.y[0][-1]
print(f"{name} from P0 = {P0:.0f}: {end}")95% of max quota from P0 = 500: P(200) = 611.8
95% of max quota from P0 = 300: collapse at t = 7.2
optimal effort from P0 = 500: P(200) = 500.0
optimal effort from P0 = 300: P(200) = 500.0
In software
- Fisheries agencies run age-structured versions of these models (systems of ODEs or difference equations) to set catch limits.
- Product analytics fit logistic and Gompertz curves to user adoption; the fitted is the "market size" estimate, and its error bar is usually much larger than people would like.
Exercises
Exercise 1: Doubling time
A bacterial culture grows exponentially and doubles every 20 minutes. What is per hour?
Answer
per hour.
Solution
gives .
Exercise 2: Maximum sustainable yield
For per year and fish, what is the maximum sustainable yield, and at which stock is it taken?
Answer
10,000 fish per year at a stock of 25,000.
Solution
, at .
Exercise 3: Allee threshold (code)
For the Allee model of the lesson, starting at and , where does each population go?
Answer
dies out; grows to .
Solution
is an unstable equilibrium separating the two basins.
import numpy as np
from scipy.integrate import solve_ivp
f = lambda t, P: 0.5 * P * (P / 100 - 1) * (1 - P / 1000)
for P0 in (99.0, 101.0):
print(P0, round(solve_ivp(f, (0, 60), [P0], rtol=1e-10, atol=1e-12).y[0][-1], 3))99.0 0.0
101.0 1000.0
Test yourself
The maximum sustainable yield of the logistic model with constant quota is…
The Allee effect means…
- populations grow without limit
- below a threshold density the population declines to extinction
- the carrying capacity is zero
- growth is linear
Why is constant-effort harvesting safer than a near-maximal constant quota?
- It catches more fish
- Its equilibrium is stable, so the stock recovers from shocks
- It has no equilibrium
- It ignores the stock size