Assignment #2

Intelligent Agent Framework
This assignment concerns itself with the actual implementation of the Intelligent Agent Framework. The authors expend significant effort in the beginning of Chapter 7 detailing their design goals, functional specifications, and design decisions that result in the final architecture. I appreciated this software engineering approach and it is helpful in grasping the overall intentions of the framework and develops realistic expectations of the capabilities.

I found the functional specifications to be a good reference point as I implemented the software and began to explore the capabilities of the system. I think it is worthwhile to repeat them here:
1. It must be easy to add an intelligent agent to an existing Java application.
2. A graphical construction tool must be available to compose agents out of other Java components and other agents.
3. The agents must support a relatively sophisticated event-processing capability. Out agent will need to handle events from the outside world or from other agents, and signal events to outside applications.
4. We must be able to add domain knowledge to our agent using if-then rules, and support forward and backward rule-based processing with sensors and effectors.
5. The agents must be able to learn to do classification, clustering, and prediction using learning algorithms.
6. Multi-agent applications must be supported using a KQML-like message protocol.
7. The agents must be persistent; once an agent is constructed, there must be a way to save it in a file and reload its state at a later time.

The name given to the framework is CIAgent. It is built around the JavaBeans component model which allows the software functions to be treated as “parts” which can be put together to construct an application. Another nice feature of the Beans model is they can be nested thus providing the ability to compose agents out of other agents. In terms of design patterns, CIAgent use the composite design which allows us to build up a hierarchy of CIAgents using other specialized CIAgents classes in the process.

Figure 1. The CIAgent UML Class Diagram

CIAgents is the base class (red highlight in Figure 1.) which resides on the Agent Platform. It is supported by four utility classes:
1. CIAgent State which maintains a simple “state” of the agent, either active or inactive.
2. CIAgent Timer which gives the agents autonomy by either “sleeping” for a set time or, queuing up and processing events in an asynchronous manner every “time period”.
3. CIAgent Events are used for agent communication while processing an application.
4. CIAgent Event Queue is well….simply a queue of events.

The CIAgent Event Listener provides an interface for external agents and Java Objects which register themselves while the Serializable interface provides a method to save and load CIAgents to files.

The framework is intended to be used in a specific sequence so that the CIAgent State follows a predictable set of transitions. The lifecycle of a typical CIAgents should progress as follows:
1. Construct the CIAgent object instance. Set the state to UNINITIATED.
2. Either programmatically or using a Customizer, set the JavaBean properties.
3. Call the initialize() method. Set the state to INITIATED.
4. Call the startAgentProcessing() method to start the eventQueue thread and any asynchronous event and timer processing. The state is set to ACTIVE.
5. Use the agent in an application by calling the process() method directly, or by sending events to be processed asynchronously.
6. Suspend and Resume the agent as needed. The state is set to SUSPENDED or ACTIVE.
7. Stop the agent. The state is set to UNKNOWN.

The original BooleanRuleBase we experimented with in Assignment #1 has been enhanced to provide support for Sensors and Effectors. Sensors are what allow our agents to gather information about its environment. Once the agent has recognized that a significant event has occurred it can then take some action through an Effector. This is the beginnings of intelligence for our agents.

Chapter 8 introduces the Personal Agent Manager application. This basic GUI platform allows us to create, configure, and control a set of personal agents that will do tasks on our behalf. The assignment is limited to the FileAgent which can detect when a file is MODIFIED, DELETED, or exceeds a specified THRESHOLD. The FileAgent can take several different actions; ALERT the user, EXECUTE a command, or notify another agent of the EVENT.

Implementation of the Framework
I created a new project (Agent Project2) in NetBeans with the source folders of pamanager, rule, and ciagent. I set the main class to PAMangerApp and compiled the project.


I copied the file into the same directory as the executable.


And ran the application.


I created a File Agent to monitor a WordPad text file for modifications.


And started the agent.


Here you can see the state has changed to ACTIVE.


When I opened the file and added to it the agent fired on the rule.


I changed the test to monitor the condition of Over Threshold and to EXECUTE a command that would rename the file. The application and textbook are unclear as to what the value of the threshold is supposed to represent. I looked in the code and it seems to be the length of the file but in what? Bytes, Characters? Here it is…bytes


Unfortunately, I got an error that my Windows XP OS is not supported.
I modified the source to printout the osType and then added the necessary code to provide support for XP.


This time it worked:


Or did it??? Actually, the file is only 253 bytes but the rule still triggered!


Hhmmm….looks like room for improvement. The logic here is pretty weak.


My threshold is 500 but the file size is 253. Yes, 500 is greater than 253 but that’s not quite the point is it?
   I think it should be: truth = length() > threshold;

I have enjoyed this assignment and can begin to see how this could be leveraged to do some powerful things. The first thing that comes to mind is intelligent performance monitoring of computer systems. As a former systems administrator I can see how this would be a wonderful tool.

Of more interest is the possibility of using the agents for Internet related work. I am looking forward to investigating the Flight Agent which purportedly does work on the Internet.