Package io.github.nhtc2005.alns.stopping
Class AnyOfStoppingCriterion<S extends Solution<S>>
java.lang.Object
io.github.nhtc2005.alns.stopping.AnyOfStoppingCriterion<S>
- Type Parameters:
S- the solution type
- All Implemented Interfaces:
StoppingCriterion<S>
public final class AnyOfStoppingCriterion<S extends Solution<S>>
extends Object
implements StoppingCriterion<S>
Stops when any contained criterion requests termination.
Criteria are checked in list order, stopping at the first true result. Skipped
criteria do not receive that check, but all criteria are reset before each solve.
-
Constructor Summary
ConstructorsConstructorDescriptionAnyOfStoppingCriterion(List<? extends StoppingCriterion<S>> criteria) Creates a criterion from a defensive copy of the supplied list. -
Method Summary
Modifier and TypeMethodDescriptionReturns the unmodifiable criteria list in evaluation order; criterion instances are shared.voidreset()Resets every contained criterion, including those skipped by short-circuit evaluation.booleanshouldStop(StoppingContext<S> context) Checks whether the search should stop, including before the first iteration.
-
Constructor Details
-
AnyOfStoppingCriterion
Creates a criterion from a defensive copy of the supplied list.- Parameters:
criteria- the non-empty list of non-null criteria, in evaluation order- Throws:
NullPointerException- if the list or any element is nullIllegalArgumentException- if the list is empty
-
-
Method Details
-
shouldStop
Description copied from interface:StoppingCriterionChecks whether the search should stop, including before the first iteration.Implementations may update their own state but must not modify solutions in the context.
- Specified by:
shouldStopin interfaceStoppingCriterion<S extends Solution<S>>- Parameters:
context- the non-null search context- Returns:
trueto stop;falseto begin another iteration
-
reset
public void reset()Resets every contained criterion, including those skipped by short-circuit evaluation.- Specified by:
resetin interfaceStoppingCriterion<S extends Solution<S>>
-
getCriteria
Returns the unmodifiable criteria list in evaluation order; criterion instances are shared.- Returns:
- the unmodifiable criteria list in evaluation order; criterion instances are shared
-