Tutorial 2 Agent Actions Specification --- Behavior Dr. Fuhua Lin School of Computing and Information Systems Athabasca University, Alberta, Canada Oct.

Slides:



Advertisements
Similar presentations
JUnit Tutorial Hong Qing Yu Nov JUnit Tutorial The testing problems The framework of JUnit A case study JUnit tool Practices.
Advertisements

1 Todays Objectives Announcements Homework #1 is due next week Return Quiz 1 – answers are posted on the Yahoo discussion page site Basic Java Programming.
Inner Classes. Nested Classes  An nested class is a class that is defined inside another class.  To this point we have only studied top-level classes.
13/04/2015Client-server Programming1 Block 6: Threads 1 Jin Sa.
C++ Classes & Data Abstraction
Programming with Java. Problem Solving The purpose of writing a program is to solve a problem The general steps in problem solving are: –Understand the.
Written by: Dr. JJ Shepherd
1 Java Programming Basics SE-1011 Dr. Mark L. Hornick.
Animation Mrs. C. Furman. Animation  We can animate our crab by switching the image between two pictures.  crab.png and crab2.png.
CS220 Software Development Lecture: Multi-threading A. O’Riordan, 2009.
Introduction to JADE presenter: Syuan-Hao Li
Outline Java program structure Basic program elements
Jade (3 h) Dott. Daniela Briola. Jade Agent JADE Agents are defined as subclasses of the predefined class Agent Their initial code (if any) must be placed.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
Object-oriented analysis (OOA) techniques are used to (1) study existing objects to see if they can be reused or adapted for new uses, and (2) define new.
Multi-Agent System for Online Auctions Jose Manuel Valladares Pernas CIS Master Project - Fall 2004 Advisor: Dr. Haiping Xu.
Java Agent Development Environment (JADE) Jade is a platform for running agents; it supports: –An asynchronous agent programming model –Communication between.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Comm Operator Tutorial How to send the data after receiving specific data automatically Serial Port Tool
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 18 Exception Handling.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Concurrency in Android with.
Workshop 9 in AOM & MAS Prof Kuldar Taveter, Tallinn University of Technology.
1 Introduction of Java Agent Development Environment (JADE) Presented by Po-Cheng Huang.
IDK5151 kohtumine kaugõppijatega
Bags Chapter 1 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Comm Operator Tutorial How to send the same data at fixed interval time automatically Serial Port Tool
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
The Java Programming Language
1 Introduction to JADE presenter: Ji-Yu Li. 2 Outline Introduction Foundation for Intelligent Physical Agents (FIPA) Java Agent Development Environment.
Tutorial 1 Running JADE Under Eclipse Dr. Fuhua Lin School of Computing and Information Systems Athabasca University, Alberta, Canada Oct. 27, 2009.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 6 September 17, 2009.
M180: Data Structures & Algorithms in Java Arrays in Java Arab Open University 1.
Static Methods. 2 Objectives Look at how to build static (class) methods Study use of methods calling, parameters, returning values Contrast reference.
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.
Concurrent Programming and Threads Threads Blocking a User Interface.
JADE: agents insights Fabiano Dalpiaz Agent-Oriented Software Engineering (AOSE)
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Threads II IS Outline  Quiz  Thread review  Stopping a thread  java.util.Timer  Swing threads javax.swing.Timer  ProgressMonitor.
 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.
Tutorial 5 Object to Agent Communication Fuhua Lin, PhD, Professor, School of Computing and Information Systems Athabasca University, Alberta, Canada Nov.
LINKED LIST’S EXAMPLES Salim Malakouti. Linked List? 523 Pointer Node ValuePointer.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
EEL 5937 The Bond Agent System (1) EEL 5937 Multi Agent Systems Lecture 8, Jan 30, 2003 Lotzi Bölöni.
Tutorial 4 Using JADE from External Java Applications Fuhua Lin, PhD, Professor, School of Computing and Information Systems Athabasca University, Alberta,
CONDITIONALS CITS1001. Scope of this lecture if statements switch statements Source ppts: Objects First with Java - A Practical Introduction using BlueJ,
JADE Java Agent Development Environment Yunus Emre ÇAKMAZ Ahmet Cahit YAŞA 1.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Real-Time Systems Laboratory Seolyoung, Jeong JADE (Java Agent DEvelopment framework )
Jae Chung and Mark Claypool
Multi-Agent System for Online Auctions Jose Manuel Valladares Pernas CIS Master Project - Fall 2004 Advisor: Dr. Haiping Xu.
Chapter 6 Queue.
Yanal Alahmad Java Workshop Yanal Alahmad
Yanal Alahmad Java Workshop Yanal Alahmad
Msury Mahunnah, Tallinn University of Technology
Exceptions, Interfaces & Generics
Tutorial 6 Directory Facilitator
Tutorial 3 ACL: Agent Communication Language
null, true, and false are also reserved.
COMPUTER 2430 Object Oriented Programming and Data Structures I
Chapter 6 Queue.
Java External Libraries & Case Study
JavaScript Reserved Words
Simple Classes in Java CSCI 392 Classes – Part 1.
Chapter 6 Queue.
Threads in Java James Brucker.
Chap 2. Identifiers, Keywords, and Types
Presentation transcript:

Tutorial 2 Agent Actions Specification --- Behavior Dr. Fuhua Lin School of Computing and Information Systems Athabasca University, Alberta, Canada Oct. 27, 2009

Agent Agent actions are normally specified through Behavior internal classes. The actions are described in the “action” method of these Behaviors. The setup method only serves to create instances of these behaviors and linking them to the Agent object. SimpleBehavior --- predefined class or defined in a separate file; How to terminate the behavior? In JADE, as long as a behavior is not “done”, its action method will be called repeatedly after every event - -- such as receipt of a message or expiry of a timer delay. A common technique used to terminate the behaviour: a FINISHED flag which is tested in the “done” method and can be set in “action”. Import jade.core.Agent; Import jade.core.behaviors.*; Public class myAgent extends Agent { protected void setup() { addBehaviour (new myBeahviour(this)); } class myBeahviour extends SimpleBehavior { public myBeahviour(Agent a) { super(a); } public void action() { // … this is where the real programming goes!! } private boolean finished = false; public boolean done() { return finished; } // end of myBehavior } // end class myAgent

Question 1

Example 1 Requirements: Run 4 simple operations in order---- Use CyclicBehaviour() Second operation should use the one-shot behavior OneShotBehaviour(myAgent) Delete the agent when the task is done

. package examplesbehaviours;import jade.core.Agent; import jade.core.behaviours.Behaviour; import jade.core.behaviours.CyclicBehaviour; import jade.core.behaviours.OneShotBehaviour; public class SimpleAgent extends Agent { private class FourStepBehaviour extends Behaviour { private int step = 1; public void action() { switch (step) { case 1: // Perform operation 1: print out a message System.out.println("Operation 1"); break; case 2: // Perform operation 2: Add a OneShotBehaviour System.out.println("Operation 2. Adding one-shot behaviour"); myAgent.addBehaviour(new OneShotBehaviour(myAgent) { public void action() { System.out.println("One-shot"); } }); break; case 3: // Perform operation 3: print out a message System.out.println("Operation 3"); break; case 4: // Perform operation 3: print out a message System.out.println("Operation 4"); break; } step++; } public boolean done() { return step == 5; } public int onEnd() { myAgent.doDelete(); System.out.println("Finished!"); return super.onEnd(); } } // END of inner class FourStepBehaviour /** Creates a new instance of SimpleAgent */ public SimpleAgent() { } protected void setup() { System.out.println("Agent "+getLocalName()+" started."); // Add the CyclicBehaviour addBehaviour(new CyclicBehaviour(this) { public void action() { System.out.println("Cycling"); } } ); // Add the generic behaviour addBehaviour(new FourStepBehaviour()); } }

Running Results jade.Boot –gui myagent:examplesbehaviours.SimpleAgent Agent myagent started. Cycling Operation 1 Cycling Operation 2. Adding one-shot behaviour Cycling Operation 3 One-shot Cycling Operation 4 Finished!