Class ThresholdConstraint

java.lang.Object
org.moeaframework.core.constraint.AbstractConstraint
org.moeaframework.core.constraint.ThresholdConstraint
All Implemented Interfaces:
Serializable, Comparable<Constraint>, Constraint, Copyable<Constraint>, Defined, Named
Direct Known Subclasses:
Equal, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, NotEqual

public abstract class ThresholdConstraint extends AbstractConstraint
Abstract class for constraints of the form <value> <op> <threshold>. To handle numerical precision when comparing floating-point values, a small epsilon difference is permitted, which by default is Settings.EPS.
See Also:
  • Field Details

    • threshold

      protected final double threshold
      The threshold value for this constraint.
    • epsilon

      protected final double epsilon
      The epsilon or numerical precision of this constraint.
  • Constructor Details

    • ThresholdConstraint

      public ThresholdConstraint(double threhsold)
      Constructs a new threshold constraint.
      Parameters:
      threhsold - the threshold value
    • ThresholdConstraint

      public ThresholdConstraint(double threshold, double epsilon)
      Constructs a new threshold constraint.
      Parameters:
      threshold - the threshold value
      epsilon - the epsilon value
    • ThresholdConstraint

      public ThresholdConstraint(String name, double threhsold)
      Constructs a new threshold constraint.
      Parameters:
      name - the name
      threhsold - the threshold value
    • ThresholdConstraint

      public ThresholdConstraint(String name, double threshold, double epsilon)
      Constructs a new threshold constraint.
      Parameters:
      name - the name
      threshold - the threshold value
      epsilon - the epsilon value
    • ThresholdConstraint

      public ThresholdConstraint(ThresholdConstraint copy)
      Constructs a copy of a threshold constraint.
      Parameters:
      copy - the copy
  • Method Details

    • getThreshold

      public double getThreshold()
      Returns the threshold value.
      Returns:
      the threshold value
    • getEpsilon

      public double getEpsilon()
      Returns the epsilon value used for numeric precision.
      Returns:
      the epsilon value
    • getDefinition

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

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

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

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