Sensor Web – TITAN Research 4/24/2017

Slides:



Advertisements
Similar presentations
Java Language Quick-Reference Guide B. Oracle10g: Java Programming B - 2 Console Output Java applications and applets can output simple messages to the.
Advertisements

FIPA Interaction Protocol. Request Interaction Protocol Summary –Request Interaction Protocol allows one agent to request another to perform some action.
SOAP.
Written by: Dr. JJ Shepherd
Inheritance Inheritance Reserved word protected Reserved word super
9. Inheritance 9.1 Subclasses 9.2 Polymorphism 9.3 Abstract Classes 9.4 Modifiers and Access 9.6 Object-Oriented Design with Use Cases and Scenarios.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes.
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.
Interfaces. In this class, we will cover: What an interface is Why you would use an interface Creating an interface Using an interface Cloning an object.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Chapter Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Chapter 10 Classes Continued
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
C++ fundamentals.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Processing of structured documents Spring 2003, Part 6 Helena Ahonen-Myka.
Web Proxy Server. Proxy Server Introduction Returns status and error messages. Handles http CGI requests. –For more information about CGI please refer.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Appendix A.2: Review of Java and Object-Oriented Programming: Part 2 “For the object-oriented project, remember that the primary unit of decomposition.
CMSC 202 Interfaces. 11/20102 Classes and Methods When a class defines its methods as public, it describes how the class user interacts with the method.
Programming Languages and Paradigms Object-Oriented Programming.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Java Classes, Interfaces, and Types 1.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Writing Classes (Chapter 4)
SSC2: Web Services. Web Services Web Services offer interoperability using the web Web Services provide information on the operations they can perform.
T Network Application Frameworks and XML Web Services and WSDL Sasu Tarkoma Based on slides by Pekka Nikander.
Workshop 9 in AOM & MAS Prof Kuldar Taveter, Tallinn University of Technology.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Java Language and SW Dev’t
Agent-Based Systems. Grading l Mid-term Exam 30% l Labs 40% l Final Presentation 30%
Software Agent Computing Agent Mobility. Agent mobility is the ability for an agent program to migrate or to make a copy (clone) itself across one or.
The Java Programming Language
XML Web Services Architecture Siddharth Ruchandani CS 6362 – SW Architecture & Design Summer /11/05.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
1 Agent-Oriented Programming (AOP). 2 Grading l Mid-term Exam 30% l Labs 40% l Final Presentation 30%
Java The Java programming language was created by Sun Microsystems, Inc. It was introduced in 1995 and it's popularity has grown quickly since A 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.
Supporting FIPA Interoperability for Legacy Multi-Agent Systems Christos Georgousopoulos 1 Omer F. Rana 1 ( ) 2.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Object Oriented Programming
IBM TSpaces Lab 2 Customizing tuples and fields. Summary Blocking commands Tuple Expiration Extending Tuples (The SubclassableTuple) Reading/writing user.
Chapter 7: Class Inheritance F Superclasses and Subclasses F Keywords: super and this F Overriding methods F The Object Class F Modifiers: protected, final.
Chain of Responsibility A graphical user interface and a user that needs help; a security system with multiple sensors; a banking automated coin storage.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
EEL 5937 The Bond Agent System (3) EEL 5937 Multi Agent Systems Lecture 17, March. 4, 2003 Lotzi Bölöni.
Classes, Interfaces and Packages
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
// Java2101.java This program tests the features of the class. public class Java2101 { public static void main (String args[]) { System.out.println("\nJAVA2101.JAVA\n");
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
Fusion Design Overview Object Interaction Graph Visibility Graph Class Descriptions Inheritance Graphs Fusion: Design The overall goal of Design is to.
(c) University of Washington10-1 CSC 143 Java Errors and Exceptions Reading: Ch. 15.
MTA SZTAKI Department of Distributed Systems Hogyan mixeljünk össze webszolgáltatásokat, ontológiákat és ágenseket? Micsik András.
Chapter 9: Continuing Classes By Matt Hirsch. Table Of Contents 1.Static Fields and Methods 2.Inheritance I. Recycle Code with Inheritance II. Overriding.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 1: Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science.
JADE Java Agent Development Environment Yunus Emre ÇAKMAZ Ahmet Cahit YAŞA 1.
Real-Time Systems Laboratory Seolyoung, Jeong JADE (Java Agent DEvelopment framework )
2-Oct-16 Basic Object-Oriented Concepts. 2 Concept: An object has behaviors In old style programming, you had: data, which was completely passive functions,
Sections Inheritance and Abstract Classes
Lecture 12 Inheritance.
ATS Application Programming: Java Programming
null, true, and false are also reserved.
Java Programming Language
An overview of Java, Data types and variables
CSC 143 Java Errors and Exceptions.
Chap 2. Identifiers, Keywords, and Types
Inheritance Lakshmish Ramaswamy.
Presentation transcript:

Sensor Web – TITAN Research 4/24/2017 JADE Ontologies Sensor Web – TITAN Research 4/24/2017

Agent Communication A fundamental characteristic of MAS Individual agents communicate and interact Accomplished through the exchange of messages To understand each other, agents agree on the format and semantics of these messages. Messages adhere strictly to the ACL (Agent Communication Language) standard which allows several possibilities for the encoding of the actual content

Ontology We can to define our own vocabulary and semantics for the content of the messages exchanged between your agents. This means defining an ontology. In fact, JADE provides three ways to implement communication between agents.

1st Communication Method Use strings to represent the content of messages What we have done so far This is convenient when the content of messages is atomic data This is not useful with abstract concepts, objects or structured data. In such cases, the string needs to be parsed to access its various parts.

2nd Communication Method Exploit Java technology to transmit Serialized Java objects directly as the content of messages. This is convenient for local systems where all agents are implemented in Java. One inconvenience is that these messages are not readable by humans.

3rd Communication Method Define objects to be transferred The objects are extensions of predefined classes so that Jade can encode and decode messages in a standard FIPA format. This allows Jade agents to interoperate with other agent systems. This introduces the ontology.

Overview of Communication Methods 1st Method: Content type: Strings Getting method: getContent() Setting method: setContent() 2nd Method: Content type: Java Objects Getting method: getContentObject() Setting method: setContentObject() 3rd Method: Content type: Ontology Objects Getting method: extractContent() Setting method: fillContent()

Bank Example The bank example consists of 3 versions The first version, Bank-1-jObjects, shows how to implement communication between agents using Java objects. The second version, Bank-2-Onto, shows how to implement the communication between agents using an ontology. And the third directory, Bank-3-Gui, adds a graphical user interface.

Bank Example 1 - Java objects Two agents implement the client and server roles for the bank with savings accounts The BankServerAgent class, acts as a server and the BankClientAgent class acts as client. The two classes use (implement) a common interface, BankVocabulary, that defines the constants which represent the terms that constitute the specific language of the agents.

Bank Example 1 - Java objects Conversation protocol REQUEST: The client agent sends this message to create an account or to make an operation. INFORM: The server agent responds with this message after processing a REQUEST. NOT_UNDERSTOOD: The client and the server agents respond with this message if it cannot decode the content of the message. QUERY_REF: The client agent sends this message to the server agent to query information about a specific account.

Bank Example 1 - Java objects Classes of Bank Example Account: concept of a bank savings account Operation: concept of a bank operation MakeOperation: action of making an operation such as deposit or withdrawal OperationList: concept of the list of last operations CreateAccount: action of creating an account Information: concept of querying information about an account such as the balance and the list of last operations Problem: result of an action that fails

Bank Example 1 - Java objects If objects are to be sent as parts of messages, it is imperative that they are declared to implement the java.io.Serializable interface, otherwise the serialization of the content of the messages before their sending will fail.

Bank Example 1 - Java objects class MakeOperation implements java.io.Serializable { private String accountId; private int type; private float amount; public String getAccountId() { return accountId; } public int getType() { return type; public float getAmount() { return amount; public void setAccountId(String accountId) { this.accountId = accountId; public void setType(int type) { this.type = type; public void setAmount(float amount) { this.amount = amount;

Bank Example 1 - Java objects Portion of client agent where the client REQUESTs the server to carry out a given operation, using a MakeOperation object MakeOperation mo = new MakeOperation(); mo.setAccountId(acc.getId()); mo.setType(command); mo.setAmount(amount); ACLMessage msg = new ACLMessage( ACLMessage.REQUEST ); msg.addReceiver(server); try { msg.setContentObject( mo ); } catch (Exception ex) { ex.printStackTrace(); } send(msg);

Bank Example 1 - Java objects class ReceiveMessages extends CyclicBehaviour { public ReceiveMessages(Agent a) { super(a); } public void action() ACLMessage msg = receive(); if (msg == null) { block(); return; } try { Object content = msg.getContentObject(); switch (msg.getPerformative()) { case (ACLMessage.REQUEST): if (content instanceof CreateAccount) addBehaviour(new HandleCreateAccount(myAgent, msg)); else if (content instanceof MakeOperation) addBehaviour(new HandleOperation(myAgent, msg)); ...

Bank Example 1 - Java objects class HandleOperation extends OneShotBehaviour { ACLMessage request; public HandleOperation(Agent a, ACLMessage request) { super(a); this.request = request } public void action() { try { Operation op = (Operation) request.getContentObject(); ACLMessage reply = request.createReply(); Object result = processOperation(op); ... } catch (Exception ex) { ex.printStackTrace(); }

Bank Example 2 - Ontology An ontology describes the elements that can be used as content of agent messages. An ontology is composed of two parts: The vocabulary that describe the terminology of concepts used by agents in their space of communication. The nomenclature of the relationships between these concepts, and that describe their semantics and structure. An ontology is implemented by extending the class Ontology predefined in JADE and adding a set of element schemas describing the structure of concepts, actions, and predicates that are allowed to compose the content of your messages. You may also extend directly the basic ontology classes BasicOntology or ACLOntology according to your need.

Bank Example 2 - Ontology In this example, we defined the BankOntology class that our two agents use to communicate in place of the java objects. We re-use our java objects from before, but instead of using them directly in the content of messages, we just wrap them into specific terms and concepts defined within the BankOntology class..

Bank Example 2 - Ontology The AgentActionSchema class inherits from the ConceptSchema class which in turn is a subclass of the TermSchema class. While the PredicateSchema class inherits from the ContentElementSchema class. But at the base, these interfaces have a common superclass which is the ObjectSchema class.

Bank Example 2 - Ontology java.lang.Object jade.content.schema.ObjectSchema jade.content.schema.ObjectSchemaImpl jade.content.schema.TermSchema jade.content.schema.ConceptSchema jade.content.schema.AgentActionSchema jade.content.schema.ContentElementSchema jade.content.schema.PredicateSchema

Bank Example 2 - Ontology An important point to know is when to use one or another of these ontology objects Agent A requests agent B to perform a specific task. FIPA requires the content of the message that A sends to B must be an action. In JADE, the task will be defined by a java object implementing the AgentAction interface and the action will be an instance of the class Action to which you pass in arguments the AID of agent B and the object describing the task to be performed. Agent A asks agent B if a given proposition is true. According to FIPA, the content of the message must be the object representing the proposition to check. In JADE a proposition can be defined by a java object implementing the interface Predicate. Some objects are not agent actions neither propositions, so we define these as concepts They implement the interface Concept.

Bank Example 2 - Ontology JADE also provides support for defining atomic elements that constitute generally the slots of the abstract concepts String, Integer, Float, etc. The support for these atomic types of objects is provided through the class PrimitiveSchema and handled by the BasicOntology class.

Bank Example 2 - Ontology Account class implements the Concept interface Operation class implements the Concept interface MakeOperation class implements the AgentAction interface CreateAccount class implements the AgentAction interface Information class implements the AgentAction interface Problem class implements the Concept interface

Bank Example 2 - Ontology Define the vocabulary of your agents communication space. public interface BankVocabulary { ... public static final String MAKE_OPERATION = "MakeOperation"; public static final String MAKE_OPERATION_TYPE = "type"; public static final String MAKE_OPERATION_AMOUNT = "amount"; public static final String MAKE_OPERATION_ACCOUNTID = "accountId"; }

Bank Example 2 - Ontology Define the java class that specifies the structure and semantic of the object MakeOperation. Same definition as Java Objects example except that it implements AgentAction and not java.io.Serializable

Bank Example 2 - Ontology class MakeOperation implements AgentAction { private String accountId; private int type; private float amount; public String getAccountId() { return accountId; } public int getType() { return type; public float getAmount() { return amount; public void setAccountId(String accountId) { this.accountId = accountId; public void setType(int type) { this.type = type; public void setAmount(float amount) { this.amount = amount;

Bank Example 2 - Ontology Define the schema of the object public class BankOntology extends Ontology implements BankVocabulary { public static final String ONTOLOGY_NAME = "Bank-Ontology"; private static Ontology instance = new BankOntology(); public static Ontology getInstance() { return instance; } private BankOntology() { super(ONTOLOGY_NAME, BasicOntology.getInstance()); try { // MakeOperation add(as = new AgentActionSchema(MAKE_OPERATION), MakeOperation.class); as.add(MAKE_OPERATION_TYPE, (PrimitiveSchema) getSchema(BasicOntology.INTEGER), ObjectSchema.MANDATORY); as.add(MAKE_OPERATION_AMOUNT, (PrimitiveSchema) getSchema(BasicOntology.FLOAT), ObjectSchema.MANDATORY); as.add(MAKE_OPERATION_ACCOUNTID, (PrimitiveSchema) getSchema(BasicOntology.STRING), ObjectSchema.MANDATORY); } catch (OntologyException oe) { oe.printStackTrace(); } } }// BankOntology

Bank Example 2 - Ontology public class BankClientAgent extends Agent implements BankVocabulary { ... private Codec codec = new SLCodec(); private Ontology ontology = BankOntology.getInstance(); protected void setup() { // Register language and ontology getContentManager().registerLanguage(codec); getContentManager().registerOntology(ontology); } void requestOperation() { MakeOperation mo = new MakeOperation(); mo.setType(command); mo.setAmount(amount); mo.setAccountId(acc.getId()); sendMessage(ACLMessage.REQUEST, mo); }//class BankClientAgent

Bank Example 2 - Ontology public class BankServerAgent extends Agent implements BankVocabulary { ... private Codec codec = new SLCodec(); private Ontology ontology = BankOntology.getInstance(); protected void setup() { // Register language and ontology getContentManager().registerLanguage(codec); getContentManager().registerOntology(ontology); } }// End BankServerAgent

Bank Example 2 - Ontology class ReceiveMessages extends CyclicBehaviour { public ReceiveMessages(Agent a) super(a); } public void action() ACLMessage msg = receive(); if (msg == null) { block(); return; } try { ContentElement content = getContentManager().extractContent(msg); Concept action = ((Action)content).getAction(); switch (msg.getPerformative()) case (ACLMessage.REQUEST): ... if (action instanceof CreateAccount) addBehaviour(new HandleCreateAccount(myAgent, msg)); else if (action instanceof MakeOperation) addBehaviour(new HandleOperation(myAgent, msg)); break; catch(Exception ex) { ex.printStackTrace(); } }// End ReceiveMessages

Bank Example 2 - Ontology class HandleOperation extends OneShotBehaviour { private ACLMessage request; HandleOperation(Agent a, ACLMessage request) super(a); this.request = request; } public void action() try { ContentElement content = getContentManager().extractContent(request); MakeOperation mo = (MakeOperation)((Action)content).getAction(); //Process the operation Object obj = processOperation(mo); //Send the reply ... catch(Exception ex) { ex.printStackTrace(); } }// End HandleOperation