1 / 170

Agent-Based Systems

Agent-Based Systems. Grading. Mid-term Exam 30% Labs 40% Final Presentation 30%. Project Documents (NOT Used). 張一二李一三 .rar 內含下列文件 : 產品說明 .doc 驗收測試 .doc 架構 .xxx (UML class diagram)

nuri
Download Presentation

Agent-Based Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Agent-Based Systems

  2. Grading • Mid-term Exam 30% • Labs 40% • Final Presentation 30%

  3. Project Documents (NOT Used) 張一二李一三.rar 內含下列文件: 產品說明.doc 驗收測試.doc 架構.xxx (UML class diagram) Scanners.java (header, pseudo code, source code) …

  4. Project Grading 1. 20% 題目 展現 agent 特色 1. FIPA CA& IP, 2. 一般網路程式不易做或做來繁雜的功能 新穎 實用 小型 (最好是一個功能) 2. 80% 品質 20% dependability (acceptance test cases) 20% usability (GUI) 20% reuse (headers of classes and public methods) 20% maintainability (pseudo code readability) 3. 兩台Notebook 電腦上網 來做 DEMO 並檢視文件

  5. Project Development Process • 先一起寫中文 產品說明驗收測試 • 再一起舉行 CRC 會議 訂出架構 • Classes 分工後 各自寫 method (unit) headers • 各自寫 unit test cases 及 test code • 各自寫 pseudo code 並用test case TRACE TO DEBUG • 各自依照 pseudo code 補上 source code • 各自用JUnit 做 unit testing • 最後,一起做驗收測試 • 注意: 各文件要反覆修改(iterative development)

  6. Changes in Computing World • 0. Single Machine C, Unix • 1. Internet TCP/IP • 2. Web HTTP, UDDI, SOAP • 3. Semantic Web Agent, Ontology

  7. Software Engineering Goal • SE goal is to reduce cognitive complexity through moving up abstraction levels. • Paradigm shifts raise the level of abstraction for developers. • We see paradigm shifts in recent SE history: agent object modal function data

  8. Three Software Engineering paradigms • 1. Function paradigm • 2. Object paradigm • 3. Agent paradigm

  9. Function paradigm • A software system is composed of functions, each performs a specific task. And the functions are not nested. • Typical language: C • The paradigm reduces cognitive load of developers, since structured constructs are used here to eliminate “goto” which causes huge cognitive load.

  10. C Example of Function paradigm main () { printf(“%d”, power(2, 3) /* 2**3 expects 8 */ ); } int power (int x,int n) /* raise x to n-th power; n>0 */ { int i, p; p=1; for (i=1; i<=n; ++i) p = p*x; return (p); }

  11. Object paradigm • A software system is composed of classes, each contains data structure and methods. • Object can be constructed at run-time that allocates a copy of the data structure of the class, and an object can invoke a method of its class. • Typical language: Java • This paradigm reduces communication load between customers and developers, as classes exactly model real-world entities. • Note that a method is actually a function just mentioned. That is, object paradigm extends function paradigm.

  12. Java Example of Object paradigm public class MathClass { private mathLevels myMathLevel; public MathClass ( ) { } /* constructor */ public power(int x, int n) { …} } // MathClass

  13. Agent paradigm • A software system is composed of agents. Agents can be created from agent classes. Each agent executes independently, and it can communicate with other agents. • An agent holds modal that presents mental model of its owner, and agent communication is driven by modal operator, such as Belief, Uncertainty. • Typical platform: JADE(Java Agent DEvelopment Framework) • This paradigm reduces communication load of customers, as agents easily model customers’ experiences, attitudes and thoughts in mental model. • Note that agent class extends Java thread class. That is, agent paradigm extends object paradigm.

  14. JADE Example of Agent paradigm /* 計算 y=x^n */ class PowerBehaviour extends SimpleBehaviour { private boolean finished = false; private int x ,n,y; public PowerBehaviour (MathAgent agent, int x, int n) { super (agent); this.x=x; this.n=n; } public boolean done() { return finished; } public void action() { for(y=x;--n>0;y*=x);finished=true; } } // end of PowerBehaviour public class MathAgent extends Agent { protected void setup() { PowerBehaviour power = new PowerBehaviour(this, 2, 3); this.addBehaviour(power); } } // end of MathAgent

  15. Agent paradigm (Cont.) The promises of agent paradigm are: • 1) Improved flexibility: Agents can register (join) or deregister (leave) a society (that is a software system) at any time. A software system is thus very dynamic and flexible. • 2) Improved reliability: Middle agent of an agent society can check agents’ history and monitor agents’ performance to expel low quality agents. Thus, a software system is more reliable.

  16. Module communication in 3 paradigms • Function paradigm: • A module is a function. Function call is the module communication scheme. • Object paradigm: • A software module is a class. A run-time module is an object. Message sending is the module communication scheme. • Agent paradigm: • A module is an agent. A modal-driven interaction is the module communication scheme.

  17. What is an agent? • A good question, and one that receives an inordinate amount of time from within the agent community itself. • Rather as was the case in the early days of object-oriented development, there is no one universally accepted definition of an agent, but instead a lot of people working in closely related areas, using similar ideas. • Put crudely, an agent is an autonomous software system: a system that can decide for itself what it needs to do.

  18. What is an agent? [cont.] • Given this basic definition, two main "religions" appear to have emerged with respect to agents: the intelligent agents community, and the mobile agents community. • Intelligent agents are essentially agents that can do reasoning or planning. • Mobile agents are agents that can transmit themselves across a computer network (e.g., the internet) and recommence execution on a remote site. [www.agentlink.org]

  19. Uses of Mobile Agent 1) Disconnected computing, such as PDA that might be disconnected in short notice. 2) Mobile agent can be sent to large data source and process the data locally. 3) Dynamic deployment of software. If you need to reconfigure hundreds of PDAs with a new version of software, use mobile agent to do it. [D. Kotz, p. 83, IEEE Concurrency, Sep. 1999]

  20. Why are agents important? • Agents are important for several reasons: 1) they are seen as a natural metaphor for conceptualising and building a wide range of complex computer systems (the world contains many passive objects), but it also contains very many active components as well); 2) they cut across a wide range of different technology and application areas, including telecoms, human-computer interfaces, distributed systems, and so on; 3) they are seen as a natural development in the search for ever-more powerful abstractions with which to build computer systems. [www.agentlink.org]

  21. JADE Introduction • JADE agent platform • fully implemented in Java language (version 1.4 or higher). • simplifies the implementation of multi-agent systems through a middle-ware that complies with the FIPA (Foundation of Intelligent and Physical Agent) specifications. • supports debugging and deployment through a set of development tools.

  22. JADE Introduction (Cont.) • The agent platform can be distributed across machines and operating systems, and the configuration can be controlled remotely via GUI (graphical user interface). • The configuration can be changed at run-time by moving agents from one machine to another (mobility), as and when required.

  23. Architecture of a FIPA Agent Platform

  24. Agent Management System (AMS) • is the agent who exerts supervisory control over access to and use of the Agent Platform. Only one AMS will exist in a single platform. • provides white-page and life-cycle service, maintaining a directory of agent identifiers (AID) and agent state. • Each agent must register with an AMS in order to get a valid AID. • Directory Facilitator (DF) • is the agent who provides the default yellow page service in the platform. • The Message Transport System (MTS) • also called Agent Communication Channel (ACC) • is the software component controlling all the exchange of messages within the platform, including messages to/from remote platforms.

  25. JADE Agent Platform distributed over several containers

  26. Agent life cycle

  27. Agent life cycle (Cont.) • INITIATED • the Agent object is built, but hasn't registered itself yet with the AMS, has neither a name nor an address and cannot communicate with other agents. • ACTIVE • the Agent object is registered with the AMS, has a regular name and address and can access all the various JADE features. • SUSPENDED • the Agent object is currently stopped. Its internal thread is suspended and no agent behaviour is being executed. • WAITING • the Agent object is blocked, waiting for something. Its internal thread is sleeping on a Java monitor and will wake up when some condition is met (typically when a message arrives). • DELETED • the Agent is definitely dead. The internal thread has terminated its execution and the Agent is no more registered with the AMS. • TRANSIT • a mobile agent enters this state while it is migrating to the new location. The system continues to buffer messages that will then be sent to its new location.

  28. Installing/Setting up JADE • Download from http://jade.tilab.com • Unzip the JADE binary package • Add jadeTools.jar, http.jar, jade.jar, iiop.jar and commons-codec\commons-codec-1.3.jar in “lib” directory to CLASSPATH • Add dot at end of CLASSPATH

  29. Starting JADE • java jade.Boot (without GUI) • java jade.Boot -gui (see figure below)

  30. Running an Agent • java jade.Boot [AgentName]:[ClassName] • AgentName: a globally unique agent name. • ClassName: the Java class name. • For example: java jade.Boot -gui ping1:PingAgent

  31. Running an HelloWorld Agent • Create a simplest JADE agent is • defining a class extending the jade.core.Agent class and • implementing the setup() method as shown in the code below. import jade.core.*; public class HelloWorld extends Agent{ public void setup(){ System.out.println("Agent Started: Hello World!"); System.out.println("-----About Me:-----"); System.out.println("My local name is:"+getLocalName()); System.out.println("My globally unique name is:"+getName() ); } } • java jade.Boot -gui hello:HelloWorld

  32. Running an HelloWorld Agent Using Eclipse • Create a new project

  33. Running an HelloWorld Agent Using Eclipse • Select Java Project and click Next

  34. Running an HelloWorld Agent Using Eclipse • Project name is Agent then click Next

  35. Running an HelloWorld Agent Using Eclipse • Click Finish

  36. Running an HelloWorld Agent Using Eclipse • Click mouse right button at mouse to set Build Path

  37. Running a HelloWorld Agent Using Eclipse • Add http.jar, • iiop.jar, • jade.jar, • jadeTools.jar and • commons-codec-1.3.jar • into Eclipse

  38. Running an HelloWorld Agent Using Eclipse • Click mouse right button at mouse to new a class

  39. Running an HelloWorld Agent Using Eclipse • Name is HelloWorld and Superclass is jade.core.Agent

  40. Running an HelloWorld Agent Using Eclipse • Copy example and paste in Eclipse

  41. Running an HelloWorld Agent Using Eclipse • Click red area and select Run…

  42. Running an HelloWorld Agent Using Eclipse • Click mouse right button at mouse and select new

  43. Running an HelloWorld Agent Using Eclipse • Name is HelloWorld and Main Class is jade.Boot • Select Arguments

  44. Running an HelloWorld Agent Using Eclipse • Program arguments is –gui Hello:HelloWorld • Click Apply and Run to run agent

  45. Running an HelloWorld Agent Using Eclipse • If run success, it will show as follow

  46. Agent Behaviors • Simple Behaviors: • SimpleBehaviour, OneShotBehaviour, CyclicBehaviour • Composite Behaviors: • ParallelBehaviour, SerialBehaviour

  47. SimpleBehaviour import jade.core.*; import jade.core.behaviours.SimpleBehaviour; public class DecativeReentrant extends Agent{ public void setUp( ){ SimpleBehaviour decative = new SimpleBehaviour(this){ boolean finished = false; int state = 0; public void action(){ switch(state){ case 0: System.out.println("Do"); break; case 1: System.out.println("Re"); break; case 2: System.out.println("Me"); finished = true; break; } state++; } // action public boolean done ( ) {return finished;} }; // new SimpleBehavior addBehaviour (decative); } //setUp }// DecativeReentrant • java jade.Boot -container doreme1:DecativeReEntrant

  48. Sequential Behaviour import jade.core.*; import jade.core.behaviours.SequentialBehaviour; import jade.core.behaviours.OneShotBehaviour; public class DecativeSequential extends Agent{ public void setUp(){ SequentialBehaviour s = new SequentialBehaviour(this); s.addSubBehaviour(new OneShotBehaviour(this){ public void action(){ System.out.println("Do");}}); s.addSubBehaviour(new OneShotBehaviour(this){ public void action(){System.out.println("Re");}}); s.addSubBehaviour(new OneShotBehaviour(this){ public void action(){System.out.println("Me");}}); addBehaviour(s); }// DecativeSequential • java jade.Boot doreme2:DecativeSequential

  49. Parallel Behaviour import jade.core.*; import jade.core.behaviours.SequentialBehaviour; import jade.core.behaviours.ParallelBehaviour; import jade.core.behaviours.OneShotBehaviour; public class ParallelBehaviourAgent extends Agent{ public void setup(){ SequentialBehaviour s1 = new SequentialBehaviour(this); s1.addSubBehaviour(new OneShotBehaviour(this){public void action(){System.out.println("1) This ");}}); s1.addSubBehaviour(new OneShotBehaviour(this){public void action(){System.out.println("1) first");}}); SequentialBehaviour s2 = new SequentialBehaviour(this); s2.addSubBehaviour(new OneShotBehaviour(this){public void action(){System.out.println("2) That ");}}); s2.addSubBehaviour(new OneShotBehaviour(this){public void action(){System.out.println("2) second");}}); ParallelBehaviour p = new ParallelBehaviour(this,ParallelBehaviour.WHEN_ALL); p.addSubBehaviour(s1); p.addSubBehaviour(s2); addBehaviour(p); } • java jade.Boot parall:ParallelBehaviourAgent

  50. Agent Communication Language (ACL) • JADE is implemented as an object of the ACLMessage class that provides get and set methods for handling all fields of a message. • Message format comprises a number of fields: • Sender • The sender of the message • Receiver (s) • The list of receivers

More Related