What you’ll build |
||
This tutorial illustrates the programming of agents' organisations in a multi-agent system. You will use and program a normative organisation coordinating and regulating the cooperation among autonomous agents interacting in the shared environment.
|
||
What you’ll need |
||
|
||
Code |
||
|
1. Creating a MAS with a simple Agent organisation
-
Download the code used in step 1 (initial and solution) Download ZIP
Learned features in this step |
|
1.1. Explanations
We are considering the multi-agent system developed in the Step by step walk in programming multi-agent environment tutorial.
The aim is to install some coordination among the agents for using the artifacts in a proper sequence.
easss_org
:An agent organisation defines an explicit and changeable coordination pattern among the agents.
Programmed in the org-spec.xml
file, it is composed by:
-
a
structural specification
that defines a groupeasssGr
with three roles:greeter
,observer
andcomputer
. These roles can be played by the agents when participating to a group of this type, -
a
functional specification
that defines and plans the performance goalscompute
,greeting
andobserve
to be achieved by the agents.It structures them into the
mCompute
,mGreeting
andmObserve
missions. -
a
normative specification
that assigns in a straightforward way obligations to each role and mission
org_agent.asl
agent program:-
The program has plans to enter the organisation, to adopt one of the roles of the organisation
-
For now this agent is obedient w.r.t. the duties it receives from the organisation given its role.
-
The agent has all the necessary skills to achieve any goal coming from the missions of the organisation (cf. file
skills.asl
in subfolderinc
of foldersrc/agt
)
user_agent.asl
agent program:-
The program has plans to focus on
Scheme Console
andGroup Console
GUI artifacts.As the
org_agent
, it has the necessary skills to realize any goal defined in the organisation. -
The two GUI artifacts are used by the agent to interact with the user. You will use them to act as an agent: entering some group in the organisation, adopt/leave some role, commit/leave some mission, etc.
server.jcm
fileThese two jacamo project files are used to distribute agents, artifacts and the organisation in the deployed multi-agent system
-
The
server.jcm
creates aserver
workspace and deploys artifacts and agents in it -
The
server.jcm
creates also theeasss_org
organisation from theorg-spec.xml
(the organisation artifacts in charge of its management are deployed in theeasss_org
workspace)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
mas server {
agent majordomo {
join: server
}
workspace server {
artifact msg_console: tools.GUIConsole()
artifact calculator: tools.Calculator()
artifact lock: tools.Lock()
artifact barrier: tools.Barrier(3)
}
organisation easss_org : org-spec.xml {
group easss_team : easssGr {
responsible-for : easss_sch
debug // used to create group inspector
}
scheme easss_sch : easssSch {
debug // used to create scheme inspector
}
}
// agent source path
asl-path: src/agt
src/agt/inc
// main node
platform: cartago("infrastructure")
}
client.jcm
file-
The
client.jcm
creates aclient
workspace and deploys artifacts and agents both in this workspace and in theserver
workspace.The agents will also join the
server
workspace to use artifacts that are deployed in it.They will also adopt some roles in the organisation.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
mas client {
agent user_agent {
instances: 1
}
agent user2 : org_agent.asl {
join: server @ servernode
roles: greeter in easss_org.easss_team @ servernode
}
agent user3 : org_agent.asl {
join: server @ servernode
roles: computer in easss_org.easss_team @ servernode
}
// java class path
class-path: lib
// agent source path
asl-path: src/agt
src/agt/inc
platform: cartago()
node servernode running @ localhost
}
1.2. Practice
-
To ease the test, you can define a group of three to four students.
One student launch the
server
workspace (server.jcm
). All students launch aclient
workspace and act on the GUI Artifact to participate to the organisation.Enter the organisation and fulfill your obligations.
-
Take care to follow the life cycle of the organisation as defined by the MOISE framework.
Thanks to the GUI artifact, you can decide to adopt a role, to commit to a mission, to declare the achievement of some goal, etc.
-
Use the
agent inspector
to monitor the evolution of the mental state of the agent, or theorganisation inspector
to inspect the evolution of the organisation state in the Group boards and Scheme boards, to detect the violations
It is also interesting to inspect the mind of the agents to see the beliefs produced by the organisation (The complete description of the observable properties of organisational artifacts are found in MOISE API) |
-
Change the specification of the organisation (e.g. cardinality of roles, order of the goals, …) by editing the file
easss_org.xml
and see how the functioning of the agents changes -
Modify the organisation specification so that at least two agents play the role
greeter
in the group -
Modify the organisation specification so that the role
greeter
is obliged to commit to missionmCompute
(after testing, undo your change)
2. Making agents create their own organisation from a specified organisation program
-
If you didn’t realize previous step, you can get the code used in this step: here (zip) otherwise just use the result of previous step
Learned features in this step |
|
2.1. Explanations
-
We reuse the previous example and refactor it, so that, agents create their own organisation.
Instead of creating the agent organisation in the
.jcm
files, agents have the necessary plans to decide on the way their organisation is deployed.
|
-
In order to deploy the organisation, create the workspace in which will be placed the organisational artifacts in charge of the management of the organisation.
1 2
createWorkspace(...); joinWorkspace(...);
-
The name of this workspace can be the name chosen for the organisation.
-
Then, create in this workspace the organisational artifact
OrgBoard
(type isora4mas.nopl.OrgBoard
). TheOrgBoard
stores all the groups and schemes that are composing the organisation. In order to create it, usewid()
with the id of the created workspace, to annotate themakeArtifact
action.The program of the organisation is stored in
./src/org/org-spec.xml
(this path has to be given when initializing the artifact)1 2
makeArtifact(...,"ora4mas.nopl.OrgBoard", ["src/org/org-spec.xml"], OrgArtId)[wid(WOrg)]; focus(OrgArtId)[wid(WOrg)];
-
Then arrives the creation of group (with eventually the way to monitor and debug this structure)
1 2 3
createGroup(Gname, easssGr, GrArtId); debug(inspector_gui(on))[artifact_id(GrArtId)]; focus(GrArtId)[wid(WOrg)];
For each creation of group, one has to use this operation
createGroup
-
And finally, the creation of schemes:
1 2 3 4
// create the scheme createScheme(Schname, easssSch, SchArtId); debug(inspector_gui(on))[artifact_id(SchArtId)]; focus(SchArtId)[wid(WOrg)];
-
In order to enable agents participating to a group, to commit to missions of a social scheme, the group must become responsible of the deployed social scheme.
This can be done only and only when the group is well formed (i.e. when all the constraints on minimal number of agents playing a role are satisfied).
-
As soon as the group is well formed, a new belief
formationStatus
is generated into the agent’s belief base -
Use a the test goal
?formationStatus
to test the presence of this belief in the belief base of the agent1
?formationStatus(ok)[artifact_id(GrArtId)];
-
The internal action
.wait
enables to wait till some condition is fulfilled (e.g. production of a belief about the formation status from a group)
-
-
The operation
addScheme
is used to make a groupGrArtId
responsible of a schemeSchname
1
addScheme(Schname)[artifact_id(GrArtId)];
-
From the time the group becomes responsible of the scheme, agents that are playing roles in this group, have the possibility to commit to missions of the scheme under the responsibility of the group.
-
Entering of agents in the organisation is realized by adopting a role in a group of an organisation (remind that you can get the Id of a group with
lookupArtifact
with a specific name in the organisation workspace)1 2
lookupArtifact(Group,GroupId)[wsp("easss_org")]; adoptRole(Role)[artifact_id(GroupId)];
You may have a look at the code of
org_agent.asl
which is realizing some very simple automated reasoning and actions on the organisation
2.2. Practice
-
Create an
org_majordomo
agent that will realize the deployment of the organisation following the different steps described above -
Refactor the code of the
jcm
file in accordance
properties observed from an organisation
group(groupId, groupType, Artid)
scheme(schemeId, schemeType, ArtId)
specification(...) |
properties observed from a group:
|
properties observed from a social scheme:
|
operations to act on an organisation:
|
operations to act on a group:
|
operations to act on a social scheme:
|
3. Reasoning on the Organization
-
If you didn’t realize previous step, you can get the code used in this step here (zip) otherwise just use the result of previous step
Learned features in this step |
|
3.1. Explanations
When executing in an agent organisation, the agents who play some roles in it receive obligations and permissions to commit to missions.
Once committed to a mission (either an obliged or permitted mission), they receive signals corresponding to obligations to achieve goals when those goals become active.
-
Fulfilling an obligation for a mission means committing to that mission in the given time constraint
-
Fulfilling an obligation for a goal means achieving that goal in the given time constraint
-
as soon as an obligation is fulfilled, the signal
oblFulfilled
is generated -
as soon as an obligation is unfulfilled, the signal
oblUnfulfilled
is generated (e.g. deadline of a goal has not been satisfied)
These signals are:
|
3.2. Practice
-
Write a plan so that the agent adopts the chosen role as soon as the group has been created (i.e. the corresponding groupBoard artifact has been deployed)
-
Write a plan so that the agent leaves its current role as soon as another agent adopts the same role in his/her group and the group is not yet well formed. After leaving the agent adopts another role.
-
Add a plan in the agent’s code so that this agent is an obedient one: as soon as one obligation, that concerns it, is created, it fullfills the obligation
-
Add a plan in the agent’s code so that each time an agent of its group fulfills an obligation, it broadcasts a message in order to increase the reputation of that agent