Class SearchAlgorithm

java.lang.Object
xal.extension.solver.algorithm.SearchAlgorithm
All Implemented Interfaces:
AlgorithmScheduleListener, SolutionJudgeListener
Direct Known Subclasses:
DirectedStep, InitialAlgorithm, RandomSearch, RandomShrinkSearch, SimplexSearchAlgorithm

public abstract class SearchAlgorithm extends Object implements AlgorithmScheduleListener, SolutionJudgeListener
Abstract super class for an optimization search algorithm.
Author:
ky6
  • Field Details

    • EFFICIENCY_COMPARATOR

      public static final Comparator<SearchAlgorithm> EFFICIENCY_COMPARATOR
      comparator for sorting based on efficiency
    • problem

      protected Problem problem
      the problem to solve
  • Constructor Details

    • SearchAlgorithm

      protected SearchAlgorithm()
      Empty constructor.
  • Method Details

    • setProblem

      public void setProblem(Problem problem)
      Assign a new problem.
    • reset

      public void reset()
      Reset this algorithm.
    • executeRun

      public final void executeRun(AlgorithmSchedule schedule, ScoreBoard scoreboard)
      Execute an algorithm run (typically many evaluations up to those proposed)
      Parameters:
      schedule - the schedule requesting the algorithm execution
      scoreboard - the scoreboard of solver status
    • evaluateTrialPoint

      public Trial evaluateTrialPoint(TrialPoint trialPoint)
      Evaluate the given trial point.
      Parameters:
      trialPoint - the trial point to evaluate
      Returns:
      the scored trial
    • getLabel

      public abstract String getLabel()
      Get the label for this search algorithm.
      Returns:
      The label for this algorithm
    • performRun

      public abstract void performRun(AlgorithmSchedule algorithmSchedule)
      Calculate the next few trial points.
    • getEvaluationsLeft

      public int getEvaluationsLeft()
      get the amount of evaluations left to run for this algorithm
    • getMinEvaluationsPerRun

      public int getMinEvaluationsPerRun()
      Get the minimum number of evaluations per run. Subclasses may want to override this method.
      Returns:
      the minimum number of evaluation per run.
    • getMaxEvaluationsPerRun

      public int getMaxEvaluationsPerRun()
      Get the maximum number of evaluations per run. Subclasses may want to override this method.
      Returns:
      the maximum number of evaluation per run.
    • setProposedEvaluations

      public void setProposedEvaluations(int proposedEvaluations)
      Sets that proposed minimum evaluations for an algorithm
    • getEfficiency

      public final double getEfficiency()
      Get this algorithm's efficiency for improving satisfaction.
      Returns:
      the efficiency
    • addSearchAlgorithmListener

      public void addSearchAlgorithmListener(SearchAlgorithmListener listener)
      Add a search algorithm listener.
      Parameters:
      listener - The listener to add.
    • removeSearchAlgorithmListener

      public void removeSearchAlgorithmListener(SearchAlgorithmListener listener)
      Remove a search algorithm listener.
      Parameters:
      listener - The listener to remove.
    • trialScored

      public void trialScored(AlgorithmSchedule schedule, Trial trial)
      Handle a message that a trial has been scored.
      Specified by:
      trialScored in interface AlgorithmScheduleListener
      Parameters:
      schedule - Description of the Parameter
      trial - Description of the Parameter
    • trialVetoed

      public void trialVetoed(AlgorithmSchedule schedule, Trial trial)
      Handle a message that a trial has been vetoed.
      Specified by:
      trialVetoed in interface AlgorithmScheduleListener
      Parameters:
      schedule - Description of the Parameter
      trial - Description of the Parameter
    • algorithmRunWillExecute

      public void algorithmRunWillExecute(AlgorithmSchedule schedule, SearchAlgorithm algorithm, ScoreBoard scoreBoard)
      Handle an event where a new algorithm run stack will start.
      Specified by:
      algorithmRunWillExecute in interface AlgorithmScheduleListener
      Parameters:
      schedule - the schedule posting the event
      algorithm - the algorithm which will execute
      scoreBoard - the scoreboard
    • algorithmRunExecuted

      public void algorithmRunExecuted(AlgorithmSchedule schedule, SearchAlgorithm algorithm, ScoreBoard scoreBoard)
      Handle an event where a new algorithm run stack has completed.
      Specified by:
      algorithmRunExecuted in interface AlgorithmScheduleListener
      Parameters:
      schedule - the schedule posting the event
      algorithm - the algorithm that has executed
      scoreBoard - the scoreboard
    • foundNewOptimalSolution

      public void foundNewOptimalSolution(SolutionJudge source, List<Trial> solutions, Trial solution)
      Send a message that a new optimal solution has been found.
      Specified by:
      foundNewOptimalSolution in interface SolutionJudgeListener
      Parameters:
      source - The source of the new optimal solution.
      solutions - The list of solutions.
      solution - The new optimal solution.