Class BKSDominance
java.lang.Object
org.ddolib.examples.boundedknapsack.BKSDominance
Implementation of a dominance rule for the Bounded Knapsack (BKS) problem.
This class defines how two states (represented here by integer capacities) can dominate one another in the search space. In this context, a state with a smaller capacity is considered dominated by a state with a larger one, since it provides fewer remaining resources for future item selections.
The dominance mechanism helps prune the search space efficiently in dynamic programming or branch-and-bound algorithms.
Example:
BKSDominance dominance = new BKSDominance();
boolean result = dominance.isDominatedOrEqual(5, 10); // true, since 5 < 10
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
BKSDominance
public BKSDominance()
-
-
Method Details
-
getKey
Returns the dominance key for a given state.In this simplified implementation, all states share the same key (0), meaning that dominance comparisons are applied globally without grouping.
-
isDominatedOrEqual
Checks whether one state (capacity) is dominated or equal to another.In this implementation,
capa1is considered dominated or equal tocapa2if it is strictly smaller.- Specified by:
isDominatedOrEqualin interfaceDominance<Integer>- Parameters:
capa1- The first capacity (potentially dominated).capa2- The second capacity (potential dominator).- Returns:
trueifcapa1 <= capa2,falseotherwise.
-