Buyer/Seller Agency: AgentBuilder Agents For Electronic Commerce

This application note describes a simple Electronic Commerce application built using AgentBuilder, an integrated toolkit that enables you to create intelligent agents quickly and easily.

This application consists of three interacting agents: one Buyer agent and two Store agents. Each kind of agent has a different role and different capabilities. Although this example features only two Store agents, the Buyer agent is able to interact with any number of Store agents.

Agency Viewer View of Electronic Commerce ApplicationThe Buyer agent acts on behalf of a human user and attempts to buy products specified by that user. The Buyer agent sends requests for price quotes to all the Store agents, waits for responses, and then buys the specified product from the store with the lowest price.

Each Store agent represents one retail store and knows the prices and available quantities of the products in its store. Store agents receive requests for price quotes from the Buyer agent and respond by telling the Buyer agent the prices and quantities that they can deliver.

Agents built with AgentBuilder are capable of communicating with each other over an intranet or the Internet. These agents communicate with each other using the Knowledge Query and Manipulation Language (KQML), which has become the de facto standard for inter-agent communications.

Figure 1 shows the Agency Viewer with icons for one Buyer and two Store agents. The Agency Viewer tool graphically shows the flow of messages between agents and allows the user to examine the contents of the messages. (Note: This tool is not part of the AgentBuilder Lite product. The Agency Viewer tool is included in AgentBuilder Pro.)

Operation of the Buyer/Seller Agency
Each agent has a graphical interface that allows the user to control the operation of the agent or examine the status of agent activity. The Buyer agent's interface allows the user to select a product and quantity to purchase. A pulldown menu lists the known products and a text field is available for specifying the quantity to be purchased. Pressing the Shop button will cause the Buyer agent to begin shopping for the specified product and quantity. Pressing the Quit button will cause the Buyer agent to send messages to shut down all of the Store agents and then shut down itself. Each agent interface also displays the agent's inventory, account balance, and the agent's activities. Figure 2 shows the interfaces for the Buyer agent and two Store agents.

E-Commerce Agent Interfaces

After the user selects a product and quantity and clicks on the Shop button, the Buyer agent sends requests for price quotes to the Store agents. The Store agents respond with price quotes for the specified product. The Buyer agent decides which store has the lowest price and sends a purchase request to the Store agent with the lowest price.

The Store agent then confirms the purchase, decreases its available inventory, adds the purchase price to its account balance, and sends a purchase confirmation message to the Buyer agent. After receiving the purchase confirmation, the Buyer agent increases its inventory and subtracts the purchase price from its account balance.

Project Accessory Classes (PACs)
Most agents built with AgentBuilder utilize a combination of built-in Java classes (supplied by the toolkit) and domain-specific Java classes supplied by the developer. All of these classes used by AgentBuilder agents are referred to as Project Accessory Classes (PACs). The AgentBuilder toolkit provides a suite of commonly used PACs, such as Time and KqmlMessage.

Most projects will also utilize domain-specific PACs to perform actions in the problem domain or to represent domain concepts. In this Electronic Commerce application a PriceQuote PAC is used to store domain-specific information, e.g., product name, quantity, and price. Simple PACs such as the PriceQuote PAC can be developed completely within the AgentBuilder toolkit; more-elaborate PACs can be written in a text editor, or imported from existing software libraries. PACs can be written entirely in Java, or can be written in C/C++ and invoked via the Java Native Interface (JNI). PACs can do anything that can be done in Java or C/C++. Furthermore, PAC objects can be enclosed inside KqmlMessage objects and sent between agents, allowing agents to reason and communicate in terms of complex objects.

Table 1 lists the domain-specific PACs used in the Buyer agent. The PriceQuote, Product, and Purchase PACs are also used by the Store agents. These PAC objects are used to store information in the agents' mental models and are also used to communicate information between agents.

Table 1. Domain-Specific PACs Used by the Buyer Agent
BuyerFrameConstructs the GUI for the Buyer agent, from which the user is able to select which products to purchase.
PriceQuoteRecords product name, quantity, store name, price. Sent from Buyer agent to all Store agents, then returned to Buyer agent with current price quote.
ProductRecords product name, quantity, price for products in inventory.
PurchaseRecords product name, quantity, total price. Sent from Buyer agent to Store agent with lowest price, then returned to Buyer agent as purchase confirmation.

Agent Behavioral Rules
Behavioral rules determine the control flow of the Buyer and Store agents. Behavioral rules determine the course of action an agent takes at every point throughout the agent's lifetime. Behavioral rules match the set of possible responses against the current environment as described by the agent's current beliefs. If a rule's conditions are satisfied by the environment, then the rule is applicable and the actions it specifies are performed.

Here's a list of some of the behavioral rules that define the behavior of the Buyer agent:

  • Build Buyer Frame
  • Start Control Panel
  • Add Product
  • Update Inventory Display
  • Receive Message from Control Panel
  • Forward Message from Control Panel
  • Choose Minimum Quote
  • Receive Purchase Confirmation
  • Receive Quit Message from PAC

Before You Run the Buyer/Seller Agency
To run the Buyer/Seller example you'll need AgentBuilder version 1.0.1 or later. Follow the instructions given below for installing and running the example.

If you wish to modify or extend the example agents, you should be familiar with all of the AgentBuilder tools and should have at least worked through the example agents described in the User's Guide, including Chapter 9 (An Agent with a Graphical PAC) and Chapter 10 (Creating Two Agents that Communicate With Each Other).

Downloading the Buyer/Seller Agency
  Download TAR file
  Download ZIP file

Installing Buyer and Store Agents
After downloading the BuyerSeller repository, you will need to import it into AgentBuilder. Start AgentBuilder, then in the Project Manager select the Edit -> Preferences... menu item and choose the Directories tab. Select the Repository row and click on the Browse... button. This will bring up the Directory Dialog. Find the directory where you downloaded the repository, select the directory in the dialog and click on OK.

Running the BuyerSeller Agency
Instructions for running the BuyerSeller Agency are detailed in the README file included in the distribution.

When you have the three agents running, you can select an item using the Buyer agent's interface and then click on Shop. Now, just sit back and watch the agent do your shopping for you!

For questions/comments about this website, please contact
Last modified: November 15, 2011
AgentBuilder is a registered trademark of Acronymics, Inc.
All other product names referenced are trademarks of their respective companies.
Copyright © 2004 - 2011 Acronymics, Inc.
Privacy Policy