Class BKSRelax
java.lang.Object
org.ddolib.examples.boundedknapsack.BKSRelax
- All Implemented Interfaces:
Relaxation<Integer>
A relaxation strategy for the Bounded Knapsack Problem (BKP) used in
relaxed decision diagrams.
This class implements the Relaxation interface, providing a way
to merge multiple states and optionally relax edge costs in the construction
of a relaxed decision diagram (DD).
Merge strategy: the merged state is the maximum remaining capacity among the given states. This ensures that the relaxation over-approximates the remaining capacity and maintains feasibility in the relaxed DD.
Edge relaxation: the cost of transitions is not modified and returned unchanged. This simple strategy preserves the original objective value.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionmergeStates(Iterator<Integer> states) Merges a set of states into a single representative state for a relaxed DD.doubleOptionally relaxes the edge cost when transitioning from a state to a merged state.
-
Constructor Details
-
BKSRelax
public BKSRelax()Default constructor.
-
-
Method Details
-
mergeStates
Merges a set of states into a single representative state for a relaxed DD.For BKP, this implementation returns the maximum remaining capacity among the given states.
- Specified by:
mergeStatesin interfaceRelaxation<Integer>- Parameters:
states- an iterator over the states to merge- Returns:
- the merged state
-
relaxEdge
Optionally relaxes the edge cost when transitioning from a state to a merged state.In this implementation, the edge cost is not modified and returned as-is.
- Specified by:
relaxEdgein interfaceRelaxation<Integer>- Parameters:
from- the origin stateto- the destination statemerged- the merged state after relaxationd- the decision taken to move fromfromtotocost- the original cost of the edge- Returns:
- the relaxed cost (unchanged in this implementation)
-