Package org.ddolib.examples.mks
Class MKSRanking
java.lang.Object
org.ddolib.examples.mks.MKSRanking
- All Implemented Interfaces:
Comparator<MKSState>,StateRanking<MKSState>
Ranking strategy for multi-dimensional Knapsack (MKS) states.
This class implements StateRanking and provides a method to compare
two MKS states based on the average remaining capacity across all knapsack dimensions.
States with smaller average remaining capacity are considered "smaller" in the ranking.
-
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
-
MKSRanking
public MKSRanking()
-
-
Method Details
-
compare
Compares two MKS states based on their average remaining capacities.The average capacity of each state is computed by summing all dimension capacities and dividing by the number of dimensions. Comparison is then performed using
Double.compare(double, double).- Specified by:
comparein interfaceComparator<MKSState>- Parameters:
o1- the first MKS stateo2- the second MKS state- Returns:
- a negative integer, zero, or a positive integer as the first state has less than, equal to, or greater average capacity than the second state
-