mutare
mutare (Latin for "to change") is a simple tool to simulate and analyze a stochastic agent-based model of adaptation in uncertain environments.
Overview
mutare simulates a stochastic agent-based model of adaptation in uncertain environments with the following characteristics:
- The environment is a discrete random variable with
n_envpossible states and follows a Markov chain with configurable transition probabilities (prob_trans_env). - Each agent carries a phenotype, a discrete variable with
n_phepossible states, and a probability distribution over phenotypes. - At every simulation step, agents may replicate or decease according to environment and phenotype specific probabilities (
prob_repandprob_dec). - The offspring's phenotype is sampled from the parent's distribution.
- The offspring inherits the parent's distribution, but with probability
prob_mutthis distribution suffers a slight mutation (modulated bystd_dev_mut). - At every simulation step, the population is capped at its initial size and reinitialized if extinction is reached.
- Each output file contains
steps_per_filerecords, and the state is saved everysteps_per_savesteps if specified.
From these output files mutare can also compute the following observables:
- The relative change in the number of agents per step.
- The probability of extinction.
- The probability of each environment.
- The average probability distribution over phenotypes across agents.
Getting Started
Prerequisites
- Rust (install via rustup)
Installation
You can install mutare via cargo:
Or build it from source:
Basic Usage
Start by creating a simulation directory (e.g. example_sim/) and placing a config file named config.toml inside it.
Here is an example config file:
[]
= 2
= 2
= [ [ 0.99, 0.01,], [ 0.01, 0.99,],]
= [ [ 0.012, 0.0,], [ 0.0, 0.008,],]
= [ [ 0.0, 0.016,], [ 0.012, 0.0,],]
= 0.001
= 0.1
[]
= 4096
= [ 0.5, 0.5,]
[]
= 16384
= 1024
Now you can begin making simulation runs and analyzing them. Here are some examples of common commands:
Run mutare --help to see more detailed help information.
Advanced Usage
The repository also includes some Python utility modules in scripts/utils/ for automating simulation workflows.
Prerequisites
- Python 3.12+
Python Setup
If you want to use these utilities you can set up the Python environment by running the following commands (after having cloned the repository):
Documentation
Documentation is available via:
License
This project is licensed under the MIT License.
Contact
For questions or collaboration, reach out to marcomc@ucm.es or open an issue on GitHub.