예제 #1
0
  @Override
  public double evaluate(NondominatedPopulation approximationSet) {
    int count = 0;

    for (Solution solution1 : referenceSet) {
      boolean match = false;

      for (Solution solution2 : approximationSet) {
        if (comparator == null) {
          double distance =
              MathArrays.distance(solution1.getObjectives(), solution2.getObjectives());

          if (distance < Settings.EPS) {
            match = true;
            break;
          }
        } else {
          comparator.compare(solution1, solution2);

          if (comparator.isSameBox()) {
            match = true;
            break;
          }
        }
      }

      if (match) {
        count++;
      }
    }

    return count / (double) referenceSet.size();
  }
예제 #2
0
  /**
   * Returns the Euclidean distance in objective space between the specified solution and the
   * nearest solution in the population.
   *
   * @param problem the problem
   * @param solution the solution
   * @param population the population
   * @return the Euclidean distance in objective space between the specified solution and the
   *     nearest solution in the population
   */
  public static double distanceToNearestSolution(
      Problem problem, Solution solution, NondominatedPopulation population) {
    double minimum = Double.POSITIVE_INFINITY;

    for (int i = 0; i < population.size(); i++) {
      minimum = Math.min(minimum, euclideanDistance(problem, solution, population.get(i)));
    }

    return minimum;
  }