| Crates.io | mutare |
| lib.rs | mutare |
| version | 0.10.0 |
| created_at | 2025-08-11 15:33:45.395305+00 |
| updated_at | 2026-01-14 15:27:43.084722+00 |
| description | A simple tool to simulate and analyze a stochastic agent-based model of adaptation in uncertain environments. |
| homepage | |
| repository | https://github.com/Marco-Mendivil-Carboni/mutare |
| max_upload_size | |
| id | 1790351 |
| size | 132,272 |
mutare (Latin for "to change") is a simple tool to simulate and analyze a stochastic agent-based model of adaptation in uncertain environments.
mutare simulates a stochastic agent-based model of adaptation in uncertain environments with the following characteristics:
n_env possible values and follows a Markov chain defined by the transition rates rates_trans.n_phe possible values, and a phenotypic strategy, a distribution over phenotypes.rates_birth and rates_death).prob_mut it suffers a random mutation and changes completely.n_agents) and reinitialized if extinction is reached.strat_phe is set, all agents will share that same strategy; otherwise, they will each have a random strategy.During the simulation, every steps_per_save steps, the following observables are computed and saved:
Every steps_per_file steps, the simulation is stopped and a new output file is written to disk.
You can install mutare via cargo:
cargo install mutare
Or build it from source:
git clone https://github.com/Marco-Mendivil-Carboni/mutare.git
cd mutare
cargo build --release # The release profile is much faster than the dev profile
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:
[model]
n_env = 2
n_phe = 2
rates_trans = [ [ -1.0, 1.0,], [ 1.0, -1.0,],]
rates_birth = [ [ 1.2, 0.0,], [ 0.0, 0.8,],]
rates_death = [ [ 0.0, 1.0,], [ 1.0, 0.0,],]
prob_mut = 0.001
[init]
n_agents = 100
strat_phe = [ 0.5, 0.5,]
[output]
steps_per_file = 65536
steps_per_save = 256
hist_bins = 16
Now you can begin making simulation runs and analyzing them. Here are some examples of common commands:
mutare --sim-dir example_sim/ --run-idx 0 create # Create run 0
mutare --sim-dir example_sim/ --run-idx 0 resume # Resume run 0
mutare --sim-dir example_sim/ --run-idx 0 analyze # Analyze run 0
Run mutare --help to see more detailed help information.
The repository also includes some Python utility modules in scripts/utils/ for automating simulation workflows.
If you want to use these utilities you can set up the Python environment by running the following commands (after having cloned the repository):
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Documentation is available via:
cargo doc --no-deps --open # Not generating docs for dependencies saves time
This project is licensed under the MIT License.
For questions or collaboration, reach out to marcomc@ucm.es or open an issue on GitHub.