EEL 5937 The Bond Agent System (3) EEL 5937 Multi Agent Systems Lecture 17, March. 4, 2003 Lotzi Bölöni.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

TP4: S TATE M ACHINE D ESIGN P ATTERN  Definition  Infrastructure  Transition Code  Conclusion.
Chapter 1 Writing a Program Fall Class Overview Course Information –On the web page and Blackboard –
Install. Will your hardware work? Most things are compatible - a few are known not to be.
An End-User Perspective On Using NatQuery Building a Dynamic Variable T
Java Programming, 3e Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
CS220 Software Development Lecture: Multi-threading A. O’Riordan, 2009.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Chapter 9 Working with Forms. Principles of Web Design 2nd Ed. Chapter 9 2 Principles of Web Design Chapter 9 Objectives Understand how forms work Understand.
Introduction to the Enterprise Library. Sounds familiar? Writing a component to encapsulate data access Building a component that allows you to log errors.
ITIS 1210 Introduction to Web-Based Information Systems Chapter 24 How Websites Work with Databases How Websites Work with Databases.
Developing Workflows with SharePoint Designer David Coe Application Development Consultant Microsoft Corporation.
Workshop 9 in AOM & MAS Prof Kuldar Taveter, Tallinn University of Technology.
IDK5151 kohtumine kaugõppijatega
Java: Chapter 1 Computer Systems Computer Programming II.
Higher Grade Computing Studies 2. Languages and Environments Higher Computing Software Development S. McCrossan 1 Classification of Languages 1. Procedural.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
The Java Programming Language
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
.Net and Web Services Security CS795. Web Services A web application Does not have a user interface (as a traditional web application); instead, it exposes.
Working with Forms. How Forms Work Forms let you build interactive Web pages that collect information from a user and process it on the Web server The.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Week 12 Working with Forms Objectives Understand how forms work Understand form syntax Create input objects Build forms within tables Build and.
Topics Sending an Multipart message Storing images Getting confirmation Session tracking using PHP Graphics Input Validators Cookies.
9 Systems Analysis and Design in a Changing World, Fourth Edition.
What is Web Site Administration Tool ? WAT Allow you to Configure Web Site With Simple Interface –Manage Users –Manage Roles –Manage Access Rules.
9 Systems Analysis and Design in a Changing World, Fourth Edition.
EEL 5937 Managing mutability in agents EEL 5937 Multi Agent Systems Lecture 26, April 10, 2003 Lotzi Bölöni.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Slide 1 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Task 2 Briefing The Design of a Computer.
Experiment Management System CSE 423 Aaron Kloc Jordan Harstad Robert Sorensen Robert Trevino Nicolas Tjioe Status Report Presentation Industry Mentor:
EEL 5937 The Bond Agent System (2) EEL 5937 Multi Agent Systems Lecture 9, Feb. 4, 2003 Lotzi Bölöni.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Java Programming, 2E Introductory Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
EEL 5937 The Bond Agent System (4) EEL 5937 Multi Agent Systems Lecture 18, March. 6, 2003 Lotzi Bölöni.
Creating a GUI Class An example of class design using inheritance and interfaces.
Introduction of Geoprocessing Lecture 9 3/24/2008.
EEL 5937 The Bond Agent System (1) EEL 5937 Multi Agent Systems Lecture 8, Jan 30, 2003 Lotzi Bölöni.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
MIT AITI 2004 Swing Event Model Lecture 17. The Java Event Model In the last lecture, we learned how to construct a GUI to present information to the.
Spell Checker web service (you build a web client that interacts with the service) The client uses a servlet class and a JSP page. The user passes information.
Integrating and Extending Workflow 8 AA301 Carl Sykes Ed Heaney.
CSC 222: Object-Oriented Programming
Development Environment
Servlets.
Principles of Software Development
Web Development Web Servers.
“Form Ever Follows Function” Louis Henri Sullivan
Java Programming Language
Collecting Information from the User
Chapter 2: System Structures
Testing and Debugging.
Pre assessment Questions
Msury Mahunnah, Tallinn University of Technology
CS 153: Concepts of Compiler Design November 30 Class Meeting
File Transfer and access
Conditional Statements
Part B – Structured Exception Handling
Exceptions 1 CMSC 202.
Lecture 9 Announcements.
CMSC 202 Lesson 20 Exceptions 1.
Chapter 1: Creating a Program.
Presentation transcript:

EEL 5937 The Bond Agent System (3) EEL 5937 Multi Agent Systems Lecture 17, March. 4, 2003 Lotzi Bölöni

EEL 5937 Review of the homework Generally, speaking, those who submitted, solved the problem. Let’s see a typical solution. Both the judge and the prisoner needs one active strategy. You might want to add extra states (e.g. for waiting, error handling etc.).

EEL 5937 Blueprint for the Judge createPlane("JudgePlane") import homework s = homework.JudgeStrategy(agent) addFirstState(s, "Judge") s = bond.strategydb.WaitAndTransitionStrategy(agent, 5000, SUCCESS) addState(s, "Wait") addTransition('Judge', 'Wait‘, SUCCESS) addTransition('Wait', 'Judge', SUCCESS)

EEL 5937 Blueprint for the prisoner Prisoner.py import homework createPlane(“PrisonerPlane") s = homework.PrisonerStrategy(agent, 0) addFirstState(s, "Prisoner") s = bond.strategydb.WaitAndTransitionStrategy(agent, 5000, SUCCESS) addState(s, "Wait") addTransition('Prisoner', 'Wait',SUCCESS) addTransition('Wait', 'Prisoner', SUCCESS)

EEL 5937 Judge strategy package homework; import bond.agent.BondAgent; import bond.agent.strategy.Strategy; import bond.util.fsm.FSM; import bond.util.fsm.FSMException; import jade.lang.acl.ACLMessage; import jade.lang.acl.MessageTemplate; import jade.core.AID; public class JudgeStrategy extends Strategy { private FSM judgeFSM; private String[] prisoners; // list of prisoners private String[] responses; // list of responses by prisoners private String[] judgement; //judgement for prisoners private final String QUESTION = "Do you confess for this crime?"; private final String CONFESS = "Confess"; private final String NOT_CONFESS = "Not Confess";

EEL 5937 Judge strategy public JudgeStrategy(BondAgent a) { super(a); String states[] = { "AskPrisoners", "GetResponseFromPrisoners", "makeJudgement", "sendVerdict", }; judgeFSM = new FSM("Judge",states); judgeFSM.addTransition("AskPrisoners", "GetResponseFromPrisoners"); judgeFSM.addTransition("GetResponseFromPrisoners", "makeJudgement"); judgeFSM.addTransition("makeJudgement","sendVerdict"); }

EEL 5937 Judge strategy public void action() { if (judgeFSM.stateIs("AskPrisoners")) { askPrisoners(); // Send questions to prisoners } if (judgeFSM.stateIs("GetResponseFromPrisoners")) { getResponseFromPrisoners(); // Wait for response from prisoners } if (judgeFSM.stateIs("makeJudgement")) { makeJudgement(); // Given the responses, make a judgement } if (judgeFSM.stateIs("sendVerdict")) { sendVerdict(); // Send verdict to respective prisoners }

EEL 5937 Judge strategy – asking the prisoners private void askPrisoners() throws FSMException { ACLMessage question = new ACLMessage(ACLMessage.REQUEST); question.setSender(theAgent.getAID()); question.addReceiver(new AID(prisoners[0],false)); question.addReceiver(new AID(prisoners[1],false)); question.setContent(QUESTION); theAgent.send(question); judgeFSM.setState("GetResponseFromPrisoners"); }

EEL 5937 Judge strategy – wait for responses private void getResponseFromPrisoners() throws FSMException { MessageTemplate mt = MessageTemplate.MatchPerformative(ACLMessage.AGREE); mt = MessageTemplate.or(MessageTemplate.MatchPerformative(ACLMessage.REFUSE), mt); ACLMessage response = theAgent.receive(mt); if (response == null) { block(500); return; } for (int i=0; i<prisoners.length; i++) { if (response.getSender().getLocalName().equalsIgnoreCase(prisoners[i])) { if (response.getPerformative() == ACLMessage.AGREE) { responses[i] = CONFESS; } else if (response.getPerformative() == ACLMessage.REFUSE) { responses[i] = NOT_CONFESS; } break; } // end if } // end for } // end if (mt == null)... else if (responses[0] != null && responses[1] != null) { judgeFSM.setState("makeJudgement"); } } // end getResponseFromPrisoners

EEL 5937 Judge strategy – making the judgement private void makeJudgement() throws FSMException { judgement = new String[2]; if (responses[0].equalsIgnoreCase(CONFESS) && responses[1].equalsIgnoreCase(CONFESS)) { judgement[0] = "You have been jailed for 2 years"; judgement[1] = "You have been jailed for 2 years"; } else if (responses[0].equalsIgnoreCase(NOT_CONFESS) && responses[1].equalsIgnoreCase(NOT_CONFESS)) { judgement[0] = "You have been jailed for 1 year"; judgement[1] = "You have been jailed for 1 year"; } else { if (responses[0].equalsIgnoreCase(CONFESS)) { judgement[0] = "You are free !!!"; judgement[1] = "You are jailed for 3 years. Bad Luck!!!"; } else { judgement[1] = "You are free !!!"; judgement[0] = "You are jailed for 3 years. Bad Luck!!!"; } judgeFSM.setState("sendVerdict"); }

EEL 5937 Judge strategy – sending the verdict private void sendVerdict() throws FSMException { for (int i=0; i<prisoners.length;i++) { ACLMessage inform = new ACLMessage(ACLMessage.INFORM); inform.setSender(theAgent.getAID()); inform.addReceiver(new AID(prisoners[i],false)); inform.setContent(judgement[i]); theAgent.send(inform); } judgeFSM.setState("ReceiveCase"); }

EEL 5937 Handling user interfaces There are two choices here (A) Integrate the GUI with the strategy. Create an external class with the user interface, inherit it from JFrame, and directly point to it from the strategy. –Advantage: simple, you have direct access –Disadvantage: difficult –Example: bond/applications/prisoners_dilemma/simple (B) Create a separate user interface, as a separate strategy. –Advantage: separation of UI and functionality. Agents can be assembled, modified. –Disadvantage: more complex interaction, through the agent state. –Example: bond/applications/prisoners_dilemma/separateui

EEL 5937 Bootstrapping a multi-agent system

EEL 5937 Bootstrapping multi-agent systems Creating a set of agents which will act in a coalition. –In practical deployments, only agents working on behalf a single user are started like this. All the projects can be seen as examples of this. –Even if some of the agents in the projects are in adversarial relations. It can be done: –By hand using the Jade Remote Agent Manager. –By a bootstrapping agent.

EEL 5937 Bootstrapping agent. A bootstrap agent –Bootstrap.py (see example in the prisoners dilemma directory) –Takes a bootstrap file as input. –Starts the agents described (potentially on multiple machines) –Terminates. The format of the bootstrap file: Example bootstrap file: localhost bond\applications\prisoners_dilemma\simple\Judge.py Judge localhost bond\applications\prisoners_dilemma\simple\Prisoner1.py Prisoner1 localhost bond\applications\prisoners_dilemma\simple\Prisoner1.py Prisoner2

EEL 5937 Basic strategies. Strategy database

EEL 5937 Strategy Database Contains a collection of general purpose strategies. Promotes code reuse. Utility strategies –Running applications System strategies –Running applications, running scripts –Transfering files (FTP etc) –Mail, Http Agent manipulation –Remotely starting, stopping agents, etc. Agent protocol implementation –Question/Reply –Contract net, auctions, etc.

EEL 5937 Utility strategies: WaitAndTransitionStrategy Usage: –addState(WaitAndTransitionStrategy()) –addState(WaitAndTransitionStrategy(5000, SUCCESS)) Functionality: –Waits for the specified number of milliseconds than performs the transition specified. Transition: –The transition specified (SUCCESS by default)

EEL 5937 Utility strategies: DummyStrategy Usage: –addState(DummyStrategy()) Functionality: –Blocks indefinitely. (Used for debugging) Transition: –None.

EEL 5937 Utility strategies: ShowMessageStrategy, ShowErrorStrategy Usage: –addState(ShowMessageStrategy(“Message”)) –addState(ShowMessageStrategy(“ErrorMessage”)) Functionality: –Shows a message / error message in a dialog box. Transitions when the user clicks on the button. Transition: –SUCCESS

EEL 5937 Utility strategies: ChoiceStrategy Usage: –addState(ChoiceStrategy(“Proceed?”)) Functionality: –Shows a dialog with the message with two buttons. Transition: –SUCCESS if the Yes button is pressed. –FAILURE if the No button is pressed.

EEL 5937 Utility strategies: ExitAgentStrategy Usage: –addState(ExitAgentStrategy()) Functionality: –Terminates the agent by calling doDelete(). Transition: –None (the agent will be terminated).