/**
  * @param cOUNT_OF_THE_WORKERS
  * @param cOUNT_OF_THE_LABELS
  * @param cOUNT_OF_THE_CATEGORIES
  */
 public MainTestDataGenerator(
     int cOUNT_OF_THE_WORKERS, int cOUNT_OF_THE_LABELS, int cOUNT_OF_THE_CATEGORIES) {
   this.cOUNT_OF_THE_WORKERS = cOUNT_OF_THE_WORKERS;
   this.cOUNT_OF_THE_LABELS = cOUNT_OF_THE_LABELS;
   answerMatrix =
       Gen.generateAM(cOUNT_OF_THE_WORKERS, cOUNT_OF_THE_LABELS, cOUNT_OF_THE_CATEGORIES);
 }
예제 #2
0
  public static void main(String string[]) {
    Gen<String> gen = new Gen<>(); // non generic class
    gen.set("sai"); // adding string
    String s = gen.get(); // no need of casting
    out.println(s);
    // int v=gen.get();//gives Compile time error,so ensures type safety

    // we can also use generic classes as non-generic classes,but then they act as non generic
    // classes-they are called as raw types.
    Gen ng = new Gen();
    ng.set("sai");
    String ss = (String) ng.get(); // casting required
    int vv = (Integer) ng.get(); // compiles ok,but gives runtime error.
    /*many legacy code(old codes but widely used) are written in non generic classes,so generic classes are
    made possible to use as non generic classes.
    the above raw type codes can give warning as:
    Note: GenTest.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.

    The term "unchecked" means that the compiler does not have enough type information to perform all type checks necessary to ensure type safety. The "unchecked" warning is disabled, by default, though the compiler gives a hint.
    To see all "unchecked" warnings, recompile with -Xlint:unchecked.

    */
  }
예제 #3
0
  public boolean run() throws Util.Exit {

    if (!javac_extras.contains("-XDsuppress-tool-removal-message")) {
      log.println(getMessage("javah.misc.Deprecation"));
    }

    Util util = new Util(log, diagnosticListener);

    if (noArgs || help) {
      showHelp();
      return help; // treat noArgs as an error for purposes of exit code
    }

    if (version || fullVersion) {
      showVersion(fullVersion);
      return true;
    }

    util.verbose = verbose;

    Gen g;

    if (llni) g = new LLNI(doubleAlign, util);
    else {
      g = new JNI(util);
    }

    if (ofile != null) {
      if (!(fileManager instanceof StandardJavaFileManager)) {
        diagnosticListener.report(createDiagnostic("err.cant.use.option.for.fm", "-o"));
        return false;
      }
      Iterable<? extends JavaFileObject> iter =
          ((StandardJavaFileManager) fileManager)
              .getJavaFileObjectsFromFiles(Collections.singleton(ofile));
      JavaFileObject fo = iter.iterator().next();
      g.setOutFile(fo);
    } else {
      if (odir != null) {
        if (!(fileManager instanceof StandardJavaFileManager)) {
          diagnosticListener.report(createDiagnostic("err.cant.use.option.for.fm", "-d"));
          return false;
        }

        if (!odir.exists()) if (!odir.mkdirs()) util.error("cant.create.dir", odir.toString());
        try {
          ((StandardJavaFileManager) fileManager)
              .setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(odir));
        } catch (IOException e) {
          Object msg = e.getLocalizedMessage();
          if (msg == null) {
            msg = e;
          }
          diagnosticListener.report(createDiagnostic("err.ioerror", odir, msg));
          return false;
        }
      }
      g.setFileManager(fileManager);
    }

    /*
     * Force set to false will turn off smarts about checking file
     * content before writing.
     */
    g.setForce(force);

    if (fileManager instanceof JavahFileManager)
      ((JavahFileManager) fileManager).setSymbolFileEnabled(false);

    JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    List<String> opts = new ArrayList<>();
    opts.add("-proc:only");
    opts.addAll(javac_extras);

    CompilationTask t;
    try {
      t = c.getTask(log, fileManager, diagnosticListener, opts, classes, null);
    } catch (IllegalArgumentException e) {
      util.error("bad.arg", e.getMessage());
      return false;
    }

    JavahProcessor p = new JavahProcessor(g);
    t.setProcessors(Collections.singleton(p));

    boolean ok = t.call();
    if (p.exit != null) throw new Util.Exit(p.exit);
    return ok;
  }
 /** @return */
 public MainTestDataGenerator addLabels() {
   o = Gen.generateLabelNameList("url", cOUNT_OF_THE_LABELS);
   return this;
 }
 /** @return */
 public MainTestDataGenerator addWorkers() {
   w = Gen.generateLabelNameList("worker", cOUNT_OF_THE_WORKERS);
   if (o.length > 1 && w.length > 1) input.addWorkers(w, o.length);
   else return null;
   return this;
 }
예제 #6
0
  /**
   * It initialize the population
   *
   * @param tam1 It contains the size of the table of training
   * @param v1 It contains the training input values
   * @param s1 It contains the training output values
   * @param tam2 It contains the size of the table of test
   * @param v2 It contains the test input values
   * @param s2 It contains the test output values
   * @param n_variables It contains the number of variables
   * @param reglas It contains the number of rules
   * @param var It contains the number of state variables
   * @param sal It contains the exit value
   * @param v It contains the values of data base
   * @param semilla It contains the value of the seed
   */
  public void Initialize(
      int tam1,
      double[][] v1,
      double[] s1,
      int tam2,
      double[][] v2,
      double[] s2,
      int n_variables,
      int reglas,
      int var,
      double sal,
      double[] v,
      long semilla) {

    /* INICIALIZAR VARIABLES */

    int i, j;
    Genes = 0;
    contador = contador2 = 0;
    Reiniciado = 0;
    Randomize.setSeed(semilla);
    E = new Ecm(tam1, v1, s1, tam2, v2, s2, n_variables, reglas, var, sal, v);
    Poblacion = new Cromosoma[2 * Popsize];
    Trials = 0;

    for (i = 0; i < n_variables; i++) {
      Genes += E.base().getN_etiquetas(i);
    }
    Ajuste = 1;
    Gene = new Gen[Genes];
    GenesA = Genes - E.base().getN_etiquetas(E.base().getN_var_estado());
    THRESHOLD = (double) ((Genes + GenesA) * BITS_GEN / 4.0);
    reduccionIni = THRESHOLD * 0.001;
    n_reglas_total = reglas;
    Gen aux = new Gen();
    aux.set_min(0.0);
    aux.set_max(1.0);

    for (i = 0; i < Genes; i++) {
      Gene[i] = aux;
    }
    for (i = 0; i < 2 * Popsize; i++) {
      Poblacion[i] = new Cromosoma(Genes, GenesA, n_reglas_total);
    }
    sample = new int[Popsize];
    BEST_CROM = new Cromosoma(Genes, Genes, n_reglas_total);

    for (j = 0; j < Genes; j++) {
      BEST_CROM.set_gene(j, Gene[j].min() + (Gene[j].max() - Gene[j].min()) / 2.);
      Poblacion[0].set_gene(j, BEST_CROM.gene(j));
    }
    for (j = 0; j < GenesA; j++) {
      BEST_CROM.set_geneA(j, Gene[j].min() + (Gene[j].max() - Gene[j].min()) / 2.);
      Poblacion[0].set_geneA(j, BEST_CROM.gene(j));
    }
    for (j = 0; j < n_reglas_total; j++) {
      BEST_CROM.set_geneR(j, (char) 1);
      Poblacion[0].set_geneR(j, (char) 1);
    }
    for (i = 1; i < Popsize; i++) {
      for (j = 0; j < Genes; j++)
        Poblacion[i].set_gene(
            j, Gene[j].min() + (Gene[j].max() - Gene[j].min()) * Randomize.Rand());
      for (j = 0; j < GenesA; j++)
        Poblacion[i].set_geneA(
            j, Gene[j].min() + (Gene[j].max() - Gene[j].min()) * Randomize.Rand());
      for (j = 0; j < n_reglas_total; j++) Poblacion[i].set_geneR(j, (char) 1);
    }
    F = new Funciones();
  }