Skip to main content
Version: 🚧 Alpha 🚧

3. Batch experiment and Latin Hypercube Sampling

This step adds a batch experiment that samples the SIR model's five parameters with Latin Hypercube Sampling (LHS). Each configuration runs once, and the experiment records its inputs and final counts in ../results/lhs_results.csv.

Configure the batch experiment​

The parameter ranges define the search space. sample: 100 requests 100 parameter configurations. The until: facet uses the same infection-end and cycle-limit conditions as the model's global stop reflex.

experiment SIR_LHS mode: batch repeat: 1 keep_seed: false
until: (cycle >= 1000 or nb_infected = 0) {
parameter "Number of agents" var: nb_agents min: 50 max: 500;
parameter "Initially infected" var: nb_infected_init min: 1 max: 50;
parameter "Infection rate" var: infection_rate min: 0.0 max: 1.0;
parameter "Infection distance" var: infection_distance min: 1 max: 20 unit: "m";
parameter "Recovery time" var: recovery_time min: 10 max: 200 unit: "cycles";

method exploration sampling: "latinhypercube" sample: 100;

reflex save_results {
ask simulations {
save [int(self), self.nb_agents, self.nb_infected_init,
self.infection_rate, self.infection_distance, self.recovery_time,
self.nb_recovered, self.cycle]
to: "../results/lhs_results.csv" rewrite: false header: true;
}
}
}

LHS samples each parameter range across 100 strata, so each range receives coverage across the selected configurations. The model saves the run index, parameter values, number recovered and stopping cycle. rewrite: false appends rows, and header: true requests column names.

The output files are relative to the model's working directory. Remove or rename an existing CSV before a new exploration when the results should contain only the new run.

See the complete SIR_LHS model source in the SIR Analysis project. For details on GAMA batch experiments and their methods, see Exploration Methods.