Class Threshold

java.lang.Object
org.ddolib.ddo.core.cache.Threshold
All Implemented Interfaces:
Comparable<Threshold>

public class Threshold extends Object implements Comparable<Threshold>
Represents a threshold value associated with a state in a dynamic programming or search model.

Each Threshold has a numeric value and a boolean flag indicating whether the state has been explored. Thresholds can be compared to each other based on their value and exploration status.

This class is typically used in caching, pruning, or dominance checks in optimization algorithms.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Threshold(int value, boolean explored)
    Constructs a new threshold with a given value and exploration status.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compares this threshold to another threshold.
    boolean
    Returns whether the state has been explored.
    double
    Returns the numeric value of this threshold.
    boolean
    Returns whether the state has been explored.
    void
    setExplored(boolean expl)
    Sets the exploration status of the state.
    void
    setValue(double val)
    Sets the numeric value of this threshold.
    Returns a string representation of this threshold.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Threshold

      public Threshold(int value, boolean explored)
      Constructs a new threshold with a given value and exploration status.
      Parameters:
      value - the numeric threshold value
      explored - true if the state is explored, false otherwise
  • Method Details

    • getValue

      public double getValue()
      Returns the numeric value of this threshold.
      Returns:
      the threshold value
    • getExplored

      public boolean getExplored()
      Returns whether the state has been explored.
      Returns:
      true if explored, false otherwise
    • isExplored

      public boolean isExplored()
      Returns whether the state has been explored.

      Alias for getExplored().

      Returns:
      true if explored, false otherwise
    • setValue

      public void setValue(double val)
      Sets the numeric value of this threshold.
      Parameters:
      val - the new threshold value
    • setExplored

      public void setExplored(boolean expl)
      Sets the exploration status of the state.
      Parameters:
      expl - true if the state has been explored, false otherwise
    • compareTo

      public int compareTo(Threshold other)
      Compares this threshold to another threshold.

      Thresholds are compared first by value (ascending), and then by exploration status (false then true) if the values are equal.

      Specified by:
      compareTo in interface Comparable<Threshold>
      Parameters:
      other - the threshold to compare with
      Returns:
      a negative integer, zero, or a positive integer as this threshold is less than, equal to, or greater than the specified threshold
    • toString

      public String toString()
      Returns a string representation of this threshold.
      Overrides:
      toString in class Object
      Returns:
      a string in the format "Threshold [value=..., explored=...]"