CS533: Program 3

(Due Monday, November 6, 2000)


Purpose

In this assignment you will gain experience with rule-based programming techniques applied to a simple routine design problem. The techniques will be used to implement a combination of generate-and-test search and constraint-propagation reasoning. Specifically, you will do four things:

Downloading and Compiling

Install the Assignment 3 files in a directory named p3 so that that from inside the p3 directory, the library routines are located in ../lib

make all

This will automatically compile the files in the ../lib directory as well as all of the files in the main directory. You will notice that first a program named preprocess is compiled and loaded. Then this program is executed to convert the rule file rules.r into a C++ header file rules.h. This file is then included into the file gears.c, and it is compiled.

Running the Program

The p3 directory will contain five test problems with the names problem1, problem2, problem3, problem4, problem5. You should try solving each of these problems. To solve a problem, issue the unix command
 gears < problem1 > problem1.log
This will cause the gears program to take its input from the file problem1 and write its output in the file problem1.log. The gears program will also write out a file named solution.data which can be used with the gnuplot program to produce a graphical image of the design.

To display the design, issue the command

 gnuplot
The program will then prompt for a command. You should issue the command
 gnuplot> plot 'solution.data'
A window should appear on your screen with the gears displayed. Each gear is displayed as two circles at the OuterRadius and PitchRadius. The shaft is shown as a third circle (with a radius of 0.125). The center of the shaft is shown as a small + symbol. The allowed locations of the input and output shafts are displayed as small rectangles. You will usually need to resize the window to make the circles circular (instead of elliptical).

To produce a printed hardcopy, you can type the following commands inside gnuplot:

 
gnuplot> set term post
gnuplot> set output 'solution.ps'
gnuplot> replot
gnuplot> quit
This will create a file named solution.ps, which you can then print on any postscript printer.

The five problems should exhibit the following behavior:

Once you have extended the rules, you should be able to find OneTwoOne solutions for problems 4 and 5.

You should especially study the behavior of problems 2 and 3, because your rules for the OneTwoOne design will need to work in a very similar way. The best way to study them is to read through the log files.

Rules for the OneTwoOne Design

The file rules.r contains rules for generating all combinations of four gears that achieve the desired ratio. You need to add TEST and PROPAGATE rules to ensure that the four gears constitute a legal solution to the design problem.

You need to handle the following cases:

Please note that every time you change the rules.r file, you must recompile the gears program. You can use the command
make gears
to do this.

What to Turn In

Please turn in a hardcopy of the following: Please turn in your solution before the start of class.
Tom Dietterich, tgd@cs.orst.edu