Record Class WorkUnitResult<S extends Solution<S,I>, I extends Instance>

java.lang.Object
java.lang.Record
es.urjc.etsii.grafo.executors.WorkUnitResult<S,I>

public record WorkUnitResult<S extends Solution<S,I>, I extends Instance>(UUID resultId, boolean success, String experimentName, String instancePath, String instanceId, Algorithm<S extends Solution<S,I>, I extends Instance> algorithm, String iteration, S extends Solution<S,I> solution, Map<String,Double> objectives, Map<String,Object> solutionProperties, long executionTime, long timeToTarget, MetricsStorage metrics, List<TimeStatsEvent> timeData) extends Record
Result of executing one work unit.

Objective values and custom properties are evaluated when the result is created. They therefore describe the solution at the end of the work unit, even if the solution is later mutated or released from memory.

  • Field Details

  • Constructor Details

    • WorkUnitResult

      public WorkUnitResult(UUID resultId, boolean success, String experimentName, String instancePath, String instanceId, Algorithm<S,I> algorithm, String iteration, S solution, Map<String,Double> objectives, Map<String,Object> solutionProperties, long executionTime, long timeToTarget, MetricsStorage metrics, List<TimeStatsEvent> timeData)
      Creates an instance of a WorkUnitResult record class.
      Parameters:
      resultId - the value for the resultId record component
      success - the value for the success record component
      experimentName - the value for the experimentName record component
      instancePath - the value for the instancePath record component
      instanceId - the value for the instanceId record component
      algorithm - the value for the algorithm record component
      iteration - the value for the iteration record component
      solution - the value for the solution record component
      objectives - the value for the objectives record component
      solutionProperties - the value for the solutionProperties record component
      executionTime - the value for the executionTime record component
      timeToTarget - the value for the timeToTarget record component
      metrics - the value for the metrics record component
      timeData - the value for the timeData record component
  • Method Details

    • ok

      public static <S extends Solution<S,I>, I extends Instance> WorkUnitResult<S,I> ok(WorkUnit<S,I> workUnit, String instanceId, S solution, long executionTime, long timeToTarget, MetricsStorage metrics, List<TimeStatsEvent> timeData)
    • failure

      public static <S extends Solution<S,I>, I extends Instance> WorkUnitResult<S,I> failure(WorkUnit<S,I> workUnit, String instanceId, long executionTime, long timeToTarget, List<TimeStatsEvent> timeData)
    • copyBestAlg

      public static <S extends Solution<S,I>, I extends Instance> WorkUnitResult<S,I> copyBestAlg(WorkUnitResult<S,I> workUnit)
    • copyBestInstance

      public static <S extends Solution<S,I>, I extends Instance> WorkUnitResult<S,I> copyBestInstance(WorkUnitResult<S,I> workUnit)
    • computeObjectives

      public static <S extends Solution<S,I>, I extends Instance> Map<String,Double> computeObjectives(S solution)
      Evaluate all configured objectives once, retaining their declaration order.
    • computeSolutionProperties

      public static <S extends Solution<S,I>, I extends Instance> Map<String,Object> computeSolutionProperties(S solution)
      Evaluate all solution-defined custom properties once.
    • mainObjectiveValue

      public double mainObjectiveValue()
      Value of the first declared objective, or Double.NaN when no objective value is available.
    • withoutSolution

      public WorkUnitResult<S,I> withoutSolution()
      Return a copy that no longer strongly references its solution.
    • 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 the compare method from their corresponding wrapper classes.
      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.
    • resultId

      public UUID resultId()
      Returns the value of the resultId record component.
      Returns:
      the value of the resultId record component
    • success

      public boolean success()
      Returns the value of the success record component.
      Returns:
      the value of the success record component
    • experimentName

      public String experimentName()
      Returns the value of the experimentName record component.
      Returns:
      the value of the experimentName record component
    • instancePath

      public String instancePath()
      Returns the value of the instancePath record component.
      Returns:
      the value of the instancePath record component
    • instanceId

      public String instanceId()
      Returns the value of the instanceId record component.
      Returns:
      the value of the instanceId record component
    • algorithm

      public Algorithm<S,I> algorithm()
      Returns the value of the algorithm record component.
      Returns:
      the value of the algorithm record component
    • iteration

      public String iteration()
      Returns the value of the iteration record component.
      Returns:
      the value of the iteration record component
    • solution

      public S solution()
      Returns the value of the solution record component.
      Returns:
      the value of the solution record component
    • objectives

      public Map<String,Double> objectives()
      Returns the value of the objectives record component.
      Returns:
      the value of the objectives record component
    • solutionProperties

      public Map<String,Object> solutionProperties()
      Returns the value of the solutionProperties record component.
      Returns:
      the value of the solutionProperties record component
    • executionTime

      public long executionTime()
      Returns the value of the executionTime record component.
      Returns:
      the value of the executionTime record component
    • timeToTarget

      public long timeToTarget()
      Returns the value of the timeToTarget record component.
      Returns:
      the value of the timeToTarget record component
    • metrics

      public MetricsStorage metrics()
      Returns the value of the metrics record component.
      Returns:
      the value of the metrics record component
    • timeData

      public List<TimeStatsEvent> timeData()
      Returns the value of the timeData record component.
      Returns:
      the value of the timeData record component