Interface Objective

All Superinterfaces:
Comparable<Objective>, Copyable<Objective>, Defined, Named, Serializable
All Known Implementing Classes:
AbstractObjective, Maximize, Minimize, NormalizedObjective

public interface Objective extends Comparable<Objective>, Copyable<Objective>, Serializable, Defined, Named
Defines an objective for optimization, including the value and the direction.

Always prefer using one of the methods, such as compareTo(Objective), for performing operations on objectives rather than using the value directly, as the methods accounts for the direction.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.moeaframework.core.Defined

    Defined.ConstructorComparator
  • Method Summary

    Modifier and Type
    Method
    Description
    default double
    applyWeight(double weight)
    Applies a weight to this objective.
    int
    compareTo(double value)
    Similar to Comparable.compareTo(Object), compares this objective to a given value.
    default int
     
    static Objective
    Returns a new instance of the default optimization objective.
    default double
    distanceTo(double value)
    Computes the distance between two objectives.
    default double
    Computes the distance between two objectives.
    double
    Returns the canonical value of this objective.
    default double
    getEpsilonDistance(double epsilon)
    The distance this objective must change, in the direction of the ideal value, to fall within the next epsilon box.
    default int
    getEpsilonIndex(double epsilon)
    Returns the index used by epsilon-dominance.
    double
    Returns the ideal or best possible value for this objective.
    static String
    getNameOrDefault(Objective objective, int index)
    Returns the name of the objective, using either the name assigned to the objective or deriving the name from its index.
    double
    Returns the objective value.
    static double
    ideal(double first, Objective second)
    Returns the objective value considered better or more ideal.
    static double
    ideal(Objective first, double second)
    Returns the objective value considered better or more ideal.
    static Objective
    ideal(Objective first, Objective second)
    Returns the objective considered better or more ideal.
    normalize(double minimum, double maximum)
    Returns a normalized objective that is: scaled between the minimum and maximum bounds, typically producing a value falling between [0, 1], and has an ideal or target value of Double#NEGATIVE_INFINITY.
    void
    setValue(double value)
    Sets the objective value.
    default Objective
    withValue(double value)
    Updates this objective with the given objective value and returns itself.

    Methods inherited from interface org.moeaframework.core.Copyable

    copy

    Methods inherited from interface org.moeaframework.core.Defined

    getDefinition

    Methods inherited from interface org.moeaframework.core.Named

    getName
  • Method Details

    • getValue

      double getValue()
      Returns the objective value.
      Returns:
      the objective value
    • setValue

      void setValue(double value)
      Sets the objective value.
      Parameters:
      value - the objective value
    • getCanonicalValue

      double getCanonicalValue()
      Returns the canonical value of this objective.

      The canonical value is the objective converted into a minimized form, with the target or ideal towards -1d/0d. This allows an implementation to use the numeric value of the objective directly, without needing to be aware of the optimization direction. This works since minimizing -f(x) is equivalent to maximizing f(x).

      Returns:
      the canonical value
    • compareTo

      int compareTo(double value)
      Similar to Comparable.compareTo(Object), compares this objective to a given value.
      Parameters:
      value - the value
      Returns:
      -1, 0, or 1 depending if this objective is less than, equal to, or greater than the given value
    • normalize

      NormalizedObjective normalize(double minimum, double maximum)
      Returns a normalized objective that is:
      1. scaled between the minimum and maximum bounds, typically producing a value falling between [0, 1], and
      2. has an ideal or target value of Double#NEGATIVE_INFINITY.
      Parameters:
      minimum - the minimum bound
      maximum - the maximum bound
      Returns:
      the normalized objective
    • withValue

      default Objective withValue(double value)
      Updates this objective with the given objective value and returns itself.
      Parameters:
      value - the objective value
      Returns:
      a reference to this objective
    • getEpsilonIndex

      default int getEpsilonIndex(double epsilon)
      Returns the index used by epsilon-dominance. This is used by EpsilonBoxDominanceArchive in its dominance calculations.

      This calculation is based on the canonical value of the objective, and as such the returned value is minimized.

      Parameters:
      epsilon - the epsilon value
      Returns:
      the index
    • getEpsilonDistance

      default double getEpsilonDistance(double epsilon)
      The distance this objective must change, in the direction of the ideal value, to fall within the next epsilon box. This is used by EpsilonBoxDominanceArchive when comparing solutions within the same epsilon box.
      Parameters:
      epsilon - the epsilon value
      Returns:
      the distance
    • applyWeight

      default double applyWeight(double weight)
      Applies a weight to this objective.

      This calculation is based on the canonical value of the objective, and as such the returned value is minimized.

      Parameters:
      weight - the weight
      Returns:
      the weighted objective value
    • getIdealValue

      double getIdealValue()
      Returns the ideal or best possible value for this objective.
      Returns:
      the ideal objective value
    • compareTo

      default int compareTo(Objective other)
      Specified by:
      compareTo in interface Comparable<Objective>
    • distanceTo

      default double distanceTo(Objective other)
      Computes the distance between two objectives.
      Parameters:
      other - the other objective
      Returns:
      the distance, a non-negative number
    • distanceTo

      default double distanceTo(double value)
      Computes the distance between two objectives.
      Parameters:
      value - the other objective value
      Returns:
      the distance, a non-negative number
    • ideal

      static Objective ideal(Objective first, Objective second)
      Returns the objective considered better or more ideal. If the objectives are equivalent, either objective will be returned.
      Parameters:
      first - the first objective
      second - the second objective
      Returns:
      the more ideal objective
      See Also:
    • ideal

      static double ideal(double first, Objective second)
      Returns the objective value considered better or more ideal.
      Parameters:
      first - the first objective value
      second - the second objective
      Returns:
      the ideal objective value
      See Also:
    • ideal

      static double ideal(Objective first, double second)
      Returns the objective value considered better or more ideal.
      Parameters:
      first - the first objective value
      second - the second objective
      Returns:
      the ideal objective value
      See Also:
    • createDefault

      static Objective createDefault()
      Returns a new instance of the default optimization objective. This is the objective used if not explicitly configured by the problem or user.
      Returns:
      the default optimization objective
    • getNameOrDefault

      static String getNameOrDefault(Objective objective, int index)
      Returns the name of the objective, using either the name assigned to the objective or deriving the name from its index.
      Parameters:
      objective - the objective
      index - the index of the objective
      Returns:
      the name of the objective