Package io.github.nhtc2005.alns.stopping
Record Class StoppingContext<S extends Solution<S>>
java.lang.Object
java.lang.Record
io.github.nhtc2005.alns.stopping.StoppingContext<S>
- Type Parameters:
S- the solution type- Record Components:
iteration- the number of completed iterations, equal to the index of the last completed iteration; zero denotes the initial solutionelapsedNanos- the elapsed search time in nanoseconds at this checkbestSolution- the best feasible solution found so farcurrentSolution- the current feasible solutionrandomGenerator- the random generator used by the search
public record StoppingContext<S extends Solution<S>>(long iteration, long elapsedNanos, S extends Solution<S> bestSolution, S extends Solution<S> currentSolution, RandomGenerator randomGenerator)
extends Record
Provides the search state when checking a stopping criterion.
Solutions are shared references, not snapshots, and must not be modified by the criterion.
-
Constructor Summary
ConstructorsConstructorDescriptionStoppingContext(long iteration, long elapsedNanos, S bestSolution, S currentSolution, RandomGenerator randomGenerator) Creates an instance of aStoppingContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thebestSolutionrecord component.Returns the value of thecurrentSolutionrecord component.longReturns the value of theelapsedNanosrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.longReturns the value of theiterationrecord component.Returns the value of therandomGeneratorrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
StoppingContext
public StoppingContext(long iteration, long elapsedNanos, S bestSolution, S currentSolution, RandomGenerator randomGenerator) Creates an instance of aStoppingContextrecord class.- Parameters:
iteration- the value for theiterationrecord componentelapsedNanos- the value for theelapsedNanosrecord componentbestSolution- the value for thebestSolutionrecord componentcurrentSolution- the value for thecurrentSolutionrecord componentrandomGenerator- the value for therandomGeneratorrecord component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
iteration
public long iteration()Returns the value of theiterationrecord component.- Returns:
- the value of the
iterationrecord component
-
elapsedNanos
public long elapsedNanos()Returns the value of theelapsedNanosrecord component.- Returns:
- the value of the
elapsedNanosrecord component
-
bestSolution
Returns the value of thebestSolutionrecord component.- Returns:
- the value of the
bestSolutionrecord component
-
currentSolution
Returns the value of thecurrentSolutionrecord component.- Returns:
- the value of the
currentSolutionrecord component
-
randomGenerator
Returns the value of therandomGeneratorrecord component.- Returns:
- the value of the
randomGeneratorrecord component
-