Table of Contents
You can run the sample project on one or more computers. In all cases you need more than one habitat running.
The following steps show how to run the sample project on a single machine.
All files for the sample project are found in the directory named kickstart. Prior to starting, be sure that you set the ADK_ROOT to <ADK_ROOT>. Further instructions on how to do this are found in the Quickstart guide.
From within this directory, open a DOS-shell and change to the kickstart directory : <ADK_ROOT>\kickstart\.
Run the command build all. Using ANT, this command will start the defined targets to compile the existing agents, create DNA files, and place agent DNA files in the right directory. If you type build instead of build all, you will get a list of all possible targets that can be used in this project.
Then copy the entire kickstart directory and all its subdirectories to another place on your computer.
Open a second DOS-shell, and change your location to the second kickstart directory.
In the first dos shell, execute the command infohabitat.
In the second dos shell, execute the command collecthabitat
Two agent runtime enviroments (habitats) will be created. One with an InfoAgent, and one with a CollectAgent.
The CollectAgent will read default settings from sampleproject.properties in the kickstart\projectsettings\. This file contains the following lines (among others):
info.to.collect=name,address
social_security_number=1234567890
This causes the CollectAgent to look for the [name, address] of a person with Sofi-number 1234567890. The CollectAgent can be given a different assignment by modifying these properties before starting the project. The CollectAgent will visit each InfoHabitat and query the InfoAgent in the habitat for information. After the required information is found, the CollectAgent will return to the jabotat where it was created and report the results. Each InfoAgent reads data from one of the following comma separated values (.csv) files:
[nawdb.csv]
# Name, address, and location info for various SoFi numbers.
# First line lists the names of fields.
sofinumber, name, address, location
1234567890, Edwin Jansen, Meessingel 32, Haarlem
3845329845, Jan Moes, Brugstraat 1, Amsterdam
2345345436, Sylvia Holsman, Bodemstraat 52, Vlissingen
3450324656, Patricia van Duin, Kruislaan 24, Zwolle
[personaldb.csv]
# Hobby, birthdate and number of kids for various SoFi numbers.
# First line lists the names of fields.
sofinumber, hobby, birthdate, number_of_kids
1234567890, voetbal, 4-8-1961, 3
3845329845, zwemmen, 21-12-1968, 1
2345345436, geen, 15-3-1972, 0
3450324656, theater, 4-4-1957, 2
[economydb.csv]
# Monthly gross salary, employer and number of CMG stocks for various SoFi numbers.
# First line lists the names of fields.
sofinumber, salary, employer, stock
1234567890, 4500, Tryllian, 20000
3845329845, 3800, IBM, 9000
2345345436, 7500, Microsoft, 0
3450324656, 3200, MMWOPS, 80000
The .csv files determine which data is available from each InfoAgent and can be modified during runtime. The output of the single habitat example should look similar to the following:
[java] [CollectAgent]: Collecting [address, name] for sofinumber 1234567890.
[java] [InfoAgent]: Offering: [sofinumber, salary, employer, stock]
[java] [InfoAgent]: Offering: [sofinumber, name, address, location]
[java] [InfoAgent]: Offering: [sofinumber, hobby, birthdate, number_of_kids]
[java] [CollectAgent]: Available locations:
(...)
[java] [CollectAgent]: Information is complete.
[java] [CollectAgent]: Returning to home location
[java]
[java]
[java] **** Results ****
[java] Result for address : Meessingel 23
[java] Result for birthdate : 4-8-1961
[java] Result for name : Hans Huisman
[java] Result for hobby : voetbal
[java]
[java] **** End of results ****
[java]
[java]
[java] [CollectAgent]: Done with my tasks
If you want to see agents visually you can start the Universal Home Base simulteneously. Just open another DOS-prompt, go to kickstart directory <ADK_ROOT>\kickstart and type homebase.bat. This is explained further later.
In the Windows environment, you can also start a habitat and the Homebase by going to the kickstart directory using Windows Explorer and double-clicking on habitat.bat and singlehabitat.bat files.
The following steps show how to run the kickstart using two computers.
Install the ADK on both computers. All files for the sample project are found in the directory named kickstart. Be sure this directory is present on both computers (computer 1 and 2). Prior to starting, be sure that you set the ADK_ROOT to <ADK_ROOT>. Refer to the instructions described earlier and in the Quickstart Guide. From within this directory, open a DOS-shell and change the kickstart directory, for instance at <ADK_ROOT>\kickstart\
Run the command build all. Using ANT, this command will start the defined targets to com[ile the existing agents, create DNA files, and place agent DNA files in the right directory. If you type build instead of build all, you will get a list of all possible targets that can be used in this project.
Computer 1 will run the CollectAgent; computer 2 will run the InfoAgent. To enable the CollectAgent to find computer 2, its habitat name has to be entered in the file: kickstart\projectsettings\hosts.cfg. The habitatname is printed upon habitat startup but can also be set in the habitat.config file.
Assuming that computer 2 has the habitatname ecotax-1, modify the hosts.cfg file to look like this:
[hosts.cfg]
##############################################################
# specify hosts to which the CollectAgent should travel here #
##############################################################
ecotax-1
Save the updated hosts.cfg file on computer 1. Execute kickstart\infohabitat.bat on computer 2 and wait until the following output appears:
[java] [InfoAgent]: Offering: [sofinumber, hobby, birthdate, number_of_kids]
Next execute kickstart\collecthabitat.bat on computer 1. The following output should appear:
[java] [RemoteCollectAgent]: Collecting info on 1234567890.
[java] [RemoteCollectAgent]: Looking for [hobby, birthdate].
[java] [CollectAgent]: Available hosts:
[java] ecotax-1
[java]
[java] [CollectAgent]: Still need more information, will try the next location
[java] [CollectAgent]: Pinging habitat at ecotax-1
The CollectAgent will move to the habitat on computer 2 and send a message to the InfoAgent. After finding all the required information, the CollectAgent will return to computer 1 and report its results.
This is almost the same as running on two computers. Install the ADK on all computers.
One computer will run the CollectAgent; the other computers will run InfoAgents. To enable the CollectAgent to find all other machines, their habitat names have to be entered as described above. Furthermore, to make the demo more interesting, each InfoAgent should be given a different data source by editing the appropriate lines in the file kickstart\projectsettings\sampleproject.properties on the InfoAgent computers.
Run the command build all. Using ANT, this command will start the defined targets to compile the existing agents, create DNA files, and place agent DNA files in the right directory. If you type build instead of build all, you will get a list of all possible targets that can be used in this project.
Edit the sampleproject.properties files on each InfoAgent computer as follows:
InfoAgent Computer 1: infoagent.file=nawdb.csv
InfoAgent Computer 2: infoagent.file=personaldb.csv
InfoAgent Computer 3: infoagent.file=economydb.csv
For a demo with more than three InfoAgent computers, extra .csv files are needed with the above specifications.
Edit the sampleproject.properties file on the CollectAgent computer as follows:
info.to.collect=name,address,employer,birthdate
This ensures that the CollectAgent visits every computer to complete its assignment. To use .csv data files with different fields, the info.to.collect property has to be extended to make the CollectAgent look for those fields.
To start the demo, execute kickstart\infohabitat.bat on the InfoAgent computers and wait until each habitat is ready. Then, execute kickstart\collecthabitat.bat on the CollectAgent computer to start the CollectAgent.
This sample is a complete example that is meant to run out of the box. Once the basics of the ADK are familiar, a next step would be to gain more development experience and extend the sample project into areas not covered in this document. The following list provides suggestions for further research and is grouped by application areas. These suggestions are listed in order of complexity, from relatively straightforward to quite extensive circumstances.
Enhanced logging to the console.
The current output can be extended in several ways:
Adding more logging information about each agent's behavior and decisions.
Adding more logging of the internal knowledge representation (agent state).
Instead of sending the log messages to the console, it can be visualized in the Home Base as an agent speech bubble by using SayTasks (tryllian.afc.ui.language.input.SayTask).
Knowledge representation. The current use of the Agent Context to store key-value pairs directly can be extended to represent the agent knowledge in separate objects.
Integration of a business object into the application.
Communication Protocols. Currently, there is only one possible FIPA response and subject from the InfoAgents to the query from the CollectAgent. Extensions to make conversation more flexible:
The InfoAgent responds differently when no new information is available (that is, provides a FAILURE message).
Instead of asking for data about Sofi-number, the CollectAgent could specify exactly which data is required in the QUERY_REF message.
Sometimes the InfoAgent may not have immediate access to the data (as in the real world). Such a situation calls for a more extensive conversation protocol. For example the CollectAgent could send a REQUEST to the InfoAgent, who answers with an INFORM if the information is directly available, an AGREE if the CollectAgent will have to wait a while before the information is sent or a REFUSE if the information is not available at all.
Embedding of the application using standard Java extensions.
HTTP
Linking an Agent to a Java servlet engine, allowing agents to write to servlets.
Accessing an agent directly with a web browser.
Make an agent send out an email at designated points.
Linking to an application server based on Java 2 Enterprise Edition middleware
Linking agents to Java Message Services.
Linking agents to EJB.
Security of Agents and the Habitat.
Creating a new security certificate for the agents.
Modifying the standard habitat security properties to more restrictive ones.
Extensive information on platform and agent security of the ADK can be found in the Developer's Guide provided with the ADK distribution. Additional information ise found in the Javadoc which describes the Application Programmer's Interface (API).