Class AbstractObjective

java.lang.Object
org.moeaframework.core.objective.AbstractObjective
All Implemented Interfaces:
Serializable, Comparable<Objective>, Copyable<Objective>, Defined, Named, Objective
Direct Known Subclasses:
Maximize, Minimize

public abstract class AbstractObjective extends Object implements Objective
Abstract class for implementing objectives. The objective value is initialized to 0d/0d, which serves as an indicator that the objective has not been assigned.

Objectives can be assigned a name, but if unset will derive its name from its current index by calling Objective.getNameOrDefault(Objective, int). Such objectives are also called "anonymous".

See Also:
  • Field Details

    • name

      protected final String name
      The objective name, or null if anonymous.
    • value

      protected double value
      The objective value.
  • Constructor Details

    • AbstractObjective

      public AbstractObjective()
      Constructs a new, anonymous objective.
    • AbstractObjective

      protected AbstractObjective(String name)
      Constructs a new objective with the given name.
      Parameters:
      name - the objective name, or null to create an anonymous objective
  • Method Details

    • getName

      public String getName()
      Description copied from interface: Named
      Returns the name of this object. The format for the name depends on the specific implementation, but in general we recommend:
      1. Prefer using alphanumeric characters including '_' and '-'.
      2. Avoid whitespace and other control characters.
      3. null can be returned, if allowed by the implementation, to indicate the object is anonymous or has no assigned name.
      Specified by:
      getName in interface Named
      Returns:
      the name
    • setValue

      public void setValue(double value)
      Description copied from interface: Objective
      Sets the objective value.
      Specified by:
      setValue in interface Objective
      Parameters:
      value - the objective value
    • getValue

      public double getValue()
      Description copied from interface: Objective
      Returns the objective value.
      Specified by:
      getValue in interface Objective
      Returns:
      the objective value
    • getDefinition

      public String getDefinition()
      Description copied from interface: Defined
      Returns the string representation, or definition, of this object.
      Specified by:
      getDefinition in interface Defined
      Returns:
      the definition
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object