Ported over bamboo benchmarks for use as non-Bamboo java benchmarks.
[IRC.git] / Robust / src / Benchmarks / Scheduling / GC / NON_BAMBOO / tsp / TestRunner.java
1
2 //import java.io.*;
3
4 /**
5  * A Java implementation of the <tt>tsp</tt> Olden benchmark, the traveling
6  * salesman problem.
7  * <p>
8  * <cite>
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
12  * </cite>
13  **/
14 public class TestRunner extends Thread
15 {
16   
17   /**
18    * Number of cities in the problem.
19    **/
20   public int cities;
21   /**
22    * Set to true if the result should be printed
23    **/
24   //private static boolean printResult = false;
25   /**
26    * Set to true to print informative messages
27    **/
28   //private static boolean printMsgs = false;
29   
30   public TestRunner(int cities) {
31     this.cities = cities;
32   }
33
34   /**
35    * The main routine which creates a tree and traverses it.
36    * @param args the arguments to the program
37    **/
38   public void run()
39   {
40     /*parseCmdLine(args);
41
42     if (printMsgs)
43       System.out.println("Building tree of size " + cities);
44     
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();
48
49     long start1 = System.currentTimeMillis();*/
50     t.tsp(150);
51     /*long end1 = System.currentTimeMillis();
52
53     if (printResult) {
54       // if the user specifies, print the final result
55       t.printVisitOrder();
56     }
57
58     if (printMsgs) {
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);
62     }
63     System.out.println("Done!");*/
64   }
65
66   /**
67    * Parse the command line options.
68    * @param args the command line options.
69    **/
70   /*private static final void parseCmdLine(String args[])
71   {
72     int i = 0;
73     String arg;
74
75     while (i < args.length && args[i].startsWith("-")) {
76       arg = args[i++];
77
78       if (arg.equals("-c")) {
79         if (i < args.length)
80           cities = new Integer(args[i++]).intValue();
81         else throw new Error("-c requires the size of tree");
82       } else if (arg.equals("-p")) {
83         printResult = true;
84       } else if (arg.equals("-m")) {
85         printMsgs = true;
86       } else if (arg.equals("-h")) {
87         usage();
88       }
89     }
90     if (cities == 0) usage();
91   }*/
92
93   /**
94    * The usage routine which describes the program options.
95    **/
96   /*private static final void usage()
97   {
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)");
103     System.exit(0);
104   }*/
105   public static void main(String[] args) {
106     int threadnum = 62;
107     int ncities = 4080*2;
108     for(int i = 0; i < threadnum; ++i) {
109       TestRunner tr = new TestRunner(ncities);
110       tr.run();
111     }
112   }
113 }
114