Package org.ddolib.ddo.core.cache
Class Threshold
java.lang.Object
org.ddolib.ddo.core.cache.Threshold
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionThreshold(int value, boolean explored) Constructs a new threshold with a given value and exploration status. -
Method Summary
Modifier and TypeMethodDescriptionintCompares this threshold to another threshold.booleanReturns whether the state has been explored.doublegetValue()Returns the numeric value of this threshold.booleanReturns whether the state has been explored.voidsetExplored(boolean expl) Sets the exploration status of the state.voidsetValue(double val) Sets the numeric value of this threshold.toString()Returns a string representation of this threshold.
-
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 valueexplored- 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
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:
compareToin interfaceComparable<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
Returns a string representation of this threshold.
-