Class SolutionGeneratedEvent<S extends Solution<S,I>,I extends Instance>

java.lang.Object
java.util.EventObject
org.springframework.context.ApplicationEvent
es.urjc.etsii.grafo.events.types.MorkEvent
es.urjc.etsii.grafo.events.types.SolutionGeneratedEvent<S,I>
Type Parameters:
S - Solution type
I - Instance type
All Implemented Interfaces:
Serializable

public class SolutionGeneratedEvent<S extends Solution<S,I>,I extends Instance> extends MorkEvent
Event triggered each time an algorithm finishes creating a solution. Contains information about the different solution characteristics. This event is created and dispatched automatically.
See Also:
  • Constructor Details

    • SolutionGeneratedEvent

      public SolutionGeneratedEvent(boolean success, String iteration, String instancePath, S solution, String experimentName, Algorithm<S,I> algorithm, long executionTime, long timeToBest, MetricsStorage metrics, List<TimeStatsEvent> timeStatsEvents)
      Create a new SolutionGeneratedEvent
      Parameters:
      iteration - solution iteration
      solution - generated solution
      experimentName - experiment name
      algorithm - algorithm that generated this solution
      executionTime - time used to generate this solution
      timeToBest - time needed ot reach the best solution. timeToBest = totalTime - timeSinceLastModification
      metrics - both framework calculated and user defined metrics
      timeStatsEvents -
  • Method Details

    • getIteration

      public String getIteration()
      Which iteration this solution corresponds to
      Returns:
      iteration
    • getExperimentName

      public String getExperimentName()
      Experiment name
      Returns:
      String representing the experiment name
    • getAlgorithm

      public Algorithm<S,I> getAlgorithm()
      Algorithm that created this solution
      Returns:
      Algorithm configuration
    • getInstanceName

      public String getInstanceName()
      Instance used to create this solution
      Returns:
      Instance name
    • getObjectives

      public Map<String,Double> getObjectives()
      Solution score when finished processing a solution.
      Returns:
      solution score
    • getExecutionTime

      public long getExecutionTime()
      Total execution time in nanoseconds used by the algorithm to create the solution.
      Returns:
      time in nanos
    • getTimeToBest

      public long getTimeToBest()
      Execution time until last modification in nanoseconds
      Returns:
      time in nanos
    • getAlgorithmName

      public String getAlgorithmName()
      Get short algorithm name that generated this solution
      Returns:
      Short string representing the algorithm that generated this solution
    • getSolution

      public Optional<S> getSolution()
      Get solution instance IF AVAILABLE Storing all generated solutions is too memory expensive.
      Returns:
      Empty optional if solution has been garbage collected, solution data if not.
    • getMetrics

      public MetricsStorage getMetrics()
      Get both framework calculated and user defined properties
      Returns:
      Map where key is metric name, value property value as calculated by the user provided function
    • isSuccess

      public boolean isSuccess()
      Was the solution generated successfully?
      Returns:
      true if the solution was generated successfully, false otherwise