Package org.ddolib.examples.lcs
Class LCSRelax
java.lang.Object
org.ddolib.examples.lcs.LCSRelax
- All Implemented Interfaces:
Relaxation<LCSState>
Relaxation strategy for
LCSState in the Longest Common Subsequence (LCS) problem.
This class implements Relaxation and is used to merge multiple LCS states into
a single relaxed state, which is useful for search algorithms such as DDO (Decision Diagram Optimization).
The merged state preserves, for each string, the earliest position among all merged states. This allows the algorithm to over-approximate the search space while maintaining feasibility.
-
Constructor Summary
ConstructorsConstructorDescriptionLCSRelax(LCSProblem problem) Constructs a relaxation object for a given LCS problem. -
Method Summary
-
Constructor Details
-
LCSRelax
Constructs a relaxation object for a given LCS problem.- Parameters:
problem- The LCS problem instance.
-
-
Method Details
-
mergeStates
Merges multiple LCS states into a single relaxed state.For each string, the merged state takes the minimum position among all states, effectively keeping the "earliest progress" along each string.
- Specified by:
mergeStatesin interfaceRelaxation<LCSState>- Parameters:
states- Iterator over the states to be merged.- Returns:
- A new
LCSStaterepresenting the merged state.
-
relaxEdge
Relaxes the cost of a transition between two LCS states.This implementation returns the original cost unchanged.
- Specified by:
relaxEdgein interfaceRelaxation<LCSState>- Parameters:
from- The state from which the transition originates.to- The state to which the transition goes.merged- The merged state that includes both 'from' and 'to'.d- The decision taken.cost- The original cost of the transition.- Returns:
- The relaxed cost, which in this case is the same as
cost.
-