注:以下链接所指向网站或资料之版权归原作者所有。
JADE官方网站
官网上拥有JADE的最新版本、最新动态、最新文档、操作规范等。
JADE 程序员指南
它是官方文档“JADE Programmer's Guide”的中文翻译。
JADE笔记 作者:不见神僧
不见神僧整理的JADE笔记,记录了JADE常用的API方法,是一些关于behaviour行为的例子,acl的例子,protocol协议的例子和其他的例子,很浅显易懂的。
不见神僧的记忆的博客网站
JADE Tutorial and Primer 作者:Jean Vaucher and Ambroise Ncho
初学者都应该看的讲解JADE的网站,介绍了JADE的开发Agent的规范,JADE的规范与说明。虽然是用英文讲解,但很通俗易懂。
JADE卖书系统中文资料 作者:王兴华
这个是天津大学一位学生的论文,前面一部分介绍了Agent和JADE的知识,后面给出了JADE examples中的一个实例(买书系统)的讲解。文章的大部分内容和JADE官方的“程序员指南”相重复。
使用JADE 平台进行智能体开发 作者:邓学
介绍了Agent和JADE的架构和简单的说明。
w3china.org论坛
论坛中的Web Services & Semantic Web Services版块和其他的一些子论坛里面有些使用JADE开发Agent系统的讨论和知识讲解。
2011年4月10日星期日
2010年12月13日星期一
JADE Agent Parameters
Agent Parameters
It is often useful to be able to pass parameters to agents. This is described in the Jade Programming Tutorial (sect. 3.4). On a command line, the parameters are placed in a list seperated by spaces after the "name:class" agent specifier. For example:
% java jade.Boot fred:ParamAgent(3 "Hi there")
Here fred will be passed 2 parameters: an integer and a string. In standard Java, we are used to retrieving command arguments from a String array parameter to the static method main. With JADE, retrieving arguments is a bit different because the same mechanism is used both to pass arguments from a command line and to pass arguments to agents created by programming.
In Jade, the arguments are obtained by calling the method getArguments which returns an array of Objects which must be cast to Strings (in this case). Here is an example of a ParamAgent which can retrieve the arguments "3" and "Hi there" shown above.
The command line shown above doesn't work under UNIX or Mac OSX.
jean% java jade.Boot fred:ParamAgent(1 "Hi there")
tcsh: Badly placed ()'s.
With these systems, each agent specifier (name, class & argument list) must be quoted.
% java jade.Boot 'fred:ParamAgent(3 "fred toto")'
p0: 3
p1: fred toto
i*i= 9
Reversing single and double quotes can give surprising results; in this case: 3 arguments !!!
jean% java jade.Boot "fred:ParamAgent(3 'fred toto')"
p0: 3
p1: 'fred
p2: toto'
i*i= 9
Passing arguments to newly created Agents
Similarly, an array of arguments can be provided for new agents in the third parameter of createNewAgent. Here is how we could create a ParamAgent with the same name and arguments as in our earlier example. Note that the arguments are passed as Objects; thus, simple types must be converted to Strings or Wrapper classes.
Responder Agent
Reference:
It is often useful to be able to pass parameters to agents. This is described in the Jade Programming Tutorial (sect. 3.4). On a command line, the parameters are placed in a list seperated by spaces after the "name:class" agent specifier. For example:
% java jade.Boot fred:ParamAgent(3 "Hi there")
Here fred will be passed 2 parameters: an integer and a string. In standard Java, we are used to retrieving command arguments from a String array parameter to the static method main. With JADE, retrieving arguments is a bit different because the same mechanism is used both to pass arguments from a command line and to pass arguments to agents created by programming.
In Jade, the arguments are obtained by calling the method getArguments which returns an array of Objects which must be cast to Strings (in this case). Here is an example of a ParamAgent which can retrieve the arguments "3" and "Hi there" shown above.
/**************************************************************
ParamAgent.java: Retrieving parameters
**************************************************************/
import jade.core.Agent;
public class ParamAgent extends Agent
{
protected void setup()
{
Object[] args = getArguments();
String s;
if (args != null) {
for (int i = 0; i s = (String) args[i];
System.out.println("p" + i + ": " + s);
}
// Extracting the integer.
int i = Integer.parseInt( (String) args[0] );
System.out.println("i*i= " + i*i);
}
}
}
The command line shown above doesn't work under UNIX or Mac OSX.
jean% java jade.Boot fred:ParamAgent(1 "Hi there")
tcsh: Badly placed ()'s.
With these systems, each agent specifier (name, class & argument list) must be quoted.
% java jade.Boot 'fred:ParamAgent(3 "fred toto")'
p0: 3
p1: fred toto
i*i= 9
Reversing single and double quotes can give surprising results; in this case: 3 arguments !!!
jean% java jade.Boot "fred:ParamAgent(3 'fred toto')"
p0: 3
p1: 'fred
p2: toto'
i*i= 9
Passing arguments to newly created Agents
Similarly, an array of arguments can be provided for new agents in the third parameter of createNewAgent. Here is how we could create a ParamAgent with the same name and arguments as in our earlier example. Note that the arguments are passed as Objects; thus, simple types must be converted to Strings or Wrapper classes.
Object [] args = new Object[2];
args[0] = "3";
args[1] = "Allo there";
String name = "Fred" ;
AgentContainer c = getContainerController();
try {
AgentController a = c.createNewAgent( name, "ParamAgent", args );
a.start();
}
catch (Exception e){}
Responder Agent
// ------------------------------------------------------------
// ParamAgent: An Agent receiving parameters
//
// Usage: % javac ParamAgent.java
// % java jade.Boot fred:ParamAgent(3 "Allo there")
//
// ... on UNIX, the agent specifier and arguments must be quoted:
//
// % java jade.Boot 'fred:ParamAgent(3 "Allo there")'
// ------------------------------------------------------------
import jade.core.Agent;
public class ParamAgent extends Agent
{
protected void setup()
{
Object[] args = getArguments();
String s;
if (args != null) {
for (int i = 0; i s = (String) args[i];
System.out.println("p" + i + ": " + s);
}
int i = Integer.parseInt( (String) args[0] );
s = (String) args[1];
System.out.println("i*i= " + i*i);
System.exit(1);
}
}
}
Reference:
2010年8月2日星期一
JADE Tutorial and Primer摘要
JADE Tutorial and Primer 是一个绝好的学习JADE的网站,文章讲解地简单明了,很适合初学者学习。下面是本人在学习过程中根据个人理解的知识摘要。
JADE Agents are defined as subclasses of the predefined class Agent and their initial code must be placed in a method called setup.
Agents are a bit like Java Applets in that they can't be executed directly; they must execute within a larger program which provides the necessary services. In the case of Applets, a browser or an Applet viewer is needed; for Jade agents the environment is provided by the class jade.Boot which finds which Agents to run from command line parameters.
Jade environments are called containers. Typically, in a multi-agent application, there will be several containers (with agents) running on different machines. The first container started must be a main container which maintains a central registry of all the others so that agents can discover and interact with each other.
Agent actions are normally specified through Behaviour classes. More exactly, the actions are described in the "action" method of these Behaviours. The setup method only serves to create instances of these behaviours and linking them to the Agent object.
A last point is the provision of a mechanism to terminate the behaviour. In Jade, as long as a behaviour 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.
Agent Parameters: the parameters are placed in a list seperated by spaces after the "name:class" agent specifier. For example: fred:ParamAgent(3 "Hi there"). In Jade, the arguments are obtained by calling the method getArguments which returns an array of Objects which must be cast to Strings Reversing single and double quotes can give surprising results.
为了实现Agent的并行,可以借助Java的线程机制。但是Java的线程不适合大规模的并行。所以,jade使用behaviour实现并行。
A behaviour is basically an Event Handler, a method which describes how an agent reacts to an event. In Jade, Behaviours are classes and the Event Handler code is placed in a method called action.
In JADE, messages adhere strictly to the ACL (Agent Communication Language) standard which allows several possibilities for the encoding of the actual content. In particular, Jade supports FIPA's SL (Semantic Language), a LISP-like encoding of concepts, actions andpredicates. It also allows the content to be serialized Java objects.
Our message uses the most common performative: INFORM whereby one agent gives another some useful information. Other types are: QUERY to ask a question, REQUEST to ask the other to do something and PROPOSE to start bargaining. Performatives for answers include AGREE or REFUSE.
We use addReceiver because there is no setReceiver method.
Note that, if you don't call block(), your behaviour will stay active and cause a LOOP. Generally all action methods should end with a call to block() or invoke it before doing return.
the CyclicBehaviour, which stays active as long as its agent is alive. by using CyclicBehaviour, we don't need to specify done.
To simplify answering, Jade provides a method createReply() which creates a new message with the sender and receiver attributes switched and all other attributes set correctly. Generally, only the content and performative have to be modified before sending it back.
For agents to interact usefully in open systems, it is imperative that they use the same language conventions and the same vocabulary. The DF entries thus concentrate on listing the ontologies, protocols and languages which are supported by the agents. Additionally, entries have sets of services which are characterized by aname and name-value properties as well as the ontology/language/protocol conventions they support
Each agent is allowed only ONE entry in the DF. Attempts to register an agent already in the DF gives an Exception.
the WakerBehaviour,its delay is computed from the time the behaviour iscreated.
一定要区别好Behavours Created和Started.
The key to implementation of interaction protocols is to assign to each conversation a unique identifier, the conversationID (CID).
JADE Agents are defined as subclasses of the predefined class Agent and their initial code must be placed in a method called setup.
Agents are a bit like Java Applets in that they can't be executed directly; they must execute within a larger program which provides the necessary services. In the case of Applets, a browser or an Applet viewer is needed; for Jade agents the environment is provided by the class jade.Boot which finds which Agents to run from command line parameters.
Jade environments are called containers. Typically, in a multi-agent application, there will be several containers (with agents) running on different machines. The first container started must be a main container which maintains a central registry of all the others so that agents can discover and interact with each other.
Agent actions are normally specified through Behaviour classes. More exactly, the actions are described in the "action" method of these Behaviours. The setup method only serves to create instances of these behaviours and linking them to the Agent object.
A last point is the provision of a mechanism to terminate the behaviour. In Jade, as long as a behaviour 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.
Agent Parameters: the parameters are placed in a list seperated by spaces after the "name:class" agent specifier. For example: fred:ParamAgent(3 "Hi there"). In Jade, the arguments are obtained by calling the method getArguments which returns an array of Objects which must be cast to Strings Reversing single and double quotes can give surprising results.
为了实现Agent的并行,可以借助Java的线程机制。但是Java的线程不适合大规模的并行。所以,jade使用behaviour实现并行。
A behaviour is basically an Event Handler, a method which describes how an agent reacts to an event. In Jade, Behaviours are classes and the Event Handler code is placed in a method called action.
In JADE, messages adhere strictly to the ACL (Agent Communication Language) standard which allows several possibilities for the encoding of the actual content. In particular, Jade supports FIPA's SL (Semantic Language), a LISP-like encoding of concepts, actions andpredicates. It also allows the content to be serialized Java objects.
Our message uses the most common performative: INFORM whereby one agent gives another some useful information. Other types are: QUERY to ask a question, REQUEST to ask the other to do something and PROPOSE to start bargaining. Performatives for answers include AGREE or REFUSE.
We use addReceiver because there is no setReceiver method.
Note that, if you don't call block(), your behaviour will stay active and cause a LOOP. Generally all action methods should end with a call to block() or invoke it before doing return.
the CyclicBehaviour, which stays active as long as its agent is alive. by using CyclicBehaviour, we don't need to specify done.
To simplify answering, Jade provides a method createReply() which creates a new message with the sender and receiver attributes switched and all other attributes set correctly. Generally, only the content and performative have to be modified before sending it back.
For agents to interact usefully in open systems, it is imperative that they use the same language conventions and the same vocabulary. The DF entries thus concentrate on listing the ontologies, protocols and languages which are supported by the agents. Additionally, entries have sets of services which are characterized by aname and name-value properties as well as the ontology/language/protocol conventions they support
Each agent is allowed only ONE entry in the DF. Attempts to register an agent already in the DF gives an Exception.
the WakerBehaviour,its delay is computed from the time the behaviour iscreated.
一定要区别好Behavours Created和Started.
The key to implementation of interaction protocols is to assign to each conversation a unique identifier, the conversationID (CID).
订阅:
博文 (Atom)