UsingBDI

Julien Mazars edited this page May 21, 2016 · 9 revisions

Using BDI

Install

You need to run the Git version.

The plugin need to be add with Eclipse doing the following:

  • In ummisco.gama.feature.core open the feature.xml file.
  • In plug-ins click add the msi.gaml.architecture.simplebdi

Acteur Projet

A website (still in construction) of the ACTEUR project can be found here http://acteur-anr.fr/

An introduction to cognitive agent

The belief-desire-intention software model (usually referred to simply, but ambiguously, as BDI) is a software model developed for programming intelligent agents.

  • Belief: State of the agent.
  • Desire: Objectives that the agent would like to accomplish.
  • Intention: What the agent has chosen to do.
    • Plan: Sequences of actions that an agent can perform to achieve one or more of its intensions.

Basic Example: A fire rescue model using cognitive agent

We introduce a simple example to illustrate the use of the BDI architecture.

This simple model consists in creating "cognitive" agent whose goal is to extinguish a fire. In a first approximation we consider only one static water area and fire area. The aim is not to have a realistic model but to illustrate how to give a "cognitive" behavior to an agent using the BDI architecture.

First let's create a BDI agent using the key control simple_bdi (A description of all existing control architectures is available here.)

Species Helicopter creation

species helicopter skills:[moving] control: simple_bdi{
...
}

Attributes

The species helicopter needs 2 attributes to represent the water value and its speed.

float waterValue;
float speed <- 10.0;

Predicates

The predicate are the structure that are used to define a belief, a desire or an intention. In this model we choose to declare 3 different predicates.

predicate patrol_desire <- new_predicate("patrol") with_priority 1;
predicate water_predicate <- new_predicate("has water", true) with_priority 3;
predicate no_water_predicate <- new_predicate("has water", false) ;

The new_predicate() tool creates a predicate. It needs a name (string type) and it can contain a map of values, a priority (double type) or a truth value (boolean type). The with_priority tool add a priority to a predicate. The priority is used as an argument when the agent has to choose between two predicates (to choose an intention for example).

Initialization

The initialization consists in setting the attribute waterValue to 1 and to add one desire. Three optional parameters are also set. The first desire added in the desire base is the patrol_desire saying that the helicopter wants to patrol. The optional parameters are specific to the BDI plug-in. You can specify the commitment of an agent to his intentions and his plans with the variables intention_persistence and plan_persistence that are floats between 0.0 (no commitment) and 1.0. The variable probabilistic_choice is a boolean that enables the agent to use a probabilistic choice (when true) or a deterministic choice (when false) when trying to find a plan or an intention.

waterValue <-1.0;
do add_desire(patrol_desire);
intention_persistence <- 1.0;
plan_persistence <- 1.0;
probabilistic_choice <- false;	

Perception

At each iteration, the helicopter has two perceptions to do. The first one is about itself. The helicopter needs to perceive if it has water or not. If it has water, it adds the belief corresponding belief and removes the belief that it does not have water. And if it does not have water, that is the contrary.

perceive target:self{
	if(waterValue>0){
		do add_belief(water_predicate);
		do remove_belief(no_water_predicate);
	}
	if(waterValue<=0){
		do add_belief(no_water_predicate);
		do remove_belief(water_predicate);
	}
}

The second perception is about the fires. Here, the fires are represented with the species fireArea. The helicopter has a radius of perception of 10 meters. If it perceives a fire, it will focus on the location of this fire. The focus tool create a belief with the same name as the focus (here, "fireLocation") and will store the value of the focused variable (here, the variable location from the specie fireArea) with a priority of 10 in this example. Once the fire is perceived, the helicopter removes its intention of patrolling.

perceive target:fireArea in: 10{
	focus fireLocation var:location priority:10;
	ask myself{
		do remove_intention(patrol_desire, true);
	}
}

Rules

The agent can use rules to create desires from beliefs. In this example, the agent has two rules. The first rule is to have a desire corresponding to the belief of a location of a fire. It means that when the agent has the belief that there is a fire in a particular location, it will have the desire to extinguish it. This permits to have the location value in the desire base. The second rule is to create the desire to have water when the agent has the belief that it not has water.

rule belief: new_predicate("fireLocation") new_desire: get_belief_with_name("fireLocation");
rule belief: no_water_predicate new_desire: water_predicate;

Plan

Patrolling

This plan will be used when the agent has the intention to patrol.

plan patrolling intention: patrol_desire{
  do wander;
}
stopFire

This plan is executed when the agent has the intention to extinguish a fire.

plan stopFire intention: new_predicate("fireLocation") {
	point target_fire <- point(get_current_intention().values["location_value"] );
	if(waterValue>0){
		if (self distance_to target_fire <= 1) {
			fireArea current_fire <- fireArea first_with (each.location = target_fire);
			if (current_fire != nil) {
				 waterValue <- waterValue - 1.0;
				 current_fire.size <-  current_fire.size - 1;
				 if ( current_fire.size <= 0) {
					ask  current_fire {do die;}
					do remove_belief(get_current_intention());
					do remove_intention(get_current_intention(), true);
					do add_desire(patrol_desire);
				}
			} else {
				do remove_belief(get_current_intention());
				do remove_intention(get_current_intention(), true);
				do add_desire(patrol_desire);
			}
		} else {
			do goto target: target_fire;
		}
	} else {
		do add_subintention(get_current_intention(),water_predicate,true);
		do current_intention_on_hold();
	}
}
gotoTakeWater

This plan is executed when the agent has the intention to have water.

plan gotoTakeWater intention: water_predicate {
    	waterArea wa <- first(waterArea);
        do goto target: wa);
    	if (self distance_to wa <= 1) {
    		waterValue <- waterValue + 2.0;
	}
}

Plans can have other options. They can have a priority (with the facet priority), a boolean condition to start (with the facet when) or a boolean condition to stop (with the facet finished_when).

Rest of the code

Aspect of the helicopter
aspect base {
	draw circle(1) color: #black;	
}
FireArea Species
species fireArea{
        float size <-1.0;	

        aspect base {
          draw circle(size) color: #red;
        }
}
WaterArea Species
species waterArea{
	float size <-10.0;

	aspect base {
	  draw circle(size) color: #blue;		
	}
}

Home

Introduction

Changes from 1.6.1 to 1.8

Platform

  1. Installation and Launching
  2. Installation
  3. Launching GAMA
  4. Headless Mode
  5. Updating GAMA
  6. Installing Plugins
  7. Troubleshooting
  8. Workspace, Projects and Models
  9. Navigating in the Workspace
  10. Changing Workspace
  11. Importing Models
  12. Editing Models
  13. GAML Editor (Generalities)
  14. GAML Editor Toolbar
  15. Validation of Models
  16. Running Experiments
  17. Launching Experiments
  18. Experiments User interface
  19. Menus and commands
  20. Parameters view
  21. Inspectors and monitors
  22. Displays
  23. Batch Specific UI
  24. Errors View
  25. Preferences

Learn GAML step by step

  1. Introduction
  2. Start with GAML
  3. Organization of a Model
  4. Basic programming concepts in GAML
  5. Manipulate basic Species
  6. Global Species
  7. Regular Species
  8. Defining Actions and Behaviors
  9. Interaction between Agents
  10. Attaching Skills
  11. Inheritance
  12. Defining Advanced Species
  13. Grid Species
  14. Graph Species
  15. Mirror Species
  16. Multi-Level Architecture
  17. Defining GUI Experiment
  18. Defining Parameters
  19. Defining Displays Generalities
  20. Defining Charts
  21. Defining 3D Displays
  22. Defining Monitors and Inspectors
  23. Defining Export files
  24. Defining User Interaction
  25. Exploring Models
  26. Run Several Simulations
  27. Batch Experiments
  28. Exploration Methods
  29. Optimizing Model Section
  30. Runtime Concepts
  31. Optimizing Models
  32. Multi-Paradigm Modeling
  33. Control Architecture
  34. Defining Equations

Recipes

  1. Manipulate OSM Datas
  2. Diffusion
  3. Using Database
  4. Calling R
  5. Using FIPA ACL
  6. Using GamAnalyzer
  7. Using BDI
  8. Using Driving Skill
  9. Manipulate dates
  10. Manipulate lights
  11. Using comodel
  12. Save and restore Simulations
  13. Using network
  14. Headless mode
  15. FAQ
  16. Known Issues

GAML References

  1. Built-in Species
  2. Agent Built-in
  3. Model Built-in
  4. Experiment Built-in
  5. Built-in Skills
  6. Built-in Architecture
  7. Statements
  8. Data Type
  9. File Type
  10. Expressions
  11. Literals
  12. Units and Constants
  13. Pseudo Variables
  14. Variables And Attributes
  15. Operators [A-A]
  16. Operators [B-C]
  17. Operators [D-H]
  18. Operators [I-M]
  19. Operators [N-R]
  20. Operators [S-Z]
  21. Index

Tutorials

  1. Predator Prey
  2. Road Traffic
  3. 3D Tutorial
  4. Incremental Model
  5. Luneray's flu
  6. Co-modeling
  7. BDI Agents

Pedagogical materials

Developing Extensions

  1. Installing the GIT version
  2. Architecture of GAMA
  3. Developing a Plugin
  4. Developing a Skill
  5. Developing a Statement
  6. Developing an Operator
  7. Developing a Type
  8. Developing a Species
  9. Developing a Control Architecture
  10. Index of annotations
  11. IScope
  12. Creating a release of GAMA
  13. Documentation generation
  14. Website generation

Scientific References

Projects using GAMA

Training Session

Events

Older versions

Coding Camp

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.