Record Class AlnsResult<S extends Solution<S>>

java.lang.Object
java.lang.Record
io.github.nhtc2005.alns.core.AlnsResult<S>
Type Parameters:
S - the solution type
Record Components:
bestSolution - the best feasible solution found by the solver
totalIterations - the number of completed iterations
elapsedNanos - the search duration in nanoseconds, excluding component resets
statistics - the collected statistics, or a disabled statistics object

public record AlnsResult<S extends Solution<S>>(S extends Solution<S> bestSolution, long totalIterations, long elapsedNanos, AlnsStatistics statistics) extends Record
Contains the best solution and measurements from a completed ALNS search.

The best solution is returned directly; this record does not defensively copy it.

  • Constructor Details

    • AlnsResult

      public AlnsResult(S bestSolution, long totalIterations, long elapsedNanos, AlnsStatistics statistics)
      Creates a result with the supplied statistics.
      Parameters:
      bestSolution - the best feasible solution found by the solver
      totalIterations - the number of completed iterations
      elapsedNanos - the search duration in nanoseconds, excluding component resets
      statistics - the collected statistics, or a disabled statistics object
      Throws:
      NullPointerException - if statistics is null
    • AlnsResult

      public AlnsResult(S bestSolution, long totalIterations, long elapsedNanos)
      Creates a result with statistics disabled.
      Parameters:
      bestSolution - the best feasible solution found by the solver
      totalIterations - the number of completed iterations
      elapsedNanos - the search duration in nanoseconds, excluding component resets
  • Method Details

    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • bestSolution

      public S bestSolution()
      Returns the value of the bestSolution record component.
      Returns:
      the value of the bestSolution record component
    • totalIterations

      public long totalIterations()
      Returns the value of the totalIterations record component.
      Returns:
      the value of the totalIterations record component
    • elapsedNanos

      public long elapsedNanos()
      Returns the value of the elapsedNanos record component.
      Returns:
      the value of the elapsedNanos record component
    • statistics

      public AlnsStatistics statistics()
      Returns the value of the statistics record component.
      Returns:
      the value of the statistics record component