Skip to main content
Version: 🚧 Alpha 🚧

13. Explore model parameters

This step adds a batch experiment that varies selected parameters and saves the results for analysis. The Optimization experiment uses Tabu search to maximize the combined prey and predator population.

Continue batch runs after a population reaches zero​

The GUI experiment pauses when either population disappears. The is_batch flag lets the batch experiment bypass that stop condition and run until its own time limit.

global {
bool is_batch <- false;

reflex stop_simulation when: ((nb_preys = 0) or (nb_predators = 0)) and !is_batch {
experiment.pause();
}
}

The batch experiment repeats each configuration twice, keeps the seed for corresponding replications, stops after simulation time 200 and searches the parameter ranges shown below.

experiment Optimization mode: batch repeat: 2 keep_seed: true until: (time > 200) {
parameter "Prey max transfer:" var: prey_max_transfer min: 0.05 max: 0.5 step: 0.05;
parameter "Prey energy reproduce:" var: prey_energy_reproduce min: 0.05 max: 0.75 step: 0.05;
parameter "Predator energy transfer:" var: predator_energy_transfer min: 0.1 max: 1.0 step: 0.1;
parameter "Predator energy reproduce:" var: predator_energy_reproduce min: 0.1 max: 1.0 step: 0.1;
parameter "Batch mode:" var: is_batch <- true;

method tabu maximize: nb_preys + nb_predators iter_max: 10 tabu_list_size: 3;

reflex save_results_explo {
ask simulations {
save [int(self), prey_max_transfer, prey_energy_reproduce, predator_energy_transfer, predator_energy_reproduce, self.nb_predators, self.nb_preys]
to: "results.csv" format: "csv" rewrite: (int(self) = 0) ? true : false header: true;
}
}
}

The experiment reflex saves the varied values and the population counts for each simulation to results.csv.

For the complete Predator–Prey model 13, see the GAMA model library.