Class KSRanking

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

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

    • KSRanking

      public KSRanking()
  • 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 - remaining capacity of the first state
      o2 - 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