Presentation is loading. Please wait.

Presentation is loading. Please wait.

高级人工智能 第十四章 分布式人工智能 多主体环境MAGE 史忠植 中国科学院计算技术所 2018/11/14 史忠植 高级人工智能.

Similar presentations


Presentation on theme: "高级人工智能 第十四章 分布式人工智能 多主体环境MAGE 史忠植 中国科学院计算技术所 2018/11/14 史忠植 高级人工智能."— Presentation transcript:

1 高级人工智能 第十四章 分布式人工智能 多主体环境MAGE 史忠植 中国科学院计算技术所 2018/11/14 史忠植 高级人工智能

2 内容提要 概述 MAGE简介 主体建模 开发平台 运行平台 移动主体 应用 2018/11/14 史忠植 高级人工智能

3 概述 http://www.agentlink.org/resources/agent-software.php
Agent Software Total: 116 MAGE: Multiagent development environment is an integrated tool suite for constructing multiagent systems 2018/11/14 史忠植 高级人工智能

4 AgentCities Beijing! 2018/11/14 史忠植 高级人工智能

5 General Development Process
Requirement Analysis System Development System Deployment System Design Behaviour Library Agent Society Agent Library 2018/11/14 史忠植 高级人工智能

6 多主体系统设计过程 用例模型 功能描述 活动模型 反应规则模型 推理模型 行为描述 状态机模型 交互协议模型 规划模型 组织关系模型
主体类模型 主体描述 本体模型 本体描述 部署模型 配置描述 2018/11/14 史忠植 高级人工智能

7 UML中的表示法 (抽象语法) OMG发布的UML定义规范中,模型的抽象语法是通过类图表示的各结构成分之间的关系给出的。
2018/11/14 史忠植 高级人工智能 UML中用例包的抽象语法

8 UML中的表示法 (静态语义) 模型结构成分之间的约束(即静态语义)是通过OCL语言描述的规则表示的。
例如:Actor只能与UseCase、Subsystem和Class发生关联,并且关联是二元的。此约束表示如下: self.associations -> forAll (a | a.connection -> size = 2 and a.allConnections -> exists(r | r.type.oclIsKindOf(Actor)) and a.allConnections -> exists(r | r.type.oclIsKindOf(UseCase) or r.type.oclIsKindOf(Subsystem) or r.type.oclIsKindOf(Class) ) ) 2018/11/14 史忠植 高级人工智能

9 AUMP 主体 交互 主体系统结构 本体 AUML 主体 类型图 系统 配置图 系统 结构图 本体图 协议图 角色图 UML 类图 分布图
协作图 2018/11/14 史忠植 高级人工智能

10 AUML扩展UML来描述多主体系统 在AUML中,我们引入了四种面向主体的图来描述一个多主体系统:
本体图:定义用来描述世界状态用到的实体以及它们之间的关系。 主体系统结构图:描述多主体系统的结构。 协议图:描述主体之间的交互协议。 角色图:描述主体在交互中扮演的角色。 2018/11/14 史忠植 高级人工智能

11 AUMP的表示法 (属性图) AUML的图形模型都是属性图。属性图是带属性的多重有向图。 属性图的形式化定义如下:
AttributeGraph=(V, E, s, d, ) s,d:EV :(E∪V)(AU) 其中,V是节点集合,E是边的集合,s,d是边到节点的函数,分别表示边的起点和终点。 是边和节点到属性描述的函数,属性描述是属性名称到属性值的函数,A表示属性名称集合,U表示属性值集合。 属性图由多重有向图的节点和边添加属性描述得到 2018/11/14 史忠植 高级人工智能

12 3.2.3 AUMP的表示法 (Meta表示法) 描述程序设计语言抽象语法的Meta表示法由两部分组成: (1)构造的有限集合。
(2)产生式的有限集合,每个产生式和一个构造对应。 聚集产生式:表示一个构造有固定数目的成分。 例Conditional = test:Boolean_expression; thenbranch: Command; elsebranch:Command; 选择产生式:表示一个构造可以选择几种类型。 例Command = Skip | Assignment | Compound | Conditional | Loop 表产生式:表示一个构造是另一个构造的实例序列。 例Compound = Command+ 属性图由多重有向图的节点和边添加属性描述得到 2018/11/14 史忠植 高级人工智能

13 3.2.3 AUMP的表示法 (结合属性图和Meta表示法)
基本思想:将模型、节点、边、属性都看作构造,模型是非终结构造,节点、边和属性是终结构造,模型通过一定的产生式由节点、边和属性构成。 扩充:扩充Meta表示法表示属性图中的函数关系。因为函数关系是实体到另外实体的映射关系,而不是构造关系。所以,符号 = 仍然表示构造关系,新加入符号  表示函数关系。如:状态机模型中的转移描述为: Transition  sourcestates; targetstates; rule:ECARule 如果t是Transition的一个实例,那么用tsource,ttarget, t.rule来表示t的起点、终点和转移规则。 属性图由多重有向图的节点和边添加属性描述得到 2018/11/14 史忠植 高级人工智能

14 3.2.3 AUMP的表示法 (状态机模型的抽象语法)
状态机模型由状态集合、目标集合、转移集合、驱动集合构成: StateChartModel = states: StateSet; goals: GoalSet; transitions: TransitionSet; drives: DriveSet; StateSet = {State}; GoalSet = {Goal}; TransitionSet = {Transition}; DriveSet = {Drive}; 状态是起始状态、结束状态和一般状态之一: State = Initial | Final | CommonState; 转移连接两个状态实例,并且有一条ECA规则描述: Transition  sourcestates; targetstates; rule:ECARule; ECA规则由事件、条件和动作构造: ECARule = event: Event; condition:Condition; action:Action; 驱动连接目标实例和状态实例: Drive  goalgoals; statestates; 属性图由多重有向图的节点和边添加属性描述得到 2018/11/14 史忠植 高级人工智能

15 AUMP的表示法 (静态语义的表示) 通过前面的表示法,已经将模型的抽象语法表示成为了集合和关系的形式,那么就可以用集合表示法中的各种约束表示法来描述模型的静态语义。 例如,状态机模型中起始状态的合法性描述为:有且只有一个起始状态;起始状态有离开的转移,没有进入转移;离开起始状态的转移的ECA规则中事件和条件为空。 形式化描述如下: 属性图由多重有向图的节点和边添加属性描述得到 2018/11/14 史忠植 高级人工智能

16 3.3.1 活动图动态语义简介 活动图为主体工作流建模,是描述主体行为最常用的方式。因此,活动图动态语义研究是AUML动态语义研究的重要组成部分。 活动图描述的是工作流的过程维度,即活动在时间上的先后顺序,而不考虑资源维度。 AUML在语法上对活动图并没有扩充,而是从语义上需要对UML定义的活动图语义进行扩充。 2018/11/14 史忠植 高级人工智能

17 3.3.2 活动图的语法 活动图是一个有向图,包括节点和有向边。 Activity节点表示一个活动的执行。
start end decision/merge fork/join wait 活动图中的节点 compound activity Activity节点表示一个活动的执行。 Wait节点表示等待某个事件的出现。 fork/join表示并发结构,decision/merge表示分支结构。 边实际上是一条ECA规则e[c]/a,其中e是事件表达式,c是限制条件,a是动作表达式。这三个部分每个都是可选的。具有e[c]/a标记的边具有如下含义:如果系统处于源状态,事件e出现,并且限制条件c满足,那么系统离开源状态,执行动作a,进入目标状态。 2018/11/14 史忠植 高级人工智能

18 3.3.4 活动图的语义 (执行算法) 2018/11/14 史忠植 高级人工智能 Initialize;
While (C ≠ final configuration) do – Repeat until I ≠ [ ]; // wait for input events – Retrieve the valuation of the local variables; – Take a super-step: Repeat 1. Compute a step; 2. Compute the internal events generated in the step; 3. Compute the next configuration; 4. Update C with the next configuration; 5. Empty the input I and fill it with the generated internal events; 6. Switch new relevant timers on and irrelevant timers off; 7. Update the bag of active edges by handling control nodes; Until I is empty and there are no enabled edges; End while ; 2018/11/14 史忠植 高级人工智能

19 3.3.5 执行示例 有了动态语义,活动图就可以被执行。例如: 工作流描述(活动图) 运行 Run1 Run2 Run3
Initial State {Activity1} State1 Activity1 Terminates {Output1} State2 {Input1} State3 State4 {Activity3} Output1 Input1 Activity3 {Activity2, Activity4} Activity2 Activity4 Run1 Run2 {Activity4} Run3 {Activity2} 运行 Activity1 Condition1 Output1 Input1 Activity2 :Goal1 Activity3 Condition2 Activity4 Role1 Role2 工作流描述(活动图) 2018/11/14 史忠植 高级人工智能

20 Tool Suite(AUMP) 2018/11/14 史忠植 高级人工智能

21 MAGE Agent Agent kernel Function Function Component Module Sensor
Interface Resource Database Engine Communicator Scheduling Function Component Plug-INs Reasoning Negotiation coOperation others Plug-in Manager Task Database 2018/11/14 史忠植 高级人工智能

22 Agent Operation Cycle 2018/11/14 史忠植 高级人工智能

23 VAStudio Architecture
2018/11/14 史忠植 高级人工智能

24 Screenshot of VAStudio
2018/11/14 史忠植 高级人工智能

25 Syntax of ADL(1) <Agent> ::= <Definition>
<Local Address> <Acquaintance Addresses> <Extra Classes> <Capabilities> <Environment Variables> <Sessions> <Definition> ::= <Agent Name> <Description > <Agent Name> ::= "[Name]" <agent> = <agent_name> <Description> ::= "[Description]" BEGIN <description> END <Local Address> ::= "[Local Address]" <agent> = <host_name>:<port> 2018/11/14 史忠植 高级人工智能

26 Syntax of ADL(2) Acquaintance Addresses> ::= "[Acquaintance Address]" BEGIN {<acquaintance> = <host_name>:<port>}* END  <Extra Classes> ::= "[Extra Classes]" {<Class>}*  <Class> ::= Instance = <instance name> CONSTRUCTOR = <constructor>  <Capabilities> ::= "[Capabilities]" {<Capability>}*  <Capability> ::= NAME = <capability_name> TYPE = <capability_type> CMDLINE = <capability_command_line> SOURCE = <capability_source>   <capability_type> ::= 0 | 1 | 2 2018/11/14 史忠植 高级人工智能

27 Syntax of ADL(3) <Environment Variables> ::= "[Environment Variables]" BEGIN {<Variable>}* END <Variable> ::= <Variable Type> <variable_name>[ = <initial_value>] <Variable Type> ::= int|boolean|char|string|float <Sessions> ::= "[SESSIONS]" {<Session>}* END  <Session> ::= SESSION <Java Sentences> END SESSION 2018/11/14 史忠植 高级人工智能

28 中国科学院 计算技术研究所 主体间通信结构 2018/11/14 史忠植 高级人工智能

29 主体通信语言(ACL) ACL 通信模块 并发对话机制 2018/11/14 史忠植 高级人工智能

30 ACL constructing 2018/11/14 史忠植 高级人工智能

31 Message Transport System (MTS)
MAGE MAGE 主体 Agent Management System Directory Facilitator Agent Message Transport System (MTS) Software Library Function Component Other Agent Platforms 2018/11/14 史忠植 高级人工智能

32 GUI of MAGE 2018/11/14 史忠植 高级人工智能

33 Mage Tools Sniffer: Debugging tool, show communication between agents with graphic interface. Dummy: Debugging tool, demonstrate conversation between agents conveniently. DF: Directory facilitator, a service providing yellow page service DLRM: A description logic based reasoning machine, providing reasoning service. ALM: Managing AAP and AAF, it will be further developed to build application via AAP and AAF. 2018/11/14 史忠植 高级人工智能

34 DummyAgent 2018/11/14 史忠植 高级人工智能

35 Sniffer 2018/11/14 史忠植 高级人工智能

36 Directory Facilitator
What is Directory Facilitator and why dose MAGE need DF. What can be done through DF? View Register Deregister Modify Search Federal search 2018/11/14 史忠植 高级人工智能

37 GUI of DF 2018/11/14 史忠植 高级人工智能

38 AAP and AAF What is Agent Application Pattern (AAP)?
What is Agent Application Framework (AAF)? The relations between them? Why does MAGE provide them? AAP management GUI 2018/11/14 史忠植 高级人工智能

39 GUI for AAP management 2018/11/14 史忠植 高级人工智能

40 FIPA inter-operation protocol library
What is inter-operation protocol? Why does MAGE provide these protocols? MAGE provides protocols such as: FipaRequestInitiatorBehaviour FipaRequestResponderBehaviour FipaQueryInitiatorBehaviour FipaQueryResponderBehaviour FipaContractNetInitiatorBehaviour FipaContractNetResponderBehaviour ContractNetInitiator …… 2018/11/14 史忠植 高级人工智能

41 AAF: reasoning service
Description logic Description logic based reasoning machine Working pattern 2018/11/14 史忠植 高级人工智能

42 DLRM 2018/11/14 史忠植 高级人工智能

43 Agent container Providing plenty of agent management function: createAgent, suspendAgent, resumeAgent, waitAgent, wakeAgent changeAgentPrincipal, changeContainerPrincipal, moveAgent, copyAgent, killAgent, dispatch, ping, installMTP, uninstallMTP, enableSniffer, disableSniffer, enableDebugger, disableDebugger. Providing toolkit for agent: handleStart, handleEnd, handleMove, handleClone, handleSend, handlePosted, handleReceived, handleChangedAgentState, handleChangedAgentPrincipal Providing event handling Demonstrate Start new agent Install a new MTP Uninstall a MTP Kill ContainerFrame 2018/11/14 史忠植 高级人工智能

44 Agent platform Providing plenty of management function for agent and container addContainer、removeContainer、suspend changeAgentPrincipal、wait、wake、move、copy、sniffOn、sniffOff、debugOn、debugOff、installMTP、uninstallMTP Notify what happened to event handler (mainly AMS) bornAgent、deadAgent、suspendedAgent、resumedAgent、changedAgentPrincipal、newMTP、deadMTP Demonstrate View APDescription Manage installed MTPs PlatformFrame 2018/11/14 史忠植 高级人工智能

45 AgentPlatforms This node includes all platforms: local platform or remote platforms Demonstrate Add platform via AMS AID Add platform via URL Add a container to a remote platform Start a tool from a remote container Communication between platforms 2018/11/14 史忠植 高级人工智能

46 移动主体 Mobility in MAGE platform
Supports user-defined content language and ontology. Inter-operation between MAGE and other agent or non-agent software. …… 2018/11/14 史忠植 高级人工智能

47 Introduction to Mobile Agents
What is Mobile Agents? Mobility: Agents that can travel in network Autonomy: migrate at times and to place of their own choosing Compare to .. Stationary agent Mobile code (Applets) Mobile object 2018/11/14 史忠植 高级人工智能

48 Network Computing Paradigms
Client-Server Paradigm Code-onDemand Paradigm Download (Applet) Server Know how Server Client Client Know- how Know- how Mobile Agent Paradigm Agent Agent Network Know- how Know- how Host Host 2018/11/14 史忠植 高级人工智能

49 Compare Client/Server & Mobile Agent Model
Limitation of Client/Server Scaling -- Multiple servers Quality of network connection Reliability , latency , bandwidth Protocol Advantage of Mobile Agents Every node is a server Request Network connection No application-level protocol 2018/11/14 史忠植 高级人工智能

50 Seven good reasons for Mobile Agents
Reduce network load Overcome network latency Encapsulate protocols Execute asynchronously and autonomously Adapt dynamically Naturally heterogeneous Fault-tolerant 2018/11/14 史忠植 高级人工智能

51 Mobile Agent Systems Java-based: Others: Odyssey. General Magic Inc.
Concordia. Mitsubishi’s Aglets. IBM Voyager. ObjectSpace Others: Tacoma: Univ.of Tromso and Cornell Univ. Agent TCL: Dartmouth College 2018/11/14 史忠植 高级人工智能

52 Mobile Agent Model Key concepts: Agent Place
-- the main entity in Mobile Agent System Place -- the environment where agents operate 2018/11/14 史忠植 高级人工智能

53 Agent State: Implementation: Interface Identifier Principals
needed for resume computation after traveling Implementation: needed for location-independent agent execution Interface needed for agent communication Identifier needed for recognize and locate traveling agents Principals needed to determine legal and moral responsibility 2018/11/14 史忠植 高级人工智能

54 Place Engine Resources Location Principals
Workhorse and virtual machines for one or more places Resources Databases,processors,and other services provided by the host Location The network address of a given place Principals Those legally responsible for the opration of a place 2018/11/14 史忠植 高级人工智能

55 The Agent Model Pyramid
Host Engines Places Agents 2018/11/14 史忠植 高级人工智能

56 Place and Engine Host Agent Place Resources Engine 2018/11/14
史忠植 高级人工智能

57 Agent Behavior(1) Creation and Disposal
Instantiation and identifier assignment Initialization Autonomous execution Disposal Preparing for disposal Suspension of execution 2018/11/14 史忠植 高级人工智能

58 Agent Behavior(2) Transfer – dispatching/receiving
Dispatch and Receive: Sender Receiver Suspend Execution Resume Execution Serialize Agent Deserialize Agent Encode Data Decode Data Transfer Data Receive Data Network 2018/11/14 史忠植 高级人工智能

59 Agent Behavior(2) Transfer – agent class transfer
Server Class code Class at Server(code on demand) Origin Server Agent Agent Class code Class code Class at origin Class at destination 2018/11/14 史忠植 高级人工智能

60 Security of Mobile Agent
What can go wrong? Agent protection – remote host , other agents, unauthorized third parties Host protection – incoming agents, third parties Network protection -- incoming agents Security Services Authentication user, host, code, agent Integrity Confidentiality Authorization Non-repudiation Auditing 2018/11/14 史忠植 高级人工智能

61 Aglet Model Basic Elements: Aglet – a mobile Java object
Proxy – a representative of an aglet Context –an aglet’s workplace Identifier Host,Server process(engine) and Context Host Context Context Aglet and Proxy: Client Interaction Proxy Aglet Imagine that you could hire the exclusive services of an agent to run errands for you throughout the Internet. The agent would scurry to distant Web sites to pick up information that you need, keep going back to monitor sites whose content changes frequently, consult with other agents to work out the best times for meetings with your colleagues, and even make bids on your behalf in Internet auctions. It would be a perfect cyber-servant that would permit you to devote your own time to other tasks. Researchers at IBM's Tokyo Research Laboratory have done more than imagine Internet agents -- they have actually created them. Named aglets, they are programmed to leave their owner's computer on request, roam the Internet, and visit other computers, where they perform specific tasks such as collecting data and interacting with other agents. Java is the universal language of the World Wide Web. Most computer users encounter Java directly in the form of applets -- small programs that users can download into their Web browsers and then run. The IBM team decided to reverse the process. It designed programs that a user could send out over the Web for execution on other computers. When they reach a target computer, these aglets present their credentials in the form of recognizable code. Once approved for entry to the remote computer, they obtain the data and services that they seek, and return them to their home computers. They can also react with other aglets at remote sites, to schedule meetings for example. Since Java code works independently of any particular computer operating system, IBM's aglets perform their tasks independently of the operating systems used by their home computer and any computers that they visit. Server Process(Engine) Network 2018/11/14 史忠植 高级人工智能

62 Aglet : Life Cycle Model
Fundamental operations: Creation Cloning Dispatching Retraction Activation and deactivation Disposal Dispose Context A Context B Clone Dispatch Aglet Aglet Retract Create Deactivate Activate Disk storage Class File 2018/11/14 史忠植 高级人工智能

63 Aglet : Event Model Clone listener Mobility listener
Persistence listener Clone event CloneListener Aglet Mobility event MobilityListener PersistenceListener Persistence event 2018/11/14 史忠植 高级人工智能

64 Aglet : Communication Model
Message passing: Allows aglets to create and exchange messages in flexible ways. Key Components: Aglet, AgletProxy,Message,Future reply, Reply set Aglet/ Application Message Message Proxy Aglet Reply Reply 2018/11/14 史忠植 高级人工智能

65 Aglet Package : a Quick Tour
Aglet Class AgletProxy Interface AgletContext Interface Message Class FutureReply Class AgletID Class 2018/11/14 史忠植 高级人工智能

66 Aglet API : Aglet Class Create a customized aglet: Overriden methods:
import com.ibm.aglet.*; Public class MyFirstAglet extends Aglet{ //put aglet’s methods here } Overriden methods: public void onCreation(Object init){ //do some initialization here… public void run() { //do something here; }//main entry point //e.g. call dispatch(new URL(“atp://some.host.com//context”)); The aglet class is the key class in the Aglet API. It is the abstract class that aglet developer can use as base class when creating customized aglets. The aglet class defines methods for controlling its own life cycle: methods for cloning, dispatching, deactivating ,and disposing of itself. It also defines methods that are supposed to be overridden by programmer in order to customize the aglet’s behavior. These methods are systematically invoked by the system when certain events take place—remember that aglet programming model is event-based. Now look at some methods in aglet class. First we start with importing the aglet package, and then define the MyFirstAglet class, which inherits from the Aglet class. For example, we want our aglet to perform some specific initialization when it is created, we can override the “onCreation” method. When an aglet has been created or when it arrives in a new context, it’s given its own thread of execution through a system invocation of its “run” method. We can look on this invocation as a means of giving the aglet a degree of autonomy. The run method is called every time when an aglet arrives at or is activated in a new context, you can say it becomes the main entry point for the aglet’s thread of execution. By overriding this method, we can customize the aglet’s autonomous behavior. For example, we want the aglet to dispatch itself to a remote context, then we can call the dispatch method, with the URL of the remote host as the argument. This URL should specify the host and domain names of the destination context and the protocol(atp) to be used for transferring the aglet over network. URL can also include the name of the remote context. If no context name specified, it will move into the default context. 2018/11/14 史忠植 高级人工智能

67 Aglet API :Aglet Class What happens when “dispatch”?
State Object Serialization Transfer Deserialization and re-create state Byte Code Host Host Sending Receiving What happens to aglet when dispatch() is called? Basically the aglet will disappear from your machine and will reappear in the same object state at the specified destination. A special technique called object serialization is used to preserve the state information of the aglet. It makes a sequential byte representation of the aglet. It’s passed to the underlying transfer layer, which brings the aglet over the network. Here the aglet actually transferred is byte code and state information The transferred bytes are deserialized to recreate the aglet’s state. State Byte Code Host Host 2018/11/14 史忠植 高级人工智能

68 Aglet API : AgletProxy Why AgletProxy? How to get a proxy?
Acts as a shield object that protects an aglet from malicious aglets Provide the aglet with location transparency How to get a proxy? Get proxy from a newly created aglet: AgletContext.createAglet(), AgletProxy.clone() Get proxy from existing aglets Aglet.getProxy() – get its own proxy AgletContext.getAgletProxies() – retrieve an enum. of proxies in a context AgletContext.getAgletProxy() – get an aglet proxy for a given aglet ID Message passing – passed as an argument AgletContext.setProperty – put proxy into context property and share it. The agletproxy interface acts as the handle of an aglet and provides a common way of accessing the aglet. Because an aglet class has several public methods that should not be accessed directly from other aglets for security reasons, any aglets that wants to communicate with other aglets must first obtain the proxy and then interact through this interface. IN other word, aglet proxy acts as a shield object that protects an aglet from malicious aglets. Another important role of the Agletproxy interface is to provide the aglet with location transparency. If the actual aglet resides at a remote host, the proxy forwards the requests to the remote host and returns the result to the local host. Creating an aglet is one way to get a proxy. The AgletContext.createAglet method will return the proxy of the newly created aglet. Other methods that return proxies include AgletContext.retractAglet, AgletProxy.clone, and AgletProxy.dispatch. Proxies of existing aglets can also be obtained in the following ways: Aglet.getProxy – AgletContext.getAgletProxies— AgletContext.getAgletProxy Get an aglet proxy via message passing. An agletProxy object can be put into a message object as an argument and sent to the aglet locally or remotely Put an agletproxy object into a context property by using the agletcontext.setProperty method and share the proxy object. 2018/11/14 史忠植 高级人工智能

69 Aglet API : AgletContext
An aglet context is the equivalent of a place. An aglet uses AgletContext interface to: Get information about its environment Send message to the environment, including other aglets currently active in that environment How it works: context=getAgletContext(); context.createAglet(); context.retractAglet(remoteContextURL,agletID); An aglet context is the equivalent of a place. An aglet spends most of its life in an aglet context. It is created in the context, it goes to sleep there, and it dies there. When it travels in a network, it moves from context to context. In other word, the context is a uniform execution environment for aglets. An aglet uses AgletContext interface to get information about its environment and to send message to the environment, including other aglets currently active in that environment. This interface provides means for maintaining and managing running aglets in an environment where the host system is secured against malicious aglets The aglet class has a method for gaining access to its current context: 2018/11/14 史忠植 高级人工智能

70 Aglet API : Message Class
Aglets communicate by exchanging objects of the Message class. “kind” field: distinguishes messages Message myName=new Message(“my name”, “Jacob”); Message yourname=new Message(“your name?”); Methods to send message(defined in AgletProxy class): Object sendMessage(Message msg) FutureReply sendFutureMessage(Message msg) Void sendOnewayMessage(Message msg) 2018/11/14 史忠植 高级人工智能

71 Aglet API : Message Class
handleMessage method: Public boolean handleMessage(Message msg){ if(msg.samekind(“my name”)){ String name=(String)msg.getArg(); return true; //Yes, I handled this message } else if(msg.samekind(“your name?”)) { msg.sendReply(“Yina”); //Return its name } else return false; //No, I did not handle this message } 2018/11/14 史忠植 高级人工智能

72 Aglet API : AgletID Class
Identity: Globally unique Throughout lifetime AgletID object Hides the implementation-specific representation Immutable Use : AgletID aid=proxy.getAgletID(); proxy=context.getAgletProxy(aid); 2018/11/14 史忠植 高级人工智能

73 Anatomy of an Aglet Creation & Disposal Clone Mobility Persistence
– Dispatch and Retract Persistence – Activate and Deactive 2018/11/14 史忠植 高级人工智能

74 Creation public final AgletContext Aglet.getAgletContext()
//Example: getAgletContext().createAglet(getCodeBase(),”SomeAglet”,null); Methods that can be overridden protected Aglet.Aglet() Public void Aglet.onCreation(Object init) Public void Aglet.run() To do anything with an aglet we must first create it by instantiating it from an aglet class or cloning an existing aglet. Firstly we take a look at create. Remember that aglet is created in a context, where it will spend most of its life. You can look on a context as a uniform environment for the aglet, no matter the aglet is executing on a PC with Windows or on a UNIX workstation, it’s guaranteed a fixed set of services from the context. One of the services, which we are going to demonstrate, is instantiation of new aglets from a given aglet class. For an aglet to instantiate new aglets it needs to access its current context first, by calling the getAgletContext method. This method has three arguments. The first one, which defines the code base of the aglet, is a URL, which specifies the base URL of the aglet class file. In other words, the directory that contains the aglet’s code, where the directory might be a remote one. If this argument is null, it is the local host’s aglet search path to be specified, as a similar way to Java’s class path. The second is the name of the aglet class(code), and the third consists of a possible initialization argument . Note that do not attempt to instantiate an aglet directly from its constructor by using the new statement in Java. All aglets instances must be properly initialized after instantiation. Although the aglet context will control the creation of new aglet, there are several hooks that programmer can use to customize the behavior of the aglet during its creation. That is, there are some methods we can override to implement the desired behavior. Here are three of particular interest here, the aglet’s constructor, on Creation, and run. As I mentioned earlier, these methods are automatically invoked by the context during the creation of the aglet. Now we use the collaboration diagrams to illustrate this mechanism. First, the createAglet method in the aglet context is called. The top most horizontal bar represents its execution. During the execution, createAglet will create an instance of the given aglet class, which is seen as an invocation of the aglet’s constructor. When the aglet instance has been constructed, on Creation is invoked, and when that has been executed, run is invoked. createAglet() Aglet() onCreation run() 2018/11/14 史忠植 高级人工智能

75 Disposal public final void Aglet.dispose();
public void Aglet.onDisposing(); Dispose() onDisposing() run() 2018/11/14 史忠植 高级人工智能

76 Event Event Types: Delegation-Based Event Mode CloneEvent
MobilityEvent PersistencyEvent Delegation-Based Event Mode CloneListener CloneAdapter MobilityListener MobilityAdapter PersistencyListener PersistencyAdapter 2018/11/14 史忠植 高级人工智能

77 Cloning Public final Object Aglet.clone()
Public final void Aglet.addCloneListener(CloneListener listener) Public final void Aglet.removeCloneListener(CloneListener listener) public CloneAdapter.CloneAdapter() public void CloneAdapter.onCloning(CloneEvent event) public void CloneAdapter.onClone(CloneEvent event) public void CloneAdapter.onCloned(CloneEvent event) 2018/11/14 史忠植 高级人工智能

78 Cloning (continued) run() original onCloning() onCloned() onClone()
public class CloningExample extends Aglet{ boolean _theClone=false; public void onCreation(Object o) { addCloneListener(new CloneAdapter(){ public void onCloning(CloneEvent e){ // print to the console } public void onClone(CloneEvent e){ public void onCloned(CloneEvent e){ } ); } public void run() { if (! _theClone) { //the original runs here… try{ clone(); } catch (Exception e) { System.out.println(e.getMessage()); } else {//the clone runs here…} run() original onCloning() onCloned() onClone() clone run() 2018/11/14 史忠植 高级人工智能

79 Mobility -- Dispatching -- Retracting Origin Destination Local Remote
run( ) Origin dispatch( ) onDispatching( ) onArrival( ) Destination run( ) retractAglet( ) Local onArrival( ) run( ) run( ) Remote onReverting( ) 2018/11/14 史忠植 高级人工智能

80 Persistence Persistence Aglet Context Activate Deactivate Before After
run( ) Before deactivate( ) onDeactivating( ) onActivation( ) After run( ) 2018/11/14 史忠植 高级人工智能

81 Inside Aglets … Architecture Overview Aglet API Aglet Runtime Layer
Services and User-defined aglets Aglet API Aglet Runtime Layer Core Framework Management Components CacheManager SecurityManager PersistanceManager Communication API Communication Layer 2018/11/14 史忠植 高级人工智能

82 Communication Layer Communication API Agent Transfer Protocol(ATP)
An ATP request consists of : a request line, header fields, content. Four standard request method: Dispatch Retract Fetch Message ATP ATP Host Host HTTP HTTP Tunneling of ATP 2018/11/14 史忠植 高级人工智能

83 Aglet Security Principal Permissions Protection Policy & Authority
Context & Server Network Domain Permissions Protection Policy & Authority Aglet owner Context owner Network Domain owner 2018/11/14 史忠植 高级人工智能

84 Comparison 2018/11/14 史忠植 高级人工智能 Phase Agent Platform AgentBuilder
AgentBuilder Jack Zeus MAGE Analysis Completeness: ★★★ ★★★★ ★★★★★ Applicability: Complexity: Reusability Design ★★ Development ★★★★★★ Deployment 2018/11/14 史忠植 高级人工智能

85 成果应用(2) 亚洲宽带—异文化协作 NTT Communication (日本) Kyoto京都大学(日本)
成果应用(2) 亚洲宽带—异文化协作 合作单位: NTT Communication (日本) Kyoto京都大学(日本) Wakayama和歌山大学(日本) Osaka大阪大学(日本) JST日本科技公司(日本) 中国科学院计算技术研究所(中国) 北京大学(中国) 2018/11/14 史忠植 高级人工智能

86 成果应用(2) 亚洲宽带—异文化协作 1 2 3 AMS DF Server Client Client MTS
成果应用(2) 亚洲宽带—异文化协作 MTS User Agent User Agent Agent Platform Chinese Academy of Science AMS DF 1 2 3 Kyoto U/Wakayama U Synchronous Collaboration Tool Synchronous Collaboration Tool P2P Collaboration Platform Asynchronous Collaboration Tool Machine Translation Morphological Analysis RDF DB User Management Asynchronous Collaboration Tool 2018/11/14 史忠植 高级人工智能 Server Client Client

87 成果应用(3) 配电网故障恢复决策系统 恢复策略
2018/11/14 史忠植 高级人工智能

88 成果应用(4) 战争仿真 决策训练 决策分析 武器体系 战略层 指挥训练 方案分析 武器系统 战役层 战术层 合成训练 合成分析 技能训练
武器运用 武器工程 技术层 “人” 2018/11/14 “方案” 史忠植 高级人工智能 “武器” 对象

89 成果应用(5) 电子商务系统结构 Application Services SearchAgent BargainAgent
InfoAgent DF Agent AMS Agent RMA Agent Agent Platform Management MAGE JavaBean JSP Servlet Web Interface Agent Browser Users Resources DataBase Strategies Models Information 2018/11/14 史忠植 高级人工智能

90 成果应用(6) 电子商务示范1 2018/11/14 史忠植 高级人工智能

91 成果应用(5) 电子商务示范2 2018/11/14 史忠植 高级人工智能


Download ppt "高级人工智能 第十四章 分布式人工智能 多主体环境MAGE 史忠植 中国科学院计算技术所 2018/11/14 史忠植 高级人工智能."

Similar presentations


Ads by Google