Class GRRanking

java.lang.Object
org.ddolib.examples.gruler.GRRanking
All Implemented Interfaces:
Comparator<GRState>, StateRanking<GRState>

public class GRRanking extends Object implements 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 Details

    • GRRanking

      public GRRanking()
  • Method Details

    • compare

      public int compare(GRState s1, GRState s2)
      Compares two GRState instances based on their last placed mark.

      A state with a smaller lastMark value is considered better, since it represents a shorter partial ruler.

      Specified by:
      compare in interface Comparator<GRState>
      Parameters:
      s1 - the first state to compare.
      s2 - the second state to compare.
      Returns:
      a negative integer if s1 has a smaller last mark than s2, zero if they are equal, or a positive integer otherwise.