This document very briefly describes how to use the MOISE platform based on CARTAGO. It follows the new approach to implement OMI (Organisation Management Infrastructure): based on a normative language and artifacts. The conceptual view of this approach is presented in [2], which is strongly based on ORA4MAS [4].
Two kinds of artifacts are implemented: GroupBoard and SchemeBoard. The usage interface (operations, observable properties, and signals) of them are available in the following links
There is a generic GUI to create organisational artifact and agents enabling the user to test the specification (it is similar to the SimOE program in S-MOISE+). To run it:
ant run-art
We can then set the organisational specification for the system and create groups, schemes, and generic GUI based agents.
You can also read the code of a simulator to learn how to program Java agents to use these artifacts. The source is available at src/ora4mas/nopl/simulator/ConsoleSimulator.java
The actions are the action provided by the OrgArts.
Observable properties of the artifacts (which are Java objects) are mapped to the beliefs inside agents by Cartago-Jason bridge. All of them are annotated with artifact(artifact id) as shown in the mind inspector:
The beliefs are the following (see API documentation of artifacts for more details):
The following signals are also translated to Jason events (see the organisational artifacts specification for more details):
We use the traditional writing paper example to illustrate the use of Jason - ORA4MAS integration [4]. In this example we have three agents:
The Jason project is:
/* (Traditional) Writing paper example the platform is ora4mas (based on artifacts) by Jomi (2010) */ MAS wp { infrastructure: Centralised environment: c4jason.CartagoEnvironment // the environment is cartago agents: bob agentArchClass c4jason.CAgentArch; // agents have a customised architecture to use cartago alice agentArchClass c4jason.CAgentArch; carol agentArchClass c4jason.CAgentArch; classpath: "../../../lib/moise.jar"; // moise: where the artifacts are included "../../../lib/cartago.jar"; // cartago: platform for artifacts "../../../lib/c4jason.jar"; // jason-cartago integration }
The code of the agents follows.
// This agent creates the group/scheme to write a paper // and adopts the role "editor" in the group { include("check_obl.asl") } // some common plans for obedient agents /* Initial goals */ !start. /* Plans */ +!start <- .my_name(Me); createWorkspace("ora4mas"); joinWorkspace("ora4mas",O4MWsp); makeArtifact("mypaper","ora4mas.nopl.GroupBoard",["../wp-os.xml", wpgroup, false, true ],GrArtId); focus(GrArtId); .print("group created"); adoptRole(editor)[artifact_id(GrArtId)]; // wait for alice ?play(alice,writer,"mypaper"); // wait for carol ?play(carol,writer,"mypaper"); !run_scheme(sch1). // general error handler for goal start -!start[error(I),error_msg(M)] <- .print("failure in starting! ",I,": ",M). +!run_scheme(S) <- makeArtifact(S,"ora4mas.nopl.SchemeBoard",["../wp-os.xml", writePaperSch, false, true ],SchArtId); focus(SchArtId); .print("scheme ",S," created"); addScheme(S)[artifact_name("mypaper")]; .print("scheme is linked to responsible group"); commitMission(mManager)[artifact_id(SchArtId)]. -!run_scheme(S)[error(I),error_msg(M)] <- .print("failure creating scheme ",S," -- ",I,": ",M). // application domain goals +!wtitle <- .wait(500); .print("writing title..."). +!wabs <- .print("writing abstract..."). +!wsectitles <- .print("writing section title..."). +!wconc <- .print("writing conclusion..."). +!wp <- .print("paper finished!"). +goalState("sch1", wp, _, _, satisfied) <- .wait(1000); lookupArtifact("sch1",SchId); destroy[artifact_id(SchId)]; disposeArtifact(SchId); .print("starting a new scheme..."); !run_scheme("sch2"). +?play(A,R,G) <- .wait({+play(_,_,_)},100,_); ?play(A,R,G). // signals +normFailure(N) <- .print("norm failure event: ", N). +destroyed(Art) <- .print("Artifact ",Art," destroyed"). // for debug (prints out the new states of goals) //+goalState(Sch,Goal,CommittedAgs,AchievedBy,State) // <- .print(" goal changed: ", goalState(Sch,Goal,CommittedAgs,AchievedBy,State)).
The included file is:
// plans to handle obligations +obligation(Ag,Norm,committed(Ag,Mission,Scheme),Deadline) : .my_name(Ag) <- .print("I am obliged to commit to ",Mission," on ",Scheme); commitMission(Mission)[artifact_name(Scheme)]. +obligation(Ag,Norm,achieved(Scheme,Goal,Ag),Deadline) : .my_name(Ag) <- .print("I am obliged to achieve goal ",Goal); !Goal[scheme(Scheme)]; goalAchieved(Goal)[artifact_name(Scheme)]. +obligation(Ag,Norm,What,Deadline) : .my_name(Ag) <- .print("I am obliged to ",What,", but I don't know what to do!"). /* (old plans not used anymore) //!check_obligations. // see obligation list, if it is for me and I am not done, obey. Repeat it forever. +!check_obligations : active_obligations(ListOfObl)[artifact_name(ArtId,ArtName)] <- for( .member(Obl,ListOfObl) ) { !check_obligation(Obl); } .wait(200); !!check_obligations. -!check_obligations <- .wait(200); !!check_obligations. +!check_obligation( obligation(Ag,Norm,committed(Ag,Mission,Scheme),Deadline) ) : .my_name(Ag) <- .print("I am obliged to commit to ",Mission); commitMission(Mission)[artifact_name(Scheme)]. +!check_obligation( obligation(Ag,Norm,achieved(Scheme,Goal,Ag),Deadline) ) : .my_name(Ag) <- .print("I am obliged to achieve goal ",Goal); !Goal[scheme(Scheme)]; goalAchieved(Goal)[artifact_name(Scheme)]. +!check_obligation( obligation(Ag,Norm,What,Deadline) ) : .my_name(Ag) <- .print("I am obliged to ",What,", but I don't know what to do!"). */
// this agent waits for the group creation and then // adopts the role write and // commits to the missions mColaborator and mBib { include("common.asl") } { include("check_obl.asl") } /* Initial goals */ /* Plans */ // application domain goals +!wsecs <- .print("writing sections..."). +!wrefs <- .print("organising bibliography..."). // conditions to leave missions @lgss1[atomic] +goalState(Scheme,wsecs,_,_,satisfied) : .my_name(Me) & commitment(Me,mColaborator,Scheme) <- !quit_mission(mColaborator,Scheme). @lgss2[atomic] +goalState(Scheme,wrefs,_,_,satisfied) : .my_name(Me) & commitment(Me,mBib,Scheme) <- !quit_mission(mBib,Scheme).
The common.asl file:
/* Common code for Alice and Carol */ /* useful rules */ /* Initial goals */ !start. !join. /* Plans */ +!start <- lookupArtifact("mypaper",GrId); adoptRole(writer)[artifact_id(GrId)]; focus(GrId). -!start <- .wait(100); !start. +!join <- .my_name(Me); joinWorkspace("ora4mas",_). -!join <- .wait(200); !!join. // keep focused on schemes my groups are responsible for +schemes(L) <- for ( .member(S,L) ) { lookupArtifact(S,ArtId); focus(ArtId) }. +!quit_mission(M,S) <- .print("leaving my mission ",M," on ",S,"...."); leaveMission(M)[artifact_name(S)].
// this agent waits for the group creation and then // adopts the role write and // commits to the mission mColaborator { include("common.asl") } /* Initial goals */ /* Plans */ // application domain goals +!wsecs[scheme(S)] <- .print("writing sections for scheme ",S,"..."). // when my goal in the scheme is satisfied, leave my mission @lqm[atomic] +goalState(Scheme,wsecs,_,_,satisfied) : .my_name(Me) & commitment(Me,mColaborator,Scheme) <- !quit_mission(mColaborator, Scheme). // plans to handle obligations +obligation(Ag,Norm,committed(Ag,mColaborator,Scheme),DeadLine) : .my_name(Ag) <- .print("I am obliged to commit to ",mColaborator); commitMission(mColaborator)[artifact_name(Scheme)]. +obligation(Ag,Norm,achieved(Scheme,Goal,Ag),DeadLine) : .my_name(Ag) <- .print("I am obliged to achieve goal ",Goal); !Goal[scheme(Scheme)]; goalAchieved(Goal)[artifact_name(Scheme)].