the problemcossentino/al3tf3/docs/garcia.pdfmetrics suite ao patterns for agent design generative...

18
1 Aspects in Agent-Based Software Engineering: Lessons Learned Alessandro Garcia Lancaster University, UK Uira Kulesza, Claudio Sant’Anna, Carlos Lucena PUC-Rio, Brazil Christina Chavez UFBA, Brazil [email protected], [uira,claudios,lucena]@inf.puc-rio.br, [email protected] © Alessandro Garcia, 2005. Copyright of material from other sources belongs to the respective authors. The Problem Crosscutting concerns in agent-based development Learning, code mobility, autonomy… It does not matter which abstractions the software developers are relying on object-oriented programming, AOSE abstractions they are always crosscutting Quality attributes depend largely on the modularity provided by SE abstractions • reusability • maintainability

Upload: others

Post on 06-Oct-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

1

Aspects inAgent-Based Software Engineering:

Lessons LearnedAlessandro Garcia

Lancaster University, UK

Uira Kulesza, Claudio Sant’Anna, Carlos LucenaPUC-Rio, Brazil

Christina ChavezUFBA, Brazil

[email protected], [uira,claudios,lucena]@inf.puc-rio.br, [email protected]

© Alessandro Garcia, 2005. Copyright of material from other sources belongs to the respective authors.

The Problem• Crosscutting concerns in agent-based

development– Learning, code mobility, autonomy…– It does not matter which abstractions the software

developers are relying on• object-oriented programming, AOSE abstractions• they are always crosscutting

– Quality attributes depend largely on the modularity provided by SE abstractions

• reusability• maintainability

Page 2: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

2

Crosscutting Agent-Related Concerns

Col

labo

ratio

n

Agentgoals...

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

CollaborationAdaptation

Autonomy

Interaction

Learning

public Result searchKW(String KW) { adaptKnowledge(KW);processInformation(KW);......<< searching-specific code >>

...

...if (result = null) {

this.move(KW)}

}

Aspect-Oriented Software Development (AOSD)

Concern 1

Concern 2

Concern 3

AOSD tools, techniquesand

methodology

Concern 1

Concern 2Concern 3

Page 3: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

3

Our Timeline

2000

Facing Crosscutting Concernsin MAS Development

2001

Aspects in MASDevelopment

2002 2003 2004

How to assessaspect-oriented artifacts?

1st Qualitative Study(MAS)

1st QuantitativeStudy (MAS)

Aspects inAgent-Oriented

Modelling

MetricsSuite

AO Patternsfor Agent Design

Generative Programmingand AOSE

AspectTFramework

Agent-DSL

AO AgentArchitecture 2nd Quantitative

Study (MAS)

2nd Qualitative Study(MAS)

200520052005

LessonsLearned?

AOSD isthe Key?

AOSD is the key?Our Approach

Learning

Code Mobility

RolesCollaboration

AOSD tools, techniquesand

methodology

Learning

Code Mobility

RolesCollaboration

Page 4: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

4

AOSD is the key?• Seeking the answers…

– Agent-DSL– Architectural approach– Design and implementation method– Design pattern language– AO generative approach– AspectT: Implementation Framework– Empirical studies

• Qualitative ones: quality model• Quantitative ones: metrics suite

Our Aspect-Oriented Approach• Agent-DSL: modelling crosscutting features

<MAS ... xsi:noNamespaceSchemaLocation= "agent-dsl.xsd"> <agent> <name>ResearcherUserAgent</name> <belief> ... </belief> <goal> ... </goal> <role> <name>Chair</name> <belief> ... </belief> <goal>

<name>PaperDistributionGoal</name> <type>Reactive</type> </goal> <plan> <name>PaperDistributionPlan</name> <type>Reactive</type> <communication>false</communication>

</plan> <interaction> <sensor> <name>sensorAgent</name> <type>AgentCommunication</type> <platform>JADE</platform> </sensor> <effector> <name>effectorAgent</name> <type>AgentCommunication</type> <platform>JADE</platform> </effector> <message> <id>REQUEST_DISTRIBUTE_PAPER</id> <performative>REQUEST</performative> <service> SERVICE_DISTRIBUTE_PAPERS </service> </message> </interaction> <autonomy> <executionAutonomy> <concurrencyStrategy> ThreadPool </c.S.> </executionAutonomy> <reactiveAutonomy>

<messageToGoal> <message> REQUEST_DISTRIBUTE_PAPER </message>

Agent TypeCode Template

Role Aspect Code Template

Autonomy SubaspectCode Template

Interaction SubaspectCode Template

Page 5: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

5

Environment

Our Approach• Detailed Design

– Aspect-oriented design patterns

absent knowledge

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

The LearningPattern

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

• The Observer Pattern with the Strategy Pattern [SML04]

Page 6: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

6

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?

The Learning Pattern (II)

The Learning Pattern (III)

• Solution:

learnPreferences()updatePreferences()...

Agent

Belief

Plan

events_()

InformationGathering Learning

LearningComponent

learningRateprocessInformation()...

belief1belief2...

action1()action2()...

LearningKnowledgeAspect

*

Page 7: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

7

The Pattern Language• Abstract aspects

– Refining the aspects to different contexts

paperInterestevaluation...getInterest()getEvaluation()...

LearningKnowledge

learnPreferences()updatePreferences()...

LearningRevisionProposalreviewerPaperdeadlinesisAccepted()getReviewer()getPaper()…

initTDLearning()getResponse()...

events_()

InformationGathering Reviewer

Learning

TD-LearningprocessInformation()getTD()getReward()setReward()…

Reviewer

UserAgent

JudgementPlanexecutePlan()judgeProposal()...

What we have learned?1. What are the main motivations to use

AOSD techniques for MAS development?

2. Successful aspectization of MAS-related concerns?

3. Limitations of existing AOSD techniques to address MAS crosscutting concerns?

4. Future directions emerged from our practical exploration of AOSD in AOSE?

Page 8: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

8

Main motivations?• Crosscutting phenomena manifests early

in the software lifecycle– domain engineering (agent-oriented product

lines)• Crosscutting agent features

– Affect other feature trees

Crosscutting in Domain Modelling

ReactiveGoalManagementReactiveGoalManagement

KnowledgeKnowledge

AgenthoodAgenthood

Agent / RoleAgent / Role

BeliefBelief GoalGoal PlanPlan

AutonomyAutonomy InteractionInteractionAdaptationAdaptation

AdditionalPropertiesAdditionalProperties

LearningLearning MobilityMobilityPlanPlan LearningLearning

PlanAdaptationPlanAdaptation BeliefAdaptationBeliefAdaptation

GoalGoal PlanPlan MessageMessage BeliefBelief

ExecutionAutonomyExecutionAutonomy

DecisionAutonomyDecisionAutonomy

InternalEventInternalEvent

ConcurrencyStrategyConcurrencyStrategy

ThreadPoolThreadPool ThreadPerRequestThreadPerRequest

DecisionGoalDecisionGoal DecisionPlanDecisionPlanBeliefBelief

Interaction Behavior

Interaction Behavior

EffectorEffector SensorSensor

PlatformPlatform

CollaborationCollaboration

Legend:mandatory feature

optional feature

alternative features

Sensory BehaviorSensory Behavior

DecisionPlanDecisionPlan

Message ReceptionMessage Reception

Message SendingMessage Sending

ParserParserParserParser

PlanPlan MessageMessage

crosscutscrosscuts

crosscuts

crosscuts

crosscuts

DecisionGoalDecisionGoal

DecisionAutonomyDecisionAutonomy

ProactiveGoalProactiveGoal

ProactiveAutonomyProactiveAutonomyProactiveAutonomyProactiveAutonomy

MessageMessage ReactiveGoalReactiveGoal

inspected features

MessageMessage

ProactiveGoal DecisionGoal

Goal

Goal

Page 9: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

9

Main motivations?• Crosscutting phenomena manifests early

in the software lifecycle– domain engineering (agent-oriented product

lines)• Crosscutting agent features

– Affect other feature trees

– software architecture (ADL and UML-based representations)

• Crosscutting architectural concerns of a software agent

– Affect several architectural components and their interfaces

Architectural Crosscutting

Kernel

Interaction

MessageReception

(a) Layered Architecture

Message Sending

Adaptation

MessageProcessingBehavior

Adaptation

Knowledge Adaptation

Autonomy

Execution Autonomy Behavior

Adaptation Message Processing

Collaboration

MessageReception

Protocol Enforcement

Services

Role Binding

Role Binding

Decision Autonomy

Mobility

Traveling

Kernel

Interaction

MessageReception

(a) Layered Architecture

Message Sending

Adaptation

MessageProcessingBehavior

Adaptation

Knowledge Adaptation

Autonomy

Execution Autonomy Behavior

Adaptation Message Processing

Collaboration

MessageReception

Protocol Enforcement

Services

Role Binding

Role Binding

Decision Autonomy

Mobility

Traveling

(b) Mediator Architecture

Mobility

Traveling

Kernel

Interaction

MessageReception

Adaptation

MessageProcessingServices

Autonomy

Behavior AdaptationKnowledge Adaptation

Collaboration

MessageSending

Role Binding

TravelingRole Binding

Protocol Enforcement

Execution Autonomy (?)

(b) Mediator Architecture

Mobility

Traveling

Kernel

Interaction

MessageReception

Adaptation

MessageProcessingServices

Autonomy

Behavior AdaptationKnowledge Adaptation

Collaboration

MessageSending

Role Binding

TravelingRole Binding

Protocol Enforcement

Execution Autonomy (?)

• Leads to tangling and scattering at the agent architecture description

• Hinders modular reasoning on architectural agent properties

• Causes architectural interface bloat

Page 10: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

10

Main motivations?• Maintainable and reusable MASs

– Finer granularity– Allow for reuse and variation of those concerns

• Adaptive MAS in open environments– Dynamic reconfiguration

• roles• collaboration protocols

– Context-aware learning strategies

• Full modularization of crosscutting concerns across MAS lifecycle

What we have learned?1. What are the main motivations to use

AOSD techniques for MAS development?

2. Successful aspectization of MAS-related concerns?

3. Limitations of existing AOSD techniques to address MAS crosscutting concerns?

4. Future directions emerged from our practical exploration of AOSD in AOSE?

Page 11: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

11

Successful aspectization?• Detailed design and implementation

– AspectJ and Hyper/J– Separable concerns

• Code mobility, learning, roles, autonomy• Autonomy

– thread management (execution autonomy)– triggering of proactive behaviour (proactive autonomy)– triggering of decision-making plans (decision autonomy)

• Roles– Separation of intrinsic and extrinsic knowledge (roles)– role binding– protocol enforcement

Quantitative Evaluation• Viewpoint: Role-related Concerns

CounterProposal

ailabilityPlan

Agent

CollaborativeAgent

CollaborationCore

Property

Autonomy AdaptationInteraction

Collaboration

CollaborationRole

Editor CallerUserAgent

InformationAgent

InterfaceAgent

MiddleAgent

Mediator Pattern

Role Pattern

Plan

Answerer

SearchingPlan

StrategyPattern

ContentSupplier

Knowledge

Proposal

Composite Pattern

Page 12: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

12

Quantitative Evaluation

CDLOC - Concern Difusion over LOC

020406080

100

Adapta

tion

Intera

ction

Autono

my

Collabo

ratio

nEdit

or

Concern

%

OOOA

CDO - Concern Difusion over Operations

020406080

100

Adapta

tion

Intera

ction

Autonom

y

Collab

oratio

nEdit

or

Concerns

%

OO

OA

CDC - Concern Diffusion over Components

02040

6080

100

Adapta

tion

Intera

ction

Autono

my

Collab

oratio

nEdit

or

Concerns

%

OOOA

Quantitative EvaluationPonto 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%

Number of Modules

System Viewpoint

PatternsAspects

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.

Page 13: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

13

Quantitative Evaluation

CounterProposal

ailabilityPlan

Agent

CollaborativeAgent

CollaborationCore

Property

Autonomy AdaptationInteraction

Collaboration

CollaborationRole

Editor CallerUserAgent

InformationAgent

InterfaceAgent

MiddleAgent

Mediator Pattern

Role Pattern

Plan

Answerer

SearchingPlan

StrategyPattern

ContentSupplier

Knowledge

Proposal

Composite Pattern

Answerer

CounterProposal

ailabilityPlan

Agent

UserAgent

InformationAgent

InterfaceAgent

MiddleAgent

Plan

SearchingPlan

Knowledge

Proposal

Autonomy

Interaction

Collaboration

Adaptation

EditorContentSupplier

Caller

Quantitative Evaluation

Page 14: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

14

Successful aspectization?• “Inseparable concerns”

– Interaction– message assembling from different

plans/roles• very coupled to the role or plan context

• the composition rules is the central contribution of AOSD– conclusions specific to the AspectJ join point

model

Successful aspectization?

• Inter-aspect relationships– mobility does not affect only the agent kernel

• also crosscuts roles, interaction, and learning• AspectJ-oriented abstractions forces indirect interaction,

which sometimes complicates the design

• Complex solution for simple reactive agents– crosscutting concern is not evident

• e.g. autonomy-related behaviour tends to be localized in few methods

Page 15: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

15

Successful aspectization?

• Aspects as the “glue”– agent kernel vs. concern-specific

implementation framework/platform (e.g. Aglets/Jade for mobility)

• Incremental process vs. iterative process– we mostly had an iterative process– lack of obliviousness

What we have learned?1. What are the main motivations to use

AOSD techniques for MAS development?

2. Successful aspectization of MAS-related concerns?

3. Limitations of existing AOSD techniques to address MAS crosscutting concerns?

4. Future directions emerged from our practical exploration of AOSD in AOSE?

Page 16: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

16

Limitations?• Our Agent-DSL requires more powerful

composition rules– ideally their specification should be separated from

the aspects themselves• Aspects in agent-oriented ADLs

– to express architectural aspects in MASs• Tropos/i* somewhat deal with aspects at

requirements stage– softgoals– But… need for enhancing agent-oriented design

languages with aspects• Gaia, AUML, MAS-ML, …

• Isolate solutions– e.g. Kendall et al – aspectization of agent roles

Limitations?

• Detailed design and implementation– Inter-aspect conflicts in the composition

• roles – introduction of similar behaviour• mobility – composition of agent kernel and

abstract methods of mobility frameworks– e.g. getName() – JADE

– Repetitive and time-consuming tasks• interaction

– enumeration of all message senders in the aspects– our 1st solution: naming convention – our 2nd solution: code generators based on the

Agent-DSL descriptions

Page 17: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

17

What we have learned?1. What are the main motivations to use

AOSD techniques for MAS development?

2. Successful aspectization of MAS-related concerns?

3. Limitations of existing AOSD techniques to address MAS crosscutting concerns?

4. Future directions emerged from our practical exploration of AOSD in AOSE?

Future Directions

• We have investigated the aspectizationof internal agent properties– systemic properties: coordination, fault-

tolerance, …• Need for improved traceability

– Aspects in agent-oriented modelling• agent-oriented meta-models• modelling languages

– Code generation

Page 18: The Problemcossentino/al3tf3/docs/garcia.pdfMetrics Suite AO Patterns for Agent Design Generative Programming and AOSE AspectT Framework Agent-DSL AO Agent Architecture 2nd Quantitative

18

Concluding remarks• In a stage where we are facing a number of

growing AOSE abstractions…– Is not the case to try to understand their

commonalities?– We see aspect-oriented abstractions and

composition mechanisms as promising candidates• Many of those abstractions are in fact to address

crosscutting concerns– Autonomy, roles, coordination, mobility…

– However, we still need to investigate effective composition rules/mechanisms to the context of AOSE

Aspects inAgent-Based Software Engineering:

Lessons LearnedAlessandro Garcia

Lancaster University, UK

Uira Kulesza, Claudio Sant’Anna, Carlos LucenaPUC-Rio, Brazil

Christina ChavezUFBA, Brazil

[email protected], [uira,claudios,lucena]@inf.puc-rio.br, [email protected]

© Alessandro Garcia, 2005. Copyright of material from other sources belongs to the respective authors.