Debugging strategy?

Duncan Smith buzzard at urubu.freeserve.co.uk
Tue Aug 1 15:27:35 EDT 2000


I have a directed tree structure (possibly a forest).   A weight (long
integer) is associated with each vertex.  I can permute the structure
locally and calculate the new (local) weight and thus the overall weight of
the tree.  The goal is to minimise the overall weight.  The vertex weights
can be very large (trillions).  I am currently using simulated annealing,
which works fine for most trees.  But occasionally, for larger trees,
something goes awry and I find that either the tree has not been permuted
correctly, or the weight has not been calculated correctly (I suspect the
former).  There is no apparent reason why this should be more likely to
occur for larger trees and I'm pretty confident my scheme is O.K. on paper.
I've tried reproducing the fault on small trees without any luck.

The problem is that I don't know how to go about debugging my code when the
problem arises so infrequently; possibly on the 20,000th iteration of an
algorithm.  Has anyone any idea how I might tackle this problem?  Does it
sound characteristic of a particular type of coding error (bearing in mind
I'm no computer scientist)?  Might I be running into problems with using
such large integers (I've checked that they remain long integers throughout
the permutation scheme)?  I'm not expecting anyone to find the bug for me
because following my code would require a much more detailed explanation of
the permutation scheme and/or the full 50+K of code.  But I would appreciate
any advice.  Thanks in advance.

Duncan Smith





More information about the Python-list mailing list