Example #1
0
  // :::::::::::::::::::::::::::  Copyright(c) M@nso  2016  :::::::::::::::::::
  ///////////////////////////////////////////////////////////////////////////
  public static void main(String[] args) {
    Random rnd = new Random(1223);
    SimplePopulation mp = new MultiPopulation();
    mp.setParameters("500");
    mp.setRandomGenerator(rnd);

    Solution i = new OneMax();
    i.setRandomGenerator(rnd);
    i.setParameters("1000");
    mp.createRandom(i);

    for (int j = 0; j < mp.getNumberOfIndividuals(); j++) {
      Solution i1 = mp.removeRandom();
      Solution i2 = mp.removeRandom();
      if (i1.compareTo(i2) > 0) {
        mp.addIndividual(i1);
        mp.addIndividual(i1);
      } else {
        mp.addIndividual(i2);
        mp.addIndividual(i2);
      }
    }
    Recombination x = new M_Uniforme();
    x.setRandomGenerator(rnd);

    for (int j = 0; j < mp.getNumberOfIndividuals(); j++) {
      System.out.println(" i " + j);
      mp = x.execute(mp);
      mp.evaluate();
    }

    System.out.println("" + mp);
  }