Class BKSRanking
java.lang.Object
org.ddolib.examples.boundedknapsack.BKSRanking
- All Implemented Interfaces:
Comparator<Integer>,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 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
-
BKSRanking
public BKSRanking()
-
-
Method Details
-
compare
Compares two states based on their remaining capacity.- Specified by:
comparein interfaceComparator<Integer>- Parameters:
o1- the first stateo2- 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
-