Package org.ddolib.examples.gruler
Class GRRanking
java.lang.Object
org.ddolib.examples.gruler.GRRanking
- All Implemented Interfaces:
Comparator<GRState>,StateRanking<GRState>
Defines a ranking strategy for states in the Golomb Ruler (GR) problem.
This class provides a simple heuristic ordering between two GRState objects
based on the position of their last mark. It can be used by search algorithms
such as DDO, A*, or Anytime Column Search to prioritize exploration.
The comparison criterion is straightforward: the state with the smaller last mark (i.e., the shorter current ruler) is considered better.
Example usage:
GRRanking ranking = new GRRanking();
int result = ranking.compare(state1, state2);
// result < 0 means state1 is preferred (smaller last mark)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
GRRanking
public GRRanking()
-
-
Method Details
-
compare
Compares twoGRStateinstances based on their last placed mark.A state with a smaller
lastMarkvalue is considered better, since it represents a shorter partial ruler.- Specified by:
comparein interfaceComparator<GRState>- Parameters:
s1- the first state to compare.s2- the second state to compare.- Returns:
- a negative integer if
s1has a smaller last mark thans2, zero if they are equal, or a positive integer otherwise.
-