L C SL C S Programming with Metaglue How to create basic agents.

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

An Overview Of Virtual Machine Architectures Ross Rosemark.
OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Python Objects and Classes
Chapter 16 Graphical User Interfaces John Keyser’s Modifications of Slides by Bjarne Stroustrup
Java Card Technology Ch07: Applet Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Computer Science & Engineering.
15-May-15 RMI Remote Method Invocation. 2 “The network is the computer” Consider the following program organization: If the network is the computer, we.
Advanced Programming Rabie A. Ramadan Lecture 4. A Simple Use of Java Remote Method Invocation (RMI) 2.
POP QUIZ!!! What kind of software is Medisoft? Name ONE of the 4 things that you can do to data in Medisoft. What is the Medisoft Program Date? What key.
Remote Method Invocation
Road Map Introduction to object oriented programming. Classes
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Reza Gorgan Mohammadi AmirKabir University of Technology, Department of Computer Engineering & Information Technology Advanced design.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
DISTRIBUTED FILE SYSTEM USING RMI
Introduction to Remote Method Invocation (RMI)
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
OOP Languages: Java vs C++
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
Programming Languages and Paradigms Object-Oriented Programming.
Java RMI Essentials Based on Mastering RMI Rickard Oberg.
CS 584 Lecture 18 l Assignment » Glenda assignment extended to the Java RMI Deadline » No Java RMI Assignment l Test » Friday, Saturday, Monday.
+ A Short Java RMI Tutorial Usman Saleem
Activities and Intents. Activities Activity is a window that contains the user interface of your application,typically an application has one or more.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Design Patterns Part two. Structural Patterns Concerned with how classes and objects are composed to form larger structures Concerned with how classes.
Installing SIGNZ on a stand- alone machine. These slides will guide you through the installation of the SIGNZ ‘server’ and ‘client’ components on one machine.
CSCE 2013L: Lab 1 Overview  Java Basics The JVM Anatomy of a Java Program  Object-Oriented Programming Overview  Example: Payroll.java JDK Tools and.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
1 Java RMI G53ACC Chris Greenhalgh. 2 Contents l Java RMI overview l A Java RMI example –Overview –Walk-through l Implementation notes –Argument passing.
IBM TSpaces Lab 1 Introduction. Summary TSpaces Overview Basic Definitions Basic primitive operations Reading/writing tuples in tuplespace HelloWorld.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
1.  Writing snippets of code that try to use methods (functions) from your program.  Each snippet should test one (and only one) function......by calling.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
We will talking about story of JAVA language. By Kristsada Songpartom.
Introduction to Java Beans CIS 421 Web-based Java Programming.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
Chapter 5 Introduction to Defining Classes
Chapter 1 Introducing Ant. What is ant? Ant is a build tool  Automate the tasks of compiling code, running test, and packaging the results for redistribution.
Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Creating a Java Application and Applet
L C SL C S Metaglue: Overview Of Current Challenges Krzysztof Gajos Oxygen Workshop, January, 2002.
Remote Method Invocation A Client Server Approach.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
1 Entity Callbacks and Listeners When you execute EntityManager methods like persist( ), merge( ), remove( ), and find( ), or when you execute EJB QL queries,
Java Object-Relational Layer Sharon Diskin GUS 3.0 Workshop June 18-21, 2002.
Netprog Java RMI1 Remote Method Invocation.
Coming up Implementation vs. Interface The Truth about variables Comparing strings HashMaps.
June 3, 2016 BANNER HR FORUM.  To receive credit on your LMS transcript, please be sure you have indicated your attendance.  As a courtesy to others,
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
Java Distributed Computing
Remote Method Invocation
Programming with Metaglue
Remote Method Invocation
C# Event Processing Model
Packages and Interfaces
Connecting Metaglue Spaces Together
Metaglue For Oxygen Partners
Constructors, GUI’s(Using Swing) and ActionListner
Connecting Metaglue Spaces Together
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Review: libraries and packages
Java Remote Method Invocation
Java Object-Relational Layer
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

L C SL C S Programming with Metaglue How to create basic agents

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Metaglue Overview – Basic Capabilities On-demand agent startup Automatic restarting of agents Direct call or publish-subscribe communication Service mapping Customization (Attributes)Attributes Persistent storage (Persistent Map, Icebox) Interfaces: speech, GUI, web On-demand agent startup Automatic restarting of agents Direct call or publish-subscribe communication Service mapping Customization (Attributes)Attributes Persistent storage (Persistent Map, Icebox) Interfaces: speech, GUI, web

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Agent Naming Society – specific to people, spaces and groups Occupation – agent’s function as Java interface name –agentland.device.Projector, –agentland.software.StartInterface Designation – to differentiate among various instances of the same agent within a society society : occupation - designation

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Agent Naming – Example e21:agentland.device.Projector-rear Society e21 for the E21 conference room Agent for controlling a projector Specifies which projector

L C SL C S Writing a Basic Agent

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Writing Metaglue Agents File Naming Conventions Two files: the agent + the interface For agent agentland.device.display.Projector : Interface: agentland/device/display/Projector.java Agent: agentland/device/display/ProjectorAgent.java

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Why separate files? The name of an object is not the object itself in RMI The Interface declares the name of the agent and what methods are available to other agents –Some methods available through inheritance The Agent is the fully implemented class object

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Writing Metaglue Agents The most basic agent interface package newbie.tutorial; import metaglue.*; import java.rmi.*; import agentland.resource.*; public interface Basic extends Managed { } // Basic The most basic agent package newbie.tutorial; import metaglue.*; import java.rmi.*; import agentland.resource.*; public class BasicAgent extends ManagedAgent implements Basic { public BasicAgent() throws RemoteException { } } // BasicAgent The interface is of type interface

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Writing Metaglue Agents The most basic agent interface package newbie.tutorial; import metaglue.*; import java.rmi.*; import agentland.resource.*; public interface Basic extends Managed { } // Basic The most basic agent package newbie.tutorial; import metaglue.*; import java.rmi.*; import agentland.resource.*; public class BasicAgent extends ManagedAgent implements Basic { public BasicAgent() throws RemoteException { } } // BasicAgent The agent is of type class and will always implement the interface for which it is named

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Writing Metaglue Agents The most basic agent package newbie.tutorial; import metaglue.*; import java.rmi.*; import agentland.resource.*; public class BasicAgent extends ManagedAgent implements Basic { public BasicAgent() throws RemoteException { } } // BasicAgent The most basic agent interface package newbie.tutorial; import metaglue.*; import java.rmi.*; import agentland.resource.*; public interface Basic extends Managed { } // Basic The basic packages you always have to import

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Writing Metaglue Agents The most basic agent package newbie.tutorial; import metaglue.*; import java.rmi.*; import agentland.resource.*; public class BasicAgent extends ManagedAgent implements Basic { public BasicAgent() throws RemoteException { } } // BasicAgent The most basic agent interface package newbie.tutorial; import metaglue.*; import java.rmi.*; import agentland.resource.*; public interface Basic extends Managed { } // Basic ManagedAgent is a superclass of all agents capable of communicating with resource managers. Most of our agents now extend ManagedAgent. This is where the ManagedAgent lives

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Writing Metaglue Agents The most basic agent package newbie.tutorial; import metaglue.*; import java.rmi.*; import agentland.resource.*; public class BasicAgent extends ManagedAgent implements Basic { public BasicAgent() throws RemoteException { } } // BasicAgent The most basic agent interface package newbie.tutorial; import metaglue.*; import java.rmi.*; import agentland.resource.*; public interface Basic extends Managed { } // Basic The constructor, as well as all exported methods (i.e. the ones specified in the interface) have to either throw RemoteException, or this exception has to be caught inside the method. It’s an RMI thing.

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Writing Metaglue Agents The second most basic agent interface package newbie.tutorial; import metaglue.*; import java.rmi.*; import agentland.resource.*; public interface Basic extends Managed { public void tellMe() throws RemoteException; } // Basic An exported method is thus declared in an interface…

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Writing Metaglue Agents The second most basic agent package newbie.tutorial; import metaglue.*; import java.rmi.*; import agentland.resource.*; public class BasicAgent extends ManagedAgent implements Basic { public BasicAgent() throws RemoteException { } public void tellMe() throws RemoteException { log(“I am “ + getAgentID()); log(“My society is “ + getSociety()); log(“My designation is “ + getDesignation(); log(“I am running on “ + whereAreYou()); } } // BasicAgent An exported method is thus declared inside an agent itself…

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Writing Metaglue Agents The second most basic agent package newbie.tutorial; import metaglue.*; import java.rmi.*; import agentland.resource.*; public class BasicAgent extends ManagedAgent implements Basic { public BasicAgent() throws RemoteException { } public void tellMe() throws RemoteException { log(“I am “ + getAgentID()); log(“My society is “ + getSociety()); log(“My designation is “ + getDesignation()); log(“I am running on “ + whereAreYou()); } } // BasicAgent Primitives that allow the agent to find out about its own identity We will talk about logs later…

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Fundamental Metaglue Primitives Agent reliesOn(AgentID aid) Agent reliesOn(String occupation) Agent reliesOn(String occupation, Object designation) void tiedTo(String hostName) void tiedTo(AgentID anotherAgent) void tieToDesignation() reliesOn() returns a pointer to proxy representing an instance of the agent with specified AgentID ; if necessary, the agent is first started. tiedTo() should only be called in the constructor! It ensures that the agent runs on a particular machine or on the same VM as another agent. reliesOn is for direct communication

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Fundamental Metaglue Primitives Agent reliesOn(AgentID aid) Agent reliesOn(String occupation) Agent reliesOn(String occupation, Object designation) void tiedTo(String hostName) void tiedTo(AgentID anotherAgent) void tieToDesignation() reliesOn() returns a pointer to proxy representing an instance of the agent with specified AgentID ; if necessary, the agent is first started. tiedTo() should only be called in the constructor! It ensures that the agent runs on a particular machine or on the same VM as another agent. These two methods take the society from the current agent

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Writing Metaglue Agents – reliesOn() The not-so basic agent package newbie.tutorial; import metaglue.*; import agentland.resource.*; import java.rmi.*; public class NotSoBasicAgent extends ManagedAgent implements NotSoBasic { Basic basic; public NotSoBasicAgent() throws RemoteException { basic = (Basic) reliesOn( Basic.class ); } public void test() throws RemoteException { log( “calling tellMe() from the basic agent:” ); basic.tellMe(); } } // BasicAgent

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Writing Metaglue Agents – reliesOn() The not-so basic agent package newbie.tutorial; import metaglue.*; import agentland.resource.*; import java.rmi.*; public class NotSoBasicAgent extends ManagedAgent implements NotSoBasic { Basic basic; public NotSoBasicAgent() throws RemoteException { basic = (Basic) reliesOn( Basic.class ); } public void test() throws RemoteException { log( “calling tellMe() from the basic agent:” ); basic.tellMe(); } } // BasicAgent Note that the whole reliesOn process happens in terms of interfaces and not actual agents. What you get back from reliesOn is an object that implements the same interface as the agent but you do not get the agent itself!

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Writing Metaglue Agents – reliesOn() The not-so basic agent package newbie.tutorial; import metaglue.*; import agentland.resource.*; import java.rmi.*; public class NotSoBasicAgent extends ManagedAgent implements NotSoBasic { Basic basic; public NotSoBasicAgent() throws RemoteException { basic = (Basic) reliesOn( Basic.class ); } public void test() throws RemoteException { log( “calling tellMe() from the basic agent:” ); basic.tellMe(); } } // BasicAgent But you talk to agents as if they were local objects…

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Logging Messages in Metaglue Better than System.out.println() void log(int logLevel, String message) void log(String logLevel, String message) void log(String message) (defaults to log(“INFO”, message) ) Log levels: As ints: LogStream.DEBUG LogStream.INFO LogStream.WARNING LogStream.ERROR LogStream.CRITICAL String shortcuts: “DEBUG” “INFO” “WARNING” “ERROR” “CRITICAL”

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) More on Logging You can specify in your agent what kind of messages from a given agent should appear on the console window: void setLogLevel(int logLevel) Example: public BasicAgent() throws RemoteException { setLogLevel(LogStream.DEBUG); }

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Why bother with Logging? In a distributed system, the console/launcher window can be the standard out for many agents These logs will be very confusing to use if you want to track the progress of a particular agent

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Viewing Logs – agentland.debug.PowerTester

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Viewing Logs – agentland.util.LogMonitor The LogMonitor agent will bring up the same logging window as in the previous slide, but it does not need to use the PowerTester agent LogMonitor will list all agents which are currently running on the catalog currently in use Even itself !

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Sending and Receiving Messages – metaglue.Notifier Producer of a message Subscriber Notifier

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Anatomy of a Message Messages are represented by instances of the object “Secret” –Name device.light.stateUpdate.on –Details – any Serializable object –Source – AgentID of the sender –Time stamp – the time when the secret was first created *based on the clock of the machine where the sender is located

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Naming of Messages Names based on the Agent’s full heirarchical name –For the agent named device.Light *device.Light.stateUpdate.on *device.Light.stateUpdate.off When you subscribe to device.Light you will receive device.Light.stateUpdate messages as well –The same as subscribing to device.Light.* When you subscribe to device.*.stateUpdate, you will receive state updates from all devices Subscribing to notifications should happen in the startup() method

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Subscribing to Notifications package newbie.tutorial; import metaglue.*; import agentland.resource.*; import java.rmi.*; public class BasicAgent extends ManagedAgent implements Basic { public BasicAgent() throws RemoteException { addSpy( “tutorial.basic.StateUpdate” ); } public void tell( Secret s ) throws RemoteException { if ( s.isA( “tutorial.basic.StateUpdate” ) ) log( “Received new state “ + s.details() ); } } // BasicAgent Processing notifications tell() is the default method for processing notifications

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Subscribing to Notifications package newbie.tutorial; import metaglue.*; import agentland.resource.*; import java.rmi.*; public class BasicAgent extends ManagedAgent implements Basic { public BasicAgent() throws RemoteException { } public void tell( Secret s ) throws RemoteException { if ( s.isA( “tutorial.basic.StateUpdate” ) ) log( “Received new state “ + s.details() ); } public void startup () { addSpy( “tutorial.basic.StateUpdate” ); } } // BasicAgent Subscribing to a family of notifications Check what kind of message has been received before working with it

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Subscribing to Notifications – cont. package newbie.tutorial; import metaglue.*; import agentland.resource.*; import java.rmi.*; public class BasicAgent extends ManagedAgent implements Basic { public BasicAgent() throws RemoteException { } public void action( Secret s ) throws RemoteException { if ( s.isA( “tutorial.basic.Action” ) ) log( “Received an action notification “ + s.details() ); } public void startup () { addSpy( “tutorial.basic.Action”, “action” ); } } // BasicAgent Specifying the method to process notifications Processing notifications through a custom method

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Sending Notifications package newbie.tutorial; import metaglue.*; import agentland.resource.*; import java.rmi.*; public class BasicAgent extends ManagedAgent implements Basic { public BasicAgent() throws RemoteException { } public void doMyThing() throws RemoteException { // do something Object stateObject = getState(); notify( “tutorial.basic.StateUpdate”, stateObject ); } } // BasicAgent Sending a notification

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Building Agents These can be run from ~/metaglue or the source code area in ~/metaglue/newbie/tutorial/ Compile all of the java source files –make javac *Remember, Java is NOT Python. You must recompile after making changes! Compile the implementation files –make rmic

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Running Agents First start the catalog: mg_ catalog [-purge] purge will remove any previous maps and registered agents from the database when it starts the catalog. Only one of these is allowed on a computer. Then start a Metaglue platform: agent society catalogHost [agent name] Any agent can be started by providing the agent’s name (the package interface. This will never end with “Agent”) Not including an agent namewill start an empty Metaglue platform ready to receive agents. or the agent tester: mg_agent society catalogHost agentland.debug.PowerTester

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Dialog boxes Many messages pop up asking for values. These are the part of the customization of Metaglue through remembered attributes The defaults for most of them are fine. Those that don’t have defaults: –username for agentland.society.Society *None needed for the class, but enter your name if you like. –Others will be particular to the agents you are running. See the class material for information on those.

Oxygen Alliance Annual Meeting — June , 2002 Presenter name goes here — MIT Artificial Intelligence Lab or Lab for Computer Science (delete one) Statistics on Metaglue 10 Tons of fun: –There are over 450 agents that exist within Metaglue –Between 50 and 80 agents are running the intelligent room –You are using more than 10 agents just while running the X10BasicLightControl *Test it! Use agentland.util.LogMonitor Metaglue has been in development since 1998 The system is used in several offices and homes including the office of the AI lab director, Rodney Brooks There are 2 full spaces at MIT (a 3 rd is coming soon!) and one space in Australia running Metaglue –Why not get your own?