-
Notifications
You must be signed in to change notification settings - Fork 99
UsingFIPAACL
GAMA allows modelers to provide agents the capability to communicate with other agents using FIPA Communication Acts (such as inform, request, call for proposal...) and Interaction Protocols (such Contract Net Interaction Protocol, Request Interaction Protocol).
To add these capabilities to the chosen species, the modeler needs to attach the fipa
skill: it adds to agents of the species some additional attributes (e.g. the list of messages received) and available actions (e.g. the possibility to send messages given the chosen Communication Act).
The exhaustive list of available Communication Acts and Interaction Protocols is available from the technical description of the fipa
skill page.
Examples can be found in the model library bundled with GAMA (Plugin models / FIPA Skill
).
- Main steps to create a conversation using FIPA Communication Acts and Interaction Protocols
- Attach the fipa skill to a species
- Initiate a conversation
- Receive messages
- Reply to a received message
- The
message
data type - The
conversation
data type
- Attach the skill
fipa
to the agents' species that need to use Communication Acts - An initiator agent starts a conversation with some agents: it chooses the Interaction Protocol and starts it by sending the first Communication Acts of the protocol
- Each agent involved in the conversation needs to check its received messages and respond to them by choosing the appropriate Communication Act.
To attach the fipa
skill to a species, the modeler has to add it in the skills
facet of the species
statement (in a way similar to any other skill).
species any_species skills: [fipa] {
...
}
Agents of any species can communicate in the same conversation. The only constraint is that they need to have the capabilities to receive and send messages, i.e. to have the skill fipa
.
Species can have several attached skills: a single species can be provided with both the moving
and fipa
skills (and any other ones).
This skill adds to every agent of the species:
- some additional attributes:
-
conversations
is the list of the agent's current conversations, -
mailbox
is the list of messages of all types of performatives, -
requests
,informs
,proposes
... are respectively the list of the 'request', 'inform', 'propose' performative messages.
-
- some additional actions, such as:
-
inform
,accept_proposal
... that replies a message with an 'inform' (respectively 'accept_proposal' performative message). -
start_conversation
that starts a conversation with a chosen interaction protocol. -
end_conversation
that replies a message with an 'end_conversation' performative message. This message marks the end of a conversation. In a 'no-protocol' conversation, it is the responsibility of the modeler to explicitly send this message to mark the end of a conversation/interaction protocol. -
reply
that replies a message. This action should be only used to reply a message in a 'no-protocol' conversation and with a 'user-defined performative'. For performatives supported by GAMA, please use the 'action' with the same name as the 'performative'. For example, to reply a message with a 'request' performative message, the modeler should use the 'request' action.
-
An interaction using an Interaction Protocol starts with the creation of a conversation by an agent, using the start_conversation
action.
The modeler specifies the chosen protocol (facet protocol
), list of participants (facet to
), communication act (facet performative
) and message (facet contents
).
species Initiator skills: [fipa] {
reflex send_propose_message when: (time = 1) {
do start_conversation to: [p] protocol: 'fipa-propose' performative: 'propose' contents: ['Go swimming?'] ;
}
Each agent (with the fipa
skill) is provided with several "mailbox" attributes filtering the various received messages by communication act: e.g. proposes
contains the list of the received messages with the "Propose" communication act.
Receiving a message consists thus in looking at each message from the mailbox, and acting in accordance with its contents, participants...
Important remark: once the contents
field of a received message has been read, it is removed from all the lists it appears in.
species Initiator skills: [fipa] {
reflex read_accept_proposals when: !(empty(accept_proposals)) {
write name + ' receives accept_proposal messages';
loop i over: accept_proposals {
write 'accept_proposal message with content: ' + string(i.contents);
}
}
}
species Participant skills: [fipa] {
reflex accept_proposal when: !(empty(proposes)) {
message proposalFromInitiator <- proposes at 0;
do accept_proposal message: proposalFromInitiator contents: ['OK! It \'s hot today!'] ;
}
}
Remark:
- To test that the agent has received a new message is simply done by testing whether the dedicated mailing box contains messages.
- To get a message, the modeler can either loop over the message list to get all the messages or get a message by its index in the message box.
Given the message it has received, an agent can reply using the appropriate Communication Act (using the appropriate action). It simply has to specify the message to which it replies and the content of the reply.
Note that it does not need to specify the receiver as it is contained in the message.
species Participant skills: [fipa] {
reflex accept_proposal when: !(empty(proposes)) {
message proposalFromInitiator <- proposes at 0;
do accept_proposal message: proposalFromInitiator contents: ['OK! It \'s hot today!'] ;
}
}
When a conversation is made in the scope of an Interaction Protocol, it is ended automatically when the last Communicative Act has been sent.
In the case of a 'no-protocol conversation', it is the responsibility of the modeler to explicitly send the end_conversation
message to mark the end of a conversation/interaction protocol.
When a conversation ends, it is automatically removed from the list conversations
.
The agents' mailbox is defined as a list of messages. Each message is a GAML object of type message
. An exhaustive description of this type is provided in the dedicated GAML Data Types page.
A message
object is defined by a set of several fields, such as:
-
contents
(typeunknown
): the content of the message -
sender
(typeunknown
): the sender of the message. In the case where the sender is an agent, it is possible to get the corresponding agent withagent(m.sender)
(wherem
is the considered message). -
unread
(typebool
): specify whether the message has been read. -
emission_timestamp
(typeint
) -
recention_timestamp
(typeint
)
The agents' conversations
contain the list of the conversations in which the agent takes part. Each conversation is a GAML object of type conversation
that contains the list of messages exchanged, the protocol, initiator... An exhaustive description of this type is provided in the dedicated GAML Data Types page.
A conversation
object is defined by a set of several fields, such as:
-
messages
(type = list of messages): the list of messages that compose this conversation -
protocol
(type = string): the name of the protocol followed by the conversation -
initiator
(type = agent): the agent that has initiated this conversation -
participants
(type = list of agents): the list of agents that participate in this conversation -
ended
(type = bool): whether this conversation has ended or not
- 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 Model Section
- Multi-Paradigm Modeling
- Manipulate 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