[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Testing the case against XP

  Jerry -- I'm confused. How do you write unit tests say for the Travelling
  Salesman Problem :) 

Ah, but don't you see - you're illustrating his point (if even in jest).  The
very fact that you're confused about writing a test case should lead you,
eventually, to the possibility that your attempt to include the TSP as part of
the solution is perhaps not the best approach to take.

  And even if you did write a couple of test instances, how does it help you
  write the code to solve the problem? 

Because it helps you understand the problem.  Is the problem such that it
really needs to solve (an instance of) the TSP?  If the customer tells you it
doesn't, then you've made an important discovery about the problem.  If it
does, how bad can the TSP solution be before the whole solution becomes
unacceptable?  Writing a test case for a solution that's within 20% of optimal
is a lot harder than writing a test case for a route that doesn't take more
than 4 hours to traverse at 60 mph.

In any event, to answer your question: take 36 points evenly spaced around a
circle and shuffle them.