Exemplo n.º 1
0
  /** Function which selects the elements of the population */
  public void Select() {

    int i, j;

    for (i = 0; i < Popsize; i++)
      for (j = i + 1; j < POPSIZE; j++)
        if (Better(Poblacion[j].perf(), Poblacion[i].perf())) INTERCAMBIAR(i, j);

    if (Poblacion[0].perf() < BEST_CROM.perf()) {
      for (j = 0; j < Genes; j++) BEST_CROM.set_gene(j, Poblacion[0].gene(j));
      for (j = 0; j < GenesA; j++) BEST_CROM.set_geneA(j, Poblacion[0].geneA(j));
      for (j = 0; j < n_reglas_total; j++) BEST_CROM.set_geneR(j, Poblacion[0].geneR(j));
      BEST_CROM.set_perf(Poblacion[0].perf());
      BEST_CROM.set_entrado(1);
    }
  }