My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Sections14  
Sections(Modeling Guide)
Updated Dec 2, 2011 by benoit.g...@gmail.com



The XML files that compose a model are structured in several sections.

include

This section allows to load another model file before loading the current file. This file can contain anything (whole definition of a model, definition of a species, of an environment, of global variables, etc.) as long as it respects the common structure of GAML models. Note that as many files as needed can be included. Example:

import "../include/schelling_common.gaml"
import "../include/data_global.gaml"

global

This "global" section defines the "world" agent, a special agent of a GAMA model. We can define variables and behaviours for the "world" agent. Variables of "world" agent are global variables thus can refered by agents of other species or other places in the model source code. Example:

global {
	var numberBugs type: int init: 100 parameter: 'true';
	var globalMaxConsumption type: float value: 1 parameter: 'true';
	var globalMaxFoodProdRate type: float value: 0.01 parameter: 'true';
	init {
		create species: bug number: numberBugs;
	}
}

entities

Definitions of species are placed int this section. Example:

entities {
	species bug skills: situated {
		var evol type: float init: 1;
		var color type: rgb value: rgb [255, 255/evol, 255/evol];
		var maxConsumption type: float value: globalMaxConsumption;
		var myPlace type: stupid_grid value: location as stupid_grid;
		reflex basic_move {
			let destination var: destination value: one_of ((myPlace neighbours_at 4) where empty(each.agents));
			if condition: destination != nil {
				set location value: destination;
			}
		}
		reflex grow {
			let transfer var: transfer value: min [maxConsumption, myPlace.food];
			set evol value: evol + transfer;
			set myPlace.food value: myPlace.food - transfer;
		}
		aspect basic {
			draw shape: circle color: color size: 1;
		}
	}
}

environment

This section contains definitions of environment. Actually, GAMA supports two kinds of environments: GRID based environment and continuous environment. A model can have several GRID environments and one continuous environment. GAMA platform is responsible for assuring the all the necessary synchronizations between these environments. Example:

environment width: 100 height: 100 {
	grid stupid_grid width: 100 height: 100 torus: true {
		var color type: rgb init: rgb('black');
		var maxFoodProdRate type: float value: globalMaxFoodProdRate;
		var maxConsumption type: float value: globalMaxConsumption;
		var foodProd type: float value: (rnd(1000) / 1000) * maxFoodProdRate;
		var food type: float init: 0.0 value: food + foodProd;
	}
}

output

This section defines outputs to display in the simulation mode of GAMA. Several kinds of output are supported.

  • display: defines views to display grids, species, charts, texts and images. For each element, it is possible to define a size (defined by a point) and a position (also defined by a point). Example of display:
display stupid_display {
	grid stupid_grid;
	species bug aspect: basic;
}
	
  • chart: defines a view to display a chart. There are three types of chart: pie, series and histogram.
    • Pie: defines a view to display the pie-based chart.
    • Series: defines a view to display the series-based chart.
    • Histogram: defines a view to display a histogram-based chart.
  • inspect: inspectors the species and agents defined in the model.
    • agent inspect: user clicks on the Grid display or Gis display to select an agent. This view will display all the attributes of the selected agents as well as the change of these attributes over the simulation.
    • species inspect: this inspector displays all the species, the corresponding agents and attributes dedined in the model in a tree-based structure.
  • monitor: a monitor is used to observe the change in value of an expression over the simulation.

Example:

output {
	display stupid_display {
		grid stupid_grid;
		species bug aspect: basic;
	}
	inspect name: 'Agents' type: agent refresh_every: 5;
	inspect name: 'Species' type: species refresh_every: 5;
	display histogram_display {
		chart name: 'Size distribution' type: histogram background: rgb('lightGray') {
			data name: "[0;10]" value: bugs count (each.evol < 10);
			data name: "[10;20]" value: bugs count ((each.evol > 10) and (each.evol < 20));
			data name: "[20;30]" value: bugs count ((each.evol > 20) and (each.evol < 30));
			data name: "[30;40]" value: bugs count ((each.evol > 30) and (each.evol < 40));
			data name: "[40;50]" value: bugs count ((each.evol > 40) and (each.evol < 50));
			data name: "[50;60]" value: bugs count ((each.evol > 50) and (each.evol < 60));
			data name: "[60;70]" value: bugs count ((each.evol > 60) and (each.evol < 70));
			data name: "[70;80]" value: bugs count ((each.evol > 70) and (each.evol < 80));
			data name: "[80;90]" value: bugs count ((each.evol > 80) and (each.evol < 90));
			data name: "[90;100]" value: bugs count ((each.evol > 90) and (each.evol < 100));
		}
	}
}

batch

Please see this section for a detailed description of the batch mode.


Sign in to add a comment
Powered by Google Project Hosting