View
224
Download
4
Tags:
Embed Size (px)
Citation preview
OntologiesReasoningComponentsAgentsSimulations
Agent-OrientedAgent-OrientedKnowledge RepresentationKnowledge Representation
Jacques Robin
OutlineOutline
MOF2 and Metamodeling UML2 Active classes and objects UML2 Components UML2 Protocol state machines UML2 Profiles A UML2 Profile for Multi-Agent Systems (MAS) A simple MAS model using the profile
Meta-modeling and MOF2Meta-modeling and MOF2
Q: What is a meta-model? A: A base of structural meta-knowledge that defines the constructs
(vocabulary) and their possible relations (grammar) of the knowledge representation language used to specify an agent’s knowledge
It does not contain knowledge about the agent’s environment, only about the language that the agent uses to represent such knowledge
MOF2 key ideas: Reuse structural core of UML2 for meta-modeling purposes While a class diagram specifying knowledge about a given domain is
part of a UML model, a class diagram specifying constructs of a knowledge representation (or modeling) language is a MOF meta-model
The abstract constructs and concrete visual syntax of a UML domain model and MOF meta-model are the same, only the modeling purposes and levels are different
Meta-circularity: MOF2 is its own meta-model (the meta-meta-model)
MOF2 Meta-Models MOF2 Meta-Models vs.vs. BNF BNF GrammarsGrammars
Same purpose Advantages of MOF:
Abstract instead of concrete syntax (more synthetic) Visual notation instead of textual notation (clarity) Graph-based instead of tree-based (abstracts from any reader
order) Entities (classes) have internal structure and behavior (strings do
not) Relations include generalization and undirected associations
instead of only order Specification reuse through inheritance and package relationships
Additional advantages with OCL: OCL constraint apply equally well to meta-models than to models Allows expressing arbitrary complex logical constraints among
language elements (more expressive) Allows defining formal semantics without mathematical syntax
Simplified MOF2 Meta-Model of itselfSimplified MOF2 Meta-Model of itself
InstanceSpecification
Parameter*
Generalization
*
AssociationClass
AssociationClass
DataType
PrimitiveType Enumeration
Interface*
1..*Relationship
Relationship
NamedElement
Constraint
*
TypedElementType
Property
ValueSpecification
Classifier
Feature Classifier
RedefinableElement
*
Element
*
NamedElement
BehavioralFeature StructuralFeature
Operation
*
UML2 Active x Passive ObjectsUML2 Active x Passive Objects
Active objects Instances of active classes
Possess their own, continuous execution thread
Concurrent to other active objects
Exchange data with other active objects asynchronously through message passing
Does not wait for the other active object target of the message to respond to pursue its own processing
Can be pro-active: execute behavior on its own initiative without waiting to receive a request from another object
Passive (regular) objects Instances of passive (regular)
classes Share a single thread with the
other passive objects constituting a sequential application
Exchange data with other passive objects synchronously through method invocation
Interrupts its processing, waiting for an answer of the other passive object before pursuing its own processing
Purely reactive: execute behavior only as response to a method invocation request from another object
UML2 Active Classes and ObjectsUML2 Active Classes and Objects
UML2 classes can encapsulate other classes
Thus, UML2 objects can encapsulate other objects
UML 2.0 Component Meta-ModelUML 2.0 Component Meta-Model
Class
Component
EncapsulatedClassifier
StrcuturedClassifierpart *
required
**
provided
ConnectableElementConnectorEnd2..* *
Connector
*
Interface
Classifier
*
Property
Structural Feature
Type
Classifier
TypedElement
Association
PackagableElement
Port*
UML2 Components: Key DistinctionsUML2 Components: Key Distinctions
UML2 Component ClassesComponent Classes appearing in Class Diagrams together with UML2 Classes, Associations, Interfaces, Ports, Dependency and Realization Relationships
UML2 Component InstancesComponent Instances appearing in Object Diagrams together with UML2 Objects, Links, Ports and Connector Relationships
UML2 UML2 Component SpecificationComponent Specification diagram that, represents the component as a black box, describes only what the component does, i.e., its provided services
and externally visible states and what the component needs from its external environment, i.e.,
its required services. UML2 Component RealizationComponent Realization diagram that,
represents the component as a white box, describes how the component does what it does, by way of an internal assembly from lower granularity
components, classes and assoiciations that it encapsulates.
Component Class vs. Component Class vs. Standard OO Programming ClassStandard OO Programming Class
Component class: Medium granularity intermediate
between system and class, corresponding to that of a module, a library, an API or a package
Necessarily encapsulates behavior, possibly also data
Possesses meta-data describing its services and requirements to compose/assemble it with other components
Necessarily designed by contract by realizing and requiring interfaces
Relationships with other component classes: essentially horizontal clientship, possibly also encapsulating containment and conceptual generalization
Compiled independently of other components, allowing binary, source code language independent compatibility
Not necessarily object-oriented
OOP class: Fine grained unit Necessarily encapsulates data,
possibly also behavior Does not possess descriptive meta-
data Not necessarily designed by
contract Relationship with other classes:
essentially conceptual generalization, possibly also horizontal clientship and encapsulating containment
Compiled together with the other classes of a program, thus preventing binary, source code language independent compatibility
Component Class vs. Component Class vs. Module, Library, Package and APIModule, Library, Package and API
API: Ambiguous term, can mean only an interface specification or an interface
specification and its implementation A component class always means the latter
Modules, libraries, packages and APIs: Not independently deployable Single unit of compilation Source code language dependent Only encapsulates behavior not data No user interface nor testing interface No meta-data
Libraries and APIs: No conceptual generalization relationships No encapsulating containment relationships
Modules and Packages: Merely a source code structuring namespaces No instantiation as run-time entity
Component Instance Component Instance vs.vs. Object Object
Component Instance: Independently deployable At run time subject to service
invocation At deployment time subject to
composition/assembly Possesses meta-data accessible at
run time through access methods that describe its services and requirements
Possesses a user-interface for stand-alone deployment
Not necessarily object-oriented A server component instance can be
substituted by another one that conforms to its contract with no need to recompile or even to interrupt the client component instances
Client component code independent of server component deployment location
Object: Must be wrapped inside a program
to be executed Only subject to method invocation Two object that cooperate to
provide a service must be recompiled together to modify one of them
Client object method code dependent of server object method code deployment location
UML2 ComponentsUML2 Components
Instantiating a component class to create a component object is a complex process that involves: Instantiating of its encapsulated owned components, classes and
associations, and Assembling these instances together through connectors
Principles of component-based object-oriented representations: Recursive decomposition: components are internally assembled
from smaller and smaller ones down to those made of a single class Uniformity: everything is a component, including the entire system Locality: a given diagram shows only the part of the entire model
that is visible from the local perspective of a single <<subject component>>
Q: Why are UML2 components interesting for AI system engineering?
A: In essence, agents are UML2 active components
Agents as Active UML2 Components: Agents as Active UML2 Components: MAS Simulation Specification Class MAS Simulation Specification Class
DiagramDiagram
<<enumeration>>SimStateKind
runningstopped
<<interface>>Simulation
+run+stop
<<subject component>>Simulation
+state:SimStateKindSimAg SimEnv
Sim
Realization relationship:component realizes services provided by interface
Port: encapsulated classifier connection point with environment
<<subject component>>Simulation
+state:SimStateKind
Agents as Active UML2 Components: Agents as Active UML2 Components: MAS Simulation Realization Class DiagramMAS Simulation Realization Class Diagram
<<component>>Agent
SimAgSensors
Effectors
<<component>>Environment
SimEnvSensors
Effectors
SimAg SimEnv
<<enumeration>>AgPubStateKind
emptyinitialized
perceptReceivedactionSent
<<enumeration>>SimStateKind
runningstopped
<<enumeration>>EnvPubStateKind
emptyinitialized
perceptsSentactionsReceived
<<interface>>SimEnv
+create+terminate
+getEnvState():EnvPubStateKind
<<interface>>SimAg
+create+terminate
+getAgState():AgPubStateKind
Sim
Dependency relationship:component requires services
provided by interface to provide the services it itself realizes
Port for connection w/ sub-component
<<subject component>>:Simulation
Agents as Active UML2 Components: Agents as Active UML2 Components: MAS Simulation Realization Object MAS Simulation Realization Object
DiagramDiagram
<<component>>: Environment
Effectors
Sensors
Sim
<<component>>Ag1:Agent
SimAg
Sensors
Effectors
<<component>>AgN:Agent
SimAgSensors
Effectors
. . .
SimAg
SimAg
SimEnv
Agents as Active UML2 Components: Agents as Active UML2 Components: Agent Specification Class DiagramAgent Specification Class Diagram
<<subject component>>Agent
SimAg
Sensors
Effectors
<<component>>Environment
SimEnv
Effectors
Sensors
<<enumeration>>SimStateKind
runningstopped
<<component>>Simulation
+state:SimStateKindSimAg SimEnv
<<interface>>SimAg
+create+terminate
+getAgState():AgPubStateKind
Percept
Percept1 Percept2
<<interface>>Sensors
+receive1():Percept1+receive2():Percept2
<<interface>>Effectors
+send1(p:Percept1,,ag:Agent)+send2(p:Percept2.ag:Agent)
<<enumeration>>AgPubStateKind
emptyinitialized
perceptReceivedactionSent
Action
Action1 Action2
<<interface>>Sensors
+receive1(ag:Agent):Action1+receive2(ag:Agent):Action2
<<interface>>Effectors
+send1(ac:Action1)+send2(ac:Action2)
Sim
Agents as Active UML2 Components: Agents as Active UML2 Components: Agent Specification Object DiagramAgent Specification Object Diagram
<<component>>: Simulation
SimAg SimEnv
<<subject component>>:Agent
SimAgSensors
Effectors
<<component>>: Environment
SimEnvEffectors
Sensors
Sim
<<subject component>>:Agent
Agents as Active UML2 Components: Agents as Active UML2 Components: Agent Realization Class DiagramAgent Realization Class Diagram
SimAg<<interface>>
updateFromPredictedActionEffect
+update(o:AgSimModel,a:Action):AgSimModel
<<component>>ActionEffectPredictor
Sensors
Effectors
AgSimModel
SimModel
<<component>>BeliefReviser
<<interface>>updateFromPercept
+update(o:AgSimModel,p:Percept):AgSimModel
<<delegates>>
<<component>>ActionChooser
<<interface>>chooseAction
+choose(m:AgSimModel):Action<<delegates>>
<<subject component>>:Agent
Agents as Active UML2 Components:Agents as Active UML2 Components:Agent Realization Object DiagramAgent Realization Object Diagram
SimAg
Sensors
Effectors
m0:AgSimModel
<<delegates>>
<<component>>:ActionChooser
:Action
:Percept
<<component>>:BeliefReviser
<<delegates>>
m1:AgSimModel
m2:AgSimModel
<<component>>:ActionEffectPredictor
Agents as Active UML2 Components: Agents as Active UML2 Components: Environment Specification Class DiagramEnvironment Specification Class Diagram
<<subject component>>Environment
SimEnv
<<component>>Agent
<<enumeration>>SimStateKind
runningstopped
<<component>>Simulation
+state:SimStateKindSimAg SimEnv
<<interface>>SimEnv
+create+terminate
+getEnvState():EnvPubStateKind
Percept
Percept1 Percept2
<<interface>>Sensors
+receive1():Percept1+receive2():Percept2
<<interface>>Effectors
+send1(p:Percept1,,ag:Agent)+send2(p:Percept2.ag:Agent)
<<enumeration>>EnvPubStateKind
emptyinitialized
perceptsSentactionsReceived
Action
Action1 Action2
<<interface>>Sensors
+receive1(ag:Agent):Action1+receive2(ag:Agent):Action2
<<interface>>Effectors
+send1(ac:Action1)+send2(ac:Action2)
SimAg
Sensors
Effectors
Effectors
Sim
Agents as Active UML2 Components: Agents as Active UML2 Components: Environment Specification Object DiagramEnvironment Specification Object Diagram
<<component>>: Simulation
SimAg SimEnv
<<component>>Ag1:Agent
SimAgSensors
Effectors<<subject component>>
: Environment
SimEnvEffectors
Sensors
<<component>>AgN:Agent
SimAgSensors
Effectors
. . .
Sim
Agents as Active UML2 Components: Agents as Active UML2 Components: Environment Realization Class Environment Realization Class
DiagramDiagram<<subject component>>
Environment
+EnvPubState:EnvPubStateKind
SimAg<<component>>
Ramifier
<<interface>>updateFromRamifications
+update(o:EnvSimModel):EnvSimModel
Sensors
Effectors
EnvSimModel
SimModel
<<component>>DirectEffectUpdater
<<interface>>updateFromDirectEffects
+update(o:EnvSimModel,ac:Action):EnvSimModel
<<delegates>>
<<interface>>computeNewPercepts
+percept(o:EnvSimModel,a:Agent):Percept
<<component>>PerceptUpdater
<<delegates>>
<<subject component>>:Environment
Agents as Active UML2 Components: Agents as Active UML2 Components: Environment Realization Object Environment Realization Object
DiagramDiagram
SimAg
Sensors
Effectors
:Action
m0:EnvSimModel
<<component>>:Ramifier
<<delegates>>
:Percept
<<component>>:PerceptUpdater
m2:EnvSimModel
m1:EnvSimModel
<<component>>:DirectEffectUpdater
<<delegates>>
UML2 Common BehaviorsUML2 Common Behaviors
BehavioralFeature
Feature
Operation
TimeEvent
ValueSpecification
ChangeEvent
Class
Classifier
Signal Reception
Class
isActive = true
Interface
*
0..1
0..1
*0..1
*
SendSignalEvent
Event
ReceiveSignalEventSendOperationEvent
ReceiveOperationEvent
BehavioredClassifier
Classifier
methodBehavior
specification
ActivityInteraction StateMachine
0..1
Trigger
*
StructuralFeature
*
UML2 Protocol State MachinesUML2 Protocol State Machines
Specialization of state machines to specify interaction protocols between concurrent components, i.e., How the state S of component C restricts the operations Os
1, ... Osk
that another component can request C to execute What are the states S1, ... Sk, that result from the execution in S of
Os1, ... Os
k (respectively)
Useful for represent cooperation, competition and negotiation protocols among agents
Meta-model:
source
target
outgoing
incoming postCondition
preCondition
StateMachine
ProtocolStateMachine
State
Vertex ProtocalTransition Constraint
Operation
*
*
Pseudostate
kind:Pseudostatekind
<<enumeration>>PseudostateKind
initialjoinfork
junctionchoice
entryPointexitPointterminate
*1..*
Concrete transition syntax:[<pre-Condition>] <Operation> / <post-Condition>
UML2 Protocol State Machines: UML2 Protocol State Machines: ExamplesExamples
empty initialized
init()/create()/
perceptsReceived actionsSent
receive() send(action)/
AgentPSM {protocol}
empty initialized
init()/create()/
perceptsSent actionsReceived
send(agent1,percept1)/
receive(agentN/)
EnvironmentPSM {protocol}
send(agentN,perceptN)/
receive(agent1)/
... ...
PseudoState
PseudoState State
Operation
ProtocolTransition
UML2 ProfilesUML2 Profiles
Self-extension mechanism to customize UML2 towards: Specific application families (i.e., multi-agent simulations) Specific implementation platforms (i.e., EJB, .net, web services)
A profile is a set of stereotypes Concrete syntax: <<string>> and/or icon
Stereotypes are specializations of meta-classes from the UML2 meta-model
Package Class
Property Association
Profile
ProfileApplication*
**
meta-class
ExtensionStereotype*
Image
icon
ExtensionEnd*
UML2 Superstructure Meta-Model
UML2 Extension/Customization Language Meta-Model
MOF Meta-Model of a Simple Multi-Agent MOF Meta-Model of a Simple Multi-Agent Simulations Modeling Language (MASML)Simulations Modeling Language (MASML)
MAS2..*
EnvironmentAgent
Sensor Actuator
1..* 1..*
Percept1..*
AgentAction1..*
MAS
ReasoningComponent1..*
Agent
ReflexAgent ReflexComponent
ReflexAgent
ReasoningComponent
Sensor
Actuator1..*
1..*
AutomataAgentGoalBasedAgent
Goal
GoalInitializationComponent
GoalUpdateComponent
GoalBasedBehaviorStrategyComponent
ReasoningComponent
GoalBasedAgent
3..*
EnvironmentStateModel
ModelBasedBehaviorStrategyComponent
AgentAutomataAgent
EnvironmentStateModel
ModelInitializationComponent
PercpetInterpretationComponent
RamificationComponent
ModelBasedBehaviorStrategyComponent
ReasoningComponent
AutomataAgent
Actuator
Sensor4..*
1..*
MOF Meta-Model of a Simple Multi-Agent MOF Meta-Model of a Simple Multi-Agent Simulations Modeling Language (MASML)Simulations Modeling Language (MASML)
Agent
KBAgent KBComponent
KBAgent
ReasoningComponent
1..*
KnowledgeBase
PersistentKB VolatileKB
0..*
KBSentence1..*
1..*
ReflexAgent
ReflexKBAgent ReflexKBComponent
ReflexKBAgent
ReflexComponent
KBAgent KBComponent PersistentKB
ReflexKB
context ReflexKBComponent inv Volat ileKB.isEmpty()
AutomataKBAgent
AutomataAgent
AutomataKBAgent KBComponent
KBAgent EnvironmentStateModelKB
4..*
VolatileKB EnvironmentStateModel
4 ..*
GoalBasedKBAgent
GoalBasedAgent
GoalBasedKBAgent KBComponent
KBAgent GoalKB EnvironmentStateModelKB
6..*
VolatileKB Goal EnvironmentStateModel
4 ..*3 ..*
UML2 Profile for MASUML2 Profile for MAS
MASML Meta-Model UML2 Meta-Model
MAS
Environment
Agent
Sensor
Actuator
Percept
AgentAction
ReasoningComponent
EnvironmentStateModel
KnowledgeBase
KBSentence
Component
isActive = true
Component
Port
Signal
Model Package
PackagableElement
TypedElement
*