Package io.github.nhtc2005.alns.stopping
Class MaxIterations<S extends Solution<S>>
java.lang.Object
io.github.nhtc2005.alns.stopping.MaxIterations<S>
- Type Parameters:
S- the solution type
- All Implemented Interfaces:
StoppingCriterion<S>
public final class MaxIterations<S extends Solution<S>>
extends Object
implements StoppingCriterion<S>
Stops once the number of completed iterations reaches the configured limit.
-
Constructor Summary
ConstructorsConstructorDescriptionMaxIterations(long maxIterations) Creates a criterion with a fixed iteration limit. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the configured iteration limit.booleanshouldStop(StoppingContext<S> context) Checks whether the search should stop, including before the first iteration.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.nhtc2005.alns.stopping.StoppingCriterion
reset
-
Constructor Details
-
MaxIterations
public MaxIterations(long maxIterations) Creates a criterion with a fixed iteration limit.- Parameters:
maxIterations- the positive maximum number of completed iterations- Throws:
IllegalArgumentException- ifmaxIterationsis not positive
-
-
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
-
getMaxIterations
public long getMaxIterations()Returns the configured iteration limit.- Returns:
- the configured iteration limit
-