6 * A Java implementation of the <tt>tsp</tt> Olden benchmark, the traveling
10 * R. Karp, "Probabilistic analysis of partitioning algorithms for the
11 * traveling-salesman problem in the plane." Mathematics of Operations Research
12 * 2(3):209-224, August 1977
15 public class TestRunner extends Thread
19 * Number of cities in the problem.
23 * Set to true if the result should be printed
25 //private static boolean printResult = false;
27 * Set to true to print informative messages
29 //private static boolean printMsgs = false;
31 public TestRunner(int cities) {
36 * The main routine which creates a tree and traverses it.
37 * @param args the arguments to the program
44 System.out.println("Building tree of size " + cities);
46 long start0 = System.currentTimeMillis();*/
47 Tree_tsp t = Tree_tsp.buildTree(this.cities, false, 0.0f, 1.0f, 0.0f, 1.0f);
48 /*long end0 = System.currentTimeMillis();
50 long start1 = System.currentTimeMillis();*/
52 /*long end1 = System.currentTimeMillis();
55 // if the user specifies, print the final result
60 System.out.println("Tsp build time " + (end0 - start0)/1000.0);
61 System.out.println("Tsp time " + (end1 - start1)/1000.0);
62 System.out.println("Tsp total time " + (end1 - start0)/1000.0);
64 System.out.println("Done!");*/
68 * Parse the command line options.
69 * @param args the command line options.
71 /*private static final void parseCmdLine(String args[])
76 while (i < args.length && args[i].startsWith("-")) {
79 if (arg.equals("-c")) {
81 cities = new Integer(args[i++]).intValue();
82 else throw new Error("-c requires the size of tree");
83 } else if (arg.equals("-p")) {
85 } else if (arg.equals("-m")) {
87 } else if (arg.equals("-h")) {
91 if (cities == 0) usage();
95 * The usage routine which describes the program options.
97 /*private static final void usage()
99 System.err.println("usage: java TSP -c <num> [-p] [-m] [-h]");
100 System.err.println(" -c number of cities (rounds up to the next power of 2 minus 1)");
101 System.err.println(" -p (print the final result)");
102 System.err.println(" -m (print informative messages)");
103 System.err.println(" -h (print this message)");
106 public static void main(String[] args) {
108 int ncities = 4080*2;
109 for(int i = 0; i < threadnum; ++i) {
110 TestRunner tr = new TestRunner(ncities);