/**
   * Init a new Plot Pannel with the given data.
   *
   * @param title the title of the Plot
   * @param xLabel the label on the xAxses
   * @param yLabel the label on the yAxses
   * @param data the dataset containter
   * @param type the type of Plot (Runtime, Memory, etc)
   * @param config the configuration object where the config can be retrieved from
   * @param tightY
   * @param tightX
   */
  public BenchmarkPlot(
      final String title,
      final String label,
      final BenchmarkDataset data,
      final PlotType xAxis,
      final PlotType yAxis,
      BenchmarkConfiguration config,
      boolean tightY,
      boolean tightX) {
    super();
    synchronized (data.getDatasetLock()) {
      data.setCurrentPlot(this);

      this.config = config;
      this.dataset = data;
      this.plotTitle = title;
      this.xAxis = xAxis;
      this.yAxis = yAxis;

      /** Process the Styling == make it lines styled */
      PlotStyle ps = new PlotStyle();
      ps.setStyle(Style.LINES);

      DataSetPlot dp = new DataSetPlot(this.dataset);
      dp.setTitle(label);
      dp.setPlotStyle(ps);

      // TODO config smooth
      dp.setSmooth(Smooth.SBEZIER);

      JavaPlot jp = new JavaPlot(this.config.getGnuPlotLocation());
      jp.setTitle(title);
      jp.getAxis("x").setLabel(xAxis.getLabel());
      jp.getAxis("y").setLabel(yAxis.getLabel());
      if (tightY) {
        double minY = dataset.getMinY();
        jp.getAxis("y").setBoundaries(minY > 0 ? minY - 1 : minY, dataset.getMaxY() + 1);
      }
      if (tightX) {
        double minX = dataset.getMinX();
        jp.getAxis("x").setBoundaries(minX > 0 ? minX - 1 : minX, dataset.getMaxX() + 1);
      }

      // Legend location
      jp.setKey(Key.TOP_LEFT);
      jp.addPlot(dp);

      this.setJavaPlot(jp);
      this.repaint();
    }
  }
示例#2
0
  private static void runABC(TestFunction cur_fct) {

    /* get nr of runs */
    Integer nr_runs = (Integer) gC_params.get(GlobalParameters.nr_runs);

    /* array holding best values for each run */
    double[] values = new double[nr_runs];

    /* array holding the iteration number when goal was reached */
    int[] lia_iterations = new int[nr_runs];

    int li_popSize = (Integer) gC_params.get(GlobalParameters.popSize);

    int li_iterations;

    /* decide how many evaluations, depends on function */
    double li_fctid = cur_fct.getID();
    if (li_fctid == 1 || li_fctid == 2) {
      li_iterations = (Integer) gC_params.get(GlobalParameters.numEval1) / li_popSize;
    } else {
      li_iterations = (Integer) gC_params.get(GlobalParameters.numEval2) / li_popSize;
    }

    /* for plotting, mean value of each cycle and cycle number */
    double[][] lda_bestvalue = new double[nr_runs][li_iterations];

    System.out.println(gC_params.get(GlobalParameters.Name));

    for (int i = 0; i < nr_runs; i++) {

      ModelInterface lC_model = null;

      if (gC_params.get(GlobalParameters.Name) == "sabc") {
        lC_model = new s_abc(cur_fct, gC_params);
      } else if (gC_params.get(GlobalParameters.Name) == "m1_abc") {
        lC_model = new m1_abc(cur_fct, gC_params);
      } else if (gC_params.get(GlobalParameters.Name) == "m2_abc") {
        lC_model = new m2_abc(cur_fct, gC_params);
      } else if (gC_params.get(GlobalParameters.Name) == "m3_abc") {
        lC_model = new m3_abc(cur_fct, gC_params);
      } else if (gC_params.get(GlobalParameters.Name) == "m4_abc") {
        lC_model = new m4_abc(cur_fct, gC_params);
      } else if (gC_params.get(GlobalParameters.Name) == "m5_abc") {
        lC_model = new m5_abc(cur_fct, gC_params);
      } else if (gC_params.get(GlobalParameters.Name) == "m6_abc") {
        lC_model = new m6_abc(cur_fct, gC_params);
      }

      if (lC_model != null) {

        double[] ld_best_it = run(lC_model, li_iterations, lda_bestvalue[i]);
        values[i] = ld_best_it[0];
        lia_iterations[i] = (int) ld_best_it[1];

        System.out.print(".");

      } else {
        break;
      }
    }

    /* calculate and print the mean, median, best, worsed, expected number of iterations
     * for reaching the goal/optima from all the experiments
     */
    System.out.print("\n[" + cur_fct.getName() + "]");
    // printIterationStatistics(lia_iterations);

    /* calculate mean for each cycle */
    double[][] lda_offperformance = new double[li_iterations][2];
    double[][] lda_globalbest = new double[li_iterations][2];

    double ld_bestvaluesum = 0;

    for (int i = 0; i < li_iterations; i++) {

      /* calculate mean of best value in each iteration */
      ld_bestvaluesum += lda_bestvalue[0][i];
      System.out.println(lda_bestvalue[0][i]);

      lda_offperformance[i][1] = (ld_bestvaluesum / (i + 1));
      lda_offperformance[i][0] = i;

      lda_globalbest[i][1] = lda_bestvalue[0][i];
      lda_globalbest[i][0] = i;
    }

    double ld_mean = mean(values);

    DataSetPlot lC_ptmp = new DataSetPlot(lda_offperformance);
    PlotStyle lC_style = new PlotStyle(Style.LINES);
    lC_ptmp.setPlotStyle(lC_style);
    lC_ptmp.setTitle((String) gC_params.get(GlobalParameters.Name) + ":op");
    gC_plot.addPlot(lC_ptmp);

    DataSetPlot lC_btmp = new DataSetPlot(lda_globalbest);
    // PlotStyle lC_bstyle = new PlotStyle(Style.LINES);
    lC_btmp.setPlotStyle(lC_style);
    lC_btmp.setTitle((String) gC_params.get(GlobalParameters.Name) + ":gbest");
    gC_plot.addPlot(lC_btmp);

    System.out.println(sc_fn.format(ld_mean) + " +/- " + sc_fn.format(sd(values, ld_mean)) + "\t");
  }