Class BKSRanking

java.lang.Object
org.ddolib.examples.boundedknapsack.BKSRanking
All Implemented Interfaces:
Comparator<Integer>, StateRanking<Integer>

public class BKSRanking extends Object implements StateRanking<Integer>
A default state ranking implementation for the Bounded Knapsack Problem (BKP).

This class implements the StateRanking interface for states represented as remaining capacities (integers). It provides a simple comparison function that ranks states in ascending order of remaining capacity.

This ranking can be used by solvers to prioritize exploration of states with smaller remaining capacity first (or larger if reversed), which may be useful for decision diagram pruning or heuristic-guided search.

See Also:
  • Constructor Details

    • BKSRanking

      public BKSRanking()
  • Method Details

    • compare

      public int compare(Integer o1, Integer o2)
      Compares two states based on their remaining capacity.
      Specified by:
      compare in interface Comparator<Integer>
      Parameters:
      o1 - the first state
      o2 - the second state
      Returns:
      a negative integer if o1 has smaller capacity than o2, zero if they are equal, a positive integer if o1 has larger capacity than o2