Package org.ddolib.examples.knapsack
Class KSRelax
java.lang.Object
org.ddolib.examples.knapsack.KSRelax
- All Implemented Interfaces:
Relaxation<Integer>
Relaxation for the Knapsack Problem (KS).
This class implements a simple relaxation of the state space for relaxed decision diagrams. The merged state corresponds to the maximum remaining capacity among all states being merged.
The edge relaxation does not modify the cost: it simply returns the original cost.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
KSRelax
public KSRelax()
-
-
Method Details
-
mergeStates
Merges multiple states into a single relaxed state.For the Knapsack problem, the merged state is defined as the maximum remaining capacity among the states being merged.
- Specified by:
mergeStatesin interfaceRelaxation<Integer>- Parameters:
states- an iterator over the states to merge- Returns:
- the merged state representing the maximum remaining capacity
-
relaxEdge
Relaxes the cost of an edge between states in the decision diagram.For the Knapsack problem, the cost is not modified by the relaxation.
- Specified by:
relaxEdgein interfaceRelaxation<Integer>- Parameters:
from- the starting stateto- the ending statemerged- the merged state after relaxationd- the decision associated with the edgecost- the original cost of the edge- Returns:
- the relaxed cost (identical to the original cost in this implementation)
-