This a continuation of the homework from previous week, which requires
further modification of your code (or the one which I provide), which
solves TSP by printing out the shortest tour length and corresponding
tours. Here you will explore how to improve the efficiency of solving
TSP.
1.(3) The code which you are starting with generates all possible solutions
and prints the total count of them. Modify the code to
count the number
of nodes visited as opposed (to just number of leaf nodes).
You can think of the permute function as generating different
nodes in
the search tree, in each turn adding an unused symbol
to the front of
partial permutation list, hence creating a child node.
If the recursion
of permute has bottomed out the, it corresponds to the
leaf node.
2.(12) Use partial tour lengths in order to prune the part of the search
space which cannot contain a minimal tour. This can be
accomplished
by keeping track of the shortest tour length constructed
so far and
comparing each partial tour length to it. If the length
of the partial
tour is already bigger then the length on the current
shortest tour it
cannot possible produce shortest tour. This will result
to additional
saving due to the reduced number of nodes visited and
tours produced.
Suggestion: Using smaller TSP get the incremental length
calculation
working first. This requires changing the permute function
to include
additional argument, the current partial tour length.
Once its is working, add the prunning code.
-------------------------------------------------------------------------
Provide answers to the following questions:
1.(5) Problem 2.1 (page 50)
2.(8) Problem 3.9 (page 89)
3.(12) Problem 4.3.(page 118)
Provide consice answers to the questions. Two pages should be enough
to describe the answers.
-------------------------------------------------------------------------
Instructions for submission:
----------------------------
(1) Using script or dribble, you are to capture the output of a Lisp
session
in which you successfully load and execute your
code, showing sufficient
testing of your function(s). On osf1 type script
and your session
will be saved in a file typescript, whose hardcopy
you will hand in.
To exit script simply type 'exit'.
(2) a. In class hand in a hardcopy report consisting of:
- a cover sheet containing:
Your name
CS580 Spring 2001,
J. Kosecka
Homework #4
(A short summary stating
whether you were successful, describing
any problems,
etc.)
- a print out of the Lisp code.
Hand in the hard copy and
include the output from a run on
cities.dat. In addition for one of the larger TSP problems
(> 7),
include the efficiency table comparing the node_count and number
of
tours generated by brute force algorithm from the previous homework
and this version which incorporates prunning. In the following
form. You can use the version of solve_tsp2 which I provide as
a
solution to hw2.
Node Count Tour Count
solve_tsp2
solve_tsp3
- answers to the questions should
be handed in together with the
hardcopy
b. Send a SINGLE email to clevcovi@cs.gmu.edu formatted
in the
following way:
- the subject field of the email should read: CS580 HW#4 Kosecka
- the content of the email should
be a commented version of the
Lisp code for HW4.
Comments at the top should include:
Your name
CS580 Spring 2001,
J. Kosecka
Homework #4
As a safety precaution,
always CC yourself when you submit homework
this way and keep
it around until it has been graded and returned.