Acquired Intelligence Inc.

Acquire® Demonstrations: How the CGI Whale Watcher Works

Overview

The Whale Watcher is a demonstration of the Acquire® expert system. At Acquired Intelligence Inc, we have a small knowledge base which can be used to determine the species of an observed whale. Details of the observation (such as the whale's size) are used by the knowledge base to reach a conclusion. This knowledge base was not designed to be an exhaustive whale identifier – but it can be used to identify many species of whales, particularly those found in Canadian coastal waters.

The CGI Program

The Whale Watcher's CGI program is written in the C Programming Language. The server hardware is currently a Sun SPARC, and the web server is Apache Stronghold. The CGI program will run on any system with a CGI-capable web server – this includes most flavours of Unix and Microsoft Windows.

The CGI program's operation is fairly simple: It begins by presenting a question to the user. When the user answers the question, it passes the answer to the Acquire® inference engine. If the engine requires further information for its determination of the whale species, the CGI program displays a new question; otherwise, a conclusion is presented to the user.

To perform these tasks, the CGI program does the following:

  1. Load the knowledge base.
  2. Retrieve the old state information from the submitting HTML page and load it into the engine.
  3. Run the engine.
  4. If the engine needs to display a question, the program creates a new HTML page containing: the current engine state; the question text; and a list of answers the user can choose from.
  5. If the engine needs to display a conclusion, the program formats the conclusion text into an HTML page.

The problem with this method is that once the program displays the question or conclusion, it must quit – and therefore loses its state. To get around this problem, the current state of the inference engine is saved in the HTML page created by the CGI program. This is accomplished by saving the answers to the previous questions in "hidden" HTML form elements.

The HTML Pages

To use the CGI program, we require an initial web page containing an HTML "submit" button. This page acts as the starting point for the Whale Watcher, and runs the CGI program for the first time. In addition to the "submit" button, the starting page has some "hidden" HTML form elements. These elements contain information to be used by the CGI program: some are used in the construction of the returned web page, and others are used by the inference engine. The elements used by the inference engine are:

When the user clicks the "submit" button, all of the "hidden" form elements are passed to the CGI program. The information associated with these elements is extracted, and the knowledge base is loaded. At this point, the CGI program loads into the inference engine any user responses that may have been saved in the page. The inference engine is run, and will do one of two things: It will tell the program that it needs to ask a question; or it will say that it has reached a conclusion.

If the engine needs to ask a question, the CGI program creates an HTML page to be displayed to the user. This is accomplished by retrieving information from the knowledge base – the question text to display, and the list of possible answers which the user may choose from. The CGI program also must insert into the page all of the "hidden" form elements which were in the original page.

When the engine needs to display a conclusion, the program constructs an HTML page containing the text of the end-user report. This text is stored in the knowledge base, and is retrieved from the inference engine.

When a page created by the CGI program is displayed in the user's web browser, the "Back" button can be used to return to a previous page. The user can run the engine forward from this point, since the engine state for the page is stored in the "hidden" form elements.

Performance Notes

By using a CGI program, an expert system application based on the Acquire® inference engine can be developed very quickly. However, using a CGI program has a downside – each time the user answers a question, the following actions occur:

  1. The web browser opens a network connection to the web server.
  2. The web server processes the browser's request.
  3. The web server loads the CGI program into memory.
  4. The CGI program loads the knowledge base.
  5. Previous user responses are entered into the inference engine.
  6. The inference engine is run.
  7. HTML output is generated by the CGI program.
  8. The web server returns the HTML output to the web browser.

Due to the amount of work required to process a single user response, a heavily used application may possibly overwhelm a server. Another approach would be to use the Acquire® Server and Acquire® Client libraries. For example, the Java Whale Watcher demonstrates a means of creating more efficient web-based applications. One advantage of this approach is that only a single network connection is used during the lifetime of the application – a new one is not created for each user response. This also means that the Server keeps the knowledge base open during the user's session, and it also remembers the engine state automatically.

CGI programs and Java Applets both allow you to easily deploy your expert system application on the World Wide Web. Contact us to discuss which solution is most suitable for your application.