- aspectt - um framework orientado a aspectos para smas alessandro garcia uirá kulesza {afgarcia,...
TRANSCRIPT
- AspectT -Um Framework Orientado a Aspectos
para SMAs
Alessandro GarciaUirá Kulesza
{afgarcia, uira}@inf.puc-rio.br
16 Novembro, 2004
Laboratório de Engenharia de Software – PUC-Rio 2
Revisão
• Frameworks Conceituais• Linguagens de Modelagem• Metodologias
• Frameworks e Plataformas– MAS Framework, RETSINA, ...– JADE e JADEX– AspectT
Laboratório de Engenharia de Software – PUC-Rio 3
Roteiro• Motivação• O Framework Orientado a Aspectos
• Propriedades de Agência• Limitações de Soluções Relacionadas• Desenvolvimento Orientado a Aspectos
• O Framework Orientado a Aspectos para SMAs– A Arquitetura – Os Pontos de Flexibilidade– O Método de Desenvolvimento
• Um Estudo de Caso
• Estudos Empíricos• Conclusões
Laboratório de Engenharia de Software – PUC-Rio 4
From Objects to Agents…
• An agent architecture includes:– basic functionality or services– interaction, adaptation, autonomy, learning, roles…
• Incorporation of agent properties into the system is a major source of complexity
• Separation of agent-specific concerns is crucial– reusability and maintainability
Laboratório de Engenharia de Software – PUC-Rio 5
Collaboration
Mobility Learning
Roles
The Problem
• The agent properties are not orthogonal– crosscut each other and the agent’s basic functionality
Interaction
Adaptation Autonomy
Basic Functionality
architectural component
Some properties: - required as the system evolves - dynamic replacement
Laboratório de Engenharia de Software – PUC-Rio 6
The Problem
• Multiple agent types heterogeneous architectures
Collaboration
Mobility Learning
Roles
Interaction
Adaptation Autonomy
Basic Functionality
Reactive Information Agents
Interaction
Adaptation Autonomy
Learning
Roles
Cognitive User Agents
Basic Functionality
Laboratório de Engenharia de Software – PUC-Rio 7
The Problem
• Multiple agent types heterogeneous architectures
Collaboration
Mobility Learning
Roles
Interaction
Adaptation Autonomy
Agenthood
AdditionalProperties
Basic Functionality
Reactive Information Agents
Interaction
Adaptation Autonomy
Agenthood
AdditionalProperties
Mobility Learning
Roles
Cognitive User Agents
Basic FunctionalityNeed for a more flexiblearchitectural approach
Laboratório de Engenharia de Software – PUC-Rio 8
Col
labo
ratio
n
The Problem: Detailed Design ViewAgent
goals...
addGoal()executePlan()…
InterfaceAgent
receiveInstruction()monitor()...
InformationAgent
search(Keyword)search(Keywords)…
UserAgent
getUser()checkPreference()…
Role
agentsprotocol
Caller
sendRequest()receiveResponse()...
Answerer
receiveRequest()sendResponse()...
Plangoal
preCond()posCond()…
action1()action2()...
Plan1action1()action2()action3()...
Plan2
Basic Functionality
getName()addAgent()…
caller answerer
DB userNameuser
efectorsadaptersthreads
adapters
move()returnHome()
itinerary
processInformation()
LCs
processInformation()
LCs
move()returnHome()startRole()
itineraryremoteEnvironmentsroles
processInf ()startRole()
LCsroles
processInf ()
LCs
sendMsg()receiveMsg()addAdapter()removeAdapter()notifyAdapters()makeDecision()startThread()
roles
startRole()
addAdapter()removeAdapter()notifyAdapters()
Mobility
Collaboration Adaptation
Autonomy
Interaction Learning
public Result searchKW(String KW) { adaptKnowledge(KW); processInformation(KW); ... ... << searching-specific code >> ... ... if (result = null) { this.move(KW) }}
Laboratório de Engenharia de Software – PUC-Rio 9
The Problem: Detailed Design View
LMSprocessInformation()getLR()…
LearningComponent
learningRateprocessInformation()…
TD-LearningprocessInformation()getTD()getReward()setReward()…
Agentgoalsplans...
addGoal()executePlan()…
InterfaceAgentreceiveInstruction()monitor()...
InformationAgentsearch(Keyword)search(Keywords)…
UserAgentgetUser()checkPreference()…
Role
agentsprotocolgetName()addAgent()removeAgent()…
Caller
sendRequest()receiveResponse()...
AnswererreceiveRequest()sendResponse()...
Learning Crosscutting concerns Code replication Functional encapsulation is lost Difficult to transform objects into agents …
Drawbacks
MASs difficult to understand, maintain and reuseMASs difficult to understand, maintain and reuse
Laboratório de Engenharia de Software – PUC-Rio 10
Solution
• AspectT: An Aspect-Oriented Framework– Modularization of crosscutting agent concerns– Flexible composition of agent properties– (Un)pluggability of agent properties– From objects to agents: transparent evolution– Avoidance of code replication– Improvements on reusability and maintainability
Laboratório de Engenharia de Software – PUC-Rio 11
Agent Properties
– Agenthood Concerns [OMG00]:• Knowledge, Interaction, Autonomy, and Adaptation
– Additional Concerns: • Mobility, Learning, and Collaboration
OBJECT MANAGEMENT GROUP – AGENT PLATFORM SPECIAL INTEREST GROUP. Agent Technology – Green Paper. Version 1.0, September 2000.
Laboratório de Engenharia de Software – PUC-Rio 12
Concerns in Multi-Agent Systems
• Agenthood Concerns
Knowledge
Legend:
mandatory feature
optional feature
alternative feature or feature
IntrinsicKnowledge
KnowledgeType
ProceduralRepresentation
KnowledgeRepresentation
… SemanticNets
Knowledge
KnowledgeStructuring Model
ExtrinsicKnowledge
Belief
Goal
Plan
Action
Pre-Conditions Post-Conditions
IntrinsicKnowledge
KnowledgeType
ProceduralRepresentation
KnowledgeRepresentation
… SemanticNets
Knowledge
KnowledgeStructuring Model
ExtrinsicKnowledge
Belief
Goal
Plan
Action
Pre-Conditions Post-Conditions
Laboratório de Engenharia de Software – PUC-Rio 13
Concerns in Multi-Agent Systems
• Agenthood Concerns
Interaction Adaptation
SensoryBehavior
MessageSending
InteractionBehavior
Interaction
EffectorSensor
MessageReception Knowledg
eAdaptatio
n
BehaviorAdaptatio
n
Adaptation
Adaptation
Protocol
Kind ofAdaptatio
nAdapter
Legend:
mandatory feature
optional feature
alternative feature or feature
1..* 1..*1..*
Laboratório de Engenharia de Software – PUC-Rio 14
Concerns in Multi-Agent Systems
• Agenthood Concerns
Autonomy
Legend:
mandatory feature
optional feature
alternative feature or feature
ExecutionAutonomy Decision
Autonomy
Autonomy
ProactiveAutonomy
ThreadStrategy
Laboratório de Engenharia de Software – PUC-Rio 15
Concerns in Multi-Agent Systems
• Additional Concerns Collaboration Learning
Learning
LearningProtocol
LearningTechnique
Legend:
mandatory feature
optional feature
alternative feature or feature
TD-Learning … LMS
Role
ExtrinsicKnowledge
Role Type
Collaboration
Protocol
Collaboration
AgentProperty
*
1..*1..* 1..*
Laboratório de Engenharia de Software – PUC-Rio 16
Concerns in Multi-Agent Systems
• Additional Concerns Mobility
Legend:
mandatory feature
optional feature
alternative feature or feature
MobilityStrategy
WeakMobility
StrongMobility
Mobility
MobilityForm
Laboratório de Engenharia de Software – PUC-Rio 17
Related Work
• The need for separation of agent concerns is widely recognized
• JAFIMA Framework [Kendall99]– Layered architectures
• Brainstorm Framework [Ama98]– Reflective architectures [Briot99, Ama98]
• SkeletonAgent Framework [Camacho03]– Mediator-based architectures
Laboratório de Engenharia de Software – PUC-Rio 18
Related Work – Agent Architectures
ADAPTATION
KNOWLEDGE
SENSORY
AUTONOMY
COLLABORATION
TRANSLATIONTRANSLATION
MOBILITY
KENDALL, E. et al. A Framework for Agent Systems. Implementing Application Frameworks – Object-Oriented Frameworks at Work, M. Fayad et al. (eds.). John Wiley & Sons: 1999.
• JAFIMA Framework– Layered Agent Architecture [Kendall99]
Laboratório de Engenharia de Software – PUC-Rio 19
Col
labo
ratio
n
Knowledge
Layered Agent Architectures
Agent Beliefs
nameaddAdapter()removeAdapter()notifyAdapters()
PrimitiveBeliefs
…
CompositeBeliefs
update()
ObservableaddAdapter()removeAdapter()notifyAdapters()
Adapter
adapt()
Observer
goalsplansadaptersaddAdapter()removeAdapter()notifyAdapters()addAgent()removeAgent()executePlan()...
RolecollaboratingAgentscollaborationProtocoladaptersaddAdapter()removeAdapter()notifyAdapters()addAgent()…
ChairpaperssubmissionDeadlinereviewDeadlineaddAgent()removeAgent()…
Reviewer
MyPapernew()coauthorskeywordspublisherstatus
chairtoReviewPapersreviewDeadlinefillForm()updateForm()getChairName()…
Legend:Adaptation Concern
public void fillForm(...) { ... notifyAdapters(); ...}
Adaptation
Laboratório de Engenharia de Software – PUC-Rio 20
Reflective Agent Architecture
MOP
Base Level
Meta-Level
object(intrinsic
knowledge)
interactionmeta-object
adaptationmeta-object
autonomymeta-object
Agent A
object(intrinsic
knowledge)
interactionmeta-object
adaptationmeta-object
autonomymeta-object
Agent Blearning
meta-objectmobility
meta-object
messageinterception
messageinterception
Legend:Adaptation Concern
• E.g.: Brainstorm, Meta-DIMA, …
Laboratório de Engenharia de Software – PUC-Rio 21
Mediator-Based Architectures
• Mediator-Based Agent Architectures [Cam03]
Mediator
Interaction Adaptation
MobilityLearning Bidirectional coupling
Laboratório de Engenharia de Software – PUC-Rio 22
Mediator-Based Architectures
Laboratório de Engenharia de Software – PUC-Rio 23
Related Work – Detailed Design
• Use of OO design patterns– Interaction: Adapter Pattern [Kendall99]– Adaptation: Observer Pattern [Kendall99]– Roles: Role Object Pattern [Baumer97]– Learning: Observer Pattern with Strategy Pattern [SML04]– Mobility: Itinerary Pattern [UT01]
• The design patterns are not able to modularize crosscutting agent concerns
Laboratório de Engenharia de Software – PUC-Rio 24
Col
labo
ratio
n
Basic Functionality
Related Work – Detailed Design
• Adaptation: Observer Pattern [Kendall99]
Agent Beliefs
nameaddAdapter()removeAdapter()notifyAdapters()
PrimitiveBeliefs
…
CompositeBeliefs
update()
ObservableaddAdapter()removeAdapter()notifyAdapters()
Adapter
adapt()
Observer
goalsplansadaptersaddAdapter()removeAdapter()notifyAdapters()addAgent()removeAgent()executePlan()...
RolecollaboratingAgentscollaborationProtocoladaptersaddAdapter()removeAdapter()notifyAdapters()addAgent()…
ChairpaperssubmissionDeadlinereviewDeadlineaddAgent()removeAgent()…
Reviewer
MyPaper
new()coauthorskeywordspublisherstatus
chairtoReviewPapersreviewDeadlinefillForm()updateForm()getChairName()…
Legend:Adaptation Concern
public void fillForm(...) { ... notifyAdapters(); ...}
Laboratório de Engenharia de Software – PUC-Rio 25
Crosscutting Concerns in MASs
• 6 Classical Crosscutting Concerns– Interaction, Adaptation and Autonomy– Collaboration, Learning and Mobility
Laboratório de Engenharia de Software – PUC-Rio 26
Interaction
• Motivation Example
PersonalAgenda
timeSlots…addAppointment()addMeeting()notifyAgent()…
PersistentCurriculum
addResearchKW()addPublication()addAward()addConference()updateAddress()…
InitialInterface
barCollor…getUserAnswer()getAnswerTime()…
Agentbelief1belief2...
action1()action2()...
action1()action2()action3()action4()...
Plan1action1()action2()action3()action4()...
Plan2
…action1()action2()action3()action4()...
Chairaction1()action2()action3()action4()...
Reviewer
Kernel Collaboration
Environment
Effector SensorsenseEvent()receiveMsg()...
send()...
Legend:Interaction Concern
effectorssensorsinboxoutbox...
receiveMsg()sendMsg()senseEvent()
Laboratório de Engenharia de Software – PUC-Rio 27
Kernel Collaboration
Environment
Interaction• Motivation Example
PersonalAgenda
timeSlots…addAppointment()addMeeting()notifyAgent()…
PersistentCurriculum
addResearchKW()addPublication()addAward()addConference()updateAddress()…
InitialInterface
barCollor…getUserAnswer()getAnswerTime()…
Agentbelief1belief2sensorsinboxoutbox...
action1()action2()receiveMsg()sendMsg()senseEvent()...
action1()action2()action3()action4()...
Plan1action1()action2()action3()action4()...
Plan2
…action1()action2()action3()action4()...
Chairaction1()action2()action3()action4()...
Reviewer
effectorssensorsinboxoutbox...
receiveMsg()sendMsg()senseEvent()
Legend:Interaction Concern
public void actionN(...) { ... agent.sendMsg(); ...}
public void addPublication(...) { ... sensor.senseEvent(); ...}
Effector SensorsenseEvent()receiveMsg()...
send()...
Laboratório de Engenharia de Software – PUC-Rio 28
Interaction
Kernel Collaboration
Environment
PersonalAgenda
timeSlots…addAppointment()addMeeting()notifyAgent()…
PersistentCurriculum
addResearchKW()addPublication()addAward()addConference()updateAddress()…
InitialInterface
barCollor…getUserAnswer()getAnswerTime()…
Agentbelief1belief2sensorsinboxoutbox...
action1()action2()receiveMsg()sendMsg()senseEvent()...
action1()action2()action3()action4()...
Plan1action1()action2()action3()action4()...
Plan2
…action1()action2()action3()action4()...
Chairaction1()action2()action3()action4()...
Reviewer
effectorssensorsinboxoutbox...
receiveMsg()sendMsg()senseEvent()
Legend:Interaction Concern
public void actionN(...) { ... agent.sendMsg(); ...}
public void addPublication(...) { ... sensor.senseEvent(); ...}
• Problem: How to separate the interaction concern from the other agency concerns?
Effector SensorsenseEvent()receiveMsg()...
send()...
Laboratório de Engenharia de Software – PUC-Rio 29
Adaptation
• Motivation Example
Col
labo
ratio
n
Kernel
Agent Beliefs
nameaddAdapter()removeAdapter()notifyAdapters()
PrimitiveBeliefs
…
CompositeBeliefs
update()
ObservableaddAdapter()removeAdapter()notifyAdapters()
Adapter
adapt()
Observer
goalsplansadaptersaddAdapter()removeAdapter()notifyAdapters()addAgent()removeAgent()executePlan()...
RolecollaboratingAgentscollaborationProtocoladaptersaddAdapter()removeAdapter()notifyAdapters()addAgent()…
ChairpaperssubmissionDeadlinereviewDeadlineaddAgent()removeAgent()…
Reviewer
MyPaper
new()coauthorskeywordspublisherstatus
chairtoReviewPapersreviewDeadlinefillForm()updateForm()getChairName()…
public void fillForm(...) { ... notifyAdapters(); ...}
Legend:Adaptation Concern
• Problem: How to separate the adaptation concern from the other agency concerns?
Laboratório de Engenharia de Software – PUC-Rio 30
Collaboration
• RolesThe Role Object Pattern withThe Decorator Pattern [KO96]
UserAgent
CollaborativeUserAgent
addRole()getRole()hasRole()getInterests()getAgenda()getResearchStage()…
userNamemyRolesresearchInterestsresearchersinformationAgentsgetInterests()getStage()getAgenda()…
UserAgentRole
userAgentCoregoalsplanscollaboratingAgentscollaborationProtocolgetInterests()getResearchStage()getAgenda()
CallerpaperssubmissionDatereviewDeadline…
Reviewer
papersToReviewchairNamereviewDatebiddingDate…
Agent
getName()setGoal()setPlan()…
roles
agent core
ChairpaperssubmissionDatereviewDeadline…
AdditionalReviewer
reviewer…
Legend: ____ replicated code
Decorator classes
Collaboration concern
intrinsic role
extrinsic roles
interface toall roles
PlanexecutePlan()
Laboratório de Engenharia de Software – PUC-Rio 31
Collaboration
UserAgent
CollaborativeUserAgent
addRole()getRole()hasRole()getInterests()getAgenda()getResearchStage()…
userNamemyRolesresearchInterestsresearchersinformationAgentsgetInterests()getStage()getAgenda()…
UserAgentRole
userAgentCoregoalsplanscollaboratingAgentscollaborationProtocolgetInterests()getResearchStage()getAgenda()
CallerpaperssubmissionDatereviewDeadline…
Reviewer
papersToReviewchairNamereviewDatebiddingDate…
Agent
getName()setGoal()setPlan()…
roles
agent core
ChairpaperssubmissionDatereviewDeadline…
AdditionalReviewer
reviewer…
intrinsic role
extrinsic roles
interface toall roles
PlanexecutePlan()
• Problem: How to separate the roles from the agent’sbasic functionality?
• Avoid code replication
Legend: ____ replicated code
Decorator classes
Collaboration concern
Laboratório de Engenharia de Software – PUC-Rio 32
Learning• The Observer Pattern with the
Strategy Pattern [SML04]
Agent RevisionProposalpaperoaoerInterestevaluationisAccepted()getReviewer()getPaperInterest()getEvaluation()…
ObservableaddLC()removeLC()notifyLC()
LMSprocessInf()getLR()…
LearningComponent
goalsplansagentsaddAgent()…
RoleagentsprotocolgetName()addAgent()removeAgent()…
ChairpapersLClistsubmissionDatereviewDeadlineaddLC()removeLC()notifyLC()getPapers()getReviewers()...
ReviewerchairNameLClistsetChair()addLC()removeLC()notifyLC()setChair()
UserAgentgoalsplansAgentsmyRolesLClistaddAgent()removeAgent()executePlan()addLC()removeLC()notifyLC()…
PlangoalagentpreConditions()posConditions()createObject()executePlan()…
DistributionPlan
LClistaddLC()removeLC()notifyLC()executePlan()distribute()...
JudgementPlan
JudgementReceptionPlan
learningRateprocessInf()…
TD-LearningprocessInf()getTD()getReward()…
LClistaddLC()removeLC()notifyLC()executePlan()judgeProposal()...
LClistaddLC()removeLC()notifyLC()executePlan()evaluate ()...
Kernel
Col
labo
ratio
n
Learning Concern
Laboratório de Engenharia de Software – PUC-Rio 33
Agent RevisionProposalpaperoaoerInterestevaluationisAccepted()getReviewer()getPaperInterest()getEvaluation()…
ObservableaddLC()removeLC()notifyLC()
LMSprocessInf()getLR()…
LearningComponent
goalsplansagentsaddAgent()…
RoleagentsprotocolgetName()addAgent()removeAgent()…
ChairpapersLClistsubmissionDatereviewDeadlineaddLC()removeLC()notifyLC()getPapers()getReviewers()...
ReviewerchairNameLClistsetChair()addLC()removeLC()notifyLC()setChair()
UserAgentgoalsplansAgentsmyRolesLClistaddAgent()removeAgent()executePlan()addLC()removeLC()notifyLC()…
PlangoalagentpreConditions()posConditions()createObject()executePlan()…
DistributionPlan
LClistaddLC()removeLC()notifyLC()executePlan()distribute()...
JudgementPlan
JudgementReceptionPlan
learningRateprocessInf()…
TD-LearningprocessInf()getTD()getReward()…
LClistaddLC()removeLC()notifyLC()executePlan()judgeProposal()...
LClistaddLC()removeLC()notifyLC()executePlan()evaluate ()...
Kernel
Col
labo
ratio
n
• Problem: How to separate the learning concern from the other agency concerns?
Learning
Laboratório de Engenharia de Software – PUC-Rio 34
Mobility
Agent
Serializable
JADEAgent
Role
collaboratingAgentscollaborationProtocolgetName()addAgent()removeAgent()…
Chair Reviewer UserAgent
researchInterestspublicationsreviewsitineraryaddPCparticipation()move()beforeMove()afterMove()setKeyword()addHost()…
Plan
goalagent…clone()execute ()…
CVUpdatePlan DistributionPlan InformationGatheringPlan
getName()move()beforeMove()afterMove()..
learningComponentsaddLC()...execute ()sendQuery()...
– mobility-specific members– methods with some mobility code
Col
labo
ratio
n
Mobility
BasicConcerns
Interaction
... ...
Effector Sensorreceive()senseEvent()...
send()...
– realization of the serialization interface– mobility-specific classes
goalsplanssensorseffectorsaddAgent()sendMsg()receiveMsg()…
Legend:
chairNamepapersToReviewlearningComponentssetChair()addLC()removeLC()notifyLC()returnJudgement()…
profilesaddLC()removeLC()notifyLC()execute ()distributePapers()getProfile()...
public class Sensor implementsSerializable {
...}
ItinerarygetName()move()beforeMove()afterMove()..
11
2
2
5
6
4
public Result sendQuery(...) { ...if (queryResult.value != null) {
...agent.returnHome(); }
...}
papersitinerarysubmissionDeadlinereviewDeadlinemove()beforeMove()afterMove()distributeProposal()addHost()... 3 3
4
learningComponentsaddLC()removeLC()execute ()updateCV()...public void execute(...) {
...if (date.getDay() == 1) {
...agent.move(); }
...}
Agent
Serializable
JADEAgent
Role
collaboratingAgentscollaborationProtocolgetName()addAgent()removeAgent()…
Chair Reviewer UserAgent
researchInterestspublicationsreviewsitineraryaddPCparticipation()move()beforeMove()afterMove()setKeyword()addHost()…
Plan
goalagent…clone()execute ()…
CVUpdatePlan DistributionPlan InformationGatheringPlan
getName()move()beforeMove()afterMove()..
learningComponentsaddLC()...execute ()sendQuery()...
– mobility-specific members– methods with some mobility code
Col
labo
ratio
n
Mobility
BasicConcerns
Interaction
... ...
Effector Sensorreceive()senseEvent()...
send()...
– realization of the serialization interface– mobility-specific classes
goalsplanssensorseffectorsaddAgent()sendMsg()receiveMsg()…
Legend:
chairNamepapersToReviewlearningComponentssetChair()addLC()removeLC()notifyLC()returnJudgement()…
profilesaddLC()removeLC()notifyLC()execute ()distributePapers()getProfile()...
public class Sensor implementsSerializable {
...}
ItinerarygetName()move()beforeMove()afterMove()..
1111
22
22
55
66
44
public Result sendQuery(...) { ...if (queryResult.value != null) {
...agent.returnHome(); }
...}
papersitinerarysubmissionDeadlinereviewDeadlinemove()beforeMove()afterMove()distributeProposal()addHost()... 33 33
44
learningComponentsaddLC()removeLC()execute ()updateCV()...public void execute(...) {
...if (date.getDay() == 1) {
...agent.move(); }
...}
Laboratório de Engenharia de Software – PUC-Rio 35
AspectT
• Supports the OO programming of:– Agents, goals, plans, actions, and beliefs
• Supports the AO modularization and programming of:– Interaction, Adaptation, and Autonomy– Collaboration, Learning, and Mobility
Laboratório de Engenharia de Software – PUC-Rio 36
Aspects
• AspectJ: general-purpose aspect-oriented language
“Crosscutting Concerns”
OO Solution
Classes
Aspect-Oriented SolutionAspect
JoinPoints
Laboratório de Engenharia de Software – PUC-Rio 37
Aspects: An Example
ServerDBreferencedisabledfailuresinitySistem()connectDB()disconnectDB()getReference()updateComplaint()getComplaints()registerHealthUnit()getHealthUnit()…
reportFault()fixServer()…
Client * 1
public Hashtable getComplaints(...) { try { ... << normal code >> ... } catch (FaultException e){ ... << exceptional code>> this.disabled = true; reportFault(); ... }}
public methods
methods implementingerror-handling-specific
behavior
Laboratório de Engenharia de Software – PUC-Rio 38
failures
reportFault()fixServer()...
Aspects: An Example
ServerDBreferenceinitySistem()connectDB()disconnectDB()getReference()updateComplaint()getComplaints()registerHealthUnit()getHealthUnit()…
Client * 1
public methods
FaultHandler
Laboratório de Engenharia de Software – PUC-Rio 39
Aspects: An Example
_services()services_()
IErrorDetection
failures
FaultHandler
reportFault()fixServer()...
disabled
Server
DBreference...
initSystem()connectDB()disconnectDB()getReference()...
crosscutting relationship
internal attribute
internal methods
inter-typedeclaration
advices
Legend: _beforeAdvice afterAdvice_ _aroundAdvice_
crosscuttinginterface
pointcutname
CHAVEZ, C. A Model-Driven Approach to Aspect-Oriented Design. PhD Thesis, Computer Science Department, PUC-Rio, April 2004, Rio de Janeiro, Brazil.
Laboratório de Engenharia de Software – PUC-Rio 40
High-Level View of an Aspect
IServices
Server
_services()services_()
IErrorDetection
failures
FaultHandler
reportFault()fixServer()...
disabled
Server
DBreference...
initSystem()connectDB()disconnectDB()getReference()...
crosscutting relationship
FaultHandler
crosscutting relationship
Laboratório de Engenharia de Software – PUC-Rio 41
Aspects: An Example
aspect FaultHandler { private boolean Server.disabled = false; private void reportFault() { System.out.println("Failure! Please fix it."); } public static void fixServer(Server s) { s.disabled = false; }
pointcut services(Server s): target(s) && call(public * *(..));
before(Server s): services(s) { if (s.disabled) throw new DisabledException(); }
after(Server s) throwing (FaultException e): services(s) { s.disabled = true; reportFault(); }}
Laboratório de Engenharia de Software – PUC-Rio 42
Research on Aspects
• Aspect-oriented solutions are limited to general concerns:– Distribution– Persistence– Error handling– Logging– …
Laboratório de Engenharia de Software – PUC-Rio 43
AspectT
• Supports the OO programming of:– Agents, goals, plans, actions, and beliefs
• Supports the AO modularization and programming of:– Interaction, Adaptation, and Autonomy– Collaboration, Learning, and Mobility
• Supports the integration with other MAS platforms:– JADE– TSpaces
• The Framework Structure • A High-Level View
Laboratório de Engenharia de Software – PUC-Rio 44
AspectT
AspectT
AspectInt(interaction)
Kernel
AspectAd(adaptation)
AspectAut(autonomy)
AspectCo(collaboration)
AspectL (learning)
AspectM (mobility)Cidiane, Alessandro, Cláudio e Uirá
Alessandro, Sardinha, Uirá e Ruy
Total
Other Contributions: Eduardo, Cidiane, Karla, ...
Laboratório de Engenharia de Software – PUC-Rio 45
IKnowledge IServices
High-Level View
Kernel
Legend:aspectual componentcomponentcrosscutting interfacenormal interface
BehaviorAdaptation
KnowledgeAdaptation
TravelingMessageReception
Interaction
Adaptation
GoalCreation
ExecutionAutonomy
Autonomy
RoleBinding
CollaborationProtocol
Collaboration
Mobility
MessageSending
ExtrinsicKnowledge
InformationGathering
LearningKnowledge
Learning
Laboratório de Engenharia de Software – PUC-Rio 46
• Dynamic View– Agent Initialization
Learning
Mobility
Collaboration
AdaptationKernel
Autonomy
Interactionagentcreation goal and plan
initializations
optionalmandatory
initial point
1
sensor and effectorinitializations
beliefsinitialization
3
4
5
roleinitialization
6
beliefsinitialization
7
High-Level View
executionautonomy
2
Laboratório de Engenharia de Software – PUC-Rio 47
• Dynamic View– Message Handling
Learning
Mobility
Collaboration
Autonomy
Adaptation
Interaction
incomingmessage
decision making
optionalmandatory
initial point
1
2
decisionplans
5 goal finding 6
belief adaptation
belief changes3
4
EnvironmentHigh-Level View
Kernel
7reactive
goal
Laboratório de Engenharia de Software – PUC-Rio 48
• Dynamic View– Goal Achievement
Learning
Mobility
Collaboration
Autonomy
Adaptation
Interaction
behavior adaptation
optionalmandatory
initial point
9
reactivegoal7 goal creation 6
execution autonomy
8
role activation 11reactive
plan10
High-Level View
Kernel
Laboratório de Engenharia de Software – PUC-Rio 49
• Dynamic View– Proactive Behavior
Learning
Mobility
Collaboration
Autonomy
Adaptation
Interaction
goal creation
ANDOR
optionalmandatory
proactivebehavior
initial point
23
learnedknowledge
changedknowledge
1
behavior adaptation
6
proactive goal4
execution autonomy
5
proactive plan7
High-Level View
Kernel
Laboratório de Engenharia de Software – PUC-Rio 50
• Dynamic View– Role Binding/Activation
Learning
Mobility
Collaboration
Autonomy
Adaptation
Interaction
ANDOR
optionalmandatory
initial pointnew environment
initializationchanged
knowledge
1
1received message
2role binding
High-Level View
Kernel
1
Laboratório de Engenharia de Software – PUC-Rio 51
IKnowledge IServices
Kernel
Kernel
Legend:aspectual componentcomponentcrosscutting interfacenormal interface
BehaviorAdaptation
KnowledgeAdaptation
TravelingMessageReception
Interaction
Adaptation
GoalCreation
ExecutionAutonomy
Autonomy
RoleBinding
CollaborationProtocol
Collaboration
Mobility
MessageSending
ExtrinsicKnowledge
InformationGathering
LearningKnowledge
Learning
Laboratório de Engenharia de Software – PUC-Rio 52
Kernel
• Step 1: Define the Agent Kernel
BeliefGoal
Plan
Kernel
Agentnamegoalsplans…new()addBelief()setGoal()executePlan()...
Laboratório de Engenharia de Software – PUC-Rio 53
Kernel
Agent
belief1belief2...goalsplanstoAchieveGoalstoPerformPlans
addGoal()removeGoal()setGoal()action1()action2()...
Belief
name...
PlanpreConditions()posConditions()execute()stop()
Goal
namesubgoals...
*
• Solution:
Laboratório de Engenharia de Software – PUC-Rio 54
Interaction
Legend:aspectual componentcomponentcrosscutting interfacenormal interface
Kernel
MessageReception
InteractionMessageSending
ServicesSensory
Environment
Laboratório de Engenharia de Software – PUC-Rio 55
EnvClass3
EnvClass2
EnvClass1
environmentclasses
Agent
Plan
messagesenders
Aspect
InteractionAspectInt
• Solution:Sensory
sendMsg()
outgoingMsg_()
MessageSending Interaction
inboxoutbox
init()marshall()unmarshall()
Effector Sensor
sense()send()
sensing_()
MessageReception
receiveMsg()
incomingMsg_()
update() 1
3
2
4
Laboratório de Engenharia de Software – PUC-Rio 56
IKnowledge IServices
High-Level View
Kernel
Legend:aspectual componentcomponentcrosscutting interfacenormal interface
MessageReception
InteractionMessageSending
Traveling
RoleBinding
CollaborationProtocol
Collaboration
Mobility
ExtrinsicKnowledge
InformationGathering
LearningKnowledge
LearningBehavior
Adaptation
KnowledgeAdaptation
Adaptation
GoalCreation
ExecutionAutonomy
Autonomy
Laboratório de Engenharia de Software – PUC-Rio 57
IKnowledge IServices
Agenthood Properties
Kernel
Legend:aspectual componentcomponentcrosscutting interfacenormal interface
BehaviorAdaptation
KnowledgeAdaptation
MessageReception
Interaction
Adaptation
GoalCreation
ExecutionAutonomy
Autonomy
MessageSending
Traveling
RoleBinding
CollaborationProtocol
Collaboration
Mobility
ExtrinsicKnowledge
InformationGathering
LearningKnowledge
Learning
Laboratório de Engenharia de Software – PUC-Rio 58
AdaptationAspectAd
• Solution:
BehaviorAdapation
adapters
adaptBelief()findPlan()adaptSpecificBelief()findSpecificPlan()
Agent
Belief
knowledgeelementsobserved
Interaction
newGoal_()failedPlan_()planFinal_()
changedBelief_()newMsg_()
KnowledgeAdaptation Adaptation
executePlan()Plan
Agent
setGoal()
Adapter
adapt()
receiveMsg() 13
2
4
1
2
3
4
Laboratório de Engenharia de Software – PUC-Rio 59
AutonomyAspectAut
• Solution:
4executePlan()
DecisionPlan
decisionGoalsproactiveGoalsautonomyDegree
initGenericGoals()initSpecificGoals()makeDecision()makeSpecificDecision()instantiateGoal()initThread()
Agent
Belief
observedelements
Interaction
events_()
GoalCreation
Autonomy
ProactivePlan
executePlan()
*
*newAgent_()
ExecutionAutonomy
receiveMsg()
3
1
2
4
Laboratório de Engenharia de Software – PUC-Rio 60
Agenthood Properties
• Step 2: Agenthood Properties
BeliefGoal
Plan
Kernel
Agentnamegoalsplans
new()addBelief()setGoal()executePlan()...
Interaction
GoalCreation
Autonomy
ExecutionAutonomy
BehaviorAdapation
KnowledgeAdaptation
Adaptation
MessageSending
MessageReception
Laboratório de Engenharia de Software – PUC-Rio 61
Agent Types
• Step 3: Define Agent Types
KernelKernelKernelInterfaceAgent
receiveInstruction()monitor()memorize()...
InformationAgentsearch(Keyword)search(Keywords)search(Sentences)…
UserAgentgetUser()checkPreference()…
Agentnamebeliefsgoalsplans...
addBelief()addGoal()executePlan()…
Laboratório de Engenharia de Software – PUC-Rio 62
IKnowledge IServices
Agenthood Properties
Kernel
Legend:aspectual componentcomponentcrosscutting interfacenormal interface
BehaviorAdaptation
KnowledgeAdaptation
MessageReception
Interaction
Adaptation
GoalCreation
ExecutionAutonomy
Autonomy
MessageSending
Traveling
RoleBinding
CollaborationProtocol
Collaboration
Mobility
ExtrinsicKnowledge
InformationGathering
LearningKnowledge
Learning
Laboratório de Engenharia de Software – PUC-Rio 63
IKnowledge IServices
Collaboration
Kernel
Legend:aspectual componentcomponentcrosscutting interfacenormal interface
BehaviorAdaptation
KnowledgeAdaptation
MessageReception
Interaction
Adaptation
GoalCreation
ExecutionAutonomy
Autonomy
MessageSending
Traveling
Mobility
InformationGathering
LearningKnowledge
Learning
RoleBinding
Collaboration
Laboratório de Engenharia de Software – PUC-Rio 64
CollaborationAspectCo
RoleRole
PlanPlan
events_()
RoleBinding
Role3Role2
AgentType
belief1belief2...goalsplans
action1()action2()
belief2belief3...goalsplans
Role1
action1action2...
Belief
beliefs
PlannamepreConditions()posConditions()
Goal
name
*
• Solution:
Laboratório de Engenharia de Software – PUC-Rio 65
IKnowledge IServices
Collaboration
Kernel
Legend:aspectual componentcomponentcrosscutting interfacenormal interface
BehaviorAdaptation
KnowledgeAdaptation
MessageReception
Interaction
Adaptation
GoalCreation
ExecutionAutonomy
Autonomy
MessageSending
Traveling
Mobility
InformationGathering
LearningKnowledge
Learning
RoleBinding
Collaboration
Laboratório de Engenharia de Software – PUC-Rio 66
IKnowledge IServices
Mobility
Kernel
Legend:aspectual componentcomponentcrosscutting interfacenormal interface
BehaviorAdaptation
KnowledgeAdaptation
MessageReception
Interaction
Adaptation
GoalCreation
ExecutionAutonomy
Autonomy
MessageSending
InformationGathering
LearningKnowledge
Learning
RoleBinding
Collaboration
Traveling
Mobility
Laboratório de Engenharia de Software – PUC-Rio 67
MobilityAspectM
• Solution:
moving_()returning_()
Traveling
itinerary...
Mobility
init()move()addHost()prepareToMove()...
Role
AgentType
belief1belief2...goalsplans
action1()action2()...
executePlan()...
*
is Mobile
move()returnHome()...
MobilityFramework
<<crosscutting interface>>
SpecificMobility
init()move()...
Plan
Legend: _beforeAdvice afterAdvice_ _aroundAdvice_
Laboratório de Engenharia de Software – PUC-Rio 68
IKnowledge IServices
Mobility
Kernel
Legend:aspectual componentcomponentcrosscutting interfacenormal interface
BehaviorAdaptation
KnowledgeAdaptation
MessageReception
Interaction
Adaptation
GoalCreation
ExecutionAutonomy
Autonomy
MessageSending
InformationGathering
LearningKnowledge
Learning
RoleBinding
CollaborationProtocol
Collaboration
ExtrinsicKnowledge
Traveling
Mobility
Laboratório de Engenharia de Software – PUC-Rio 69
IKnowledge IServices
Learning
Kernel
Legend:aspectual componentcomponentcrosscutting interfacenormal interface
BehaviorAdaptation
KnowledgeAdaptation
MessageReception
Interaction
Adaptation
GoalCreation
ExecutionAutonomy
Autonomy
MessageSending
RoleBinding
CollaborationProtocol
Collaboration
ExtrinsicKnowledge
Traveling
Mobility
InformationGathering
LearningKnowledge
Learning
Laboratório de Engenharia de Software – PUC-Rio 70
LearningAspectL
• Solution:
learnPreferences()updatePreferences()...
Agent
Belief
Plan
events_()
InformationGathering Learning
LearningComponent
learningRateprocessInformation()...
belief1belief2...
action1()action2()...
LearningKnowledgeAspect
*
Laboratório de Engenharia de Software – PUC-Rio 71
Additional Properties
• Step 4: Define the Additional Properties
KernelKernelKernel
InformationGathering
Learning
InterfaceAgentreceiveInstruction()monitor()memorize()...
InformationAgentsearch(Keyword)search(Keywords)search(Sentences)…
UserAgentgetUser()checkPreference()…
CollaborationProtocol
Collaboration
Laboratório de Engenharia de Software – PUC-Rio 72
Flexible Composition• Portalware
KnowledgeUpdating
BehaviorAdaptation
Kernel
Services
KnowledgeAdaptation
TravelingMessageReception
Interaction
Adaptation
GoalCreation
ExecutionAutonomyAutonomy
RoleBinding
CollaborationProtocol
Collaboration
Mobility
Legend:aspectual componentcomponentcrosscutting interfacenormal interface
MessageSending
ExtrinsicKnowledge
- no learning component- no sensing behavior
Laboratório de Engenharia de Software – PUC-Rio 73
Flexible Composition
KnowledgeUpdating
BehaviorAdaptation
Kernel
Services
KnowledgeAdaptation
TravelingMessageReception
Interaction
Adaptation
GoalCreation
ExecutionAutonomy
Autonomy
RoleBinding
CollaborationProtocol
Collaboration
MobilityMessageSending
Agenthood Additional Properties
Environment
ExtrinsicKnowledge
Sensory
InformationGathering
LearningKnowledge
Learning
KnowledgeUpdating
BehaviorAdaptation
Kernel
Services
KnowledgeAdaptation
TravelingMessageReception
Interaction
Adaptation
GoalCreation
ExecutionAutonomy
Autonomy
RoleBinding
CollaborationProtocol
Collaboration
MobilityMessageSending
Agenthood Additional Properties
Environment
ExtrinsicKnowledge
Sensory
InformationGathering
LearningKnowledge
Learning
• Expert Committee - learning component- sensing behavior
Laboratório de Engenharia de Software – PUC-Rio 74
Um Estudo de Caso
• Descrever o uso do framework em um exemplo de SMA
• Aplicar em alguns cenários do EC as diretrizes de projeto detalhado
• Projeto incremental de cada um dos componentes que definem a arquitetura usando o framework como base
Laboratório de Engenharia de Software – PUC-Rio 75
Cenários - ExpertCommittee• Cenário 1: Atribuição básica de artigos• Cenário 2: Avaliação da proposta de revisão
Laboratório de Engenharia de Software – PUC-Rio 76
Diretrizes de projeto detalhado
• Passo 1: Refinar componente Kernel• Passo 2: Refinar componente Interaction• Passo 3: Refinar componente Adaptation• Passo 4: Refinar componente Autonomy• Passo 5: Refinar componente Mobility• Passo 6: Refinar componente Learning• Passo 7: Refinar componente Collaboration
Laboratório de Engenharia de Software – PUC-Rio 77
Passo 1: Refinar o kernel do agente
• Definir os tipos de agentes, bem como suas crenças, metas e planos
BeliefGoal
Plan
Kernel
Agentnamegoalsplans…new()addBelief()setGoal()executePlan()...
Laboratório de Engenharia de Software – PUC-Rio 78
Passo 1: Refinar o kernel do agenteAgent
InformationAgent ResearcherUserAgentuserNameresearcherListresearchInterestresearcherStageagenda...
set...()get...()
...sendCNPqReport()...
...
...
namereactiveGoalListreactivePlanListtoAchieveGoalstoPerformPlansagentList
Agent Types
Laboratório de Engenharia de Software – PUC-Rio 79
Passos 1 e 7: Refinar o kernel do role
...
...
Chair
goalListplanListpaperListreviewerListproposalEvalDeadlinereviewDeadlinepapersWithoutReviewers
sendReviewProposal()receiveProposalResponse()receiveRetirementRequest()...
Reviewer
chairNameplanListacceptedPapersrejectedPapers
receiveProposal()judgesProposal ()askReviewerRetirement()sendProposalResponse()...
Plan
PaperDistribution
ReviewerInvitation
ProposalRespEvaluationFinalDistribution
execute()precondiitions()...
execute()precondiitions()...execute()precondiitions()...
AuctionInitialization
ProposalReception
AuctionBidding
ProposalJudgementexecute()precondiitions()...
ResearcherUserAgentuserNameresearcherListresearchInterestresearcherStageagenda...
set...()get...()
...sendCNPqReport()...
<<crosscuts>>
<<crosscuts>>
Agent Roles and Agent Plans
Laboratório de Engenharia de Software – PUC-Rio 80
Passo 2: Refinar a Interação do agente • Definir sensores e efetuadores• Definir parsers concretos• Definir aspectos concretos de Interação
– Inicializar sensores e efetuadores• Definir pontos de envio e recepçaõ de msgs
Adaptation
Kernel
IMessageReception
InteractionIMessageSending
IServicesISensory
Environment
Laboratório de Engenharia de Software – PUC-Rio 81
Passo 2: Refinar a Interação do agente
Autonomy
Adaptation
ISensory
sendMsg()
outgoingMsg_()
IMessageSending Interaction
inboxoutbox
init()marshall()unmarshall()
Agent
Plan
Effector Sensor
sense()send()
Class3
Class2
Class1
environmentclasses
messagesenders
Aspect
sensing_()
IMessageReception
receiveMsg()
incomingMsg_()
Laboratório de Engenharia de Software – PUC-Rio 82
Passo 2: Refinar a Interação do agente
Autonomy
ISensory
sendMsg()
outgoingMsg_()
IMessageSending Interaction
inboxoutbox
init()marshall()unmarshall()
sensing_()
IMessageReception
receiveMsg()
incomingMsg_()
Effector Sensor
sense()send()
JADEEffector BBEffector JADESensor
send() send() sense() sense()
BBSensor
Parser
marshalMsg()unmarshalMsg()
JADEParser
sense()
Agent Sensors, Effectors and Parsers
Laboratório de Engenharia de Software – PUC-Rio 83
Passos 2 e 7: Refinar a Interação do role
ResearcherUserAgent
ISensory
sendMsg()
outgoingMsg_()
IMessageSending
sensing_()
IMessageReception
Interaction
inboxoutbox
init()marshall()unmarshall()sendMsgEffector()
receiveMsg()
incomingMsg_()
ISensory
sendMsg()
outgoingMsg_()
IMessageSending
sensing_()PersistentCV
updateInterest()Agenda
updateAgenda()
ChairInteraction
init()sendMsgEffector()...
PaperDistributionPlan
DSInterfaceMobility
prepareToMove()prepareReturn()
GUIoperation()
Message SendingSensors and
Effectors InitializationExternal Sensory
Laboratório de Engenharia de Software – PUC-Rio 84
Passo 3: Refinar a Adaptação do agente
• Definir adaptação de crenças a partir do recebimento de mensagens externas
• Definir adaptação de planos a partir de metas que precisam ser alcançadas
Adaptation
IKnowledgeUpdating
IPlanAdaptation
Kernel
IBeliefAdaptation
IMessageReception
Interaction
Adaptation
IMessageSending
IServices
Laboratório de Engenharia de Software – PUC-Rio 85
Passo 3: Refinar a Adaptação do agente
Agent
removeAgent()...Belief
updateKeywords()...
executePlan()Plan
IPlanAdaptation
adapters
adaptBelief()findPlan()adaptSpecificBelief()findSpecificPlan()
Interaction
newGoal_()failedPlan_()planFinal_()
AgentchangedBelief_()newMsg_()
IBeliefAdaptation Adaptation
setGoal()
receiveMsg()...
Laboratório de Engenharia de Software – PUC-Rio 86
IPlanAdaptation
newGoal_()failedPlan_()planFinal_()
Passos 3 e 7: Refinar a Adaptação do role
Agent
removeAgent()...Belief
updateKeywords()...
executePlan()Plan
IPlanAdaptation
adapters
adaptBelief()findPlan()adaptSpecificBelief()findSpecificPlan()
Interaction
newGoal_()failedPlan_()planFinal_()
AgentchangedBelief_()newMsg_()
IBeliefAdaptation Adaptation
setGoal()
receiveMsg()...
...
adaptSpecificBelief()findSpecificPlan()updateDataPaperDist()...
changedBelief_()
IBeliefAdaptation Chair
Adaptation PaperDistributionPlan
updateKeywords()...
ProposalEvaluationPlan
...Chair
paperList...
BeliefAdaptation PlanAdaptation
Laboratório de Engenharia de Software – PUC-Rio 87
IPlanAdaptation
newGoal_()failedPlan_()planFinal_()
Passos 3 e 7: Refinar a Adaptação do role
Agent
removeAgent()...Belief
updateKeywords()...
executePlan()Plan
IPlanAdaptation
adapters
adaptBelief()findPlan()adaptSpecificBelief()findSpecificPlan()
Interaction
newGoal_()failedPlan_()planFinal_()
AgentchangedBelief_()newMsg_()
IBeliefAdaptation Adaptation
setGoal()
receiveMsg()...
...
adaptSpecificBelief()findSpecificPlan()...
changedBelief_()
IBeliefAdaptation Reviewer
Adaptation ProposalReceptionPlan
updateKeywords()...
ProposalJudgementPlan
...Reviewer
papersToReview...
Laboratório de Engenharia de Software – PUC-Rio 88
IServices
Passo 4: Refinar a Autonomia do agente
• Definir inicialização de metas do agente
• Definir estratégias de criação de metas– Reativas– Proativas– Decisão
Autonomy
IKnowledgeUpdating
IPlanAdaptation
Kernel
IMessageReception
Interaction
Adaptation
IGoalCreation
IExecutionAutonomy
Autonomy
IMessageSending
IBeliefAdaptation
Laboratório de Engenharia de Software – PUC-Rio 89
Passo 4: Refinar a Autonomia do agente
executePlan()DecisionPlan
decisionGoalsproactiveGoalsautonomyDegree
initGenericGoals()initSpecificGoals()makeDecision()makeSpecificDecision()instantiateGoal()initThread()
Agent
Belief
observedelements
Interaction
events_()
IGoalCreation
Autonomy
ProactivePlan
executePlan()
*
*newAgent_()
IExecutionAutonomy
Laboratório de Engenharia de Software – PUC-Rio 90
Passos 4 e 7: Refinar a Autonomia do role
decisionGoalsproactiveGoalsautonomyDegree
initGenericGoals()initSpecificGoals()makeDecision()makeSpecificDecision()Instantiate*Goal()initThread()
Autonomy
receiveMsg()...
executePlan()...
PaperDistributionGoal
specificGoals...
initSpecificGoals()makeSpecificDecision()
events_()
IGoalCreation
ChairAutonomy
ProposalReceptionGoal
executePlan()...
Chair
Agenda
addAppointment()...
Goal Instantiation
Laboratório de Engenharia de Software – PUC-Rio 91
Passos 4 e 7: Refinar a Autonomia do role
decisionGoalsproactiveGoalsautonomyDegree
initGenericGoals()initSpecificGoals()makeDecision()makeSpecificDecision()instantiate*Goal()initThread()
Autonomy
receiveMsg()...
executePlan()...
DistributePaperGoal
specificGoals
initSpecificGoals()makeSpecificDecision()instantiateReactiveGoal()instantiateProactiveGoal()instantiateDecisionGoal()
events_()
IGoalCreation
ProposalEvaluationGoal
executePlan()...
Reviewer
Agenda
addAppointment()...
ReviewerAutonomy
Laboratório de Engenharia de Software – PUC-Rio 92
Passo 6: Refinar o Aprendizado do agente
• Padrão de Projeto que pode ser aplicado na definição de aprendizado para SMAs
• Definição de eventos de interesse e coleta de informações para o processo de aprendizado
• Definição de algoritmos de aprendizado a serem utilizados
• Atualização do conhecimento do agente
Autonomy
Laboratório de Engenharia de Software – PUC-Rio 93
Passo 6: Refinar o Aprendizado do agente
InformationGathering
<< crosscutting interface >>
events_() initLC()learnPreferences()...
learnPreferences()updatePreferences()...
Agent
Role
Plan
events_()
InformationGathering
LearningComponent
learningRateprocessInformation()...
attribute1...method1()...
LearningKnowledge
*
SpecificLearning
<< crosscutting interface >>
<< crosscutting interface >>
Learning
operation1()...
Laboratório de Engenharia de Software – PUC-Rio 94
Passo 6: Aprendizado no EC
• Agente-Reviewer atualiza os graus de interesse do usuário baseado na aceitação ou rejeição de artigos atribuídos para ele
• Agente-Chair atualiza preferências do usuário baseado no feedback de propostas enviadas para agentes reviewers.
Laboratório de Engenharia de Software – PUC-Rio 95
Passo 6: Refinar o Aprendizado do agente
paperInterestevaluation...getInterest()...
LearningKnowledgeRevisionProposal
reviewerpaperdeadlinesisAccepted()getReviewer()getPaper()…
<< crosscutting interface >>
InformationGathering
<< crosscutting interface >>
learnPreferences()updatePreferences()...
Learning
initTDLearning()getResponse()...
ReviewerLearning TDLearning
processInformation()getTD()getReward()setReward()…
Reviewer
UserAgent
JudgementPlanexecute()judgeProposal()...
LearningComponent
learningRateprocessInformation()...
*
events_()
Laboratório de Engenharia de Software – PUC-Rio 96
Empirical Studies
• 4 qualitative studies and 1 quantitative study• 3 prototypes in different application domains• Portalware URL: www.teccomm.les.inf.puc-rio.br/alessandro/portal.zip• Expert Committee URL: www.teccomm.les.inf.puc-rio.br/alessandro/ec.zip
System Name Domain AgentTypes
Agency ConcernsLOC
In Ad Au Co Ro Mo Le
TSA TrafficSimulation Reactive 1859
Portalware v.1 (qualitative study) Development
Environment
Reactive 1654
Portalware v.2 (quantitative study)
Reactive Cognitive 3063
Expert Committee ConferenceManagement Hybrid 6564
Laboratório de Engenharia de Software – PUC-Rio 97
Evolution of the Studies
Portalware(Quantitative)Case Study 5:
• The Experimental Setting– Subjects:
• 3 PhD Students and 1 Master’s Student
– Almost 2 years:• January 2001 – December 2002
– GQM methodology– Use and evaluation of the
assessment framework
• Two phases– Construction– Reuse and Maintenance
Traffic Simulator
Architecture
Portalware(Mapping)
Case Study 1:
Case Study 3:
ExpertCommitteeCase Study 4:
Portalware(Comparison)Case Study 2:
GARCIA, A. et al. Separation of Concerns in Multi-Agent Systems: An Empirical Study. In: Software Engineering for Multi-Agent Systems II, Springer, LNCS 2940, March 2004, pp. 49-72.
Laboratório de Engenharia de Software – PUC-Rio 98
The Quality Model and Metrics
Reusability Understandability
FlexibilityMaintainability
Size
Coupling
Cohesion
Separation of Concerns
Factors Internal Attributes Qualities
VS
LOCNOAWOC
CBC
LCOO
CDC
CDO
CDLOC
Metrics
DIT
Reusability Understandability
FlexibilityMaintainability
Size
Coupling
Cohesion
Separation of Concerns
Factors Internal Attributes Qualities
VS
LOCNOAWOC
CBC
LCOO
CDC
CDO
CDLOC
Metrics
DIT
• Measure well-known software attributes
Laboratório de Engenharia de Software – PUC-Rio 99
The Metrics
ReusabilityUnderstandability
FlexibilityMaintainability
Size
Coupling
Cohesion
Separation of Concerns
Factors Internal Attributes Qualities
VS
LOC
NOAWOC
CBC
LCOO
CDC
CDO
CDLOC
Metrics
DIT
Concern Difusion over ComponentConcern Difusion over OperationConcern Difusion over LOCVocabulary SizeLines of CodeNumber of AttributesWeighted Operations per Component
Coupling between ComponentesDepth of InheritanceLack of Cohesion in Operations
Chidamber, S., Kemerer, C. “A Metrics Suite for Object Oriented Design”. IEEE Transactions on Software Engineering, 20 (6), June 1994, pp. 476-493.
Laboratório de Engenharia de Software – PUC-Rio 100
The Quantitative Study
CounterProposal
ailabilityPlan
Agent
CollaborativeAgent
CollaborationCore
Property
Autonomy AdaptationInteraction
Collaboration
CollaborationRole
Editor Caller User
AgentInformation
Agent
InterfaceAgent
MiddleAgent
Mediator Pattern
Role Pattern
Plan
Answerer
SearchingPlan
StrategyPattern
ContentSupplier
Knowledge
Proposal
Composite Pattern
Laboratório de Engenharia de Software – PUC-Rio 101
Answerer
CounterProposal
ailabilityPlan
Agent
UserAgent
InformationAgent
InterfaceAgent
MiddleAgent
Plan
SearchingPlan
Knowledge
Proposal
Autonomy
Interaction
Collaboration
Adaptation
EditorContentSupplier
Caller
The Quantitative Study
Laboratório de Engenharia de Software – PUC-Rio 102
Quantitative Evaluation (I)
Ponto de Vista do Sistema
0102030405060708090
100
Nro. Componentes
LOCNro. Atributos
Peso de Operações
Acoplamento Componentes
Profundidade Herança
Falta de Coesão
%
OOOA
7% 12% 9% 6% 9% 40% 3%
Vocabulary Size
System Viewpoint
Patterns
Aspects
Attributes
Weighted Operations
Coupling
Inheritance
Cohesion
GARCIA, A. et al. Separation of Concerns in Multi-Agent Systems: An Empirical Study. In: Software Engineering for Multi-Agent Systems II, Springer, LNCS 2940, March 2004, pp. 49-72.
Laboratório de Engenharia de Software – PUC-Rio 103
Quantitative Evaluation (II)
CounterProposal
ailabilityPlan
Agent
CollaborativeAgent
CollaborationCore
Property
Autonomy AdaptationInteraction
Collaboration
CollaborationRole
Editor Caller User
AgentInformation
Agent
InterfaceAgent
MiddleAgent
Mediator Pattern
Role Pattern
Plan
Answerer
SearchingPlan
StrategyPattern
ContentSupplier
Knowledge
Proposal
Composite Pattern
Laboratório de Engenharia de Software – PUC-Rio 104
Reuse and Maintenance Phase
• Evolution and Reuse ScenariosS1) Change on the Agent Roles (Evolution)S2) Creation of an Agent Type (Evolution)S3) Reuse of the Agenthood Concern (Reuse)S4) Inclusion of Collaboration in an Agent Type (Reuse and
Evolution)S5) Reuse of Roles (Reuse)…
Laboratório de Engenharia de Software – PUC-Rio 105
Reuse and Maintenance Phase
MODIFIABILITYEXTENSIBILITY
ChangedEntities
ChangedOperations
AddedEntities
AddedOperations
ChangedRelations.
AddedRelations.
AddedLOCs
ChangedLOCs
CopiedEntities
CopiedLOCs
PO AO PO AO PO AO PO AO PO AO PO AO PO AO PO AO PO AO PO AOS1 1 1 3 3 5 5 2 3 0 0 15 15 101 98 1 1 - - - -S2 0 0 2 2 4 4 0 0 0 0 10 10 84 86 0 0 - - - -S3 0 0 2 2 4 4 0 0 0 0 10 10 84 86 0 0 0 0 0 0S4 0 0 2 3 8 8 0 0 0 0 29 25 188 167 0 8 0 0 0 0S5 1 1 2 1 0 0 1 1 0 0 4 2 16 14 0 0 0 0 6 6S6 0 0 0 0 0 0 0 0 0 0 0 0 15 15 0 0 - - - -S7 5 1 0 0 0 0 0 0 5 2 1 1 0 0 5 1 0 0 40 0
The aspect-oriented approach required less modification of the selected MAS
Laboratório de Engenharia de Software – PUC-Rio 106
The Pattern Language
absent knowledge
Environment
Agenthood Additional Properties
Autonomy
Mobility
Legend: Crosscuts
new message
new message
incoming message
new goal
collaborationjoining
agent creation
Kernel
new eventabsent knowledge
new eventoutgoing
message
Roles
Interaction Learning
Adaptation
Laboratório de Engenharia de Software – PUC-Rio 107
Conclusions
• AspectT enables– improved modularization of agent properties– flexible composition of agent properties– (un)pluggability of agent properties– from objects to agents: transparent evolution– avoidance of code replication– improvements on reusability and maintainability
• Empirical evidence– The proposed approach is promising to improve separation of
concerns in complex agent architectures
Laboratório de Engenharia de Software – PUC-Rio 108
FAQ
• Why should I use the AspectT framework?– It supports the fundamental agent characteristics– It supports common abstractions in agent modeling
• Agents, Goals, Plans, Actions, Beliefs, Roles, ...– Easy integration with MAS platforms– Tested in three different applications– Comprehensive documentation
• When should we use the AspectT framework?– Not only in complex software agents– The aspects can be applied separately to some extent
• E.g.: Interaction, Roles, Learning, Mobility
Laboratório de Engenharia de Software – PUC-Rio 109
FAQ
• What are the framework limitations?– It does not support some MAS abstractions (e.g.
organizations)
• Which MAS platform should we use together with the AspectT framework?– JADE (mobility, remote communication)– Blackboard (local communication)– TSpaces, JavaSpaces (local and remote communication)
Laboratório de Engenharia de Software – PUC-Rio 110
Documentation
• AspectT
• The Method/ProcessGARCIA, A.; KULESZA, U.; LUCENA, C. Aspectizing Multi-Agent Systems: From
Architecture to Implementation. "Software Engineering for Multi-Agent Systems III”, Springer-Verlag, LNCS, December 2004.
GARCIA, A. et al. An Aspect-Based Approach for Developing Multi-Agent Object-Oriented Systems. Proceedings of the 15th Brazilian Symposium on Software Engineering, Rio de Janeiro, Brazil, October 2001, pp. 177-192. (Nomination for the Best Paper Award)
GARCIA, A.; LUCENA, C.; COWAN, D. Agents in Object-Oriented Software Engineering. Software: Practice and Experience, Elsevier, May 2004, pp. 1-32.
GARCIA, A.; KULESZA, U.; LUCENA, C. From Objects to Agents: An Aspect-Oriented Pattern Language. Submitted to ACM Transactions on Software Engineering Methodologies.
Laboratório de Engenharia de Software – PUC-Rio 111
Documentation
• Empirical Studies
• AspectL
GARCIA, A. et al. Engineering Multi-Agent Systems with Aspects and Patterns. Journal of the Brazilian Computer Society, Special Issue on Software Engineering and Databases, N. 1, Vol. 8, July 2002, pp. 57-72.
GARCIA, A. et al. Separation of Concerns in Multi-Agent Systems: An Empirical Study. In: Software Engineering for Multi-Agent Systems II, Springer-Verlag, LNCS 2940, March 2004, pp. 49-72.
GARCIA, A.; KULESZA, U.; SARDINHA, J.; LUCENA, C.; MILIDIÚ, R. The Learning Aspect Pattern. In: Proceedings of the The 11th Conference on Pattern Languages of Programs (PLoP2004), September 8 - 12, 2004, Allterton Park, Monticello, Illinios.
CHAVEZ, C.; GARCIA, A.; LUCENA, C. Some Insights on the Use of AspectJ and Hyper/J. Proceedings of the Tutorial and Workshop on Aspect-Oriented Programming and Separation of Concerns, Lancaster, UK, August 2001
Laboratório de Engenharia de Software – PUC-Rio 112
Documentation
• AspectM
• The Assessment Framework
• The Pattern LanguageGARCIA, A.; KULESZA, U.; LUCENA, C. From Objects to Agents: An Aspect-
Oriented Pattern Language. Submitted to ACM Transactions on Software Engineering Methodologies.
SANT'ANNA, C.; GARCIA, A.; CHAVEZ, C. ; LUCENA, C.; VON STAA, A. On the Reuse and Maintenance of Aspect-Oriented Software: An Assessment Framework. Proceedings of 17th Brazilian Symposium on Software Engineering, Manaus, Brazil, October 2003.
GARCIA, A.; KULESZA, U.; SANT’ANNA, C.; LUCENA, C. The Mobility Aspect Pattern. Proc. of 4th Latin American Conference on Pattern Languages of Programming, SugarLoafPLoP'04. August, 2004, Fortaleza, Brazil.
LOBATO, C.; GARCIA, A.; ROMANOVKSY, R.; SANT’ANNA, C.; KULESZA, U.; LUCENA, C. Mobility as an Aspect: The AspectM Framework. Proc. of the 1st Brazilian Workshop on Aspect-Oriented Software Development – WASP’04, SBES’04, Brasília, October 2004.
Laboratório de Engenharia de Software – PUC-Rio 113
Ongoing and Future Work
• Aspect-Oriented Refactoring of Existing MASs– REFAZENDA WEBSITE. Refactoring with Aspects. URL:
http://twiki.im.ufba.br/bin/view/Aside/Refazenda
• Additional Quantitative Studies
- AspectT -Um Framework Orientado a Aspectos
para SMAs
Alessandro GarciaUirá Kulesza
{afgarcia, uira}@inf.puc-rio.br
16 Novembro, 2004