Class MinMaxObjectiveComparator

java.lang.Object
org.moeaframework.algorithm.single.MinMaxObjectiveComparator
All Implemented Interfaces:
Comparator<Solution>, AggregateObjectiveComparator, DominanceComparator

public class MinMaxObjectiveComparator extends Object implements AggregateObjectiveComparator
Weighted min-max aggregate function. By default, all weights are assumed to be equal.
See Also:
  • Constructor Details

    • MinMaxObjectiveComparator

      public MinMaxObjectiveComparator(double... weights)
      Constructs a new comparator using a weighted min-max aggregate function. One weight should be given for each objective; if fewer weights are provided, the last weight is repeated for the remaining objectives. Defaults to weights of 1.0 if none are provided.
      Parameters:
      weights - the weight vector
  • Method Details

    • getWeights

      public double[] getWeights()
      Description copied from interface: AggregateObjectiveComparator
      Returns the weights used by this aggregate function.
      Specified by:
      getWeights in interface AggregateObjectiveComparator
      Returns:
      the weights
    • 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
    • calculateFitness

      public double calculateFitness(Solution solution)
      Description copied from interface: AggregateObjectiveComparator
      Calculates the aggregate (fitness) value of the solution using this aggregate function.
      Specified by:
      calculateFitness in interface AggregateObjectiveComparator
      Parameters:
      solution - the solution
      Returns:
      the aggregate value (smaller is better)
    • calculateFitness

      public static double calculateFitness(Solution solution, double[] weights)
      Computes the weighted min-max aggregate fitness of the solution. One weight should be given for each objective; if fewer weights are provided, the last weight is repeated for the remaining objectives.
      Parameters:
      solution - the solution
      weights - the weight vector
      Returns:
      the fitness, where smaller values are preferred