5 * A Java implementation of the <tt>tsp</tt> Olden benchmark, the traveling
9 * R. Karp, "Probabilistic analysis of partitioning algorithms for the
10 * traveling-salesman problem in the plane." Mathematics of Operations Research
11 * 2(3):209-224, August 1977
14 public class TestRunner extends Thread
18 * Number of cities in the problem.
22 * Set to true if the result should be printed
24 //private static boolean printResult = false;
26 * Set to true to print informative messages
28 //private static boolean printMsgs = false;
30 public TestRunner(int cities) {
35 * The main routine which creates a tree and traverses it.
36 * @param args the arguments to the program
43 System.out.println("Building tree of size " + cities);
45 long start0 = System.currentTimeMillis();*/
46 Tree_tsp t = Tree_tsp.buildTree(this.cities, false, 0.0f, 1.0f, 0.0f, 1.0f);
47 /*long end0 = System.currentTimeMillis();
49 long start1 = System.currentTimeMillis();*/
51 /*long end1 = System.currentTimeMillis();
54 // if the user specifies, print the final result
59 System.out.println("Tsp build time " + (end0 - start0)/1000.0);
60 System.out.println("Tsp time " + (end1 - start1)/1000.0);
61 System.out.println("Tsp total time " + (end1 - start0)/1000.0);
63 System.out.println("Done!");*/
67 * Parse the command line options.
68 * @param args the command line options.
70 /*private static final void parseCmdLine(String args[])
75 while (i < args.length && args[i].startsWith("-")) {
78 if (arg.equals("-c")) {
80 cities = new Integer(args[i++]).intValue();
81 else throw new Error("-c requires the size of tree");
82 } else if (arg.equals("-p")) {
84 } else if (arg.equals("-m")) {
86 } else if (arg.equals("-h")) {
90 if (cities == 0) usage();
94 * The usage routine which describes the program options.
96 /*private static final void usage()
98 System.err.println("usage: java TSP -c <num> [-p] [-m] [-h]");
99 System.err.println(" -c number of cities (rounds up to the next power of 2 minus 1)");
100 System.err.println(" -p (print the final result)");
101 System.err.println(" -m (print informative messages)");
102 System.err.println(" -h (print this message)");
105 public static void main(String[] args) {
107 int ncities = 4080*2;
108 for(int i = 0; i < threadnum; ++i) {
109 TestRunner tr = new TestRunner(ncities);