Class Max2SatRanking

java.lang.Object
org.ddolib.examples.layered.max2sat.Max2SatRanking
All Implemented Interfaces:
Comparator<Max2SatState>, StateRanking<Max2SatState>

public class Max2SatRanking extends Object implements StateRanking<Max2SatState>
Class used to compare two states for the Max2Sat problem.
A positive value means that we have a bigger benefit by setting xk to T.
A negative value means that we have a bigger benefit by setting xk to F.
When comparing two states, the best is the one that can generate the biggest benefit, independently of the decisions. That's why we sum the absolute value of each benefit to compare the states.
  • Constructor Details

    • Max2SatRanking

      public Max2SatRanking()
      Creates a new instance of this ranking.
  • Method Details

    • rank

      public static int rank(Max2SatState state)
      Computes the ranking value of a state, defined as the sum of the absolute value of the net benefit of each variable not yet assigned.
      Parameters:
      state - the state to rank
      Returns:
      the ranking value of the state
    • compare

      public int compare(Max2SatState o1, Max2SatState o2)
      Specified by:
      compare in interface Comparator<Max2SatState>