JADE (Week 1)
JADE (Week 1)
Note:
Programming paradigm is a way or style of programming. Some languages are adopted to work
in some paradigms.
Some of the known programming paradigms are:
• Imperative.
• Declarative.
• Structured.
• Procedural.
• Object-Oriented.
• Event-Driven.
• Logic.
One language may support multiple programming paradigms and called multi-paradigm
languages.
What is agent?
An agent or specifically a software agent is a term has its roots in AI and means a software entity
that can do intelligent actions continuously and autonomously on behalf of the user in an
environment in which other agents exist.
The goal of creating an agent is to work on behalf of the user. So as much as the user can work
the agent should be. Because the user can make decisions and do intelligent actions, the agent
should also make decisions and do intelligent actions. The user can adapt with its environment
easily even after changing it, so also the agent should adapt with its environment.
[[EXPLAIN THE MEANING OF ENVIRONMENT BY EXAMPLE]]
There are other characteristics that should be found in the agent to be efficient to work on behalf
of the user.
Software agents should have a number of properties like:
• Mobile: Agents in general should be mobile and move from its location to other locations
in its environment. Software agents can exchange data with the other nodes in its
environment or network.
• Autonomous: Agents can independently do tasks.
• Rational: Agents should know how to think and know how to achieve their tasks in the
right way.
• Reactive: Agents monitors their environment and respond to changes that occur in the
environment.
• Proactive: Agents don`t act only in responding to their environment but can be initiative.
• Social: Agents can cooperate with humans and other agents in order to achieve tasks.
Agents should know about other agents in its environment and their capabilities and how
to negotiate with them.
• Self-learning: Agents can learn from the surrounded environment to improve themselves
and adapt to the environment.
Agent Frameworks
A software agent can live within its environment and can`t live outside it. The environment that
hosts the agents is called an agent framework.
Examples of agent frameworks:
• JACK.
• Agent Factory.
• Agent Builder.
• JADE.
• IMPACT.
• ZEUS.
The framework used in the course for developing software agents is JADE.
JADE
JADE Architecture
JADE is used to create a runtime environment where agents can live. The JADE runtime
environment is called a Container. JADE Container is called so because it can contain multiple
agents.
The JADE Container is a Java process that provides all services for hosting and executing agents
inside the JADE Container.
JADE >> Runtime Environment >> Container >> Java Process
The following figure represents the main architectural elements in JADE and the relationship
among them.
JADE can have multiple containers as shown in the figure. For sure each container will have its
agents. The set of all active containers is called a Platform.
But there is a special JADE Container called the Main Container. The platform can have only one
Main Container which is regarded the default JADE Container. The JADE Main Container is the first
container to be launched.
LADT
To overcome such problem, there will be a Local Agent Descriptor Table (LADT) in each container.
So when an agent wants to find a service, it searches for such service in its Container LADT. If the
service found it will use it and if not it will query the JADE Main Container for an agent outside its
local Container providing that service.
Explanatory example:
GADT Cache
To decrease the number of JADE Main Container queries for a specific service, the containers will
also have a local GADT.
After the agent queried the Main Container for a service, the Main Container will reply by the
agents providing such service in addition to information helping to access such agent.
If the agent wants to use that service another time, it needs to call the Main Container again for
information about agents providing such a service.
To avoid requesting information requested earlier, the containers other than the Main Container
will have a local GADT cache. This cache will contain information about the services used
previously. If the agent wants to use a previously used service, it will query the local GADT. If it
want to use a new service, it will query the Main Container GADT and caches the received
information. This helps in reducing the number of calls sent to the JADE Main Container.
Explanatory example:
Dynamic System
Because the JADE systems are dynamic, it is possible for an agent to be killed and that may cause
problems in cached information in GADT. Suppose that information about Agent3 Srvc1 was
cached in Caontainer1 GADT cache and Agent3 was killed, then there is wrong information stored
in the Container1 GADT cache. To overcome that problem, updates should be sent about cached
data.
Downloading JADE
JADE can be downloaded from its official site http://jade.tilab.com/download/jade.
JADE distribution contains five archive files:
1. jadeBin.zip: Pre-compiled JADE Java archive (JAR) files.
2. jadeDoc.zip: JADE offline documentation.
3. jadeExamples.zip: Java source code of various examples.
4. jadeSrc.zip: Java source code.
5. jadeAll.zip: Contains all the above four archive files.
GUI
1.From the desktop, right click the My Computer icon.
2.Choose Properties from the context menu.
3.Click the Advanced tab (Advanced system settings link in Vista).
4.Click Environment Variables. In the section System Variables, find the CLASSPATH
environment variable and select it. Click Edit. If the CLASSPATH environment variable does
not exist, click New
5. In the Edit System Variable (or New System Variable) window, specify the value of the
CLASSPATH environment variable. Click OK. Close all remaining windows by clicking OK.
https://docs.oracle.com/javase/tutorial/essential/environment/paths.html
CMD
Values of the environment variables can be changed in three scopes:
• Shell/Window.
• User.
• System/Machine/Global.
You can check if the CLASSPATH variable exists or not by dumping all environment variables using
the set command. This command prints all environment variables in addition to their values.
C:> set
setx modifies the value permanently and the change take effect for future shells not the shells
already running. You need to exit the close shell and reopen it again to see the changes.
setx by default changes the environment variables for the current user. To make setx changes the
environment variables values for the system, use the /M option.
For example:
setx /M PATH 'VALUE'
To print only the value of the CLASSPATH environment variable, use the echo command:
C:> echo %CLASSPATH%
If the output was %CLASSPATH% in Windows, then that environment variable doesn`t exist.
But there is a problem in setting the CLASSPATH environment variable by changing the CLASSPATH
environment variable value.
Assuming that you need to run Class1 and it was located in PATH1, then you need to add that
path to the CLASSPATH environment variable.
To run another class Class1 located in PATH2, you also need to add that path to the CLASSPATH
environment variable.
Now, two classes of the same name Class1 are located in different paths PATH1 and PATH2 added
into the CLASSPATH environment variable. There might be confliction about which Class1 you
mean.
To solve that problem, you need to remove the PATH1 value from the CLASSPATH environment
variable to be able to use the new version of the Class1 into the PATH2.
For example:
C:> set CLASSPATH 'PATH2'
To run the Class1 in PATH1, you need to change the path again.
C:> set CLASSPATH 'PATH1'
So you will end running one class and breaking another class.
classpath Option
Another way to specifying the CLASSPATH variable value is using the java/javac -classpath (-cp)
option.
This option assigns a temp value of the CLASSPATH environment variable. After the running of the
class stops, that value is removed from the CLASSPATH environment variable.
Example, to run the previous Java class without changing the CLASSPATH environment variable
value, use this command:
C:> java -cp 'PATH2' Class1
This command runs Class1 in PATH2 and after run the CLASSPATH environment variable stays
unchanged.
Where jade in jade.Boot is the package name and Boot is the class name within that package.
The -gui option has the effect of running the JADE graphical user interface.
This GUI is provided by an agent called Remote Monitoring Agent (RMA). That agent allows the
administrator to manipulate and monitor the running platform.
JADE creates its own network that differs slightly from the normal networks discussed earlier.
Transport Layer
There was a layer responsible for creating connections which is the transport layer number 4 in
OSI. This layer has two common protocols called UDP and TCP. To create a connection, the TCP is
used.
The following figure represents the main JADE GUI with the RMA address shown in the bar:
JADE Agents Connections
Connections between agents in JADE network can be:
1. Inter-platform: Connections between agents in the same platform.
2. Intra-platform: Connections between agents in different platforms.
Monitoring JADE Environment via the RMA GUI
There are different monitoring options provided by the RMA GUI to allow the administrator to
control the JADE platforms and agents. For example, the JADE RMA GUI provides the following
options to control agents:
• Create.
• Kill.
• Suspend.
• Resume.
• Clone.
• Sending messages.
Killing Agent
We can try killing the RMA agent using the RMA GUI monitoring options. Just highlight the RMA
agent and click the Kill icon or right-click the agent and click the Kill option in the options menu.
You will note that the GUI was terminated because the agent responsible for the GUI was killed.
After learning how to launch JADE, next is to learn how to program JADE applications in Java.
What was done is just importing a Java library and next is to know about the following:
• Packages in that library.
• Classes in each package.
• Methods and attributes in each class.