My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Skills14  
Skills(Modeling Guide)
Updated Jan 23, 2012 by benoit.g...@gmail.com



Overview

Skills are built-in modules, written in Java, that provide a set of related built-in variables and built-in actions (in addition to those already provided by GAMA) to the species that declare them. A declaration of skill is done by filling the skills attribute in the species definition:

species my_species skills: [skill1, skill2] {
    ...
}

Skills have been designed to be mutually compatible so that any combination of them will result in a functional species. The list of available skills in GAMA is:

  • moving: for agents that need to move.
  • carrying: for agents that need to carry other agents.
  • communicating: for agents that need to communicate using the FIPA protocols.
  • exploring: for agents that need to explore a region of space.

So, for instance, if a species is declared as:

species foo skills: [moving, carrying]{
...
}

its agents will automatically be provided with the following variables : "speed, heading, destination (r/o), capacity, contents(r/o)" and the following actions: "move, goto, wander, drop, load" in addition to those built-in in species and declared by the modeller. Most of these variables, except the ones marked read-only, can be customized and modified like normal variables by the modeller. For instance, one could want to set a maximum for the speed; this would be done by redeclaring it like this:

var speed type:float max:100 min:0;

Or, to obtain ever growing agents:

var speed type:float max:100 min:0 value: area * 1.01;

Or, to change their capacity in a behavior:

if condition: capacity = 5 {
     set capacity value: 10;
}

moving

variables

speed

float, the speed of the agent, in meter/second.

heading

int, the absolute heading of the agent in degrees (in the range 0-359).

destination

point, read-only, continuously updated destination of the agent with respect to its speed and heading.

actions

follow

moves the agent along a given path passed in the arguments.
  • speed: float, optional, the speed to use for this move (replaces the current value of speed).
  • path: a path to be followed
  • ← return: path, the path followed by the agent.
do action: follow {
     arg speed value: speed * 2;
     arg path value: road_path;
}

goto

moves the agent towards the target passed in the arguments.
  • target: point or agent, mandatory, the location or entity towards which to move.
  • speed: float, optional, the speed to use for this move (replaces the current value of speed).
  • on: list, agent, graph, geometry, optional, that restrains this move (the agent moves inside this geometry).
  • ← return: path, the path followed by the agent.
do action: goto{
     arg target value: one_of (list (species (self)));
     arg speed value: speed * 2;
     arg on value: road_network;
}

move

moves the agent forward, the distance being computed with respect to its speed and heading. The value of the corresponding variables are used unless arguments are passed.
  • speed: float, optional, the speed to use for this move (replaces the current value of speed).
  • heading: int, optional, the direction to take for this move (replaces the current value of heading).
  • bounds: localized entity, optional, the geometry (the localized entity geometry) that restrains this move (the agent moves inside this geometry).
  • ← return: path, the path followed by the agent
do action: move {
     arg speed value: speed - 10;
     arg heading value: heading + rnd (30);
     arg bounds value: agentA;
}

wander

moves the agent towards a random location at the maximum distance (with respect to its speed). The heading of the agent is chosen randomly if no amplitude is specified. This action changes the value of heading.
  • speed: float, optional, the speed to use for this move (replaces the current value of speed).
  • amplitude: int, optional, a restriction placed on the random heading choice. The new heading is chosen in the range (heading - amplitude/2, heading+amplitude/2).
  • bounds: localized entity or geometry, optional, the geometry (the localized entity geometry) that restrains this move (the agent moves inside this geometry).
  • ← return: path, the path followed by the agent.
do action: wander{
     arg speed value: speed - 10;
     arg amplitude value: 120;
     arg bounds value: agentA;
}

carrying

variables

capacity

int, the maximum number of agents that can be carried

contents

list, read-only, the current list of agents carried.

actions

drop

makes the agent leave, at its location, all or some of the agents it was carrying.
  • → agents: list, optional, the list of agents to drop. If not specified, all the agents carried are dropped.
  • ← return: list, the list of agents actually dropped.
do action: drop
     arg agents value: contents of_species foo;
}

load

makes the agent pick & carry all or some of the agents specified by the arguments.
  • → agents: list, optional, the list of agents to load. If not specified, the action is ignored.
  • → number: int, optional, the number of agents to load from the list. If not specified, all the agents are loaded until the capacity is reached.
  • ← return: list, the list of agents actually loaded.
do action: load {
     arg agents value: (agents_overlapping (self)) of_species foo;
     arg number value: 10;
}

communicating

This skill implements the major FIPA communication and negotiation protocols and enable the agents to communicate using them. It brings along two new datatypes : message and conversation. GAMA implements the following interaction protocols of FIPA : FIPA Brokering, FIPA Contract Net, FIPA Propose, FIPA Query, FIPA Request, FIPA Request When, FIPA Subscribe. Besides the standard interaction protocols of FIPA, GAMA support a special interaction protocol named "no-protocol".

variables

conversations

list, read-only, the conversation in which the agent is currently engaged.

messages

list, read-only, the messages received by the agent.

accept_proposals, agrees, cancels, cfps, failures, informs, proposes, queries, refuses, reject_proposals, requests, requestWhens, subscribes

list, read-only, the messages received by the agent, broken down by performative.

actions

send

allows the agent to send an existing message, or to create one and send it immediately.

Either use the argument:

  • → message: message, optional, the message to send.

Or a combination of the following arguments:

  • → receivers: list, mandatory, the list of agents to send the message to.
  • → content: list, mandatory, the content of the message. Can be anything.
  • → performative: string, mandatory. The performative of the message (see this page)
  • → protocol: string, mandatory, the protocol followed by this message (see this page)
  • → conversation: conversation, optional, the conversation in which the message should be inserted. If nil, creates a new conversation.
  • ← return: message, the message actually sent or nil if an error has occurred.
let mes type: list of: message value: [];
create species: message number: 1 return: mes {
    set receivers value: (agents_overlapping (self));
    set content value:['Hello !'];
    set protocol value:'no-protocol';
    set performative value:'inform';
}
do action: send {
     arg message value: first(mes);
}
do action: send {
     set receivers value: (agents_overlapping (self));
    set content value:['Hello !'];
    set protocol value:'no-protocol';
    set performative value:'inform';
}

end, failure, inform, propose, query, refuse, reject-proposal, request, subscribe

replies a list of messages with the corresponding performatives "end", "failure", "inform", "propose", "query", "refuse", "reject-proposal", "request", "subscribe". The replied messages will be filled automatically with the corresponding performatives.
  • → message: list, mandatory, messages to reply to.
  • → content: list, optional, the content of the replied messages.
let noProtocolInformMsgs type: list value:(informs) where: ((species (each.sender) = foodCarrier) and (each.protocol = 'no-protocol'));
do action: end {
    arg message value: noProtocolInformMsgs;
}

data types

message

An instance of message represents a piece of information exchanged between agents. It has the following attributes :

  • sender : agent, the sender of the message.
  • receivers : a list of agents, contains all the receivers of the message.
  • performative : string, the performative of the corresponding message. For more details concerning the performative, please refer to the FIPA Communicative Act Library Specification.
  • content : list, contains the content of the corresponding message. The modeller can put whatever content in this list.

conversation

An instance of conversation represents a FIPA interaction protocol. It helps ensure that a conversation between agents respects the specification of a corresponding protocol defined by FIPA. It has the following attributes :

  • messages : list, the currently unread messages of the conversation.
  • protocol : string, the name of the interaction protocol that this conversation respects.
  • initiator : agent, the agent which initiates the conversation/the interaction protocol.
  • participants : a list of agents, all the participants of the conversation (except for the initiator).
  • ended : bool, helps determine if the corresponding conversation/interaction protocol has already finished or not yet.

Notes

GAMA supports a special interaction protocol named "no-protocol". If the modeller finds that no supported FIPA Interaction Protocols fits his modelling case, he can use the "no-protocol". Uppon declaring a conversation following this procotol, the modeller is free to send messages having whatever performative between agents. But it 's upto the modeller to finish up the corresponding conversation by using the "end" primitive.

exploring

This skill implements the patrolling capability of agents, enables the agents to go on patrol in a list of given points.

variables

points

list, the list of points to patrol. This list must not be empty before the agents can begin its patrolling activity.

patrolling

bool, determines if the corresponding agent is going on patrol or not.

actions

patrol

do the patrolling activity if the list of points is not empty.
  • → speed: float, optional, the speed of the corresponding agent.
task name: patrol_the_terrain while: patrolTheTerrain {
  priority if: patrolTheTerrain value: 10 else: 0;
  duration max: 2 hours;			
  repeat action: patrol {
    arg speed value: maxSpeed;
  }
}

Sign in to add a comment
Powered by Google Project Hosting