Defining GUI Experiment
When you run a simulation, an experiment can define its inputs, outputs and behaviors:
- Inputs are parameters the user can set for a simulation.
- Behaviors define experiment-level actions and reflexes.
- Outputs can include displays, monitors and inspectors. Declare them inside
outputand use thelayoutstatement to arrange them.
A typical GUI experiment code follows this pattern:
experiment exp_name mode: gui {
[input]
[behaviors]
output {
layout [layout_option]
[display statements]
[monitor statements]
}
}
Experiment execution facets​
In current GAML syntax, use mode: gui for an interactive experiment. Use mode: batch for a batch experiment that runs simulations repeatedly, often with different parameter values, and mode: test for model tests. The legacy type: facet is accepted with a deprecation warning; see the migration guide when updating older models. See also batch experiments and writing tests.
Recording simulations​
The record: facet records simulation states so you can step backward through a run (see save and restore simulations). Batch experiments cannot be recorded.
Experiment attributes​
Inside an experiment, built-in attributes include minimum_cycle_duration, which sets the minimum wall-clock duration of each cycle in seconds. Its default value is 0.
experiment my_experiment mode: gui {
float minimum_cycle_duration <- 2.0#s;
}
The simulations attribute contains the simulations currently running in the experiment. The simulation attribute refers to the current simulation; it is nil if no simulation has been created and refers to the latest simulation when several exist.
Experiment facets​
Finally, in the case of a GUI experiment, the facets autorun and benchmark can be used as follows:
experiment name mode: gui autorun: true benchmark: true { }
When autorun is set to true, the experiment starts running after launch. When benchmark is set to true, GAMA records how often statements and operators run and how long they take across the experiment's simulations. The results are saved to a CSV file in a benchmarks folder when the experiment closes.
For other experiment built-ins, see the experiment reference.
Defining displays layout​
A layout can be added to output to specify the layout of the various displays defined below (e.g. #none, #split, #stack, #vertical or #horizontal). It will also define which elements of the interface are displayed: parameters, navigator, editors, consoles, toolbars, tray, or tabs facets (expecting a boolean value). You will find more detailed information in the statement's documentation
Defining elements of the GUI experiment​
This section covers the different parts of a GUI experiment: defining input parameters, and the outputs of the experiment, namely displays, monitors and inspectors and export files. It ends with the definition of user commands.