コード例 #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
ファイル: RVEA.java プロジェクト: MOEAFramework/MOEAFramework
  /**
   * 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");
    }
  }
コード例 #3
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));
  }
コード例 #4
0
ファイル: RVEA.java プロジェクト: MOEAFramework/MOEAFramework
  @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++;
  }