Class AlgorithmPool

java.lang.Object
xal.extension.solver.AlgorithmPool
All Implemented Interfaces:
SearchAlgorithmListener, AlgorithmScheduleListener, SolutionJudgeListener

public class AlgorithmPool extends Object implements SearchAlgorithmListener, SolutionJudgeListener, AlgorithmScheduleListener
AlgorithmPool keeps track of the available algorithms.
Author:
ky6, t6p
  • Constructor Details

    • AlgorithmPool

      public AlgorithmPool(Collection<SearchAlgorithm> algorithms)
      Creates a new AlgorithmPool instance Constructor that takes a list of algorithms
      Parameters:
      algorithms - the collection of algorithms to populate the pool
    • AlgorithmPool

      public AlgorithmPool()
      Empty constructor which populates the pool of all algorithms
    • AlgorithmPool

      public AlgorithmPool(SearchAlgorithm algorithm)
      Creates a new AlgorithmPool instance Constructor that takes a list of algorithms
      Parameters:
      algorithm - Description of the Parameter
  • Method Details

    • generateDefaultAlgorithms

      public static Collection<SearchAlgorithm> generateDefaultAlgorithms()
      Get all the algorithms.
      Returns:
      The default set of algorithms
    • reset

      public void reset()
      Reset the algorithm pool by resetting all the algorithms.
    • setProblem

      public void setProblem(Problem problem)
      Assign the problem to each algorithm in the pool.
      Parameters:
      problem - the problem to solve
    • addAlgorithmPoolListener

      public void addAlgorithmPoolListener(AlgorithmPoolListener listener)
      Add an algorithm pool listener.
      Parameters:
      listener - The listener to add.
    • removeAlgorithmPoolListener

      public void removeAlgorithmPoolListener(AlgorithmPoolListener listener)
      Remove a algorithm pool listener.
      Parameters:
      listener - The listener to remove.
    • setAlgorithm

      public void setAlgorithm(SearchAlgorithm algorithm)
      Set the algorithm as the sole algorithm in the pool.
      Parameters:
      algorithm - the algorithm to set as the only item in the pool
    • addAlgorithms

      public void addAlgorithms(Collection<SearchAlgorithm> algorithms)
      Add existing algorithms to the algorithm list.
      Parameters:
      algorithms - The feature to be added to the Algorithms attribute
    • addAlgorithm

      public void addAlgorithm(SearchAlgorithm algorithm)
      Add an algorithm to the pool.
      Parameters:
      algorithm - The feature to be added to the Algorithm attribute
    • removeAlgorithm

      public void removeAlgorithm(SearchAlgorithm algorithm)
      Remove an algorithm from the pool.
      Parameters:
      algorithm - the algorithm to remove from the pool
    • removeAlgorithms

      public void removeAlgorithms(Collection<SearchAlgorithm> algorithms)
      Remove the specified algorithms.
      Parameters:
      algorithms - the algorithms to remove
    • removeAllAlgorithms

      public void removeAllAlgorithms()
      Remove all algorithms.
    • getAlgorithms

      public Collection<SearchAlgorithm> getAlgorithms()
      Get a copy of the algorithms.
      Returns:
      The list of algorithms.
    • getAvailableAlgorithms

      public Collection<SearchAlgorithm> getAvailableAlgorithms()
      Get the available algorithms.
      Returns:
      The list of available algorithm.
    • trialScored

      public void trialScored(AlgorithmSchedule algorithmSchedule, Trial trial)
      Send a message that a trial has been scored.
      Specified by:
      trialScored in interface AlgorithmScheduleListener
      Parameters:
      algorithmSchedule - The algorithm schedule that holds the trial scored.
      trial - The trial that was scored.
    • trialVetoed

      public void trialVetoed(AlgorithmSchedule algorithmSchedule, Trial trial)
      Send a message that a trial has been vetoed.
      Specified by:
      trialVetoed in interface AlgorithmScheduleListener
      Parameters:
      algorithmSchedule - The algorithm schedule that holds the trial vetoed.
      trial - The trial that was vetoed.
    • 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
    • algorithmAvailable

      public void algorithmAvailable(SearchAlgorithm source)
      Send a message that an algorithm is available. An algorithm is available if it has all the data it needs to propose a new trial.
      Specified by:
      algorithmAvailable in interface SearchAlgorithmListener
      Parameters:
      source - The source of the available algorithm.
    • algorithmUnavailable

      public void algorithmUnavailable(SearchAlgorithm source)
      Send a message that an algorithm is not available.
      Specified by:
      algorithmUnavailable in interface SearchAlgorithmListener
      Parameters:
      source - The source of the available algorithm.
    • foundNewOptimalSolution

      public void foundNewOptimalSolution(SolutionJudge source, List<Trial> solutions, Trial solution)
      Event indicating 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.