The class of discrete and continuous model system is huge. In LPL it is not possible right now to model differential systems, however an example of a discrete dynamic system is given here. It is the famous predator-prey model.
Problem
“Consider a forest containing foxes and rabbits where the foxes eat the rabbits for food. We want to examine whether the two species can survive in the long-term. A forest is a very complex ecosystem. So to simplify the model, we will use the following assumptions:
The only source of food for the foxes is rabbits and the only predator of the rabbits is foxes.
Without rabbits present, foxes would die out.
Without foxes present, the population of rabbits would grow.
The presence of rabbits increases the rate at which the population of foxes grows.
The presence of foxes decreases the rate at which the population of rabbits grows.”
(This problem is from [1] p. 132ff).
Modeling Steps
The populations are modeled using a discrete dynamical system, that is, at each point in time – let’s say each month – the size of the two populations is calculated and then mapped on a graph (for more information see [1]). We calculate the populations over a period of 500 months. Hence, let i ∈ I = {0,…, 500} a set of time points (first of month). Furthermore, let R_{i} and F_{i} be the population at time i. In the absense of the other specie, the populations would grow/shrink proportionally to the actual size, so (with 0 ≤ α,δ ≤ 1) (The foxes would die out, while the population of rabbits grows infinitely.):
Now, The presence of the other specie either increases (the foxes) its population by a rate of β, or decreases (the rabbits) its population by a rate of γ. Therefore we have:
Reassigning the terms gives:
Given an initial population of F_{0} = 110 and R_{0} = 900, and the rates α = 0.12, β = 0.0001, γ = -0.0003, and δ = 0.039, it is easy to calculate the population at each time point using the simple LPL model :
model foxrabbit "Discrete Dynamic System";
parameter n:=500;
set i:= 0..n;
parameter x{i}:=i; F{i}; R{i};;
F[0]:= 110, R[0]:=900,
{i|i<#i-1} (F[i+1]:=0.88*F[i] + 0.0001*F[i]*R[i],
R[i+1]:=-0.0003*F[i]*R[i] + 1.039*R[i]);
Draw.Scale(1,1);
Draw.DefFont('Verdana',8);
Draw.XY(x,F,R);
end
Solution
With the rates given, the populations ocillate as can be seen in Figure 4 (Black the population of foxes, red the population of rabbits.)