You should place p2.tar
in a separate directory and issue
the command tar xvf p2.tar
to extract the individual
files. You should type make c-random
and make
ir-random
to compile the two main programs.
NOTE: The Makefile and #include statements assume that if you are in
the directory for program 2, that the library files are located in
../lib/
.
make
and the file Makefile
. The
Makefile
describes what steps must be carried out to
compile and load a program. If you want to use the HP CC or Borland
C++ compilers, you will need to edit the Makefile
to
comment out the g++ definitions and uncomment the appropriate commands
for your compiler. These definitions specify the name of the compiler
and the file extensions used for object files and executable files.
There are two programs: ir-random
and
c-random
. These programs are very similar: they both
conduct a random search through a scheduling problem space. The
ir-random
program searches the iterative repair problem
space, while the c-random
program searches the
constructive problem space. To compile each of these programs, you
must issue the commands make ir-random
and make
c-random
. On unix, these commands are issued to the shell
while connected to the directory that contains the Makefile and all of
the programs.
After you have the programs compiled and installed, you should test
them. The file example.sch
contains the specifications
for a simple scheduling problem similar to the one used in class. To
solve this problem using ir-random
you should type the
following (on unix):
% ir-random Enter the filename containing the schedule: example.sch Enter a number to seed the random number generator: 1 Enter the number of trials to perform: 10You must enter the filename, the seed for the random number generator, and the number of trials to perform. The program will then perform 10 trials. Each trial will look like this:
Beginning Trial 1 Expansion# Depth Branching Factor Chosen child 1 0 3 2 2 1 2 1 End of trial 1 length = 22
This table contains four columns. The first column simply counts the number of expansions. The second column gives the depth of the search tree at the point of this expansion. The third column gives the branching factor. In this example, the first expansion created three children. Finally, the last column indicates which of the three children was chosen to be expanded next (the children are numbered consecutively starting at 0). If an expansion creates no children, the trial ends without a solution.
When all of the trials are finished, you will see something like the following:
The final schedule is: 2 8 8 8 0 2 1 5 3 (1 2) 1 5 4 0 5 (3) 2 9 2 0 5 () 3 11 2 0 4 () 4 9 5 4 0 () 5 2 3 1 2 (1 4) 6 3 6 5 0 (2 4) 7 0 2 0 5 (0 5 6) It has length 14
This is the printed representation of a schedule. The first line
"2 8 8
" says that there are two types of resources
available, each with capacity 8. The second line tells how many tasks
are in the schedule. Each of the subsequent lines describes one task.
For example, the line "0 2 1 5 3 (1 2)
" says that task 0
starts at time 2. It has duration 1. It requires 5 units of the
first resource and 3 units of the second. It has two prerequisites,
tasks 1 and 2 (given in parentheses). Note that the tasks must appear
in order numbered consecutively from 0. The list of prerequisites can
appear in any order.
test.sch
contains a new scheduling problem
similar to the ones we've seen in class. Your assignment is to run
each of the two programs on this schedule for a fairly large number of
trials and then estimate the average branching factor, solution depth
(for feasible solutions), solution density, and total size of the
state space.
Schedule::rdf
. Keep the temperature fixed during each run.
After implementing this, repeat the same kinds of runs you performed
with the random search programs and determine whether the use of
Boltzmann exploration has improved the density of feasible solutions
or the average quality of the solutions. Can you find a temperature
that gives good performance? As the temperature is increased,
Boltzmann exploration should resemble random search. As the
temperature is decreased, it should resemble greedy search.
ir-random.c
implementing
Boltzmann exploration