CS533: Program 3
(Due Monday, November 6, 2000)
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:
- Download and install a C++ program for gear design.
- Run the program on some example problems to understand how the
rules for OneOneOne designs work.
- Extend the rules to handle OneTwoOne designs, and test them on
five example problems.
- Make up three more problems and solve them using the modified system.
Downloading and Compiling
Install the Assignment 3 files in a directory named
that that from inside the
p3 directory, the library
routines are located in
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
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
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
To produce a printed hardcopy, you can type the following commands
gnuplot> set term post
gnuplot> set output 'solution.ps'
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.
- Problem 1 should have a OneOne solution.
- Problem 2 should have a OneOneOne solution.
- Problem 3 should have a OneOneOne solution.
- Problem 4 should not have any solution.
- Problem 5 should not have any solution.
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
- The two idler gears may not be able to reach from the
- The inGear may hit the output shaft. Each shaft has a radius of
0.125 and you should require an additional 0.05 inches of clearance
- The outGear may hit the input shaft.
- The idler1Gear1 may hit the output shaft.
- The idler1Gear2 may hit the input shaft.
- You must generate the possible locations for the idler shaft
(idler1). To do this, you should study Rule8_GenerateIdler1
and write an analogous rule.
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.
- Your modified file rules.r
- Three problems of your own devising. One problem should have a
OneOne solution, one problem should require a OneOneOne solution, and one
problem should require a OneTwoOne solution. The set of available
gears is given in the file
Tom Dietterich, email@example.com