Beispiel #1
0
 /**
  * Invokes a test as a command, with specified number of warmup runs, test runs, class name, and
  * string arguments. The command-line syntax is:
  *
  * <blockquote>
  *
  * <code>
  *   java com.aliasi.test.time.Stopwatch
  *   <br>&nbsp;&nbsp;&nbsp;
  *   <i>numWarmups</i> <i>numTests</i> <i>className</i>
  *                  <i>arg1</i> ... <i>argN</i>  [<i>N</i> &gt;= 0]
  * </code>
  *
  * </blockquote>
  *
  * The arguments are strings, and there must be an <i>N</i>-argument constructor with string
  * argument types for the class with the name <i>className</i>. In particular, if there are no
  * arguments, there must be a no-argument constructor.
  *
  * @param args Command-line arguments.
  */
 public static void main(String[] args) throws Exception {
   if (args.length < 3) {
     String msg = "Must specify name of class as argument.";
     throw new IllegalArgumentException(msg);
   }
   int numWarmups = Integer.parseInt(args[0]);
   int numTests = Integer.parseInt(args[1]);
   String className = args[2];
   String[] consArgs = new String[args.length - 3];
   System.arraycopy(args, 3, consArgs, 0, consArgs.length);
   Runnable runnable = (Runnable) Reflection.newInstance(className, consArgs);
   if (runnable == null) {
     String msg = "Could not construct runnable.";
     throw new IllegalArgumentException(msg);
   }
   Results results = test(runnable, numWarmups, numTests);
   System.out.println();
   System.out.println("RESULTS");
   System.out.println(results.toString());
 }
Beispiel #2
0
  /**
   * Converts the information stored at this node to a string
   *
   * @return the converted string
   * @exception Exception if something goes wrong
   */
  public final String singleNodeToString() throws Exception {

    StringBuffer text = new StringBuffer();

    text.append("Print single node (" + itemsets.numItemsets() + "):\n");
    if (type == true) {
      text.append("    Type:\t\t\tNODE\n");
    } else {
      text.append("    Type:\t\t\tLEAF\n");
    }
    text.append("    Unsmoothed function:\t\t");
    unsmoothed.toString(itemsets, 0);
    System.out.print("    Smoothed function:\t\t");
    smoothed.toString(itemsets, 0);
    text.append("    Value node:\t\t\t" + valueNode + "\n");
    if (errors != null) {
      text.append(errors.toString());
    }
    if (upNode != null) {
      text.append("    upNode:\t\t\tyes\n");
    } else {
      text.append("    upNode:\t\t\tnull\n");
    }
    if (leftNode != null) {
      text.append("    leftNode:\t\t\tyes\n");
    } else {
      text.append("    leftNode:\t\t\tnull\n");
    }
    if (rightNode != null) {
      text.append("    rightNode:\t\t\tyes\n");
    } else {
      text.append("    rightNode:\t\t\tnull\n");
    }
    text.append("    number of parameters:\t" + numParameters + "\n");
    text.append("    LEAF number(lm):\t\t" + lm + "\n");
    text.append("    Number of itemsets\t\t" + itemsets.numItemsets() + "\n");

    return text.toString();
  }