You are on page 1of 2

PLAGIARISM COMPARISON SCAN REPORT

Content FILE FILE


Type

Values Modularity_in_BDI_Agent_Programming_and_Artifact_based_Environments.pdf 2016-emas-lncs-ortiz.pdf


First Content 1% matched Second Content 1% matched
ArticleModularityinBDI-AgentProgrammingandArtifact-basedEnvironmentsGustavoOrtiz-Hernndez1,JomiF.Hbner2,RafaelH.Bordini3,AlejandroGuerra-Hernndez1,GuillermoJ.Hoyos-Rivera1,OlivierBoissier4,AlessandroRicci5andGerardoOrtiz-Torres61CentrodeInvestigacionesenInteligenciaArticial,UniversidadVeracruzana,Xalapa91000,Veracruz,Mxicogusorh@gmail.com2Federal University of Santa Catarina, UFSCCTCDASPPGEAS - PO Box 476, Florianpolis, SC 88040-
900,Braziljomi@das.ufsc.br3Pontical Catholic University of Rio Grande do Sul - Postgraduate Programme in Computer Science, SchoolofInformatics,PortoAlegre-RS-Brazilrafael.bordini@pucrs.br4LaboratoireHubertCurienUMRCNRS5516,InstitutHenriFayol,MINESSaint-Etienne,Saint-
Etienne42023,FranceOlivier.Boissier@emse.fr5AlmaMaterStudiorum,UniversitdiBologna,ViaVenezia52,Cesena,Italya.ricci@unibo.it6DepartamentodeCienciasComputacionaleseIngenieras,CentroUniversitariodelosValles,UniversidaddeGuadalajara,Ameca46600,Mxicogerardo.ortiztorres@academicos.udg.mxCorrespondence @gmail.comVersionMarch10,2020submittedtoAppl. Sci.AbstractThis paper proposes an extension for the Agents Artifacts (AA) meta-model, to
enable1the adoption of modularity principles. As usual in this context, the Belief-Desire-Intention (BDI)2model of agency is adopted. In this paper, modules are intended to encapsulate functionality,3expressed in BDI terms, into independent and reusable units of code which can be dynamically4loaded by agents. In this way, well-known software engineering principles related to
modularity5suchasreusability,extensibilityandmaintainability,canbepromotedintheresultingAgent-Oriented6Programming(AOP)proposal. Thekeyideaistoexploitthesyntacticnotionofnamespacetoorganize7both, agent and environment related components, into modules so that the agents can decide which8beliefs, goals, events, percepts and actions will be independently handled by a particular module.9Ourapproachallowstoaddressthename-
collisionissue,alsoprovidesauseinterfaceformodules10that follows the information hiding principle. We state that this facilitates multiple development task,11suchasindependentdevelopment,i.e.,whenanagentprogramisbuiltbymultipleprogrammers.12We present a generic proposal, suitable for AOP languages adopting the AA meta-model, and also13aconcreteimplementationinJaCaanintegrationofJasonandCArtAgO,anAOPlanguageandan14infrastructure for programming
artifact-based environments, respectively. The proposal is evaluated15by developing an auction scenario, whose source code enhances scores from the Halstead complexity16metrics,whencomparedagainstthenon-modularversionofthesystem.17KeywordsAgentOrientedProgrammingModularityNamespaceBDIArtifacts.181. Introduction19Theincreasingcomplexityofsoftwaredemandstoolsandmodelsallowingthedevelopmentof20such systems in a simpler way, while
reducing the effort invested in maintaining and extending them.21Several programming paradigms have been proposed with this purpose, e.g., structured, declarative,22object-oriented, and component-oriented programming. All of them have promoted engineering23principles in response to the software requirements prevailing at their time including maintainability,24SubmittedtoAppl. Sci.,pages126www .mdpi.comjournalapplsciextensibility and reusability, among
others. These principles have became desiderata when designing25anddevelopingsoftwaresystems[126However, new software requirements have arisen during the so called Internet revolution,27demanding systems able to exhibit some degree of autonomy, reactivity and proactivity for facing28highlydynamic,distributedandheterogeneousscenarios. TheAOPparadigm[2copesnaturallywith29suchrequirements,reducinguserintervention[3andpromotingwell-
knownstrategiesfordealing30with complexity, as decomposition, abstraction and hierarchy [46Additionally,theAgentsand31Artifacts (AA) meta-model [7,8promotesamodularapproachforprogrammingtheenvironmentin32whichtheagentsaresituated,providingasuitablemodeltoexternalize[9thefunctionalityrequiredby33theagents toactand perceive. Unfortunately, currentAOP proposals usuallyaddressthis complexity34at the Multi-Agent System (MAS) level, disregarding the
individual agent level, despite an agent35is intrinsically a complex system as well. Therefore, we state that the strategies for dealing with36complexitymustbeenforcedalsowhendesigninganddevelopingindividualagents.37The principle of modularity can signicantly facilitate and improve such vision. This paper38proposes an extension of the AA meta-model, enabling the adoption of modularity principles39at the agent level. As usual in this context, the BDI model of
agency is adopted. Modules are40intended to encapsulate functionality into independent and reusable units of code which can be41dynamicallyloadedbyagents. Fourmajorissuesneedtobefacedtosupportmodularityinsuchterms42i) avoiding name-collision, ii) fullling the information hiding principle, iii) interfacing modules, and43iv)integratingenvironmentcomponents.44Thekeyideaofourapproachistoexploitthesyntacticnotionofnamespacetoaddressthesefour45issues,
providing a generic proposal of modularity suitable for AOP languages based on the AA46meta-model. Thus, every component of a module has an associated namespace which makes possible47toresolvename-collison issues. Alsonamespaces canbeprivate orpublic,so thatcomponentscanbe48encapsulated tofulll theinformation hidingprinciple. Module componentsmay beassociated with49an abstract namspace that will be concretized at run-time, once the module has
been loaded. Abstract50namespace provides both a bidirectional use interface for modules and a mechanism to load a module51as many times as needed in different concrete namespaces, enabling a behavior close to that of the52classinstancerelationshippropertoObject-OrientedProgramming(OOP).Addingnamespacesto53thebridge(componentthatmediatesbetweenagentsandartifactstranslatingactionsandevents,i.e.,a54conceptual representation of sensors and
actuators that are incorporated into physical agents), results55inamodulessystemwhichtransparentlyintegratesenvironmentcomponentsforbothAOPlanguages56andtheartifactsinfrastructure.57Our proposal is based on the approach followed in [10Themainnoveltyofourproposalisthat,58beyondcomposingmoduleswithonlyelementsinherenttoagentprograms(e.g. beliefs,objectives,59intentions), we also consider components related to the environment, such as perceptions
and actions.60Ournotionisthatbyincludingtheenvironmentcomponentsinthedenitionofmodule,agentscan61decide the particular set of perceptions and actions that will be independently handled by modules. In62other words, a module handles only the actions and percepts related to its functionality while the rest63remaintransparent.64This paper is organized as follows given that modularity has been an active research area in65AOP, Section2 r eviewsand compar esdif
ferentappr oachesr eportedin literatur eand our curr ent66proposal. We intend such review to be useful for establishing the contribution and novelty of our67approach (encapsulating environment components into modules). Section3 intr oducesthe AA 68meta-model, focusing on the elements involved in modularization. Although the ideas presented69in this paper can be generalized to BDI programming languages, for the sake of conciseness
and70clarity,AgentSpeak(L)[11isassumedasthemodelofagency.Ourproposalforintroducingmodularity71in the AA meta-model is exposed in Section4 . In order to prove the feasibility of our approach,72an implementation has been done in JaCa, the integration of Jason [12andCArtAgO[13This73implementation is briey discussed in Section5 . We introduce a case study based on an auction74Modularityapproach Lang Indep Env InfoHid NameCol InterfaceBusettaetal.
[16JACK7 7 3 3ExplicitimportexportBraubachetal. [18JADEX7 7 3 3ExplicitimportexportDastanietal. [202APL7 7 3 3SetofpredenedoperationsCapetal. [212APL7 7 3 3SharingscopesMaddenetal.[22Jason7 7 3 3ExplicitimportexportHindriks[23GOAL7 7 7 3Mental-stateconditionRiemsdijketal. [243APL7 7 7 3GoaldispatchingOrtizetal. [25Jason7 7 7 3Unique-commonscopeOrtizetal. [10Jason3 7 3 3GlobalabstractnamespacesOurcurrentproposal JaCa3 3 3
3GlobalabstractnamespacesTable 1.DifferentapproachesformodularityintheBDImodelofagency,comparedregarding Theirimplementation language (Lang) their independence (Indep) with respect to the implementationlanguagetheintegrationofenvironmentcomponents(Env)thefulllingoftheinformationhidingprinciple(InfoHid)theresolutionofnamecollisions(NameCol)andtheinterfaceprovidedforthemodules.scenario for building a house in Section6 . The case study is positively
evaluated by the Halstead75complexitymetrics[14whencomparedagainstanon-modularsolution.Section7offersthedetailsof76the evaluation. Section8 discusses how our appr oachis suitable to constr uctassociation, composition, 77generalization and cardinality relationships between modules [15sothatitispossibletoextend78andbuildcomplexfunctionalitieswhilepromotingcodereuse. ItalsomentionsthewaysomeOOP79concepts, such as multi-inheritance, can be modeled
using our approach. Finally, conclusions are80offeredinSection9.812. RelatedWork82The diversity of approaches for adopting modularity in the BDI model of agency reveals the83relevance of this subject for the AOP community P. Busetta et al. [16usemodulestoencapsulate84beliefs, plans and goals related to a specic functionally, within a common scope called capability.
The85programmercanspecifyasetofscopingrulestosaywhichelementsareaccessibletoothercapabilities.86An implementation is developed for JACK [17L.Braubachetal.[18extendthecapabilityconceptto87fulll theinformation hidingprinciple by ensuringthat all elements in acapability are partof exactly88one capability and remainhidden from outside, guaranteeing that the information hiding principleis89not violated. They provide a mechanism for conguring capabilities with
some initial mental state.90AnimplementationforJADEX[19isprovided.Bothapproachesproposeanexplicitimportexport91mechanismfordeningtheinterface.92The importance of solving modularity in the BDI model of agency is revealed as in literature93there exist multiple approaches for tackling this subject Busetta et al. [16usemodulestoencapsulate94beliefs, plans and goals related to a specic functionally, within a common scope called capability.95The implementation
is developed for JACK [17withthepossibilityofspecifyingasetofscoping96rules in order to identify which elements are accessible to other capabilities. L. Braubach et al. [1897extendthecapabilityconcepttofullltheinformationhidingprinciplebyensuringthatallelements98in a capability are part of exactly one capability and remain hidden from outside, guaranteeing the99informationhidingprincipleisnotviolated.
Theypresentamechanismforconguringcapabilities100withsomeinitialmentalstateandprovideanimplementationforJADEX[19Bothaforementioned101approachesproposeanexplicitimportexportmechanismfordeningtheinterface.102Dastani et al. [20conceivemodulesasseparatementalstatesinstantiated,updated,executed103and tested using a set of predened operations. In this context, executing a module means that
the104agentstartsreasoninginaparticularmentalstateuntilapredenedconditionholds. Inotherwords,105oncethattheagentexecutesamodule,thecontrolistransferredtothisandreturnstotheagentuntil106the module ends its execution. This approach is extended by Cap et al. [21byintroducingthenotion107of sharing scopes to, mainly, enhance the interface. Shared scopes allow modules posting events, such108thatthesearevisibletoothermodulessharingthesamescope.
Initiallyeachagentcontainsonesharing109scopetocontaintheagent'smainmoduleinstance. Thenmodulesareactivatedbymeansofinclusion',110i.e., the module instance is added to the existing sharing scope and deactivated by seclusion', that is111to create a new sharing scope for adding the module. These ideas are conceived in the context of 2APL112[26byextendingitsoperationssemantics,andalsoanimplementationisdescribedbyM.Dastaniet113al. in[27114Dastani et al.
[20conceivemodulesasseparatementalstates.Thesestatesareinstantiated,115updated, executed and tested applying a set of predened operations. In this context, executing116impliesthattheagentstartsreasoninginaparticularmentalstateuntilapredenedconditionholds.117In other words, once the agent executes a module, control is transferred and returns to the agent's118main programuntil themodule endsits execution. Anextension ofthis approach is proposed
inCap119et al. [21Moreover,theyintroducethenotionofsharingscopestomainlyenhancetheinterface,120among other features. Shared scopes allow modules posting events, such that these are visible to121othermodulessharingthesamescope. Initially,eachagentcontainsonepredenedsharingscopeto122contain the agent's mainmodule instance. Then modules areactivated by means of inclusion', i.e., the123module instance is added to the existing sharing scope and
deactivated by seclusion', that is to create124anewsharingscopeforaddingthemodule. Theseideasareconceivedinthecontextof2APL[26by125extendingitsoperationssemantics. AlsoanimplementationisdescribedbyM.Dastanietal. in[27126N. Madden and B. Logan [22proposeacapabilityapproachbasedontheXML'sstrategyof127namespaces [28suchthateachmoduleisconsideredasanuniqueandseparatenamespaceidentied128by an URI. They propose to handle a local belief-
base, local goal-base and local events-queue for each129module, and then to specify, by means of an exportimport statement, which beliefs, goals and events130are visibleto other modules. In thissystem, there isonly one instanceof each module, i.e., references131totheexportedpartofthemodulearesharedbetweenallothermodulesthatimportit. Theseideas132aresupportedbytheJasonlanguage,implementedbyLoganandKiss[29133A capability approach based on the
XML's strategy of namespaces [28isgiveninN.Madden134and B. Logan [22Theyconsidereachmoduleasanuniqueandseparatenamespaceidentiedby135an URI. Likewise, local goal-base and local events-queue for each module is proposed to handle a136localbelief-base, andthentospecify, bymeansofanexportimportstatement, whichbeliefs, goals137and events are visible to other modules. In this system, there is only one instance of each
module,138i.e.,referencestotheexportedpartofthemodulearesharedbetweenallothermodulesthatimport139it. These ideas are supported by the Jason language, implemented by Logan and Kiss [29ssets140of beliefs, plans, and an importexport list referring to module components. The name collision141problem is solved using annotations to label beliefs, plans and events according to the module to142which they belong. Imported and exported elements are added to a
unique common scope accessible143toallmodules. AnimplementationofthisapproachisdevelopedasalibraryforJason[12144Hindriks [23adoptanapproachinspiredinpolicy-basedintentions,asdenedforGOAL[30A145moduleisassociatedwithamentalstatecondition,andwhenthatconditionissatised,themodule146becomes the focus of execution, temporarily dismissing any other goal. The condition that triggers
the147activationofamoduledenestheinterfaceofthemodule,whichcanbespecieddeclaratively. The148approachemphasizestheisolationofgoalsandeventstoavoidthepursuitofcontradictorygoals.149Riemsdijketal. [24associatemoduleswithaspecicgoal,thustheyareexecutedonlytoachieve150the goal for which they are intended to be used. In this approach, every goal is dispatched to a specic151module. Then all plans in the moduleare executed one-by-one in the pursuit of
such goal until ithas152beenachieved,oreveryplanhasbeentried. Thisproposalispresentedinthecontextof3APL[31153A relation between modules and a specic goal is proposed in Riemsdijk et al. [24Themodules154areexecutedonlytoachievethegoalforwhichtheyareintendedtobeused. Inthisapproach,every155goalisdispatchedtoaspecicmodule. Thenallplansinthemoduleareexecutedone-by-oneinthe156pursuitofsuchgoaluntilithasbeenachieved,oreveryplanhasbeentried.
Thisproposalispresented157inthecontextof3APL[31158TheseapproachesarecomparedinTable1 Allofthemprovidediverseinterfacesamongmodules159and solve the name collision problem (NameCol), providing a mechanism to scope the visibility of160goalsevents. However,notallofthemfullltheinformationhidingprinciple(InfoHid). Excepting161our current and previous proposals, all the approaches are not independent (Indep) of the AOP162language (Lang) in which they
have been conceived and implemented, probably difculting its reuse163in other languages. Excepting our current proposal, all of them miss a suitable mechanism to consider164environmentrelatedcomponents(Env).1653. TheAAmeta-model166TheAAmeta-model[7,8promotesaviewofMASwhereboth,theagentsandtheenvironment,167arerst-classabstractions. Fig.1introducesthemeta-model,using UMLnotation.In
thisview,the168environmentisconceivedasasetofworkspacesthattheagentscanjoinandquit,creating,linking,169using, and disposing of artifacts for pursuing their goals. A MAS in the AA meta-model is modeled170as a tuplehAgs,Bdg,Envi, composed by a set of agents (Ags), an environment (Env), and a bridge171(Bdg)betweenthem.172Given the generic nature of the meta-model, different AOP languages and artifact infrastructures173can be adopted as shown in Fig.2 .
The artifact infrastructure, provides an abstraction of the174environment that works as an interface between the agents and their real environment. Agents175and artifacts interact in BDI terms Artifacts are the source of some of the beliefs of the agents, and176theactionsexecutedbytheagentsareindeedoperationsoftheartifacts.
Artifactsandenvironment177interactinmoretraditionalterms,e.g.,OOP.Anyobjectcanbeencapsulatedinanartifact,contributing178inthiswaytowhatShoham[2calledagentication,i.e.,thetransformationofanarbitrarydevice179into a programmable agent. The bridge is anad hoccomponent that mediates between the agents180andtheartifacts,translatingactionsandevents. Inwhatfollows,artifacts,agents,andthebridgeare181describedindetail.182Figure1.TheAAmeta-
model,adaptedfromA.Riccietal. [13Figure2.AMASundertheAAmeta-model.3.1. Artifacts183Artifacts, asshown also inFig.2 , are tools thatprovide operations thatthe agents canexecute as184actions. When focusing on an artifact, an agent can perceive its observable properties and its emitted185signals. Observable properties can be seen as state variables of the artifacts, that the agents perceive as186persistentbeliefs. Signalsareproduced whenexecutingoperations,
beingperceivedasnon persistent187beliefs. Somenotationisrequiredtodenotethecomponentsoftheartifactinfrastructure188Environment. For the sake of simplicity, an environment is assumed to be a set ofn1artifacts,189Envfart1,...,artng.190Artifact. Eachartifactisatuplehid,Pr,Sg,Opi,composedby191Auniqueidentierid,providedbytheagentthatcreatedtheartifact.
Itisusedtodenote192theartifactwhenusedbytheagents.193AsetofobservablepropertiesPrfp1,...,png194AsetofsignalsSgfs1,...,sng195AsetofoperationsOpfo1,...,ong.196Auxiliary functions. A set of functions to access the components of the artifacts are assumed,197e.g.,id(art)returns the identier of the artifactartart(id)returns the artifact denoted by the198identieridandsoon.1993.2. Agents200AlthoughanyAOPlanguagecanbeadoptedintheAAmeta-
model,usuallyaBDImodelof201agency is assumed. This kind of models have strong philosophical foundations on three aspects of202Intentionality, allowing for i) Representations based on the intentional stance [32wherethebehavior203of the agents is modeled and interpreted in terms of beliefs, desires, intentions, and other intentional204attitudesii)Reasoningmethodsbasedontheprinciplesofpracticalreasoning[33whereintentions205are seen as plans and iii)
Communication based on speech acts [34Thismodelhasbeenformally206studiedunderdifferentlogics[35,36andimplementedindifferentAOPlanguages[37,38207For the sake of conciseness and clarity, a simplied version of the BDI model known as208AgentSpeak(L)[11willbeadopted.Thesimplicationfocusesonthecomponentsofthemodel,209thatarerelevantformodularity.
Thismodelisbasedontheconceptofagentconguration,denotedby210atupleAghag,C,si,whereaghbs,ps,gsiisanagentprogramcomposedofbeliefs(agbs),plans211(agps),andgoals(aggs)andthecircumstanceofanagentChI,E,Aiincludestheintentionsofthe212agent (CI), the events perceived by the agent (CE), and the actions to be executed (CA). The labels213indicates the state of the agent in the reasoning cycled induced by the operational semantics of
the214model[12showninFig.3. Followingthiscycle,anagentcanbeseenaspermanentlyexecutingthe215followingalgorithm2161.At ProcMsg,updatetheeventsCE,perceivedbytheagent.2172.AtSelEv, select one event fromCEto be processed. If there are no events, proceed withSelIntG).2183.AtRelPl,computethesetofrelevantplans,i.e.,thesubsetofagpsusefultocopewiththeselected219event.
Iftherearenorelevantplans,proceedagainwithSelEvB).2204.AtApplPl,computethesetofapplicableplans,i.e.,thesubsetoftherelevantplansthatcanbe221executedaccordinglytoagbs. Iftherearenoapplicableplans,proceedwithSelIntG).2225.At SelAppl,selectanapplicableplan.2236.At AddIM,addtheselectedapplicableplantoCI.2247.AtSelInt, select one intention fromCIto be executed. If there are no intentions, proceed
with225ProcMsgA).2268.AtExecInt,executetheselectedintention,i.e.,taketheplaninthetopoftheintentionandprocess227therstelementofitsbody. Ifthisisanaction,addittoCA.2289.At ClrInt,clearC,aspertinent.229Figure3.TheoperationalsemanticsofAgentSpeak(L),adaptedfromBordinietal. [12.Ofparticularinterestforusistheconceptofagentprogram. Whendeninganagentprogram,230an alphabet is assumed, consisting of a nite set of symbols for variables (Var), constants
(Const),231functions(Func),predicates(Pred),andactions(Actn). Thesyntaxofag,denedinTable2,includes232Beliefs (bs). As usual, beliefs are a possibly empty set of ground rst-order atoms, as those used233inPrologtorepresentfacts. Anatom(at)isapredicateappliedtoacertainnumberofterms. A234termisavariable,aconstant,orafunctionappliedtoacertainnumberofterms.235agbs ps gsbsb1...bnj (n1)bat(ground(at))atpjp(t1,...,tn) (p2Pred,n1)tvjcjf(t1,...,tn)
(v2Var,c2Const,f2Func,n1)psp1...pn(n1)ptect hte atj atjgj gctct1j ct1atj atjct1ct1hh1 j h1ajgjujh1h1aaja(t1,...,tn) (a2Actn,n1)gsg1...gnj (n1)gatjatu bj atTable2.Thesyntaxofanagentprogramag,denedinBNFnotation.Plans(ps). Anonemptysetofplansisassumed. Eachplanphasatriggereventteexpressingfor236whicheventtheplanisrelevant. Triggereventsincludeaddingordeletingabelief,andadding237or deleting a goal a contextctexpressing the conditions that make the plan
applicable, as a238logicalformulaandabodyh. Thebodyisasequenceofactions(a),goals(g),andupdates(u),239i.e.,theadditionanddeletionofbeliefs.240Goals (gs). The agent program can include initial goals (gs), although this is not mandatory.241Achievable goals (at) are solved through practical reasoning, forming intentions with the plans242oftheagenttosolvethegoal. Testgoals(at)aresolvedthroughlogicalconsequencefromthe243beliefsoftheagent.2443.3. Bridge245Given
thegeneric nature ofthe AA meta-model, different models and implementations for the246AOP language and the agent infrastructure can be adopted. It is necessary to dene a bridge between247them,mappingtheactionsoftheagentstotheoperationsoftheartifactsandtheobservableproperties248and signals of the artifacts to the corresponding events and beliefs of the agents. The bridge can be249denedastupleBrghE,AO,Fi,where250The observable eventsEfe1,...,engis a
set of observable properties and signals generated251by the artifacts. Each eventeihid,ps,typeiis composed by the identier of the artifact252generatingtheevent(id)thecontentoftheeventcanbeanobservableproperty(p)orasignal253(s) and the type of event. Three types of events can be generated by the artifacts emitting a254signalandaddingandremovinganobservableproperty.255Amappingfromactionstooperationsisrequired. ThefunctionAO(ac)
opj9art2Envac256op2op(art)returnstheoperationopofanartifactartintheenvironmentEnv,corresponding257theactionacexecutedbyanagent.258AfocusregisterFh(ag,Art),...istoringcouplesdenotingwhichartifactsArtarefocusedby259anagentag.260Asusual,asetoffunctionstoaccessthecomponentsofthebridgeareassumed,e.g.,focus(ag)261returnsthesetofartifactsbeingfocusedbytheagentagtype(e)returnsthetypeoftheeventeand262so on. The bridge is anad hoccomponent,
strongly dependent of the AOP language and artifacts263infrastructure. Differentdenitionsarepossibleforthebridge,aslongastheyprovidethefunctionality264describedhere.2654. ModularityintheAgentsArtifactsmeta-model266Modularity in the AA meta-model is obtained through the extension shown in Fig.4 . An267agent program is now an aggregate of modules, resulting from loading at least an initial
module.268Eachmodulehasthesamecomponentsofanagentprogram,i.e.,beliefs,plans,andgoals,butevery269componentisnowassociatedwithanamespace.2704.1. Namespaces271Thesyntaxproposedforthemodules(SeeTable3)addsanamespacedeclaration(ns),whichis272alistofatoms,possiblyempty,oftheformnamespace(nid,scp),wherenidisanamespaceidentier273andscp2 flocal,globalgindicatesthescopeofthenamespace.
AsetofnamespacesNidisassumed.274Theproposedsyntaxallowsthemembersofthealphabet(Var[Const[Func[Actn)tobeprexed275withanamespaceidentier,andbecauseoftheyareusedforbeliefs,goalsandactions,byprexing276them these components are associated with a particular namespace. Plans are also associated with277namespacesgiventhattheirtriggeringeventsarebasedonbeliefsorgoals.278So, every component of a module may, or may not, be explicitly prexed
with a namespace279identier. For instance, the beliefsprice(),fixTVprice(), andfixPCprice()are all280different, since they are associated with different namespaces, as denoted by their prexes. The same281Figure4.TheAAmeta-modelextendedformodularity.strategy is followed for other components of the modules, e.g., plans, goals, actions. In this way,282namespacesprovideasyntacticsolutiontothename-collisionproblem. Thefactthattherstbelief283in the previous
example is not explicitly prexed, means its namespace is abstract. Sometimes the284namespace of a component is intended to be dened at run-time, once the module is loaded. In285such case, it is said that the component has an abstract namespace, and it is not prexed. Explicit286prexes indicate concrete namespaces. Abstract and concrete namespaces allow loading
modules287usingdifferentconcretenamespaces,enablingabehaviorclosetotheclassinstancerelationinOOP.288Inthisway,namespacescontributetoenhanceabstractionandhierarchization.289A namespace can be either global or local. Components associated with a global namespace290can be accessed anywhere in the agent program. Those associated with a local namespace are only291accessibleinthemoduledeclaringthenamespace.
Inthisway,namespacesprovideasyntacticsolution292totheinformationhidingprincipleandinterfacing. Someauxiliaryfunctionstoworkwithnamespaces293include294ids(mod) fidjid2 fmodVar[modConst[modFunc[modActng, returns the set of all the295identiersusedinthedenitionofthemodulemod.296ns(id) nsreturnsthenamespaceofanidentiernsid.297local(id) true,iffns(id) nsnamespace(ns,local)2modns,otherwiseitisfalse.298global(id) local(id).299abstract(id) true,iffns(id)
,otherwiseitisfalse.3004.2. Loadingmodules301Inthisproposal,anagentprogramagistheresultofloadingatleastonemodule,whichisnot302expressible at the syntactic level. The extended meta-model proposes a loading action for the modules.303Whena moduleis loaded,all itscomponents associatedwith theabstract namespaceare concretized.304For this, a concrete namespace identier (nid) must be specied when loading a module. Then,
the305modulecomponentsareaddedtotheagentprogramcomponents. Thefollowingsemanticrule,denes306theloadingoperationasanactionoftheagent307(Load)S(CA) load(mod,nid)hag,C,ExecInti hag0,C0,ClearIntiwheremod0mangling(mod,nid)ag0bsagbs[mod0bsag0psagps[mod0psag0gsaggs[mod0gs308modns bs ps gsnsn1,...,njj (j1)nnamespace(nid,scp) (nid2Nid,scp2 fglobal,localg)bsb1...bnj (n1)bat(ground(at))atpjp(t1,...,tn) (p2Pred,n1)jnidpjnidp(t1,...,tn)
(nidp2Pred,nid2Nid,n1)tvjcjf(t1,...,tn) (v2Var,c2Const,f2Func,n1)jnidvjnidcjnidf(t1,...,tn) (nidv2Var,nidc2Const,nidf2Func,nid2Nid,n1)psp1...pn(n1)ptect hte atj atjgj gctct1j ct1atj atjct1ct1hh1 j h1ajgjujh1h1aaja(t1,...,tn) (a2Actn1)anidajnida(t1,...,tn) (nida2Actn1)gsg1...gnj (n1)gatjatu bj atTable3.Thesyntaxofamodule,denedinBNFnotation.Algorithm 1mangling(mod,nid)replaces every abstract namespace inmodwith theconcrete namespacenid and decorates every local
namespace with an internally generatedprex,tomaketheminaccessiblefromothermodules.1beginInputmod amoduleInputnid aconcretenamespace2mod0parse(mod)3foreachid2ids(mod0)do4ifabstract(id)then5replaceidbynidid6iflocal(id)then7replaceidbynidid8returnmodThe functionS(CA)denotes the action that has been chosen to be executed by the agent.
The309manglingfunction,asusual,decoratesthecodeoftheloadedmoduleaccordinglytotheAlgorithm1.310Basically,itreplaceseveryabstractnamespaceintheloadedmodulemod,withtheconcretenamespace311nidanditdecorateseverylocalnamespacewithaninternallyauto-generatedprexdenotedbyto312makelocal namespacesinaccessible fromother modules Since theidbecomessyntactically incorrect313for the parser, but still valid for the interpreter, it can only be used locally
by the mangled module. For314instance,thebeliefprivprice(99)isreplacedbyprivprice(99),ifprivisdeclaredasalocal315namespace. Sinceprivpriceis a syntactically invalid identier, no developer can write a program316thataccessesthisbeliefitisonlyaccessibleinthemangledmoduledeclaringitsnamespace.317Loadingtheinitialmoduleofanagentisaspecialcase. Therstthinganagentprogramdoesis318loading its initial module, assumingniddefault. The initial module program
determines the initial319belief base, plan library and goals of the agent. The agent components are empty before initialization.320Observe that, since the agent program is initialized loading a module, the namespaces provide an321interface between two modules when loading. Fig.5 illustrates this When a module mod1loads a322modulemod2,interactionsarebidirectional.
Thecomponentsofbothmodulesassociatedwithlocal323namespacesarekeptseparateineachmodule. Thecomponentsofmod2,associatedwithanabstract324namespace, are imported bymod1, concretizing their abstract namespace the concrete namespace,325provided bymod1, is used to extendmod2. The components ofmod2, associated with a concrete global326namespace, are imported bymod1 those ofmod1extendsmod2. This enables a relation close to the327OOP,
where the loaded modulemod2source code can be seen as a template, and each load as an328instantiation referred by the concrete namespace provided at loading time. This allows to dynamically329extend the functionality of modules in two ways. i) by adding components to the concrete namespace330used to load a module (instantiate), it is possible to extend the functionality for only such
module331instanceandii)toextendthefunctionalityeffectingalltheinstancesofthesamemodule,byadding332componentstotheglobalnamespacesofsuchmodule. Inthisway,namespacesprovideasyntactic333approachforinterfacing.334Figure5.Theinterfacewhenmodulemod1loadsthemodulemod2.Althoughloadis a semantic rule, it is indeed a case of the rule for executing actions dened in335AgentSpeak(L). The resultof executingloadis strictly syntactical, an agent
programagdecorated with336namespaces. Thismeans thatthe semanticsofAgentSpeak(L)and itsinterpreter donot requirefurther337intervention.3384.3. ArtifactsandNamespaces339Namespaces provide a syntactic solution for integrating the perceptions and the actions of agents340into modules. For this, the bridge (Brg) needs to be extended to support namespaces. The
bridge341includes342AfocusregisterFh(ag,Art),...istoringcouplesdenotingwhichartifactsArtarefocusedby343an agentag. But in this version of the register, eachart2Arthas the form(art,Nid), expressing344thattheartifactartisfocusedbytheagentusingnamespacesNid.345A set of functions to access the components of the focus register are assumed, e.g.,346focus(ag,art) Nidreturnsthenamespacesusedbyagentagtofocusonartifactart.347This simple syntactic arrangement,
allows the denition of modularity aware of actions for348creating, focusing, perceiving, using, and disposing artifacts. In what follows, the transition rules349for these actions will be dened. Observe that these are transitions between states of a MAS under350the AA meta-model, i.e., states have the formhAgs,Brg,Envi. Most of the time, a single agent351perspective is adopted, replacing the set of agents in the systemAgs, with a single agent
conguration352Aghag,C,si.3534.3.1. Creatingartifacts354Creating artifacts does not involve namespaces. As usual, an agent can create an artifactartid355oftypeartType,byexecutingtheactionmakeArtifact,providedbytheenvironment(Env). Weuse356functionmakeArtifact2todenotethelow-levelprocessofinstantiatinganartifact. Auniqueidentier357(id)generatedthroughthefunctionnewUniqueId()isusedtorefertheartifact,whichisaddedtothe358environment359(MakeArt)S(CA)
makeArtifact(artType)hhag,C,ExecInti,Brg,Envi hhag,C,ClearInti,Brg,Env0iwhereidnewUniqueId()artmakeArtifact(id,artType)Env0Env[fartg3604.3.2. Focusingonartifacts361Anagentstartsperceivinganartifactart2Env,byexecutingtheactionfocus,providedbythe362environment. Inthisapproach,anamespacemustbeprovidedwhenfocusing363(Focus)S(CA) nidfocus(art)hhag,C,ExecInti,hE,AO,Fi,Envi
hhag0,C0,ClearInti,hE,AO,F0i,EnviwhereF0F[f(ag,(art,fnidg))gag0bsagbs[fnidpjp2pr(art)gC0ECE[fnidpjp2pr(art)g364Forexample,supposeanagentfocusonanartifactauctionToolwithanassociatednamespace365auc1. IftheartifactincludesanobservablepropertycurrentBid(9),thenasaresultoffocusing,the366beliefauc1currentBid(9)isaddedtothebeliefsoftheagent. Acorrespondingeventtothebelief367addition is placed in the agent's events queue too. Observe that an agent can
focus in the same artifact368withdifferentassociatednamespaces,replicatingperceptionfromanartifactinmultiplemodules.3694.3.3. ObservableEvents370Theartifactsproduceobservableeventsthatareperceivedbytheagentsfocusingonthem. This371meansthatsome eventsinCEcomesfromthe bridge,generatedbysomeartifact intheenvironment.372Since there are three types of observable events, the same number of transition rules are
required.373Observethattheseactionsarenotactuallyexecutedintentionallybytheagent. Observethatthey374areexecutedatsProcMsgtoupdatetheeventsandbeliefsoftheagent. Theyareasfollows375Signals. The events generated from artifact signals are also associated with a corresponding376namespace. Signals from artifacts are placed as events in every namespace used to focus the377artifact.
Forinstance,asignaltickproducedfromartifacttool,focusedbysomeagentusing378namespacesns1andns2,produceseventsns1tickandns2ticktobeprocessedbythe379reasoning cycle of the agent. Since signals stand for non persistent events, the agent's belief base380isnotupdated381(Signal)S(E) hid,s,signalihhag,C,ProcMsgi,hE,AO,Fi,Envi hhag,C0,ProcMsgi,hE0,AO,Fi,EnviwhereC0ECE[fnidsg jnid2focus(ag,art(id))gE0Enfhid,s,signalig382Observable property addition. This
type of percept is produced when an observable property is383added in some artifact being observed by the agent. The observable property is added to the384agent's belief base, in every namespace used to focus the artifact. An event reecting this is385addedtoo. Theperceptisremovedafterbeingprocessed386(ObsPropAdded)S(E) hid,p,obsPropAddedihhag,C,ProcMsgi,hE,AO,Fi,Envi hhag0,C0,ProcMsgi,hE0,AO,Fi,Enviwhereag0bsagbs[fnidpg
jnid2focus(ag,art(id))gC0ECE[fnidpg jnid2focus(ag,art(id))gE0Enfhid,p,obsPropAddedig387Observable property deletion. When an observable property has been deleted from some artifact388being focused, such observable property is removed from every namespace used to focus the389artifact. Aneventtonotifythebeliefdeletionisgenerated,andtheperceptisremoved390(ObsPropDel)S(E) hid,p,obsPropDelihhag,C,ProcMsgi,hE,AO,Fi,Envi
hhag,C0,ProcMsgi,hE0,AO,Fi,Enviwhereag0bsagbsnfnidpg jnid2focus(ag,art(id))gC0ECE[fnidpg jnid2focus(ag,art(id))gEEnfhid,p,obsPropDelig391Observable property updates can be handled as a sequence of rules(ObsPropAdded)and392(ObsPropDel). However,atimplementationlevelafourthtypeofobservableevent,standingforan393artifactobservablepropertyupdate,isconsideredforpracticalreasons.3944.3.4.
Stopfocusingartifacts395AgentscanstopfocusingartifactsbyexecutingtheactionstopFocus. Thiscausesthatthepercepts396andoperationsofaspecicartifactceasetobemappedtotheagent397(StopFocus)S(CA) nidstopFocus(id)hhag,C,ProcMsgi,hE,AO,Fi,Envi hhag0,C0,ProcMsgi,hE,AO,F0i,EnviwhereF0Fnf(ag,(art(id),nid))gag0bsagbsnfnidpjp2pr(art(id))gC0ECE[fnidpjp2pr(art(id))g3984.3.5. Artifactsdisposal399Artifact disposal complements the artifact creation. When an artifact is
disposed, every belief and400action related to the artifact is removed, and the artifact is not longer eligible to be focused, because it401is also removed from the environment. Events to notify and reect belief deletions are produced to be402processedifnecessary. Agentscanusetheactiondisposetoeliminateartifacts403(Dispose)S(CA) niddispose(id)hhag,C,ProcMsgi,hE,AO,Fi,Envi
hhag0,C0,ProcMsgi,hE,AO,F0i,Env0iwhereF0Fnf(ag,(art(id),nid))gag0bsagbsnfnidpjp2pr(art(id))gC0ECE[fnidpjp2pr(art(id))gEnv0Envnfart(id)g4044.3.6. Operationexecution405Theexecutionofanactionacassociatedwithsomenamespacedenotedbynid,isprocessedas406follows407(ExecAct)S(CA) nidacOA(ac) opnid2focus(ag,art(op))exec(op)hhag,C,ProcMsgi,hE,AO,Fi,Envi hhag,C,ProcMsgi,hE,AO,Fi,EnviwhereC0ACAnfnidacg408The rule results in matching an actionacwith a
corresponding operationop, with the restriction409that the namespacenidassociated with actionacmust be currently used to focus on the artifact410implementingop. In other words, the actionacis successfully executed only if a corresponding411operationoptoacisavailableinnamespacenid. Theexecutionofoperationiscarriedonbyfunction412exec(...). Finally, it must be highlighted that default artifact operations,
e.g.,makeArtifact,focus,413etc.,areavailableinanynamespace.4145. Implementation415In order to evaluate our proposal, it has been implemented in JaCa the integration of Jason [12416an extended interpreter for AgentSpeak(L) [11implementedinJavaandCArtAgO[13an417infrastructure based on the AA meta-model, implemented in the same language. Some general418implementation issues are discussed here, before introducing a case study in the next section.
The419implementation consists basically in extending Jason for allowing namespaces and providing two420ways of loading modules and extending the bridge with CArtAgO for allowing the artifacts to exploit421namespaces too. Both extensions are merely syntactical, i.e., the interpreter of Jason and the CArtAgO422implementation do not change, warranting in this way, full backward compatibility with non-modular423MASwritteninJaCa.424Jason is extended exploiting
its facilities to adopt user dened pre-processing directives. A425pre-processingdirectivenamespace2isaddedforallowingthedeclarationofnamespaces. Therst426argument of the directive is the identier of the namespace, and the second one is its scope (local427or global). The identiers of the expressions enclosed within this directive are associated with the428specied namespace. Other identiers can be associated to the namespace by prexing them with
the429correspondingnamespaceidentier.430The pre-processing directiveinclude, and the internal action.include, are extended to take a431secondparameterforsupportingnamespaces. BothimplementtheruleloaddenedinSection4.2.432Theirrstargumentisthelewiththesourcecodeofthemodule,andtheirsecondargumentisits433associated namespace. If a free variable is passed as the second argument of.include, an unique434namespaceidentier isinternally auto-
generated,it isbounded tothe variable,and then,it isused to435loadthemodule. Theinternalactionanddirectivecanbeusedtodynamicallyandstaticallyloading436modules,respectively.437For practical reasons, the identiers used for terms are associated with the default namespace438when a module is loaded, as long as they are not explicitly prexed. However, a term prexed
with439isassociatedwiththeabstractnamespace,e.g.,instartedAuct(tool),thetermtoolisassociated440with the abstract namespace. Jason keywords, as well as strings, lists and numbers terms can not441be associated with namespaces. Jason denes two types of actions An external action changes the442environment,unlikeaninternalactionwhichisexecutedinternallytotheagent. Internalactionscan443notbeassociatedwithnamespaces,whileexternalactionscan.444The bridge
between Jason and CArtAgO is also customized to deal with namespaces. Jason445implements this bridge as an agent architecture class, dening how percepts and actions are handled.446ThisclassisextendedtoimplementtherulesintroducedinSection4.3.447ArtifactsareinstancesoftheJavaclassArtifact,providedbyCArtAgO.Theycanbedenoted448by an identier, as dened in Section3.1 , and by a name dened by the programmer. Names are449implemented as a Jason term,
allowing then the use of namespaces to avoid name clashes when450using them inmodules. If a namespaceis not explicitly speciedwhen creating an artifact, thedefault451namespaceisadopted,becausetermsareassociatedwithsuchnamespacebydefault.452Observe that the operations provided by the artifacts are invoked by the agents through their453externalactions. Theseactionscanbeannotatedtoindicatetheartifactpreferredbytheagentwhen454executing an action.
Such annotations have precedence over the namespace prex. The predened455operations, exceptingfocusandfocusWhenAvailable, which have a different semantic regarding456namespaces,omittheprexbecausetheyareavailableineverymodule.4576. Casestudy458This section illustrates our proposal in detail, presenting a MAS for running auctions to contract459services1. The modulesauctionandparticipant(Codes6 and 7 ) encapsulate the functionality to460create
andparticipatein anauction, respectively. The MASis composedof theauctioneer agentsbob461andalice, whoseinitialmodulesarepresentedinCodes2and3respectivelyand theparticipants462companyAandcompanyB(Codes4and5). Inthisimplementation,everyinstanceofmoduleauction463isolates the beliefs and events of each negotiation, so that they do not interfere with other negotiations464orevenothermodulecomponents.
Ourcasestudyshowshowtheperceptsandactionsfromobserved465artifactsareindependentlyhandledbymultiplemodulesfortheirownpurposes.466Artifacts of typeAuctArt(Code1 ) are used by auctioneers and participants to manage their467auctions. Theseartifactsarecreatedandinitializedbytheauctioneers,usingataskdescriptionand468the initial price as parameter, e.g., line9 of Code 6 . They provide an operationbidfor placing an469offer, e.g., lines19 -26 and an
operationclosefor closing an auction. When an auction nalizes the470corresponding artifact signals the nal winner (c.f. line16 of Code 1 ). Agents focusing the artifact can471perceive through the artifact's observable properties and signals, the task being auctioned, current472bid,currentwinnerandthenalwinner.
Ourcasestudyshowshowtheperceptsandactionsfrom473observedartifactsareindependentlyhandledbymultiplemodulesfortheirownpurposes.474Theagentbobcreatesmultipleauctions. Itusestheinternalaction.include2fordynamically475loadingmoduleauction(line14)andtostartanauctionforeachelementinagivenlistoftasks(initial476goal at line2 ). It uses dynamic denition of namespaces (second parameter of action include is a477variable) to encapsulate the internal state of
each auction it creates, such that each namespace used to478loadthemodulecanbeseenasanauctioninstancefromtheauctioneer'spointofview. Postingthe479sub-goalstartinnamespaceAlaunchestheauction(line18). Next,theagentbobwaitsuntilaxed480deadline has expired to close all auctions (lines4 -9). The agents participating in those auctions
can481observethecorrespodingartifactstondoutthenalwinners.4821Thecompleteversionoftheexampleisavailablefordownloadathttpssourceforge.netprojectshouse-building1public class AuctArt extends Artifact 23privateb ooleano pentrue45public void init(String taskDesc, double maxPrice) 6defineObsProperty(task,t askDesc)7defineObsProperty(currentBid,m axPrice)8defineObsProperty(currentWinner, nowinner)91011@OPERATION12public void close() 13ObsProperty
opCurrentWinner getObsProperty(currentWinner)14if(getOpUserName().equals(getCreatorId().getAgentName()))15openfalse16signal(won,o pCurrentWinner.stringValue())171819@OPERATION20public void bid(double bidValue) 21ObsProperty opCurrentValue getObsProperty(currentBid)22ObsProperty opCurrentWinner getObsProperty(currentWinner)23if (open bidValue opCurrentValue.doubleValue())
24opCurrentValue.updateValue(bidValue)25opCurrentWinner.updateValue(getOpUserName())2627Code1.AuctArt.java1 an initial goal2contract([site,wall,floor,roof,pool).34contract([)5- .wait(2500) a deadline6 close auctions and notify winners7for(AinstanceOf(auction))8Aclose9.1011contract([TTs)12- v arA i sb oundedt oa u niquen spi d13 one instance for each auction14.include(auction.asl,A)15 starts auction for task T,16 no maximum price17 posts a sub-goal with
new focus18Astart(T,9999)19contract(Ts).20Code2.bob.asl1include(logger.asl,log) s taticl oad23begin namespace(priv,local)4maxprice(floor,1200).5maxprice(plumbing ,600).6maxprice(pool,1000).7end89contract([floor,plumbing,pool).1011contract([)12- .wait(4500)13for(AinstanceOf(auction))14Aclose15.16contract([TTs)privmaxprice(T,P)17- .include(auction.asl,A)18Astart(T,P)19logfocusWhenAvailable(Atool)20contract(Ts).Code3.alice.aslAgentaliceruns auctions for
building a pool and setting up the oor and plumbing of its house483(line9 ). It statically denes local namespaceprivfor hiding its maximum price for each task from484other modules (line3 ). The identiers without an explicit namespace between lines4 and 6 will be 485placedinthelocalnamespacepriv. Artifactsarecreatedatline9ofCode6,andthebeliefs,eventsand486actions mapped from them are handled by the instances of moduleauction. The line1 loads module
487logger, which provides functionality for informing the progress of specic auctions. A pre-processing488directiveinclude2isusedtoperformastaticloadingoflogger. Agentalicealsoplacesthepercepts489from the auction artifacts into namespacelog(line19 in this way, the events produced from them can490be independently used by moduleloggerfor printing out information about the progress of auctions.491Dynamic loading and namespaces allowbobandaliceto
encapsulate the components related to492aparticularauction,e.g.,observehowauctioneeragentscaninitializeanauctionusinganidentical493nameforatask,withoutproducinganame-collision.494ThecompanyAis interested in auctions for taskssite,wallandroof. It participates only in495auctions executed byalice. When an auction starts under these conditions. The directive.include2496isusedforloadingthemoduleparticipant(line1).
Thisagentextendsthefunctionalityofthemodule4971include(participant.asl,p)23myprice(1650). minimum plus 15045 acceptable tasks6paccept([site,wall,roof).78ptrust([alice).trustedagents910 I can improve a bid if11pimprove(Bid,T,Bid-150)- myprice(P) P Bid.Code4.companyA.asl1include(participant.asl,p)23myname(companyB).45overworked - myname(Me)6 .count(AcurrentWinner(Me),C) C 3.78pacceptable().9ptrust(All) -
.allnames(All).10pimprove(Bid,,math.random(999)800)11-n oto verworked.Code5.companyB.asl1instanceOf(auction).23namespace(priv,local) f orwardd efinition45@p1[atomic6start(Task,MaxPrice)7- associates a term with abstract nsp8makeArtifact(tool,9jcm.AuctArt,[Task,MaxPrice,Aid)10privstate(open)11.broadcast(tell, started(Task))12 percepts from Aid go to abstract nsp13focus(Aid).1415 operator - updates beliefs16@p2 close - -privstate(closed) close.1718 allow
other modules get the state of auction19@p3 state(S) - privstate(S).20@p4 -state(none).Code6.auction.asl1acceptable(T) - accept(Ts) .member(T,Ts).2trusted(Ag) - trust(Ags) .member(Ag,Ags).34@p[atomic5Astarted(Task)[source(Ag)6 trusted(Ag) acceptable(Task)7- .include(bidder.asl,A)8Aimprove(Bid,MyBid)9- improve(Bid,Task,MyBid)1011 used here to focus byn ame12AfocusWhenAvailable(Atool).1314 auction artifact produces a signal15 to notify the final
winner,16 react if iti sm e1718Awon(MeS)19 .myname(Me) .term2string(Me,MeS)20- println(IW onA uction,A,).Code7.participant.aslinstance by adding beliefs to the namespace where the module was loaded (p) namely, it adds beliefs498abouttasksofinterestandtrustedagents(lines6and8). Theagentsetsupitsstrategyforparticipating499in auctions at line11 . The moduleparticipantuses the beliefs added to the namespace where it500was loaded to decide what tasks can
be accepted, what agents are trusted and to know how much501and when to bid (cf. lines6 ,8 and 9 of Code 7 ). A different strategy is adopted by thecompanyB,502who accepts all auctions but never commits to a new task if it is overworked, i.e., it abstains from503participating in an auction if it is already winning more than three (lines5 -6of Code 5 ). ThecompanyB504bidsaboundedrandomquantity(line11).505Theauctionmodule encapsulates the functionality to
create and manage an auction. It starts506with a belief used to identify the module instances, specically, those namespaces used as an instance507of moduleauction, e.g., lines7 and 13 of Codes 2 and 3 , respectively. Next, a forward declaration508of the local namespaceprivin line3 is dened. Observe that the namesp aceof start2is abstract,509andaconcretenamespacewillbegivenwhenthemoduleisloaded(lines14,17and7ofCodes2,3510and7,respectively).
Theauctionmoduleexportselementsassociatedwiththeabstractnamespace,511e.g., plans@p1and@p2. The local namespaceprivis not visible to other modules, thus it does not512interfereorclashwithanynamespaceinothermodules,eveniftheyhavethesamename,e.g.,line5133of Code 3 . Namespaceprivin moduleauctionis used to encapsulate the belief representing the514currentstateofarunningauction,itmeansthatsuchbeliefisaccessibleonlyfromthismodule,e.g.,515line10 .
However, a loader module can retrieve the current state of the auction by me

Report Generated on March 10, 2020 by prepostseo.com

You might also like