Skip to main content
Version: 🚧 Alpha 🚧

Batch experiments

A batch experiment runs simulations for a set of parameter values. It can support parameter exploration, repeated runs, or optimization. Batch experiments can run in the graphical interface or in headless mode. See exploration methods for ways to choose parameter values.

A batch experiment declares its stopping condition, parameters and exploration method inside the experiment block:

experiment model_sweep mode: batch until: stop_condition {
parameter "Parameter label" var: parameter_value min: lower_bound max: upper_bound;
method exploration;
}

The variable referenced by var: must be declared in the model. The until: expression is evaluated for each simulation and should become true so that the run can finish.

Main batch facets​

  • until: sets the Boolean condition that stops a simulation.
  • repeat: sets the number of simulations for each parameter configuration. It defaults to 1.
  • keep_seed: controls whether the same random seed is kept between simulations. It defaults to false.
  • parallel: controls how many simulations can run concurrently. When omitted or false, they run sequentially; true uses the configured thread count, and a positive integer sets a maximum.
  • keep_simulations: controls whether completed simulation agents stay available for analysis. It defaults to true; disabling it discards simulation agents after results are collected.
  • group_parameter_sets: controls whether simulations from different parameter configurations are grouped for evaluation. It defaults to true. With false, the batch processes one parameter configuration at a time. This also changes when experiment-level behavior and outputs are stepped.

Reading results from simulations​

A reflex in the experiment can read completed simulation agents through simulations. When group_parameter_sets: is true, experiment behavior is stepped after the grouped simulations finish; when it is false, it is stepped after each parameter configuration. Access to completed simulation agents requires keep_simulations: true.

A model can save values from each completed simulation in an experiment reflex. The model must declare the variables used in the output fields. For example:

reflex save_results {
ask simulations {
save [self.nb_recovered, self.cycle]
to: "results.csv" format: "csv" rewrite: false header: true;
}
}

This pattern is used by GAMA model examples that explore parameter sets and collect simulation results.

Experiment outputs​

A permanent block defines experiment-level outputs in a batch experiment. These outputs are not reinitialized for each simulation; they are filled as simulations complete. A permanent chart can summarize a measure across parameter values.

Example chart of a model measure across parameter values.

Use a chart kind and data declarations supported by the chart statement.