コード例 #1
0
ファイル: IBEA.java プロジェクト: Gan0k/MOEAFramework
  @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);
    }
  }
コード例 #2
0
ファイル: SPEA2.java プロジェクト: gxzhouyong/MOEAFramework
  @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));
  }