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 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 - if maxIterations is not positive
  • Method Details

    • shouldStop

      public boolean shouldStop(StoppingContext<S> context)
      Description copied from interface: StoppingCriterion
      Checks 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:
      shouldStop in interface StoppingCriterion<S extends Solution<S>>
      Parameters:
      context - the non-null search context
      Returns:
      true to stop; false to begin another iteration
    • getMaxIterations

      public long getMaxIterations()
      Returns the configured iteration limit.
      Returns:
      the configured iteration limit