Package org.ddolib.examples.knapsack
Class KSRanking
java.lang.Object
org.ddolib.examples.knapsack.KSRanking
- All Implemented Interfaces:
Comparator<Integer>,StateRanking<Integer>
State ranking for the Knapsack Problem (KS).
The ranking is based on the remaining capacity of the knapsack. States with a larger remaining capacity are considered "better" (i.e., ranked higher).
This ranking can be used by solvers to prioritize states during search.
-
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
-
KSRanking
public KSRanking()
-
-
Method Details
-
compare
Compares two states based on their remaining capacity.- Specified by:
comparein interfaceComparator<Integer>- Parameters:
o1- remaining capacity of the first stateo2- remaining capacity of the second state- Returns:
- a negative integer, zero, or a positive integer if the first state has less, equal, or greater remaining capacity than the second state
-