Exemplo n.º 1
0
  /**
   * benchmark a tsp algorithm
   *
   * @param instances the instances
   * @param algo the algorithm class
   * @param params the parameters
   */
  public static final void benchmark(
      final ArrayListView<Instance> instances,
      final Class<? extends TSPAlgorithm> algo,
      final String[] params) {
    final Logger log;
    final Configuration cfg;
    final TSPAlgorithmRunner r;

    cfg = new Configuration();
    try {
      cfg.configure(params);

      r = new TSPAlgorithmRunner(instances, algo, null);
      r.configure(cfg);

      log = r.getLogger();

      if ((log != null) && (log.isLoggable(Level.INFO))) {
        log.info(
            "TSP Algorithm Benchmarker now running "
                + //$NON-NLS-1$
                ((algo != null) ? algo.getSimpleName() : String.valueOf(null)));
      }

      if (cfg.getBoolean(Configurable.PARAM_HELP, false)) {
        r.printParameters(System.out);
        return;
      }

      r.benchmark();
    } catch (final Throwable t) {
      t.printStackTrace();
    }
  }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  @Override
  public final void configure(final Configuration config) {
    super.configure(config);

    this.m_maxThreads =
        config.getInt(TSPAlgorithmRunner.PARAM_MAX_THREADS, 1, 10000, this.m_maxThreads);

    this.m_algoInst =
        config.getInstance(
            TSPAlgorithmRunner.PARAM_ALGO_CLASS, TSPAlgorithm.class,
            this.m_algo, this.m_algoInst);
    if (this.m_algoInst != null) {
      this.m_algo = this.m_algoInst.getClass();
    }

    this.m_initInst =
        config.getInstance(
            TSPAlgorithmRunner.PARAM_DET_INIT_CLASS, TSPAlgorithm.class,
            this.m_init, this.m_initInst);
    if (this.m_initInst != null) {
      this.m_init = this.m_initInst.getClass();
    }

    this.m_queue.configure(config);
    this.m_creator.configure(config);
  }