# 猎食者猎物系统¶

## 经典猎食者猎物系统¶

$\dot{x}_{r} = \alpha x$

$\dot{y}_{s} = -\gamma y$

$\begin{split}\dot{x}_p &= -\beta x y \\ \dot{y}_p &= \delta x y\end{split}$

$\begin{split}\dot{x} &= \dot{x}_r + \dot{x}_p \\ \dot{y} &= \dot{y}_p + \dot{y}_s\end{split}$

$\begin{split}\dot{x} &= x (\alpha - \beta y) \\ \dot{y} &= y (\delta x - \gamma)\end{split}$

model ClassicModel "This is the typical equation-oriented model"
parameter Real alpha=0.1 "Reproduction rate of prey";
parameter Real beta=0.02 "Mortality rate of predator per prey";
parameter Real gamma=0.4 "Mortality rate of predator";
parameter Real delta=0.02 "Reproduction rate of predator per prey";
parameter Real x0=10 "Start value of prey population";
parameter Real y0=10 "Start value of predator population";
Real x(start=x0) "Prey population";
Real y(start=y0) "Predator population";
equation
der(x) = x*(alpha-beta*y);
der(y) = y*(delta*x-gamma);
end ClassicModel;


model ClassicModelInitialEquations "This is the typical equation-oriented model"
parameter Real alpha=0.1 "Reproduction rate of prey";
parameter Real beta=0.02 "Mortality rate of predator per prey";
parameter Real gamma=0.4 "Mortality rate of predator";
parameter Real delta=0.02 "Reproduction rate of predator per prey";
parameter Real x0=10 "Initial prey population";
parameter Real y0=10 "Initial predator population";
Real x(start=x0) "Prey population";
Real y(start=y0) "Predator population";
initial equation
x = x0;
y = y0;
equation
der(x) = x*(alpha-beta*y);
der(y) = y*(delta*x-gamma);
end ClassicModelInitialEquations;


  Real x;
initial equation
x = 5;


Real x(start=5, fixed=true);


## 稳定状态初始化¶

$\begin{split}\dot{x} &= 0 \\ \dot{y} &= 0\end{split}$

model QuiescentModel "Find steady state solutions to LotkaVolterra equations"
parameter Real alpha=0.1 "Reproduction rate of prey";
parameter Real beta=0.02 "Mortality rate of predator per prey";
parameter Real gamma=0.4 "Mortality rate of predator";
parameter Real delta=0.02 "Reproduction rate of predator per prey";
Real x "Prey population";
Real y "Predator population";
initial equation
der(x) = 0;
der(y) = 0;
equation
der(x) = x*(alpha-beta*y);
der(y) = y*(delta*x-gamma);
end QuiescentModel;


$x(t) = \int_{t_0}^{t_f} \dot{x}\ \mathrm{d}x + x(t_0)$

（当然了，在$$y$$$$\dot{y}$$之间也存在着类似的关系）

$\begin{split}\dot{x} &= 0 \\ \dot{x} &= x \ (\alpha - \beta y) \\ \dot{y} &= 0 \\ \dot{y} &= y \ (\delta x - \gamma)\end{split}$

$\begin{split}\dot{x} &= 0 \\ \dot{y} &= 0 \\ x (\alpha - \beta y) &= \dot{x} \\ y (\delta x - \gamma) &= \dot{y}\end{split}$

model QuiescentModelUsingStart "Find steady state solutions to LotkaVolterra equations"
parameter Real alpha=0.1 "Reproduction rate of prey";
parameter Real beta=0.02 "Mortality rate of predator per prey";
parameter Real gamma=0.4 "Mortality rate of predator";
parameter Real delta=0.02 "Reproduction rate of predator per prey";
Real x(start=10) "Prey population";
Real y(start=10) "Predator population";
initial equation
der(x) = 0;
der(y) = 0;
equation
der(x) = x*(alpha-beta*y);
der(y) = y*(delta*x-gamma);
end QuiescentModelUsingStart;


## 避免重复¶

model ClassicModel "This is the typical equation-oriented model"
parameter Real alpha=0.1 "Reproduction rate of prey";
parameter Real beta=0.02 "Mortality rate of predator per prey";
parameter Real gamma=0.4 "Mortality rate of predator";
parameter Real delta=0.02 "Reproduction rate of predator per prey";
parameter Real x0=10 "Start value of prey population";
parameter Real y0=10 "Start value of predator population";
Real x(start=x0) "Prey population";
Real y(start=y0) "Predator population";
equation
der(x) = x*(alpha-beta*y);
der(y) = y*(delta*x-gamma);
end ClassicModel;

model QuiescentModelUsingStart "Find steady state solutions to LotkaVolterra equations"
parameter Real alpha=0.1 "Reproduction rate of prey";
parameter Real beta=0.02 "Mortality rate of predator per prey";
parameter Real gamma=0.4 "Mortality rate of predator";
parameter Real delta=0.02 "Reproduction rate of predator per prey";
Real x(start=10) "Prey population";
Real y(start=10) "Predator population";
initial equation
der(x) = 0;
der(y) = 0;
equation
der(x) = x*(alpha-beta*y);
der(y) = y*(delta*x-gamma);
end QuiescentModelUsingStart;


model QuiescentModelWithInheritance "Steady state model with inheritance"
extends ClassicModel;
initial equation
der(x) = 0;
der(y) = 0;
end QuiescentModelWithInheritance;


model QuiescentModelWithModifications "Steady state model with modifications"
extends QuiescentModelWithInheritance(gamma=0.3, delta=0.01);
end QuiescentModelWithModifications;


 [Lotka] Lotka, A.J., “Contribution to the Theory of Periodic Reaction”, J. Phys. Chem., 14 (3), pp 271–274 (1910)
 [Volterra] Volterra, V., Variations and fluctuations of the number of individuals in animal species living together in Animal Ecology, Chapman, R.N. (ed), McGraw–Hill, (1931)
 [Guldberg] C.M. Guldberg and P. Waage,”Studies Concerning Affinity” C. M. Forhandlinger: Videnskabs-Selskabet i Christiana (1864), 35