-
Notifications
You must be signed in to change notification settings - Fork 5
DefiningParameters
When playing a simulation, you have the possibility to define input parameters, in order to change them and replay the simulation. Defining parameters allows to make the value of a global variable definable by the user through the user graphic interface.
You can define parameters inside the global scope when defining your global variables with the facet parameter
(this way of defining parameters is not the recommended one, as it makes the variable a parameter of all the experiments that will be defined and does not offer the possibility to redefine its initial and possible values in several ways in each experiment):
global {
int my_integer_global_value <- 5 parameter: "My integer global value";
}
When launching your experiment, the parameter will appear in your "Parameters" panel, with the name you chose for the parameter
facet.
You can also define your parameter inside the experiment (recommended), using the statement parameter
. You have to specify first the name of your parameter, then the name of the global variable through the facet var
.
global {
int my_integer_global_value <- 5;
}
experiment MyExperiment type: gui {
parameter "My integer global value" var:my_integer_global_value;
}
NB: This variable has to be initialized with a value. If you do not want to initialize your value in the global
block, you can initialize the value directly in the parameter
statement, using the facet init
or <-
.
global {
int my_integer_global_value;
}
experiment MyExperiment type: gui {
parameter "My integer global value" var: my_integer_global_value init: 5;
}
You can use some facets to arrange your parameters. For example, you can categorize your parameters under a label, using the facet category
:
global {
int attr_1 <- 5 ;
int attr_2 <- 5 ;
int attr_3 <- 5 ;
}
experiment MyExperiment type: gui {
parameter "attr 1" category: "Category 1" var: attr_1 <- 5;
parameter "attr 2" category: "Category 1" var: attr_2 <- 5;
parameter "attr 3" category: "Category 2" var: attr_3 init: 5;
}
You also can add some facets such as min
, max
, step
or among
to improve the declaration of the parameter (and define the possible values the parameter can take).
global {
string fruit <- "none" ;
string vegetable <- "none";
int integer_variable <- 5;
}
experiment MyExperiment type: gui {
parameter "fruit" category:"food" var: fruit <- "none" among:["none","apple","banana"] ;
parameter "vegetable" category:"food" var: vegetable <- "none" among:["none","cabbage","carrot"];
parameter "integer variable" category:"other"var: integer_variable <- 5 min:0 max:100 step:5;
}
We can notice that the parameters will not appear graphically in the same way if they are defined with a set of possible values (with among
) or with a range of possible values (defined by a min
, max
and a step
).
The definition of the initial value and of the possible values can be set in the global
or in the experiment
depending on the aim of this limitation: for example if a variable has a maximum value set to 1 in the global, this limitation can be used in the model in order that the variable value does not exceed this value. If the maximum boundary is set in the experiment, some executions of the model can be done without it...
- Installation and Launching
- Workspace, Projects and Models
- Editing Models
- Running Experiments
- Running Headless
- Preferences
- Troubleshooting
- Introduction
- Manipulate basic Species
- Global Species
- Defining Advanced Species
- Defining GUI Experiment
- Exploring Models
- Optimizing Models
- Multi-Paradigm Modeling
- Manipulate OSM Data
- Cleaning OSM Data
- Diffusion
- Using Database
- Using FIPA ACL
- Using BDI with BEN
- Using Driving Skill
- Manipulate dates
- Manipulate lights
- Using comodel
- Save and restore Simulations
- Using network
- Headless mode
- Using Headless
- Writing Unit Tests
- Ensure model's reproducibility
- Going further with extensions
- Built-in Species
- Built-in Skills
- Built-in Architecture
- Statements
- Data Type
- File Type
- Expressions
- Exhaustive list of GAMA Keywords
- Installing the GIT version
- Developing Extensions
- Introduction to GAMA Java API
- Using GAMA flags
- Creating a release of GAMA
- Documentation generation