Example #1
0
  /**
   * Constructs a new instance of the RVEA algorithm.
   *
   * @param problem the problem being solved
   * @param population the population used to store solutions
   * @param variation the variation operator
   * @param initialization the initialization method
   * @param maxGeneration the maximum number of generations for the angle-penalized distance to
   *     transition between convergence and diversity
   * @param adaptFrequency the frequency, in generations, that the reference vectors are normalized.
   */
  public RVEA(
      Problem problem,
      ReferenceVectorGuidedPopulation population,
      Variation variation,
      Initialization initialization,
      int maxGeneration,
      int adaptFrequency) {
    super(problem, population, null, initialization);
    this.variation = variation;

    // catch potential errors
    if (variation.getArity() != 2) {
      throw new FrameworkException("RVEA only supports operators requiring 2 parents");
    }
  }
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));
  }