Class FitnessComparator

java.lang.Object
org.moeaframework.core.comparator.FitnessComparator
All Implemented Interfaces:
Comparator<Solution>, DominanceComparator

public class FitnessComparator extends Object implements DominanceComparator, Comparator<Solution>
Compares two solutions based on their fitness value.
See Also:
  • Constructor Details

    • FitnessComparator

      public FitnessComparator(boolean largerValuesPreferred)
      Constructs a dominance comparator for comparing solutions based on their fitness value.
      Parameters:
      largerValuesPreferred - true if larger fitness values are preferred; otherwise smaller fitness values are preferred
  • Method Details

    • compare

      public int compare(Solution solution1, Solution solution2)
      Description copied from interface: DominanceComparator
      Compares the two solutions using a dominance relation, returning -1 if solution1 dominates solution2, 1 if solution2 dominates solution1, and 0 if the solutions are non-dominated.
      Specified by:
      compare in interface Comparator<Solution>
      Specified by:
      compare in interface DominanceComparator
      Parameters:
      solution1 - the first solution
      solution2 - the second solution
      Returns:
      -1 if solution1 dominates solution2, 1 if solution2 dominates solution1, and 0 if the solutions are non-dominated