The surge of technologies like WebAssembly and its associated ecosystem ecmscripten , pyscript and panel, allow the development of web content in languages like C, Go, Julia or Python, which can be executed on almost any modern web-browser. This provided me with an excellent justification to revise some interesting models and simulations close to my heart, and which can be used to produce demos I can put on spaces like this website.
One example which is very much of interest today not only to me but to several people in the ecology and evolution communities is that of the formation, co-evolution and resilience of ecological networks.
The advantage of being able to share codes in repositories for anybody to run their own simulations, is now enhanced with the ability to literally execute the same code in the browser! This allows anybody to get a flavour of the dynamics without having to install and download anything.
Ecological Evolution as a complex system.#
Foodwebs#
The webworld model - evolution as a complex system.#
Complex systems, are those in which their components interact locally amongst them according to some set of rules and are unaware of any global pattern emerging from those interactions. For instance, in an ecosystem, species interact by predator/prey relationships. Some species prey on other species, and at the same time are eaten by some predator species, alongside those processes, species also produce offspring an die of natural causes with some seasonal rate, thus, modifying the species population. The population update processes, might lead to patterns, such as oscillatory behaviours, stable co-existence and extinctions, events which occur at the ecosystem level, well beyond the level of the events of eating and being eaten.
These seasonal population updates occur in the time scale of months/years and in general we can write a model as follows.
$$\dot{N_i}(t)=\lambda \sum_j g_{ij}(t)N_i(t) - \sum_j g_{ji}(t)N_j(t)-d_iN_i(t) \quad (1)$$
The parameters \( \lambda\) and \(d_i\) correspond to the efficiency at which the resources transfer from a prey to its predator, and the natural death rates.
The only remaining quantities required to complete this model are the specification of the predation rates \(g_{kl}(t) \) between species \( k \) and \( l \). However, the goal here is more ambitious, we want to know, how does and ecosystem is formed in the first place, and how does natural selection drives the system to a mature configuration, in which the system (1) operates. To do so, we might, first consider a starting ecosystem consisting of a single species and establish the criteria for species evolution, and how to determine if two species posses a predator/prey relationship.
Species features and mutations.#
$$S_{ij} = \max \lbrace 0,\frac{1}{L}\sum_{a \in i, \thinspace b \in j} M_{a,b}\rbrace \quad(2)$$
Which allow us to determine if there exists a predator prey relationship between \( i \) and \( j\). With this definition of species and species score \( (2) \) we can treat the external resources as species \( “0” \), with a string fixed and a large population value \( R \).
Choice of diet, rates and evolutionarily stable strategies.#
$$\alpha_{ij} = c+(1-c)q_{ij}\quad(3)$$
Where \(c \in (0,1)\) is a competition parameter and \(q_{ij}\) is the fraction of common features between species.
For the rates \( g_{ij}(t) \) the model uses the generalised ratio dependent functional response:
$$g_{ij} = \frac{ f_{ij}S_{ij}N_j }{bNj + \sum_{k} \alpha_{ki}f_{kj}S_kjN_k} \quad(4)$$
This choice \( (4) \) introduces the fractions of effort \( f_{ij} \) a species \( i \) puts into foraging for \(j \). In other words:
$$ f_{ij} = \frac{g_{ij}}{\sum_j g_{ij}} \quad(5)$$
Equations \( (4) \) and \( (5) \) are re-adjusted each time the populations change. These, determine the foraging strategy of the each predator. This choice of efforts is an evolutionary stable strategy (ESS), which means that any other strategy can not be successful against it, provided the ESS is already taken by the majority. The dynamics of the efforts takes place in the shorter time scale of the model, which is that of days.

Code repositories.#
For the live version of the code, the hugginface model space lives here and its embedded below!
Live Version.#
Suggested readings for in-depth details and discussion of the model and results.#
For a thorough discussion on the theory of ecological communities, details in the implementation of webworld and other evolutionary approaches, please check the papers and references in the following list:
Modelling coevolution in multispecies communities J. Theor. Biol.
The influence of predator–prey population dynamics on the long-term evolution of food web structure J. Theor. Biol.
The impact of nonlinear functional responses on the long-term evolution of food web structure. J. Theor. Biol.
Modelling food webs Handbook of Graphs and Networks: From the Genome to the Internet
Topological structure and interaction strengths in model food webs. Ecol. Model.
The robustness of the Webworld model to changes in its structure. Ecological Complexity
The characteristics of species in an evolutionary food web model J. Theor. Biol.