Ingen I As Manual
Ingen I As Manual
http://grasia.fdi.ucm.es
IDK MANUAL
SUMMARY
THISDOCUMENT PRESENTS THE INGENIAS DEVELOPMENT KIT (IDK), A SET
OF TOOLS FOR THE SPECIFICATION, VERIFICATION, AND IMPLEMENTATION OF
MULTI- AGENT SYSTEMS . IT IS ORIENTED TO RESEARCHERS LOOKING FOR AN
AGENT-ORIENTED SPECIFICATION TOOL AND DEVELOPERS WANTING TO FOLLOW
AN AGENT-ORIENTED PROCESS (SUCH AS THE INGENIAS METHODOLOGY).
PROJECT: INGENIAS
VERSION: 2.5.2 (Corresponds to version 2.5 of IDK)
STATUS: DRAFT
DATE: 26/11/2005
AUTHORS: Jorge J. Gmez Sanz and Juan Pavn
II
INDEX
INDEX ______________________________________________________________________________iii
1. INTRODUCTION _________________________________________________________________ 1
1.1. Scope and Use ________________________________________________________________ 1
1.2. Credits ______________________________________________________________________ 1
1.3. Guide to read the document_____________________________________________________ 2
2. Getting started with the IDK _________________________________________________________ 3
2.1. Installing the IDK _____________________________________________________________ 3
2.2. Specification of a multi-agent system _____________________________________________ 4
2.3. Code generation for the Jade platform ____________________________________________ 8
2.4. Running the agents ___________________________________________________________ 10
3. The graphical editor_______________________________________________________________ 13
3.1. Parts of the editor and related operations ________________________________________ 13
3.1.1 Project view _____________________________________________________________ 14
3.1.2 Entities view _____________________________________________________________ 15
3.1.3 Diagram editor ___________________________________________________________ 15
3.1.4 Logs & Module output._____________________________________________________ 18
3.1.5 Main menu ______________________________________________________________ 19
3.2. Working with the editor _______________________________________________________ 20
4. AUML__________________________________________________________________________ 22
4.1. Creating a protocol diagram ___________________________________________________ 22
4.2. Defining protocols ____________________________________________________________ 22
4.3. Connecting two lifelines _______________________________________________________ 25
4.4. Sending a simple message______________________________________________________ 25
4.5. Creating an alternative________________________________________________________ 26
4.6. Creating a sub protocol _______________________________________________________ 28
4.7. To be done __________________________________________________________________ 30
5. Modules ________________________________________________________________________ 31
5.1. Use of modules_______________________________________________________________ 31
5.2. Development of new modules___________________________________________________ 31
5.2.1 Traversing the specification _________________________________________________ 33
5.2.2 Marking up the prototype ___________________________________________________ 35
5.2.3 Generating the code _______________________________________________________ 37
5.2.4 Deploying a module _______________________________________________________ 39
5.3. Module examples available with the IDK distribution ______________________________ 41
5.3.1 HTML module ___________________________________________________________ 41
5.3.2 JADE module ____________________________________________________________ 41
5.3.3 JADE Leap module________________________________________________________ 45
5.3.4 JADE Organization module _________________________________________________ 48
5.3.5 SOAR module____________________________________________________________ 61
5.3.6 Servlet based workflow simulator module ______________________________________ 63
5.4. Conclusions on modules _______________________________________________________ 67
6. Case Studies _____________________________________________________________________ 68
6.1. Collaborative Information Filtering _____________________________________________ 68
III
6.1.1 Modules ________________________________________________________________ 68
6.2. Booksellers__________________________________________________________________ 68
6.2.1 Modules ________________________________________________________________ 68
6.3. Quake ______________________________________________________________________ 69
6.3.1 Modules ________________________________________________________________ 69
6.4. Robocode ___________________________________________________________________ 69
6.4.1 Modules ________________________________________________________________ 69
6.5. SOAR ______________________________________________________________________ 69
6.5.1 Modules ________________________________________________________________ 70
7. INGENIAS ______________________________________________________________________ 71
7.1. Introducing INGENIAS _______________________________________________________ 71
7.2. Meta-modelling ______________________________________________________________ 72
7.3. INGENIAS Meta-models ______________________________________________________ 73
7.4. FAQ about diagrams _________________________________________________________ 75
8. Conclusions _____________________________________________________________________ 77
9. Annex I: INGENIAS metamodel_____________________________________________________ 78
References __________________________________________________________________________ 79
IV
1. INTRODUCTION
This document describes the INGENIAS Development Kit (IDK), a set of tools for the
specification, verification and implementation of Multi-Agent Systems (MAS). There are two
main types of IDK tools:
A Graphical Editor. This allows the developer to create and modify specifications of a
multi-agent system (MAS) using agent concepts. The underlying agent model is defined
in the INGENIAS methodology, but it is incorporating other languages such as Agent
UML. Graphical specifications can be drawn as UML diagrams or using the notation
defined in the INGENIAS methodology.
Modules. They allow working with MAS specifications to perform verification of
properties and automatic code generation. Apart of the modules that are already
provided with the IDK distribution, developers can extend IDK functionality by creating
their own modules and plugging them in the IDK to perform verification of specific
properties or automatic code generation for a particular target platform. The
implementation of modules is supported by a framework that facilitates traversing
specifications and producing some output, which can be code or the result of a
verification of some properties.
The INGENIAS methodology guides the developer in the process of analysing, designing and
implementing a MAS. Although the IDK has been conceived to support the INGENIAS
methodology, it can be also used with other development process model in practice.
1.2. CREDITS
To the members of the Grasia! Research group, specially to the authors of this technical report
(Jorge J. Gmez-Sanz and Juan Pavn). Also to the rest of the people that has collaborated in
1
the development of the IDK (Rubn Fuentes), and those who participated as beta-testers
(Guillermo Jimnez, Juan Antonio Recio, Carlos Celorrio, Alberto Fernndez, and many others).
This work has been developed in the project INGENIAS (TIC2002-04516-C03-03), which is
funded by Spanish Council for Science and Technology.
2
2. GETTING STARTED WITH THE IDK
This section describes how to install the IDK and a simple example of specification of a system
with two agents (one of them a mobile agent), their automatic implementation, and deployment
on two JADE systems (JADE is a FIPA compliant agent platform, http://jade.tilab.com/).
3
2.2. SPECIFICATION OF A MULTI-AGENT SYSTEM
As an example of use of IDK we can try one of the examples that are distributed with the IDK.
The example is quite simple just in order to illustrate basic functionality of IDK. It has been
originally developed by one of our students, Carlos Celorrio, in 2004. Although it does not show
all features that can be specified in a multi-agent system, it provides enough information to get
some agents finally running on an existing agent platform.
First, start the IDK, and the main editor will appear as shown in Figure 1. Some messages
appear in the Logs tab to indicate that several modules of the IDK have been loaded.
To start working, you can create a new project or load one specification. Here, to get the
specification of the first example, go to the File menu and select Load (see Figure 2). Then
select the specification file for the example. This is in the same directory of the installation of
IDK, in a directory called examples. There are several examples, and in this case we choose
cinema.xml (specifications are stored as XML files), as it shows Figure 3.
4
Figure 2. Loading a specification
When the specification has been loaded, on the left side (Figure 4) we can see the Project view,
to navigate through the structure of the specification and the Entities view to navigate through
the specification entities. To open a diagram, just click twice on it.
In this example, there are three agents. One is an interface agent that interacts with the user in
order to get requests for some service and presenting the results. In this case the service is
obtaining a ticket for the cinema. The interface agent uses services from other agents. In this
5
example, there is one agent, BuyerAgent, that takes care of finding and buying the cinema
tickets for the user. Finally, the SellerAgent has tickets for sale. Each agent in this system plays
a role, as specified in the Role Association diagram, which is a diagram of type Agent Model
(Figure 5).
The InterfaceAgent and the BuyerAgent initially reside in the PDA environment. The SellerAgent
is on another environment, CinemaEnvironment. This can be represented with an environment
model diagram, as in Figure 6. Here agents are associated to each application environment with
relationship of type <<ApplicationBelongsTo>>.
The behaviour is defined by the goals and tasks of the agents, and the interactions between
agents.
The BuyerAgent, for instance, pursues the goal of serving requests for buying, in this case,
cinema tickets. This goal can be broken down into simpler goals, such as FindCinema and
GetTicket. These simpler goals can be achieved by some plans, sequences of tasks. For
instance, to get a ticket the BuyerAgent can choose a cinema, move to that cinema, buy the
tickets there, and return to the users PDA. This is illustrated in the goals-tasks diagram in
Figure 7.
6
Figure 7. Goals tasks diagram for the Buyer Agent
In this example there is only one interaction, which is shown in Figure 8. In INGENIAS one
interaction may be a multi-party association, with one initiator and one or more collaborators, as
in this example. In fact, an interaction in INGENIAS is considered something more than just a
message-passing and may represent more the idea of a transaction, which may consist of the
exchange of several messages or annotations in a shared tuple space, depending on the
communication paradigm.
The flow of messages in the specification can be specified by a Grasia collaboration diagram as
the one in Figure 9, or by other types of interaction diagrams, such as UML or Agent UML
sequence diagrams, see chapter 224. In INGENIAS interactions are triggered in tasks. The flow
of tasks and interactions determines the global behaviour of the system. This information is very
important when generating code.
7
Figure 9. Grasia collaboration diagram
For some tasks, it may be interesting to include some code that can be applied in the
implementation. This is the case for the code for mobility in task GoBackHome, for instance,
that is the code we will need later on for the Jade platform. To get a description of the task, just
click on it and you get a window with the identifier for the task and a description field, as in
Figure 10, with some code that the code generator module can use.
8
Figure 11. Invocation of a module
But if everything goes right, a celestial music sounds and a message Specification is correct
appears in the Logs window. In this moment we can try the code generation, which is just using
the option generate instead of verify. In fact, the generate option can be invoked without the
verification, but this last is faster and useful to see what is missing in a specification.
When running the generate option, the Logs window tab shows the files that have been created
(Figure 13). If there are no error messages, we can go to the compilation and execution of the
output files in order to see how agents work on a real platform, Jade in this case.
9
2.4. RUNNING THE AGENTS
In order to facilitate the process, the IDK distribution provides some facilities to compile and
execute the generated agents on the Jade platform.
Open a command or shell window and move to the directory of the IDK distribution.
There, execute
ant compjadeleapj2se
and you get something as in Figure 14.
Figure 14. Compiling for Jade Leap the generated agents code
10
To run the agents, just type in another console:
ant runjadeleapmas
and the agents will execute.
Each agent has one window to interface for this experiment, as the one of Figure 16 for the
SellerAgent. As all the windows start in the same coordinates, you should move them to other
places in the screen to visualize all.
Initially the three agents are in the Container-1 and to start the experiment we can first put this
agent in the Main-container by pressing the button Move on the right.
To start the application, the user has to request to the InterfaceAgent to buy the cinema ticket.
This can be done by pressing the lower button on the corresponding window (see Figure 17).
When doing so, this agent will request to the BuyerAgent to get the ticket, the BuyerAgent will
travel to the Main-Container to find the SellerAgent, negotiate to get the ticket, and come back
to Container-1, the original location, to provide this to the InterfaceAgent.
This process can be monitored in the JADE platform by observing the agents at each container
and with the Sniffer Agent to see the different interactions, as shown in Figure 18.
11
Figure 18. Snapshot of the interactions captured by the JADE Sniffer Agent
The state of each of the agents is shown in their respective windows. At the end they look like in
Figure 19.
Figure 19. States that have passed each agent in the experiment
12
3. THE GRAPHICAL EDITOR
The main purpose of the graphical editor (Figure 20) is to create and modify the specifications of
multi-agent systems (MAS). A specification here is a set of diagrams that represent different
views of a MAS. The diagrams constitute a project, and they are organized using package-like
constructs.
The editor saves these specifications using XML, so that other external tools can analyse them
and produce other kind of outputs. Also, the editor provides access in runtime for installed
plugins, and is able to load new plugins in run-time. These plugins are called in this document
modules (which are described in section 5).
13
B Edit bar
a
r Tabs for selected diagrams
Project view O
f
A Diagram window
l
l
o
w
e
d
E
Entities view
n
t
i
t
i
e
Logs & module output
s
14
3.1.2 Entities view
The Entities view contains a tree-like view of the types of entities that exist in the specification.
The tree shows types as well as current type instances (the entities in the specification, which
may appear in several diagrams). Types are represented by folders. Type instances are
distinguished by icons different of folders.
Several operations can be performed on each entity by selecting the corresponding icon (not a
folder) and pressing the right button of the mouse. Then a pop-up menu appears that shows
several operations:
Add the selected entity to the current diagram. It creates a copy of the entity in the
diagram, but only if the diagram can handle that specific type. An entity can appear in
several diagrams.
Remove the entity. It removes the entity from all diagrams and set all attributes of
entities pointing at it to null.
Edit properties. It shows different properties associated to the selected entity.
15
moment, release the mouse button. A new window will appear, showing different
possible valid relationships that could be defined (in case that the relationship is not
allowed in this diagram the new window will notice this). You have to select one (also
when there is only one possible relationship type you have to acknowledge it).
Afterwards, it asks how to configure the extremes of the relationship, since, sometimes,
several assignments are valid (although normally those selected by default are the best
option). On finishing, a new relationship is created.
DRAG
Figure 23. A window for editing an entity, showing a combo box with fixed values
Edit an entity. By double left-clicking on an entity. A new window will appear with data
that can be edited in several ways:
16
o Text fields. Just write whatever you want to. It should admit the ISO-8859-1
character set.
o Combo box fields. These fields can admit only values defined in the
associated list (see Figure 23). A value has to be selected.
o Diagram reference fields. This field allows to refer to other diagrams (see
Figure 24). The procedure consists in selecting in the combo the name of the
diagram. The combo will show only existing diagrams of a preconfigured type.
Once selected, press Select one model. This will make the current value label
change. To jump to the selected diagram, press show selected.
Figure 24. An editing window for an entity showing a field that refers to another diagram
o List box fields. These fields are used to store references to entities already
defined in some diagram or create new entities. They also can refer to a
collection of values or a single value.
Collection. The list should appear initially in blank. By left-clicking in the
list, a pop-up menu will appear with four options:
o Add existing. A dialog window will appear with a combo box
showing valid already defined entities that could be used. Select
one and press yes.
o Add new. A dialog window will appear with a combo box showing
valid types of entities that could be used. Select one and press yes.
Another window will appear to fill in the data of the new entity.
o Open selected. It opens a window that shows the data of the
selected entity. This window allows the same functionality to edit
the data as presented here. So proceed recursively.
o Remove selected. It removes the entity from the list but not from
the main repository visible in the Entities View.
Single value. The list (see Figure 25) will show possible types that could be
allowed in that part of the definition. You have to select one of them and
press one of the available buttons. With Create new, you will create a new
instance of the selected type and associate it directly with this field. The
new instance will also appear in the Entities View. With Select Existing, you
will associate this field with an existing entity. Existing entities of selected
type will be shown in a dialog window in form of a combo box.
17
Figure 25. An editing window for an entity showing how to modify single value entity field.
Changing the icon of an entity. Some entities have different associated views. You
can select one of them by right clicking on an element and going to the views option.
There, available views will be shown (see Figure 26).
Figure 26. Different views associated with a GRASIA Specification. First view is the icon view, and the
second the box view
o Zoom/unzoom. By pressing the and the buttons. The zoom will return to
its normal state when pressing the button.
o Redo/undo actions. By pressing the and buttons. Undo/redo actions
should be limited to changes of positions of diagram components. It will not
work to undelete entities, relationships, or unedit changes made to properties.
o Copy/paste/delete. By pressing the , , or respectively. Relationships
cannot be copied or pasted. If some are selected, the editor will unselect them
automatically. Deleting an entity requires to delete first the relationships it
participates into or the edges that connect the to-be-deleted entity to the
relationship. In some cases, when the mandatory arity of the relationship would
be violated, there is no other option but deleting the relationship before.
o Relationship layout. It sets how relationships are lay out into the diagram.
Automatic stands for allocating the relationship in the middle of all participating
entities. Manual stands for you are responsible for allocating the entity. By
default, Automatic layout.
18
The window can be cleared by right-clicking in it. A pop-up menu will appear with a clear option.
Select it.
Figure 27. Properties of a project. You can edit only the value column of the window.
Modules menu. This menu allows the execution of modules installed in the editor.
Each module has an entry that can be allocated in the tools or code generator section
(see Figure 28). The tools entry contains modules whose main purpose is not
generating code but analizing the specification to generate reports or detect
inconsistencies, for instance. The code generator entry contains modules that generate
code from diagrams. The concrete procedure will be explained later in this document.
19
By now, it is enough to know that modules can both generate code and verify properties
of a set of diagrams. The list of modules can be updated if a developer allocates a new
module in the extension folder. Also, if the module has the same name as an existing
one, the new version will replace the old one.
Figure 28. Module list available in the 2.2 version of the IDK
Help menu. It provides access to a summarised version of this document (tool manual
option), the credits, and the possibility of forcing a garbage collection to optimise
memory usage (Force GC option). Please note that according to SUN specifications, it
seems that calls to the garbage collector do not imply an immediate garbage collection.
2. Use meaningful names. This will help to trace diagrams and make the documentation
more readable. Also, fill in the description fields of each entity and diagram when
possible.
3. Do not be afraid if there are too many diagrams. This is usual in any conventional
development, why not in an agent oriented one? That is why we recommend to start
using packages from the beginning. Anyway, you can always create them later and use
the drag&drop feature to rearrange them.
20
Figure 30. The number of diagrams can grow easily if you get into details. See how a package structure
helps to manage them
4. Copy diagrams to the clipboard. Remember that the editor allows you to copy a
diagram to your favourite text editor by copy&paste. You can also save the image to a
file for later use.
21
4. AUML
The IDK Editor includes an alpha version of AUML Protocol diagrams. These diagrams are
defined according to the last AUML draft (October 2004) that can be found at
http://www.auml.org.
The icon that represents a diagram of this type is the same as the one belonging to a common
interaction ( ).
As a result, a protocol box is created. Initially, this Box only shows the title of the protocol (see
Figure 33). You can edit the name of the protocol by modifying the id field, and this will be
changed in the diagram.
22
Figure 33. Protocol box renamed to My protocol
Once the protocol box is created, it is time to create some life lines. In this implementation, a
lifeline is an entity that represents an role or an agent instance that is going to send messages
to other roles or agents.
To create a lifeline, a protocol box has to be selected first. Lifelines are created with one of the
buttons that you can see in Figure 32. The result can be seen in Figure 34.
Lifelines do not show any special information until they are edited. Relevant data is (see Figure
35):
Name: The name of the instance.
Agent: the type of agent that represents this instance. You can create a new kind of
agent or select an existing type.
23
Role: The role that the agent instance is playing at the moment. You can create a new
kind of role or select an existing one.
After modifying the different fields, you will see that the representation of the lifeline incorporates
the new data (see Figure 36).
Figure 36. Modified lifeline after typing the name of the agent instance
Now, we will create another lifeline and start defining the messages among agents. The process
is the same as before, but this time we previously moved the first lifeline to the right so that
there is enough space for the new one. Please, remember to select the protocol box before
creating the lifeline.
24
Figure 37. Two lifelines in a protocol box
The process is the same as when connecting two entities as shown in section 3.2. So the next
step is selecting the kind of association between the two lifelines. At the moment there are
three.
Figure 39. Dialog window for determining the type of connection between two lifelines
What happens when selecting each of these options is explained in the following sections.
25
Figure 40. Result of selecting AUML Send simple
Figure 41. Data for a message (left) and resulting drawing (right)
26
Figure 42. Alternative between ag1 and ag2
Figure 42 shows an alternative and an alternative row. The first one is just a container for the
different possibilities that may consider a message selection in the middle of a protocol. Each
one of these possibilities is an alternative row. Alternative rows can be edited and their
attributes modified. In this case, the attribute is the condition that this alternative row represents.
You can draw messages from one alternative lifeline to another, just as you did in the previous
section (see Figure 44)
Figure 44. Drawing messages between two lifelines with an existing alternative
To add a new Alternative Row, we select the alternative again and press the alternative row
button.
27
Figure 45. Defining another alternative
Again, we define a condition for the alternative row and define the message as well. The result
is shown in Figure 46.
Figure 46. Alternative with two possible responses from ag1 to a request sent by ag2
28
Figure 47. Subprotocol creation
Figure 48 shows the edit dialog. There, we have to choose either create new or select existing.
In this case, as we want to reuse an existing protocol, we chose select existing and then My
protocol, which is the one we defined in Figure 46. The result is shown in Figure 49.
29
Figure 49. Initialized subprotocol instance
4.7. TO BE DONE
There are several aspects that have not been completed in this version (thats why it is an
alpha). In concrete, we could highlight:
Layout problems. Alternatives and Subprotocols are always appended at the bottom of
the life lines. This is correct for alternatives, but not for subprotocols. Besides, the gap
between orange squares is something we want to remove.
Implement other AUML protocol diagrams primitives. So far, only alternatives, basic
messages, and subprotocols have been implemented.
Semantics of AUML primitives. Throughout the implementation of the diagrams,
many questions have arosen that were not considered in the FIPA AUML Draft
diagrams. For instance, what kinds of connections were allowed. Is it correct to nest a
subprotocol in an alternative? Does the lifeline end in an alternative (can we define
messages after an alternative)? Is it possible to add another lifeline to an existing
alternative if the new lifeline has already defined an alternative? These an other
questions make us think that there are still missing aspects in AUML that need to be
further detailed.
30
5. MODULES
Modules (see Figure 50) are programs that process specifications and produce some output:
Source code. There is an infrastructure that facilitates the generation of source code.
The infrastructure bases on templates defined with XML. These templates are filled in
with information extracted from the diagrams.
Reports. Diagrams can also be analysed to check, for instance, whether they have
certain properties or whether special semantics (defined by the developer) are being
respected, or to collect statistics of usage of different elements.
Modifications on current diagrams. Though this feature is in beta stage, a module
could insert and/or modify entities in the diagrams, or insert/delete diagrams. This
feature is useful to define personal assistants that interact with the tool.
modelo de modelo de
organization modelo de
modelo de model
organizacin
modelo de
objetivos/tareas
agente
modelo de
agent modelo de
tasks/goals
objetivos/tareas
agente
agente
model
model objetivos/tareas
model
environment
modelo de modelo de
modelo de
entorno
model interacciones
modelo de
interaction
interacciones
interacciones
model
Descripcin
produce process
IDK
Mdulo
Editor Mdulo
Mdulo
contains Mdulo
Module
31
a. Tools: A conventional development environment (depending on the
programming language and target platform, in the case of code generation).
b. Output: A prototype of an application in the target platform that realizes a small
part of the specification, with a selected set of features.
2. Mark up the prototype code. Parts of the prototype should match against parts of the
specification. As a result, a developer identifies the possible mappings from the
specification to the prototype code.
a. Tools: An XML editor or a text editor.
b. Output: Prototype code marked up with tags. The marked-up pieces of source
code are known as templates.
3. Generate/modify a module. The module will traverse the specification and obtain the
information required by the prototype. This can be done with a conventional Java
development environment (IDK libraries are written in Java), including IDK module
development packages (which are described in the following sections).
a. Tools: Java development environment.
b. Output: One or more Java classes that extend BasicToolImp or
BasicCodeGeneratorImp classes. Other classes may be created as well.
4. Deploy the module. Java classes and templates are put together into a jar file. This jar
file is put in a specific folder where the IDK Editor can load it.
a. Tools: J2SDK and ant (http://ant.apache.org). The J2SDK jar tool generates
the jar, and the ant tool executes the appropriate ant task to perform the
compilation and copy of the source and binary files.
b. Output: A jar file that has the module code and the templates obtained from the
prototype.
5. Test the module. Testing tasks are launched from the IDK Editor. By executing the
module over the specification, the developer can check if the diagram is traversed
properly and if all templates have been filled in as they should. Also, as templates
demand concrete information, it may be possible that this is not present or that it is not
expressed as it should. Therefore, it may turn out that the specification was not correct
or incomplete.
a. Tools: The IDK editor mainly. Other tools may be needed when testing the
output code (appropriate compilers and runtime environments).
b. Output: Problems with the code generated by the module, problems with the
traversal of the specification, or problems with the specification.
6. Debug. If something goes wrong, debug the prototype and go to:
a. Step 2. If there is new code that was not marked up before.
b. Step 3. If the failure was in the module and the data traversal.
c. Step 4. If there was a failure in the prototype and could be solved without
marking up the code again.
7. Refinement and extension. When the module is finished, it can translate diagram
specifications into code or perform some verification of properties. However, the module
performs these tasks with a reduced set of the diagram specification. The next step
would be to take the code generated by the module and extend it so that it can satisfy
other parts of the specification. Therefore, we would go back to step 1.
Modules produce code using a template based approach. As an example, Figure 51 shows how
to generate code for a rule based system, in this case JESS (Friedman-Hill, 2002). A developer
defines a template of a JESS rule and extracts data from the MAS specification to generate the
rest of rules. Rules need a condition, an action, and a name. These data are expressed using a
concrete structure that will be presented later. As a result, we get two different rules, which are
instantiated from the same template.
32
TEMPLATE
<repeat id=rules>
(defrule <v>name</v> GENERATED CODE
<v>cond</v> => <v>action </v>
</repeat> (defrule R1
A => (assert B))
(defrule R2
B => (printout t done))
SECUENCIAS
DATA
repeat id=rules
id=reglas repeat id=rules
id=reglas
var name=R1
nombre=R1 var name=R2
nombre=R2
var cond=A var cond=B
var accion
action =(assert B) var accion
action =(printout t hecho)
done)
According to this description, the reader may infer that we assume that:
There are parts of the specification that are very similar among themselves.
There are parts of the code that are very similar among themselves.
One may be a consequence of the other, since code is supposed to satisfy a specification, and
if there are parts of the specification that are repeated, there should be parts of the code that
repeat as well.
A module can be of two different types: a code generator or a specification processor. To create
a module of the first type, you have to extend the ingenias.editor.extension.
BasicCodeGeneratorImp class. If you try to create a module of the second type (e.g., a
verification tool), you have to extend the ingenias.editor.extension.BasicToolImp class.
Both classes define abstract methods that have to be redefined into their inheriting classes.
Also, both classes initialise internal variables that give access to the internal data structure of
the IDK. Once created the corresponding derived class, developers will realize that most of the
work is done, and that only traversal specification and template creation needs to be done.
In the next sections, there are further instructions for some of these tasks. Section 5.2.1
describes how to traverse the specification graph. Section 5.2.2 presents how to create
templates from prototypes. Section 5.2.3 introduces the facilities to create the data needed to fill
in the templates. Finally, Section 5.2.4 explains how to deploy a module.
33
Figure 52. Logical view of the data stored in the IDK
The access to this structure is controlled by a set of interfaces, which are shown in Figure 53.
These interfaces take advantage of the commonalities of the elements of Figure 52, such as
that all elements have properties (graphs, relationships, and entities).
In the IDK, a developer can obtain instances of Graph, GraphRelationship, and GraphEntity by
using a Singleton pattern (Gamma, Helm, Johnson, & Vlissides 1995). A class that implements
this pattern in the IDK is the ingenias.generator.browser.BrowserImp and the method to invoke
to get a valid instance of this class is getInstance( ):
Browser browser=BrowserImp.getInstance();
This kind of instantiation is valid only when the module is executed inside the IDK Editor. If you
plan to execute outside the editor directly over an specification file generated by the IDK Editor,
you should put into your main method the following:
File file;
....
ingenias.editor.Log.initInstance(new java.io.PrintWriter(System.err));
ingenias.generator.browser.BrowserImp.initialise(file);
Browser browser=BrowserImp.getInstance();
Traversing the specification means to define a graph traversal algorithm that goes through
elements of the specification and:
1. Ensure that all requested elements are present. A traversal intends to find certain
elements and, from them, go to other elements in the diagrams.
2. Extract information from the requested elements. Information extraction is a matter of
invoking specific methods of GraphEntity, Graph, and GraphRelationship.
Initially, the developer has a list of existing graphs or a list of existing entities in all graphs. At
this point, it is important to clarify that some objects may be already present in different
diagrams. From these initial graphs or entities list, the developer articulates the traversal. It can
be as simple as In each diagram, look for instances of the relationship X, and tell me what
elements they connect or as complex as a traversal with the purpose of generating code for the
Jade platform.
34
Figure 53. Interfaces provided to access the data stored as XML
A simple example of how to traverse existing diagrams and printing out their names is the
following:
// browser has been previously initialised
Graph[] gs = browser.getGraphs();
StringBuffer result = new StringBuffer();
for (int k = 0; k < gs.length; k++) {
Graph g = gs[k];
result = result.append( "\n###### Diagram " + g.getName()+
" ######\n");
result.append(this.generaInformeDiagrama(g)+"\n");
}
System.out.println(result);
We use StringBuffer because the concatenation of Strings is inefficient and may lead to memory
exhausted errors.
35
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT file (#PCDATA | v)*>
<!ATTLIST file overwrite (yes|no) #REQUIRED>
<!ELEMENT program (#PCDATA|repeat|saveto|v)*>
<!ELEMENT repeat (#PCDATA | saveto | v | repeat)*>
<!ATTLIST repeat id CDATA #REQUIRED>
<!ELEMENT saveto (file, text)>
<!ELEMENT text (#PCDATA | repeat | v | saveto)*>
<!ELEMENT v (#PCDATA)>
<program>
if (a < b)
cout << hello
</program>
We would write:
@program@
if (a < b)
cout << hello
@/program@
Of course, other uses of @ symbol would be forbidden in the code. Both formats can be used to
generate code, though specific methods should be invoked in each case.
So that this decision does not affect the rest of the framework, we have prepared some tools
that translate one format to another. The command that performs the translation is the following:
36
5.2.3 Generating the code
The code generation facilities take as input a template that satisfies the DTD from Figure 54 and
data to fill the template v and repeat tags. The data that feeds the code generator has the
structure shown in Figure 55. We name this data sequences due to some data structures we
used in the past for this purpose. Right now, there are Java classes that implement this
structure and provide adequate translation mechanisms for XML.
Sequences
*
Repeat
* *
Var
*
Figure 55. UML Description of the data structure
As Figure 55 remarks, there can be several repeat instances and v instances. Each one is
created using an id, in the case of the repeat, and an id and data, in the case of the var. The id
of repeat and var is used to distinguish among the different v and repeat tags that may exist
along the template. Data is supplied as an unordered sequence of repeat or var structures and
the effect is a replacement of the template by concrete data, in the case of var structures, or
duplicates of existing data, in the case of repeat structures.
But, what data should be extracted and what structure should it have? We answer partially this
question with an utility that parses a template and returns text representing how the data
structure should look like. The utility is started from command line in the install folder of the IDK:
java
cp lib\ingeniaseditor.jar; lib\xerces_2_3_0.jar; lib\xercesImpl.jar; lib\xerces-
J_1.4.0.jar" ingenias.generator.util.ObtainInstantiationStructure
template_filename
As an example of the kind of output, Figure 56 shows the data structure needed to instantiate a
template of the html code generator module included in the IDK distribution (this module
produces HTML to document a MAS specification). The template corresponds to an index.htm
file.
37
@program xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../plantilla.xsd"@
@saveto@
@file overwrite="yes"@
@v@output@/v@ /index.html @/file@
@text@
<HTML>
<BODY bgcolor="#FFFFFF">
@repeat id="paquete"@
<li><font size="4"><b> @v@name@/v@ </b></font> </li>
<ul>
@repeat id="graph"@
<li>Diagram name: <A HREF=" @v@name@/v@ .html"> @v@name@/v@ </A> type :
<font color="#000099"> @v@tipo@/v@ </font>
</ li>
@/repeat@
</ul>
<br>
@/repeat@
</BODY>
</HTML>
@/text@
@/saveto@
@/program@
v output
repeat id = package
v name
repeat id = graph
v name
v name
v type
A similar Java structure with the classes from Figure 55 would look like the following:
Sequences seq=new Sequences();
Repeat r1=new Repeat(package1);
Repeat r2=new Repeat(package2);
seq.add( r1 ); seq.add( r2 );
r1.addVar(new Var(name,mipackage1));
r1.addVar(new Var(type,agent diagram));
r2.addVar(new Var(name, mipackage 2));
r1.addVar(new Var(type,interaction diagram));
.....
38
And to launch the code generator, the following code should be executed. The input stream is a
stream whose source is a file containing the template. The sequence structure is transformed
into a string, whose toString() method is overloaded to generate the XML structure.
Sequence seq;
InputStream is;
...
ingenias.generator.interpreter.Codegen.applyArroba(seq.toString(),is);
The interpreter will analyse the template and will produce the output code. If there are saveto
tags into the templates, the interpreter will save the results to the specified files. If not, the
output will be the standard one (in the IDKs Logs and Modules window, see section 3.1.4).
These tasks can be automatized if the developer uses the ant utility. In the build.xml file, the
developer can find examples of how these tasks look like. For instance, the modhtml tasks, are
specified as follows (bolder and italics represent comments inserted to facilitate understanding):
Change the location attribute to the path to your module source folder
<property name="modhtmldoc" location="modules/srchtmldoc" />
....
<target name="modhtmldoc">
39
<depend srcdir="${modhtmldoc.dir}" destdir="${temp.dir}"
cache="depcache">
</depend>
<classpath>
<fileset dir="lib">
</fileset>
</classpath>
</javac>
<fileset dir="${modhtmldoc}/templates"></fileset>
</copy>
A jar is created with the name of the module
<jar jarfile="${modhtmldoc}/modhtmldoc.jar"
basedir="${temp}" />
The resulting jar is moved to the deploy folder. Change the name of
the module to avoid collision with other jars
<move file="${modhtmldoc}/modhtmldoc.jar"
toDir="${moddeploy}" />
</target>
Only by changing the modhtmldoc property, you could get a personalized task to compile and
deploy your module. The task would be started with:
ant modhtmldoc
40
Of course, we recommend not reusing completely the ant task code, copying and pasting the
modhtmldoc tasks into your build.xml file, and modifying the copy trying to personalize if
possible, specially changing modhtmldoc with other more appropriate names. For more
information about how ant works, we strongly recommend reading the ant manual, which is
available at http://ant.apache.org.
5.3.1.2 Requirements
This module is integrated with the IDK distribution so there is no requirement for using it.
5.3.1.3 Configuration
No configuration is provided for this module.
41
5.3.2.2 Requirements
J2SDK 1.4.2. The IDK is distributed with a JADE distribution together with its distribution license
(LGPL).
5.3.2.3 Configuration
This platform does not need special configuration. JADE libraries are already included in the
distribution. First, you have to compile the JADE module, though it is already compiled in the
IDK distribution. To compile the JADE module from the IDK distribution folder, type:
ant modJADE
Once compiled, start the IDK editor and load an specification like examples/cinema.xml (written
by Carlos Celorrio and translated to English by Jorge Gmez).
The specification for the JADE platform requires the definition of the following diagrams:
A protocol, which is defined using an Interaction Diagram and with messages exchange
and message ordering.
Figure 58. Interaction Protocol definition. Note that there is a separate definition of the messages to be
sent (UIInitiates and UIColaborates) and the message order (IUPrecedes)
Interaction diagrams where Interactions and agents are related (IInitiates and
Icolaborates), see Figure 59. It is important also to link a GRASIA Specification entity to
the interaction. In this GRASIA Specification, you will have to select the interaction
diagram previously defined. Select it in the combo and press select one for this.
42
Figure 59. Interaction diagram defining the Interaction entity, interaction participants, and the specification
entity, a GRASIA Specification in this case
An organization diagram where agents are associated to the roles defined in the
interaction
Figure 60. Association of roles participating into the Interaction with their agents
Once defined these diagrams, you can go to the module code generation option and select
generate code as in Figure 61.
43
Figure 61. Code generation option for JADE platform
This will produce the source code to run the JADE agents. The next step is to compile the JADE
code:
ant compJADEmas
This will produce the required binaries to run the simulation. Then, to run the simulation, open
two consoles in the same IDK distribution folder.
In the first one, type
ant runJADE
This will start a JADE platform instance. Once launched, you will see the JADE GUI. You have
to type in the second console:
ant runJADEmas
This will open another window with an interface like the one shown in Figure 62.
Figure 62. Snapshot of the main panel that starts individual agent protocols
You can hit any button as many times as you want. The agent will distinguish the different
conversation instances of the same or different type.
44
During the execution, new state machines may appear and make the window size change. Size
changes are not handled properly and you may have to resize a little the window to start the
layout algorithm and size the frame properly.
Size changes happen because generated agents start protocol state machines under demand.
So, you may start with one white panel and see how new panels are created without pressing
buttons. The interface window does not close state machine protocol panels when one state
machine finishes. To clean a state machine, press close button allocated right on the left of the
affected state machine panel.
45
2. A Main class that launches requested agents.
5.3.3.2 Requirements
JDK 1.1.8 (for JADE Leap to run) and J2SDK 1.4.2 (for IDK to run) installed. The JADE Leap
platform installed.
5.3.3.3 Configuration
In order to run properly the ant task that compiles the code generated by the JADE Leap
module, you must edit the leapBuild.xml file and edit the boot-java-1.1-classes ant property so
that it points to the lib/classes.zip allocated in the distribution folder of JDK1.1.8.
The Demo runs on a PC and a PDA. We assume that the PDA has already a JADE Leap
distribution properly installed (please, consult the JADE Leap manual). The PC is a Windows
based one, though could be Unix based as well. The PDA in our case is a Sharp Zaurus.
The steps to perform on the PC are:
Open a command console and go to the IDK distribution folder.
Deploy the module with:
ant modJADEleap
Go to the IDK Editor with:
ant runide
Load an specification, for instance the cine.xml specification allocated in the examples
folder of the IDK distribution.
Go to modules code generators JADE LEAP agents generator generate
Check that the IDK Editor says that some files were created and written
46
Compile the generated code with:
ant compJADEleappjava
Upload the generated jar genlib/demoPjava.jar into the PDA. This step depends on
the software that allows to transfer files from the PC and the PDA. Sometimes, it is a
desktop application that connects directly with the PDA; others, it is a matter of
transferring with ftp the file to the PDA or dragging and dropping it into a special My PC
drive.
Start Jade Leap Main Container with:
ant runJADEleap
In the PDA (once the Main Jade Leap is running and the code of the agents code (the
previously mentioned jar file) is uploaded into the PDA:
Start Jade Leap Agents within the PDA. In the ZAURUS, this is done with the JVM
implementation named evm
evm cp demoPjava.jar:JadeLeap.jar ingenias.JADE.Main container host 192.168.129.1
The -host parameter may be changed because it is the IP location of the Jade Leap
Main Container (that must be running in the PC). Zaurus USB Lan uses 192.168.129.1
to identify the PC.
Agents GUIs should appear in the PDA, like the one from Figure 65
Move Vendor Agent to the PC by selecting Main-Container in its GUI location selector
and clicking Move.
To start the interaction click on the Interaction Button placed in the bottom of the
Interface Agents GUI.
47
Every agent who does start an interaction (the interaction initiator) will have a button in
the bottom of the window. When that button is clicked, the interaction will initiate. There
will be a button for each interaction and it is possible for an agent to have more than
one button.
The state machine that governs the behaviour of the agents is the same as in the JADE Module.
48
with these elements is assigned to the user. The user can decide which task to execute and
what to do with each mental state entity by means of a graphic user interface.
This module has been developed using the Juul Bokhandle case study as base. Readers can
review this case study in section 6.2.
5.3.4.2 Requirements
JDK 1.5.0 Update 4 installed. JADE is required as well, but it is included within the IDK
5.3.4.3 Configuration
All libraries needed to compile the module are already included in the distribution
ant modjadeorg
Once compiled, it will be uploaded automatically by the IDK. Remember that the IDK supports
hot deployments, i.e. you can compile modules while the IDK is running.
To define a MAS system to be processed by this module the following diagrams have to be
defined:
An agent diagram per agent. This diagram will show each agent's initial mental state
and pursued goals.
Figure 66. Initial mental state for the responsible of the organization. The diagram states that the
responsible of the organization Juul starts with three facts in its mental state.
49
Figure 67. Representation of the workflow of the tasks in the system. WFConnects relationships represent
input-output dependencies among tasks. WFResponsable denote responsibility relationships. Note that we
use only roles and not agents. This is a requirement of the module.
Goal tasks diagrams for each task and goal. Each goal defined in the system has to
be associated with
Figure 68. Description of the task select an organization to subscribe to. WFConsumes relationship
indicates which elements has to present in order to initiate the task. Also, the task is linked with a goal to
indicate that it can produce the elements required to satisfy the goal.
50
Figure 69. High level representation of the interaction. The interaction pursues the goal belong to an
organization and is specified into a separated protocol with the GRASIA notation. The protocol is detailed
in Figure 70. Participants of the interaction can be only roles. There have to be exactly one initiator and at
least one colaborator.
An interaction diagram showing the protocol. By now, we still use grasia protocol
representations. AUML diagrams are not supported yet. During the representation of
the protocol, it will be required that you
51
Figure 70. Protocol representation for the interaction subscribing agent into organization, which is
represented in Figure 69
Figure 71. Mental state required to initiate a request subscription interaction unit
Once defined these diagrams, it is required to proceed as in the case of the JADE module:
generating the code as Figure 72 remarks.
During code generation several warnings can be raised in the messages panel:
[02:39] WARNING: In Interaction unit notify_students_of_book_discounts the collaboration
relationship does not remark a mental condition. If you feel that this collaboration requires a
mental condition, just double click on the relationship
52
This warning states that in an interaction unit, the collaborator is not describing any guards for
defining conditions that enable participation. The effect is that no matter what is happening, the
collaborator will process the message and the information it contains will be asserted into the
agent mental state.
[02:39] WARNING:There are no FRAME FACTS defined in diagram diagram mental condition
to collaborate with request subscription. Interaction Subcribing_agent_into_Organization in
interaction unit RequestSubscriptionsays that this diagram defines a mental state condition and
facts may be required. Please, check that you are using FrameFacts. To do so, select a fact
that you are using and right click on it, and check that there is no any refine option. If there is,
select in the refine submenu the FrameFact entry
This time, we have defined an empty mental state condition in a interaction diagram. The
message explains how to solve it.
If the developer considers convenient ignoring these warnings, the next step is compiling the
output. This is executed with an ant command
ant compjademasorg
Now it is time to open another console within the same folder. In one, you have the JADE
platform
ant runjade
In the other, you will start the main GUI to handle the resulting MAS
ant runjademasorg
53
progresses, the reason may be that it is waiting a task to produce certain mental
entities.
Task Management. Figure 76 presents the GUI used to interact with tasks. At any
moment, only those tasks whose execution satisfies a goal are shown. This is related
with the Rationality Principle and BDI concerns. By clicking on the radion button
situated at the right side of each tasks, we can inspect what kind of inputs it is expecting
and what outputs. The representation of inputs and outputs is achieved by means of
agent diagrams, since these are the most adequate to represent mental entities. Since
we are handling agent diagrams, exactly the same used in the IDK, we are allowed to
edit entities, move them, or resize. Deletion or aggregation of new ones will not have
any effect in this version, though the interface allows to execute these operations. This
way, a user can manually modify the behavior of a task without altering its code. When
the user decides to execute a task, all expected inputs have to be present in the mental
state of the agent, otherwise an error message will be triggered. If executed, the user
can check the agent mental state and verify that new entities have been added.
Mental State Management. Figure 77 shows the GUI for monitoring the agent mental
state. As in the task management GUI, the user can resize, move, or edit existing
entities. Also, deleting or adding new entities will not have any effect, since the diagram
reads the agent mental state but is not able to write on it, though it provides modification
operations of already defined entities.
54
Figure 75. When the mental conditions defined in the interaction do not hold, an alert message is shown
Figure 76. Task management GUI. It shows for the current selected task, the one with his radio button
activated, the expected inputs there should exist and the outputs that should be produced. The name of
the task appears in the external border of the right panel. The upper part of the right panel contains the
inputs and the bottom one, the outputs.
Figure 77. Initial mental state associated to Juul Agent. It shows two goals and the name of the agent in
the border of the right panel.
55
Figure 78. Initial mental state of agent Juul Organization Responsible
To demonstrate the capabilities of the module, we will show the different steps in executing the
subscribing agent into organization, presented in Figure 69 and Figure 70.
Step 1. We go to the task manager and press on execute select an organization to
subscribe. This button is shown in Figure 76. To view the result, switch to the mental state
manager and watch the mental state of agent Juul by pressing its show mental state button.
You should see what Figure 79 shows.
Figure 79. Mental state of the Juul Agent after executing task select an organization to subscribed,
presented in Figure 76.
Step 2. Go to the interactions manager and press the button with label Role: Subscriber Int:
subscribing agent into organization. After pressing it, new panels will appear in the right side.
The first describe the states recognised by the subscriber, and the second the states recognised
by the subscription manager, as shows Figure 80. The protocol will evolve until there is some
step that requires certain information to be present. This information is defined with diagrams
such as Figure 71 and it is associated to the UIInitiates or UIColaborates relationship by double
clicking on them in the IDK. In this case, the communication progresses until reaching a division
of the communication flow: whether to accept the subscription request or not. This cannot be
decided yet, since the agent needs to evaluate the proposal. Hence, that both protocol state
machines, the one from the sender and the receiver, are currently into two states: it waits for
both confirmation or the rejection. A secondary effect of the execution of the interaction is the
aggregation of new mental entities to the mental state of the receiver, the Juul Organization
Responsable. Figure 81 presents the mental state of this agent. If you compare it with the
previous one Figure 78. The information sent is the one produced by task select an organization
56
to subscribe to, presented in Figure 68. It is sent because this task appears linked to the
UIInitiates relationship, shown in Figure 70.
Figure 80. Interaction subcribing agent into organization in the middle of its execution. The different words
represent states in the interaction. Nodes in red represent current states. The notation is petri-net like.
Black circles represent end states. Initial states are those located at the left hand side.
Figure 81. As a result of the interaction, some information has been sent to the receiver, the Juul
Organization Responsible Agent. You can review the new information by pressing on its button.
Step 3. Now it is time to decide whether if Juul Organization Reponsible agent accepts Juul
proposal or not. According to Figure 84 and Figure 85, we need to set a field of a the Evaluation
Result fact to either accepted or rejected. To do so, we select the task evaluate agent
capabilities in the task manager, as shows Figure 82. Now it is required to edit the evaluation
result as Figure 83 illustrates. Once modified, we press the execute evaluate agent capabilities
button
57
Figure 82. Activation of a new task, the evaluate agent capabilities task. We need to edit the Evaluation
Result fact in order to modify its default value
Figure 83. Editing the evaluation result fact. Edition is applied as in is done in the IDK. First you double
click the fact. In the resulting dialog window, you scroll down, select the entry result in the list, right click on
it and select open. Once opened, write down in the value field either rejected or accepted.
Figure 84. Mental state condition required to initiate the You are in interaction unit in Figure 70.
58
Figure 85. Mental state condition required to initiate the I dont want to admit you interaction unit in Figure
70
Step 4. There is little more to do. Since the state machines representing the procotols have
automatically self activated, the interaction manager will show you some changes in the original
state machines presented in Figure 80. Figure 86 contains the final state reached. The state
machine for agent Juul Agent has reached two final states. This happen due to the protocol
definition. According to how it was defined, there is no way to distinguish between the executing
of a I dont want you and a you are in interaction units without inspecting the evaluation result
fact sent by Juul Organization Responsible Agent. Unfortunately, evaluation result cannot be
known by Juul Agent until it is asserted into its mental state. Nevertheless, if it is asserted, then
it can be said that the interaction unit has been executed successfully. The solution would be to
define conditions to be applied not only to the agent mental state, but to the interaction unit iself.
Figure 86. Interaction final state after introducing the evaluation result fact in the Juul Organization
responsible agent.
The effect of the interaction can be observed in the mental state of Juul Agent, see Figure 88.
Also, by finalizing the interaction, new tasks are enabled, as shows Figure 87. These new tasks
are activated due to the goal keep the organizational health, and the presence of the fact
evaluation result.
59
Figure 87. New activated tasks in agent Juul Agent after receiving the Evaluation Result fact.
Figure 88. Mental state of Juul Agent after finalizing the interaction. Note that there is a new fact, the
evaluation result fact.
60
what causes problems when trying to repeat an interaction. When repeating an
interaction, all facts required to make it progress are already present, so it would
continue without control.
Facts in the mental state manager and in the task manager do not show their default
values
5.3.5.2 Requirements
Having installed the SOAR distribution in your system. You can download SOAR 8.5.1 from:
http://sitemaker.umich.edu/soar/soar_software_downloads
To run SOAR demos, you will need also the TCL/TK. For windows, the binary with the
distribution can be downloaded from:
http://prdownloads.sourceforge.net/tcl/tcl805.exe
You will need also the J2SDK 1.4.2.
5.3.5.3 Configuration
To build the SOAR module, you should type, in a command console
ant modsoar
Then, after launching the editor with
ant runide
Now it is time to setup where you want your code to be allocated. SOAR Tank demo requires
that customized tanks are allocated at C:\Program Files\Soar\Soar-Suite-8.5.1\tanksoar-
3.0.7\agents. Therefore we set the outputFolder property to C:\Soar\Soar-Suite-
8.5.1\tanksoar-3.0.7\agents\soarAgent as shows Figure 89. The project properties dialog
window is opened with the option shown in Figure 27.
61
Figure 89. Project properties to modify the Soar output folder
Now, you should open the demo specification file, which is the tanksoar.xml file, allocated in the
examples folder. Then, selecting the generate option of the soar module as shows the Figure 90
to generate code
The message panel should show something like the output of the Figure 91
Now you should open SOAR by choosing Tank Soar from the Windows Start menu or starting
the corresponding batch or shell file in other OS
62
Figure 92. Starting the Tank SOAR demo
5.3.6.2 Requirements
This implementation requires an application server that supports servlet execution. In this case,
we used the resin application server (http://www.caucho.com). It is very easy to configure and
launch. In any case we provide further instructions for this case study configuration.
The IDK includes the resin distribution and its associated licenses.
5.3.6.3 Configuration
Open the build.xml file included in the IDK distribution and change the property resinfolder so
that it points at the home folder where the resin server is installed
<!-- Change this property to the folder where resin is installed -->
<property name="resinfolder" location="resin-2.1.11"/>
To compile the module, use the following command (windows)
ant modservlet
Once it is compiled, launch the editor, load the specification file (juul.xml in this case) and:
1. Open project properties (Project-> properties), and set the property named "document
folder" to the doc/WEB-INF/classes folder under the resin home folder.
63
2. Go to the main menu selecting Modules -> servlet based workflow simulation ->
generate.
If everything goes as expected, it will start generating code of the servlet, note that the module
output will show where it is writing files. If some part of the specification is not correct, it will
show red messages showing the failures and what to do to solve them.
The IDK distribution has a preconfigured resin application server. This server has a special file,
named resin.conf, that is read by the application server to know what ports to use, where are
the www document root, etc. To run the generated servlet, in the IDK we added the following
lines to the resin.conf file (NO NEED TO DO THIS):
<web-app id='juul'>
<context-param info='An application information string'/>
<servlet servlet-name='juul' servlet-class='Juul'>
<init-param info='A servlet information string'/>
</servlet>
</web-app>
To start the web server, a specialised task has been defined in the build.xml included in IDK. To
run this task from command line console you should type (windows & unix):
ant launchhttpserver
64
The output will be something like:
C\foo\>ant launchhttpserver
Buildfile: build.xml
launchhttpserver:
[java] Resin 2.1.11 (built Mon Sep 8 09:36:19 PDT 2003)
[java] Copyright(c) 1998-2003 Caucho Technology. All rights reserved.
[java] Starting Resin on Wed, 18 Feb 2004 19:37:44 +0100 (CET)
[java] [2004-02-18 19:37:46.892] initializing application
http://localhost:8080/
[java] [2004-02-18 19:37:46.892] initializing application
http://localhost:8080/java_tut
[java] [2004-02-18 19:37:46.892] initializing application
http://localhost:8080/juul
[java] [2004-02-18 19:37:46.892] initializing application
http://localhost:8080/examples/tags
[java] [2004-02-18 19:37:46.892] initializing application
http://localhost:8080/examples/tictactoe
[java] [2004-02-18 19:37:46.892] initializing application
http://localhost:8080/examples/navigation
[java] [2004-02-18 19:37:46.972] initializing application
http://localhost:8080/examples/xsl
[java] [2004-02-18 19:37:47.363] initializing application
http://localhost:8080/examples/templates
[java] [2004-02-18 19:37:47.363] initializing application
http://localhost:8080/examples/login
[java] http listening to *:8080
[java] srun listening to 127.0.0.1:6802
Once launched, the server will be accessible from this URL: http://localhost:8080/servlet/Juul
65
Figure 95. Navigator window showing selected tasks
Figure 95 shows a snapshot of the servlet. Each button represents a task that can be activated.
It also has text presenting who is supposed to execute the task.
Be advised that some tasks enact other workflows. So it would not be surprising that when you
thought that the workflow had finished, it turns out that the browser keeps on showing you new
buttons.
66
Diagram Entity Expected behaviour and constraints Target Platform representation
67
6. CASE STUDIES
The IDK currently incorporates several cases of study. In this section we introduce briefly each
one of them and what modules could be applied to them. In principle, any module can be
applied to any specification. However, some of them are specially adapted to specific
configurations. This is one of the reasons why we have considered that module development
should be open to any user of IDK.
6.1.1 Modules
This case study only provides the specification, but you can try to apply the following modules:
Servlet Based Workflow simulation. Described in section 5.3.6.
JADE module. Described in 5.3.2.
JADE Leap module. Described in 5.3.3.
6.2. BOOKSELLERS
We chose as case study the Juul Boklander case study written by Espen Andersen from
http://www.aspen.com. The case study is a bookseller company that sells books to university
students. The company has an agreement with professors and students to obtain a list of books
used in their courses and sell them at special prices. The bookseller is considered an
organization in which there are departments in charge of sales and departments in charge of
logistics. Sales can be conventional or through internet. In this case, the goal is how to define
electronic sales.
This case study was performed following the INGENIAS methodology and recommended
design steps. Different steps of the development process are available:
juul-analysis-elab.xml
juul-analysis-init.xml
juul-design-elab.xml
6.2.1 Modules
This case study provides several suitable files for the following modules:
Servlet Based Workflow simulation. You can use as input for this module the
following files:
o juul-design-elab-servlet.step1.xm: example with failures
o juul-design-elab-servlet.step2.xm: example with failures
68
o juul-design-elab-servlet.step3.xml: operational example.
JADE module. You can use as input for this module the following files
o juul-design-elab-JADE.step1.xml. example with failures
o juul-design-elab-JADE.step2.xml. example with failures
o juul-design-elab-JADE.step3.xml. example operational.
JADE Leap module. You can use as input for this module the following files:
o juul-interaction.xml. example operational.
6.3. QUAKE
This example was developed by: Guillermo Jimenez ([email protected]). This is case study
only considers modelling with the INGENIAS specification language in order to show its ability to
deal with a complex environment such as the QUAKE game.
The example is based on a demo video of an implementation of quake bots made with
PROLOG. The video is in Spanish and it is available at http://grasia.fdi.ucm.es/video
Current specification is on file quake.xml.
6.3.1 Modules
This is a modelling case study only, but you can try to apply the following modules:
Servlet Based Workflow simulation. Described in section 5.3.6.
JADE module. Described in 5.3.2.
JADE Leap module. Described in 5.3.3.
6.4. ROBOCODE
This case study is not finished yet. The purpose of this case study is to translate ROBOCODE
primitives to the IDK front end, and leave coding tasks apart. ROBOCODE is a game developed
by IBM for educational purposes, and is available at http://robocode.alphaworks.ibm.com. In the
game, you code the behaviour of a tank or a team of tanks in order to win battles.
This case study comes with an example of what would be the expected results of each stage of
the INGENIAS methodology:
robocode-inception.xml
robo-elaboration.xml
6.4.1 Modules
Robocode module. To be provided.
6.5. SOAR
The case study developed by Juan Antonio Recio ([email protected]) and consisted in
adapting the Tank SOAR demo to INGENIAS. Adaptation process transformed the rule based
behaviour that SOAR uses to diagrams that could be represented in INGENIAS. Basically, it
expresses all a tank needs to know with two kind of diagrams: task and goal, and agent
diagrams.
The specification file for soar is tanksoar.xml
69
6.5.1 Modules
Soar module. This module has been described in Section 5.3.5.
70
7. INGENIAS
This section presents the INGENIAS methodology. INGENIAS has been developed taking
MESSAGE (Caire et al., 2001) as starting point. MESSAGE proposed a notation for the
specification of MAS, extending UML with agent related concepts such as agent, organization,
role, goals and tasks. It also adopted the Rational Unified Process as software development
process and defined activities for identification and specification of MAS components in
analysis, and partially in design. INGENIAS improves MESSAGE in several aspects:
Integration of design views of the system. INGENIAS links concepts of different
diagrams and allows mutual references.
Integration of research results. Each meta-model has been elaborated attending to
current research results in different areas like coordination, reasoning, and workflow
management.
Integration of software development lifecycle. The coupling of the Rational Unified
Process and INGENIAS is stronger now. We have defined concrete activities as well as
how they should be distributed along the development life-cycle.
Support tools. The support tool in MESSAGE was an editor that based in a
commercial meta-case tool, named METAEDIT+. The INGENIAS Development Kit
(IDK) is fully programmed in the Java language and uses open source libraries, which
makes it more portable, extensible, and configurable. Apart from a graphical editor, the
IDK provides a framework for the implementation of modules for verification and code
generation.
Implementation concerns. MESSAGE did not research how specifications could help
in the implementation. The IDK framework allows to translate specification diagrams
into any programming language and target platform. This facility has driven us to
consider a development process where it is possible to perform rapid prototyping, and
where specifications and implementations feed each other.
71
for parameterization and instantiation of MAS frameworks, given a concrete MAS specification.
The usability of this language and associated tools, and its integration with software engineering
practices have been validated in several examples from different domains, such as PC
management, stock market, word-processor assistant, and specially the application to
collaborative filtering information systems.
7.2. META-MODELLING
Though there may be previous interpretations of what meta-modeling is, in this document we
attend to the definition provided in the Meta Object Facilities (MOF) specification (OMG, 2000).
This definition states that there are several levels in the definition of a language. In fact, it
defines four levels where different language grammars are defined and each level defines the
grammar to be used in the next level. This process could be understood as a backwards
stepwise abstraction from the information level. The process ends at the M1 level, which so far
has proven to be enough to UML.
Meta-meta-model
Meta-Meta-model (built in)
(M1)
MetaClass(Register,[MetaAttribute(name,String Meta-model
), MetaAttribute (Fields,List<Field>)] (M2)
MetaClase(Field,...)
Register Model
(Action,[Field(Company,String),Field(Price,Real)]) (M3)
Action(Telefonica,114.29)
Information
(M4)
72
<<Object>> <<Object>>
Autonomous Entity Agent
<<Relationship>> <<Relationship>>
<<Property>> WFPlays AHasMSManager
Identity
<<Role>>
<<Object>>
WFResponsableSource
<<Relationship>> MentalStateManager
GTPursues
<<Relationship>>
<<Object>> AHasMS
<<Object>> Role
Goal
<<Object>>
<<Relationship>> MentalState
WFResponsable
<<Relationship>>
AHasMSProcessor
<<Object>> <<Object>>
MentalEntity Task
<<Object>>
MentalStateProcessor
<<Relationship>>
GTPursues
INGENIAS meta-models are defined in the M2 level. IDK implements M2 meta-models and is
used to create specifications of M3 models. Therefore, instances of the meta-models, according
to Figure 98, are the concrete diagrams that the developer defines (level M3) with the IDK.
There is an extra level, the M4, that is supposed to hold instances of M3 models. In INGENIAS
we leave this instantiation to the developer. In our experience, models at the M3 level can be
expressive enough to be used as if they were M4, but we do not. However, an M4 could be
considered.
Figure 97 shows an example of a meta-model M2 which is part of the agent meta-model. It is
represented using a UML class diagrams and stereotypes. GOPRR primitives appear as
stereotypes of the different elements of the diagram. Basically, the diagram says that an agent
is an autonomous entity that pursues goals. Goals are mental entities that form part of the
mental state of the agent. An agent plays roles and, that way, it assumes responsibilities. An
agent uses tasks to modify its mental state and the environment. These tasks are assigned to
agents directly or through roles played. Changes in the Mental state are controlled using the
mental state manager. This entity takes care of the consistency of the mental state and provides
the primitives to change it. Decision procedures of the agent are built in the mental state
processor.
73
Organization
Interactions Environment
So INGENIAS uses five meta-models that describes five types of diagrams of the same name.
Entities of these meta-models, i.e. meta-entities, are not unique in the sense that anyone could
be used in any of them. As a result, an entity, instance of an meta-entity, could appear in
different diagrams.
Organization meta-model. It defines organization diagrams. The organization is the
equivalent of the MAS architecture. An organization has structure and functionality. The
structure is similar to the one stated in AALAADIN framework (Ferber & Gutknecht,
1998) that later originated MADKIT. As a developer, you define the organization
attending to how you think agents should be grouped. Functionality is determined when
defining the goals of the organization and what workflows it should execute.
Environment meta-model. It defines environment diagrams. The environment is what
surrounds the MAS and what originates agent perception and action, mainly. As a
developer, one of your first tasks is to identify system resources, applications, and
agents. System resources are represented using TAEMS (Wagner & Horling, 2001)
notation. Applications are wrappers of whatever is not an agent or a resource, and
could be understood as the equivalent of objects in INGENIAS. Using these elements, a
developer should be able to define how the MAS interact with the surrounding systems.
Task/Goal meta-model. It describes how the mental state of agents change over the
time, what is the consequence of executing a task with respect to the mental state of an
agent, how to achieve goals, and what happens when a goal cannot be achieved. It
also gathers dependencies among different systems or agent goals.
Agent meta-model. It defines primitives to describe a single agent. It can be used to
define the capabilities of an agent or its mental state. The mental state is an aggregate
of mental entities that satisfy certain conditions. The initial or intermediate mental state
is expressed in terms of mental entities such as those of AOP (Shoham, 1993) and BDI
(Kinny, Georgeff, & Rao, 1997).
Interaction meta-model. It describe two or more interacting agents. The interaction
itself is a first class citizen whose behaviour is described using different languages,
such as UML collaboration diagrams, GRASIA interaction diagrams, or AUML protocol
diagrams. An interaction has a purpose that has to be shared or partially pursued by
interaction participants. Usually it is related with some organizational goal.
An extensive detailed list of the entities, relationships, and diagrams that IDK supports, can be
found in the section Error! No se encuentra el origen de la referencia.. Icons and notation
appear in section Error! No se encuentra el origen de la referencia..
74
7.4. FAQ ABOUT DIAGRAMS
What is the semantics of meta-models?
o Semantics of the meta-entities defined with the GOPRR meta-language are rather
naive, nothing further from what a relationship or an entity means. However, with
respect to MAS, something else could be said. In the original work of INGENIAS
(Gomez-Sanz, 2002) there is an deep explanation of the intended meaning of each
element, though right now it is in plain natural language. We are planning to
elaborate something more formal, but there is much work to do.
When to use them? It depends of what you intend to do. Here we provide some hints:
o Agent diagrams.
When you want to express an intermediate state of the agent. Figure
99 presents an example.
Figure 99. Mental state required to determine if an agent should be expulsed or not
75
Figure 100. Interaction protocol specification by means of different specification mechanisms
76
8. CONCLUSIONS
The document is not finished yet and it will evolve as INGENIAS methodology does. Developing
a methodology and the associated tools is not easy at all, because it is not only about theorizing
what could be useful to develop a system, but a matter of experimentation.
The document presents key elements of INGENIAS Development Kit (IDK) and how to use
them. We hope that this text has helped you, but in case it did not, feel free to contact us, mainly
through the ingenias.sourceforge.net forums and mail lists. We only ask for a little patience
since we have many responsibilities, however, we dedicate to INGENIAS as much time as we
can.
Also, if you feel that you could contribute to INGENIAS, you can contact us at same place or by
email to [email protected] or [email protected].
77
9. ANNEX I: INGENIAS METAMODEL
INGENIAS metamodel is no more included within this document. Interested readers, should visit
http://grasia.fdi.ucm.es/ingenias/metamodel
There, readers will find a MOF compliant definition of the INGENIAS concepts, relationships,
and diagrams, as well as guidelines and explanations of the use of them. As an example of
what readers can find, we show Figure 101 and Figure 102.
78
REFERENCES
Caire, G., Leal, F., Chainho, P., Evans, R., Garijo, F., Gomez-Sanz, J. J., et al. (2001). Agent
Oriented Analysis using MESSAGE/UML, LNCS, Vol. 2222, Springer Verlag,
Ferber, J., & Gutknecht, O. (1998, 1998). A Meta-Model for the Analysis and Design of
Organizations in Multi-Agent Systems, Proceedings of the Third International
Conference on Multi-Agent Systems (ICMAS98), IEEE CS Press,
Friedman-Hill, E. (2002). Java Expert System Shell (JESS), http://herzberg.ca.sandia.gov/jess/.
Gamma, E., Helm, R., Johnson, R., & Vlissides , J. (1995). Design Patterns: Elements of
Reusable Object-Oriented Software.
Gomez-Sanz, J. J. (2002). Modelado de Sistemas Multi-Agente. Unpublished software
engineering, Universidad Complutense de Madrid, Madrd.
Kinny, D., Georgeff, M., & Rao, A. (1997). A Methodology and Modelling Technique for Systems
of BDI Agents. Australian Artificial Intelligence Institute.
Lyytinen, K. S., & Rossi, M. (1999, 1999). METAEDIT+ A Fully Configurable Multi-User and
Multi-Tool CASE and CAME Environment, L, Vol. #1080, Springer-Verlag,
OMG. (2000). MOF. Meta Object Facility (specification) (No. V.1.3. formal).
Pavn, J., & Gmez-Sanz, J. (2003). Agent oriented software engineering with INGENIAS.
Paper presented at the International Central and Eastern European Conference on
Multi-Agent Systems, Springer Verlag.,
Shoham, Y. (1993). Agent Oriented Programming. Artificial Intelligence, 60, 51-92.
Wagner, T., & Horling, B. (2001, 2001). The Struggle for Reuse and Domain Independence:
Research with TAEMS, DTC and JAF, Proceedings of the 2nd Workshop on
Infrastructure for Agents, MAS, and Scalable MAS,
79