Class BKSFastLowerBound
java.lang.Object
org.ddolib.examples.boundedknapsack.BKSFastLowerBound
- All Implemented Interfaces:
FastLowerBound<Integer>
A fast lower bound implementation for the
BKSProblem (Bounded Knapsack Problem).
This class computes a lower bound on the optimal solution value from a given state and a subset of variables (items) using a fractional knapsack relaxation. The algorithm sorts the remaining items by their value-to-weight ratio and greedily fills the remaining capacity to approximate the best possible completion from the current partial solution.
The lower bound is returned as a negative value (following the solver convention where the objective is to minimize the total cost or maximize the profit).
Example:
BKSProblem problem = new BKSProblem(values, weights, quantities, capacity);
FastLowerBound<Integer> flb = new BKSFastLowerBound(problem);
double bound = flb.fastLowerBound(currentCapacity, remainingItems);
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBKSFastLowerBound(BKSProblem problem) Constructs a fast lower bound evaluator for the given bounded knapsack problem. -
Method Summary
Modifier and TypeMethodDescriptiondoublefastLowerBound(Integer state, Set<Integer> variables) Computes a fast lower bound for the given state and remaining variables.
-
Constructor Details
-
BKSFastLowerBound
Constructs a fast lower bound evaluator for the given bounded knapsack problem.- Parameters:
problem- the knapsack problem instance containing item values, weights, and capacities
-
-
Method Details
-
fastLowerBound
Computes a fast lower bound for the given state and remaining variables.The algorithm:
- Computes the value-to-weight ratio for each remaining item.
- Sorts the items in descending order of their ratio (most efficient items first).
- Greedily fills the remaining capacity using as many units as possible of each item, possibly using a fractional last item (relaxation).
- Returns the negative of the total achievable value as the lower bound estimate.
- Specified by:
fastLowerBoundin interfaceFastLowerBound<Integer>- Parameters:
state- the current capacity remaining in the knapsackvariables- the set of indices of remaining items to consider- Returns:
- a fast lower bound estimate (as a negative value) of the optimal solution
-