Example #1
0
  @Override
  protected void iterate() {
    ReferenceVectorGuidedPopulation population = getPopulation();
    Population offspring = new Population();
    int populationSize = population.size();

    // update the scaling factor for computing the angle-penalized distance
    population.setScalingFactor(Math.min(generation / (double) maxGeneration, 1.0));

    // create a random permutation of the population indices
    List<Integer> indices = new ArrayList<Integer>();

    for (int i = 0; i < populationSize; i++) {
      indices.add(i);
    }

    PRNG.shuffle(indices);

    // add an extra entry so the number of indices is even
    if (indices.size() % 2 == 1) {
      indices.add(indices.get(0));
    }

    // generate the offspring
    for (int i = 0; i < indices.size(); i += 2) {
      Solution[] parents =
          new Solution[] {population.get(indices.get(i)), population.get(indices.get(i + 1))};
      Solution[] children = variation.evolve(parents);

      offspring.addAll(children);
    }

    evaluateAll(offspring);

    // select the survivors
    population.addAll(offspring);
    population.truncate();

    // periodically normalize the reference vectors
    if ((generation > 0) && (generation % adaptFrequency == 0)) {
      population.adapt();
    }

    generation++;
  }
Example #2
0
  @Override
  protected void iterate() {
    Population offspring = new Population();
    int populationSize = population.size();

    while (offspring.size() < populationSize) {
      Solution[] parents = selection.select(variation.getArity(), population);
      Solution[] children = variation.evolve(parents);

      offspring.addAll(children);
    }

    evaluateAll(offspring);
    population.addAll(offspring);
    fitnessEvaluator.evaluate(population);

    while (population.size() > populationSize) {
      int worstIndex = findWorstIndex();
      fitnessEvaluator.removeAndUpdate(population, worstIndex);
    }
  }
Example #3
0
  @Override
  protected void iterate() {
    // mating and selection to generate offspring
    Population offspring = new Population();
    int populationSize = population.size();

    while (offspring.size() < numberOfOffspring) {
      Solution[] parents = selection.select(variation.getArity(), population);
      Solution[] children = variation.evolve(parents);

      offspring.addAll(children);
    }

    // evaluate the offspring
    evaluateAll(offspring);

    // evaluate the fitness of the population and offspring
    offspring.addAll(population);
    fitnessEvaluator.evaluate(offspring);

    // perform environmental selection to downselect the next population
    population.clear();
    population.addAll(truncate(offspring, populationSize));
  }